Exemple #1
0
        public void GetGameWinnerName_BothPlayersOutOfCards_ShouldReturnNoWinnerString()
        {
            InitializeTwoPlayerGame();
            _mockPlayerService.Setup(mps => mps.IsPlayerOutOfCards(It.IsAny <Player>())).Returns(true);

            var result = _warGameController.GetGameWinnerName();

            Assert.AreEqual("Nobody", result);
        }
Exemple #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);
        }