public GameResponse Join(LobbyUser user, string password) { if (PlayersAndSpectators.ContainsKey(user.Name)) { return(GameResponse.Failure("You are already in that game.")); } if (Started) { return(GameResponse.Failure("That game has already started.")); } if (GetPlayers().Count >= 2) { return(GameResponse.Failure("That game is full.")); } if (!string.IsNullOrEmpty(Password) && Password != password) { return(GameResponse.Failure("Incorrect password for that game.")); } if (GetPlayers().Values.Any(player => player.User.HasUserBlocked(user) || user.HasUserBlocked(player.User))) { return(GameResponse.Failure("You cannot join that game.")); } // TODO Add message PlayersAndSpectators.Add(user.Name, new LobbyPlayer { User = user, IsSpectator = false }); return(GameResponse.Succeeded(this)); }
public void NewGame(LobbyUser user) { var player = new LobbyPlayer { User = user, IsSpectator = false }; PlayersAndSpectators.Add(user.Name, player); }
public bool HasUserBlocked(LobbyUser otherUser) { return(BlockList.Contains(otherUser.Name)); }