From bde93c9833d7fb88a3f6dfdaf248fdb0d24a263d Mon Sep 17 00:00:00 2001 From: milimoe Date: Wed, 15 Nov 2023 20:24:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E4=BA=8E=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E5=9C=A8=E6=88=BF=E9=97=B4=E4=B8=AD=E5=87=86=E5=A4=87?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/System/Room.cs | 3 +-- Model/RoomList.cs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Entity/System/Room.cs b/Entity/System/Room.cs index dab0838..4c49743 100644 --- a/Entity/System/Room.cs +++ b/Entity/System/Room.cs @@ -9,13 +9,12 @@ namespace Milimoe.FunGame.Core.Entity 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 Players { get; set; } = new(); public User RoomMaster { get; set; } = General.UnknownUserInstance; public RoomType RoomType { get; set; } public RoomState RoomState { get; set; } public bool HasPass => Password.Trim() != ""; public string Password { get; set; } = ""; - public GameStatistics? Statistics { get; set; } = null; + public GameStatistics Statistics { get; set; } = new(); internal Room() { diff --git a/Model/RoomList.cs b/Model/RoomList.cs index 39b123d..dbebe0a 100644 --- a/Model/RoomList.cs +++ b/Model/RoomList.cs @@ -8,6 +8,7 @@ namespace Milimoe.FunGame.Core.Model { private readonly Dictionary _List = new(); private readonly Dictionary> _PlayerList = new(); + private readonly Dictionary> _ReadyPlayerList = new(); public int Count => _List.Count; @@ -21,6 +22,7 @@ namespace Milimoe.FunGame.Core.Model { _List.Clear(); _PlayerList.Clear(); + _ReadyPlayerList.Clear(); } public void AddRoom(Room Room) @@ -53,6 +55,28 @@ namespace Milimoe.FunGame.Core.Model } } + public List GetReadyPlayerList(string RoomID) => _ReadyPlayerList.ContainsKey(RoomID) ? _ReadyPlayerList[RoomID] : new(); + + public int GetReadyPlayerCount(string RoomID) => GetReadyPlayerList(RoomID).Count; + + public List GetNotReadyPlayerList(string RoomID) => _PlayerList.ContainsKey(RoomID) ? _PlayerList[RoomID].Except(GetReadyPlayerList(RoomID)).ToList() : new(); + + public void SetReady(string RoomID, User User) + { + if (RoomID != "-1" && _ReadyPlayerList.ContainsKey(RoomID) && User.Id != 0) + { + _ReadyPlayerList[RoomID].Add(User); + } + } + + public void SetNotReady(string RoomID, User User) + { + if (RoomID != "-1" && _ReadyPlayerList.ContainsKey(RoomID) && User.Id != 0) + { + _ReadyPlayerList[RoomID].Remove(User); + } + } + public void QuitRoom(string RoomID, User User) { if (RoomID != "-1" && User.Id != 0)