private void FinishRound() { _dealerViewModel.AddDealersSecondCard(_round.DealersSecondPlayedCard); _round.FinalizeRoundResults(); if (_round.PlayerCards[EPlayers.Dealer].Count > 2) { _dealerViewModel.UpdateDealersCards(_round.PlayerCards[EPlayers.Dealer]); } foreach (EPlayers player in _round.PlayerResults.Keys) { if (_round.PlayerResults[player] == ERoundResult.PlayerWins) { _playerViewModels[player].CardSum = $"{_playerViewModels[player].CardSum} - Player wins the round!!!"; } if (_round.PlayerResults[player] == ERoundResult.DealerWins && _round.PlayerRoundStates[player] != EPlayerRoundState.ExceededTwentyOne) { _playerViewModels[player].CardSum = $"{_playerViewModels[player].CardSum} - Player loses the round"; } if (_round.PlayerResults[player] == ERoundResult.Push) { _playerViewModels[player].CardSum = $"{_playerViewModels[player].CardSum} - Player draws the round!"; } } }
public void ScenarioFour_PlayerCardsSummedCorrectly() { //Arrange int numberOfPlayers = 3; List <Card> cardsForRound = CardsForScenarioFour(); //Player one's cards : Ace of Clubs, Ace of Clubs, Spades 7 => Sum is 11 + 1 + 7 = 19 //Player two's cards : Ace of Diamonds, Hearts 4, Ace of Hearts => Sum is 11 + 4 + 1 = 16 //Player three's cards : Diamonds 3, Clubs 2, Diamonds 9 => Sum is 14 //Dealers' cards : Hearts 8, Hearts 9 => Sum is 17 //Act IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers); gameRound.DealCards(); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand); gameRound.FinalizeRoundResults(); //Assert if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 19) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 16) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 14) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 17) { Assert.Fail(); } }
public void ScenarioThree_PlayerCardsSummedCorrectly() { //Arrange int numberOfPlayers = 3; List <Card> cardsForRound = CardsForScenarioThree(); //Player one's cards : Clubs 6, Spades 10, Hearts 5 => Sum is 21 //Player two's cards : Diamonds 10, Jack of Hearts => Sum is 20 //Player three's cards : Diamonds 3, Clubs 2, Diamonds 9 => Sum is 14 //Dealers' cards : Ace of Spades, Hearts 9 => Sum is 20 //Act IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers); gameRound.DealCards(); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand); gameRound.FinalizeRoundResults(); //Assert if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 21) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 20) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 14) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 20) { Assert.Fail(); } }
public void ScenarioOne_PlayerCardsSummedCorrectly() { //Arrange int numberOfPlayers = 3; List <Card> cardsForRound = CardsForScenarioOne(); //Player one's cards : Hearts 7, Queens of Spades => Sum is 17 //Player two's cards : Jack of Diamonds, Jack of Hearts => Sum is 20 //Player three's cards : Diamonds 2, Spades 4, Diamonds 9 => Sum is 15 //Dealers' cards : Clubs 5, Clubs 9 => Sum is 14 //Act IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers); gameRound.DealCards(); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand); gameRound.FinalizeRoundResults(); //Assert if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 18) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 20) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 19) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 17) { Assert.Fail(); } }
public void ScenarioTwo_PlayerCardsSummedCorrectly() { //Arrange int numberOfPlayers = 3; List <Card> cardsForRound = CardsForScenarioTwo(); //Player one's cards : Clubs 2, Spades 3, Diamonds 7 => Sum is 12 //Player two's cards : Spades 4, Jack of Diamonds => Sum is 14 //Player three's cards : King of Diamonds, Spades 2, Clubs 5 => Sum is 17 //Dealers' cards : Diamonds 8, King of Spades => Sum is 18 //Act IBlackjackGameRound gameRound = new BlackjackGameRound(cardsForRound, numberOfPlayers); gameRound.DealCards(); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player2, ERoundCalls.Stand); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Hit); gameRound.PlayerCall(EPlayers.Player3, ERoundCalls.Stand); gameRound.FinalizeRoundResults(); //Assert if (gameRound.PlayersSumOfCards[EPlayers.Player1] != 12) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player2] != 14) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Player3] != 17) { Assert.Fail(); } if (gameRound.PlayersSumOfCards[EPlayers.Dealer] != 18) { Assert.Fail(); } }