mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-23 04:29:36 +08:00
添加社团功能
This commit is contained in:
parent
188316e1ef
commit
98fcbf1a6c
@ -5,12 +5,12 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
public abstract class BaseEntity : IBaseEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体的数字ID
|
||||
/// 实体的数字 ID
|
||||
/// </summary>
|
||||
public virtual long Id { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 实体的唯一ID
|
||||
/// 实体的唯一 ID
|
||||
/// </summary>
|
||||
public virtual Guid Guid { get; set; } = Guid.Empty;
|
||||
|
||||
@ -19,6 +19,20 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
/// </summary>
|
||||
public virtual string Name { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 比较两个实体是否相同
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
/// <returns></returns>
|
||||
public abstract bool Equals(IBaseEntity? other);
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体的 Id.Name
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetIdName()
|
||||
{
|
||||
return Id + "." + Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -414,15 +414,6 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
|
||||
internal Item() { }
|
||||
|
||||
/// <summary>
|
||||
/// Id.Name
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetIdName()
|
||||
{
|
||||
return Id + "." + Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示物品的详细信息
|
||||
/// </summary>
|
||||
|
@ -442,15 +442,6 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Id.Name
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetIdName()
|
||||
{
|
||||
return Id + "." + Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断两个技能是否相同 检查Id.Name
|
||||
/// </summary>
|
||||
|
@ -10,18 +10,13 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
public bool IsPublic { get; set; } = false;
|
||||
public double ClubPoins { get; set; } = 0;
|
||||
public User? Master { get; set; }
|
||||
public Dictionary<string, User> Admins { get; set; } = [];
|
||||
public Dictionary<string, User> Members { get; set; } = [];
|
||||
public Dictionary<string, User> Applicants { get; set; } = [];
|
||||
|
||||
public bool Equals(Club other)
|
||||
{
|
||||
return Equals(other);
|
||||
}
|
||||
public Dictionary<long, User> Admins { get; set; } = [];
|
||||
public Dictionary<long, User> Members { get; set; } = [];
|
||||
public Dictionary<long, User> Applicants { get; set; } = [];
|
||||
|
||||
public override bool Equals(IBaseEntity? other)
|
||||
{
|
||||
return other?.Id == Id;
|
||||
return other is Club && other?.Id == Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,6 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
(SettleTime.HasValue ? $"\r\n结算时间:{SettleTime.Value.ToString(General.GeneralDateTimeFormatChinese)}" : "");
|
||||
}
|
||||
|
||||
public string GetIdName()
|
||||
{
|
||||
return Id + "." + Name;
|
||||
}
|
||||
|
||||
private string GetStatus()
|
||||
{
|
||||
return Status switch
|
||||
|
@ -5,5 +5,7 @@
|
||||
public long Id { get; }
|
||||
public Guid Guid { get; }
|
||||
public string Name { get; }
|
||||
|
||||
public string GetIdName();
|
||||
}
|
||||
}
|
||||
|
98
Library/Common/JsonConverter/ClubConverter.cs
Normal file
98
Library/Common/JsonConverter/ClubConverter.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using System.Text.Json;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Interface.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Common.Architecture;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
||||
{
|
||||
public class ClubConverter : BaseEntityConverter<Club>
|
||||
{
|
||||
public override Club NewInstance()
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
public override void ReadPropertyName(ref Utf8JsonReader reader, string propertyName, JsonSerializerOptions options, ref Club result)
|
||||
{
|
||||
switch (propertyName)
|
||||
{
|
||||
case nameof(Club.Id):
|
||||
result.Id = reader.GetInt64();
|
||||
break;
|
||||
case nameof(Club.Guid):
|
||||
result.Guid = NetworkUtility.JsonDeserialize<Guid>(ref reader, options);
|
||||
break;
|
||||
case nameof(Club.Name):
|
||||
result.Name = reader.GetString() ?? "";
|
||||
break;
|
||||
case nameof(Club.Prefix):
|
||||
result.Prefix = reader.GetString() ?? "";
|
||||
break;
|
||||
case nameof(Club.Description):
|
||||
result.Description = reader.GetString() ?? "";
|
||||
break;
|
||||
case nameof(Club.IsPublic):
|
||||
result.IsPublic = reader.GetBoolean();
|
||||
break;
|
||||
case nameof(Club.IsNeedApproval):
|
||||
result.IsNeedApproval = reader.GetBoolean();
|
||||
break;
|
||||
case nameof(Club.ClubPoins):
|
||||
result.ClubPoins = reader.GetDouble();
|
||||
break;
|
||||
case nameof(Club.Master):
|
||||
long master = reader.GetInt64();
|
||||
result.Master = new(master);
|
||||
break;
|
||||
case nameof(Club.Admins):
|
||||
List<long> admins = NetworkUtility.JsonDeserialize<List<long>>(ref reader, options) ?? [];
|
||||
foreach (long id in admins)
|
||||
{
|
||||
result.Admins[id] = new(id);
|
||||
}
|
||||
break;
|
||||
case nameof(Club.Members):
|
||||
List<long> members = NetworkUtility.JsonDeserialize<List<long>>(ref reader, options) ?? [];
|
||||
foreach (long id in members)
|
||||
{
|
||||
result.Members[id] = new(id);
|
||||
}
|
||||
break;
|
||||
case nameof(Club.Applicants):
|
||||
List<long> applicants = NetworkUtility.JsonDeserialize<List<long>>(ref reader, options) ?? [];
|
||||
foreach (long id in applicants)
|
||||
{
|
||||
result.Applicants[id] = new(id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Club value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
|
||||
writer.WriteNumber(nameof(Club.Id), value.Id);
|
||||
writer.WritePropertyName(nameof(Club.Guid));
|
||||
JsonSerializer.Serialize(writer, value.Guid, options);
|
||||
writer.WriteString(nameof(Club.Name), value.Name);
|
||||
writer.WriteString(nameof(Club.Prefix), value.Prefix);
|
||||
writer.WriteString(nameof(Club.Description), value.Description);
|
||||
writer.WriteBoolean(nameof(Club.IsPublic), value.IsPublic);
|
||||
writer.WriteBoolean(nameof(Club.IsNeedApproval), value.IsNeedApproval);
|
||||
writer.WriteNumber(nameof(Club.ClubPoins), value.ClubPoins);
|
||||
writer.WriteNumber(nameof(Club.Master), value.Master?.Id ?? 0);
|
||||
writer.WritePropertyName(nameof(Club.Admins));
|
||||
JsonSerializer.Serialize(writer, value.Admins.Keys, options);
|
||||
writer.WritePropertyName(nameof(Club.Members));
|
||||
JsonSerializer.Serialize(writer, value.Members.Keys, options);
|
||||
writer.WritePropertyName(nameof(Club.Applicants));
|
||||
JsonSerializer.Serialize(writer, value.Applicants.Keys, options);
|
||||
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ namespace Milimoe.FunGame.Core.Service
|
||||
ReferenceHandler = ReferenceHandler.IgnoreCycles,
|
||||
Converters = { new DateTimeConverter(), new DataTableConverter(), new DataSetConverter(), new UserConverter(), new RoomConverter(),
|
||||
new CharacterConverter(), new MagicResistanceConverter(), new EquipSlotConverter(), new SkillConverter(), new EffectConverter(), new ItemConverter(),
|
||||
new InventoryConverter(), new NormalAttackConverter()
|
||||
new InventoryConverter(), new NormalAttackConverter(), new ClubConverter()
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user