milimoe e7214c3fb9
添加新的枚举、字符常量和方法 (#59)
* 添加大量新的枚举,添加缺少的枚举字符串,修改枚举转字符串方法的位置

* 添加StartGame和Gaming的SocketHandler方法

* 添加MainInvokeType.StartGame

* 优化代码格式

* 添加默认的User.ToString()

* 添加EndGame

* 添加GameMode.GetTypeString

* 添加GameMode.GetRoomType
2023-11-23 00:43:34 +08:00

67 lines
2.3 KiB
C#

using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Entity
{
public class User : BaseEntity
{
public static readonly User Empty = new();
public string Username { get; set; } = "";
public DateTime RegTime { get; set; }
public DateTime LastTime { get; set; }
public string Email { get; set; } = "";
public string NickName { get; set; } = "";
public bool IsAdmin { get; set; } = false;
public bool IsOperator { get; set; } = false;
public bool IsEnable { get; set; } = true;
public decimal Credits { get; set; } = 0;
public decimal Materials { get; set; } = 0;
public decimal GameTime { get; set; } = 0;
public string AutoKey { get; set; } = "";
public UserStatistics Statistics { get; }
public Inventory Inventory { get; }
internal User()
{
Statistics = new(this);
Inventory = new(this);
}
internal User(long Id = 0, string Username = "", DateTime? RegTime = null, DateTime? LastTime = null, string Email = "", string NickName = "", bool IsAdmin = false, bool IsOperator = false, bool IsEnable = true, decimal Credits = 0, decimal Materials = 0, decimal GameTime = 0, string AutoKey = "")
{
this.Id = Id;
this.Username = Username;
this.RegTime = RegTime ?? General.DefaultTime;
this.LastTime = LastTime ?? General.DefaultTime;
this.Email = Email;
this.NickName = NickName;
this.IsAdmin = IsAdmin;
this.IsOperator = IsOperator;
this.IsEnable = IsEnable;
this.Credits = Credits;
this.Materials = Materials;
this.GameTime = GameTime;
this.AutoKey = AutoKey;
Statistics = new(this);
Inventory = new(this);
}
public override bool Equals(IBaseEntity? other)
{
if (other == null) return false;
if (((User)other).Id == Id) return true;
return false;
}
public override string ToString()
{
string str = Username;
if (NickName != "")
{
str += " ( " + NickName + " ) ";
}
return str;
}
}
}