Modify Room

This commit is contained in:
milimoe 2023-09-11 21:34:29 +08:00
parent 35382bf703
commit 83699eb766
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
3 changed files with 5 additions and 3 deletions

View File

@ -5,11 +5,12 @@ namespace Milimoe.FunGame.Core.Entity
{
public class Room : BaseEntity
{
public static readonly Room Empty = new();
public override long Id { get => base.Id ; set => base.Id = value; }
public string Roomid { get; set; } = "-1";
public DateTime CreateTime { get; set; } = General.DefaultTime;
public Dictionary<string, User> Players { get; set; } = new();
public User? RoomMaster { get; set; }
public User RoomMaster { get; set; } = General.UnknownUserInstance;
public RoomType RoomType { get; set; }
public RoomState RoomState { get; set; }
public bool HasPass => Password.Trim() != "";
@ -26,7 +27,7 @@ namespace Milimoe.FunGame.Core.Entity
this.Id = Id;
this.Roomid = Roomid;
this.CreateTime = CreateTime ?? General.DefaultTime;
this.RoomMaster = RoomMaster;
this.RoomMaster = RoomMaster ?? General.UnknownUserInstance;
this.RoomType = RoomType;
this.RoomState = RoomState;
this.Password = Password;

View File

@ -7,6 +7,7 @@ namespace Milimoe.FunGame.Core.Entity
{
public class User : BaseEntity
{
public static readonly User Empty = new();
public override Guid Guid { get; set; } = Guid.NewGuid();
public override long Id { get; set; }
public string Username { get; set; } = "";

View File

@ -47,7 +47,7 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
case RoomQuery.Column_RoomMaster:
string master = reader.GetString() ?? "";
room.RoomMaster = JsonSerializer.Deserialize<User>(master, options);
room.RoomMaster = JsonSerializer.Deserialize<User>(master, options) ?? General.UnknownUserInstance;
break;
case RoomQuery.Column_RoomType: