Exemple #1
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);
        }
Exemple #2
0
        public void GetGameStandings_TwoPlayers_ShouldContainPlayerCardCounts()
        {
            var players = InitializeTwoPlayerGame();

            players[0].Deck = new List <Card>()
            {
                new Card(Suit.Clubs, Rank.Eight), new Card(Suit.Clubs, Rank.Ace)
            };
            players[1].Deck = new List <Card>()
            {
                new Card(Suit.Diamonds, Rank.Jack)
            };

            var result = _warGameController.GetGameStandings();

            Assert.IsTrue(result.Contains(players[0].Name + ": " + players[0].Deck.Count));
            Assert.IsTrue(result.Contains(players[1].Name + ": " + players[1].Deck.Count));
        }