コード例 #1
0
ファイル: Game.cs プロジェクト: davidmilligan/M
        public string Admit(string currentUser, string name)
        {
            if (IsStarted)
            {
                return("Game has already started!");
            }
            if (currentUser != Owner)
            {
                return("Only game owner can admit users!");
            }
            if (Players.Count >= MaxPlayers)
            {
                return($"Maximum number of players is {MaxPlayers}");
            }
            var player = WaitingRoom.FirstOrDefault(t => t.Name == name);

            if (player == null)
            {
                return($"Player not found: {name}");
            }

            WaitingRoom.Remove(player);
            player.Order = Players.Count;
            Players.Add(player);
            Message(null, $"{player} was admitted");
            return(null);
        }