public void AddPlayersToGame(GameSettings gameSettings) { GameBoard _gameBoard = new GameBoard(gameSettings); _gameBoard.AddPlayerToGame(gameSettings, "Andrew"); _gameBoard.AddPlayerToGame(gameSettings, "Max"); Assert.True(_gameBoard.Players.Where(p => p.TypeOfPlayer == Player.PlayerType.Human).ToList().Count == 2); }
public static void Main(string[] args) { __gameSettings = LoadConfiguration(); __gameBoard = new GameBoard(__gameSettings); Console.Clear(); Console.WriteLine(__welcome); Console.Write(__usernamePrompt); if (__gameSettings.Players > 0) { // add human player, multi player possible but limitation on single player due to console __gameBoard.AddPlayerToGame(__gameSettings, Console.ReadLine().ToString()); } while (__gameBoard.GetGameStatus() == GameBoard.GameStatus.InProgress) { // iterate through the list of players until we have a winner foreach (Player player in __gameBoard.Players) { __coordinate = null; DisplayGameGrid(player); if (player.TypeOfPlayer == Player.PlayerType.Human) { DisplayPromptForMissile(); } var _missileResponse = player.PlayersBoard.FireMissile(__coordinate); DisplayMissileResult(player, _missileResponse); // check if this was a winning hit if (_missileResponse == MissileResponse.Hit && __gameBoard.GetGameStatus() == GameBoard.GameStatus.PlayerWins) { DisplayGameGrid(player); Console.WriteLine(String.Format(__winnerMessage, player.Name)); Console.WriteLine(__pressAnyKey + Environment.NewLine); Console.ReadLine(); return; } } } }