Beispiel #1
0
        private SingleCardPlayResult PlaySingleCardDraw()
        {
            var singleCardPlayResult = _gameRoundService.GetResultIfNotEnoughCardsToContinue(_currentRound);

            if (singleCardPlayResult == null)
            {
                _gameRoundService.AddCardFromAllPlayersToPot(_currentRound);
                var cardDrawResult = _gameRoundService.GetCardDrawResult(_currentRound);
                switch (cardDrawResult.ComparisonResult)
                {
                case ComparisonResult.Tie:
                    singleCardPlayResult = new SingleCardPlayResult(cardDrawResult.FirstPlayerCard, cardDrawResult.SecondPlayerCard, true, RESULT_WAR_REQUIRED);
                    break;

                case ComparisonResult.FirstCardWins:
                    singleCardPlayResult = new SingleCardPlayResult(cardDrawResult.FirstPlayerCard, cardDrawResult.SecondPlayerCard, false, string.Format(RESULT_ROUND_WINNER_FORMAT, _players[0].Name));
                    CollectPotWinnings(_players[0]);
                    break;

                case ComparisonResult.SecondCardWins:
                    singleCardPlayResult = new SingleCardPlayResult(cardDrawResult.FirstPlayerCard, cardDrawResult.SecondPlayerCard, false, string.Format(RESULT_ROUND_WINNER_FORMAT, _players[1].Name));
                    CollectPotWinnings(_players[1]);
                    break;
                }
            }

            return(singleCardPlayResult);
        }
Beispiel #2
0
        public void GetCardDrawResult_TwoPlayerCards_ShouldPopulatePlayerCardsInResult()
        {
            var player1Card  = new Card(Suit.Clubs, Rank.Eight);
            var player2Card  = new Card(Suit.Diamonds, Rank.King);
            var currentRound = new CurrentRound(new List <Player>()
            {
                new Player("1"), new Player("2")
            });

            currentRound.CardPot.Add(player1Card);
            currentRound.CardPot.Add(player2Card);

            var result = _gameRoundService.GetCardDrawResult(currentRound);

            Assert.AreEqual(player1Card, result.FirstPlayerCard);
            Assert.AreEqual(player2Card, result.SecondPlayerCard);
        }