Example #1
0
        public void Initialize_WithOnePlayerName_ShouldThrowArgumentException()
        {
            var playerNames = new List <string>()
            {
                "Tester1"
            };

            Assert.Throws <ArgumentException>(() => _warGameController.Initialize(playerNames));
        }
Example #2
0
        public void PlayGame()
        {
            Console.WriteLine(WELCOME_MESSAGE);
            var playerName = GetPlayerName();
            var gameMode   = GetGameMode();

            _warGameController.Initialize(new List <string>()
            {
                playerName, COMPUTER_PLAYER_NAME
            });

            while (!_warGameController.IsGameOver())
            {
                Console.WriteLine(_warGameController.GetGameStandings());
                WaitForSpaceBarIfNeeded(gameMode);
                Console.WriteLine();
                var roundResult = _warGameController.StartNewRound();
                Console.WriteLine(roundResult);
                while (roundResult.IsWarRequired)
                {
                    WaitForSpaceBarIfNeeded(gameMode);
                    Console.WriteLine();
                    roundResult = _warGameController.ContinueRoundWithWar();
                    Console.WriteLine(roundResult);
                }
            }

            Console.WriteLine();
            Console.WriteLine(string.Format(WINNER_MESSAGE_FORMAT, _warGameController.GetGameWinnerName()));
            Console.WriteLine();
            Console.WriteLine(PRESS_Q_TO_QUIT);
            WaitForKeyPress(ConsoleKey.Q);
        }