public void SecondPlayerShouldWins(Card firstPlayerCard, Card secondPlayerCard, CardSuit trumpSuit) { var cardWinner = new CardWinnerLogic(); var result = cardWinner.Winner(firstPlayerCard, secondPlayerCard, trumpSuit); Assert.AreEqual(PlayerPosition.SecondPlayer, result); }
public RoundPlayerInfo Play() { var context = new PlayerTurnContext( this.stateManager.State, this.deck.TrumpCard, this.deck.CardsLeft, this.firstToPlay.RoundPoints, this.secondToPlay.RoundPoints); // First player var firstPlayerAction = this.GetFirstPlayerAction(this.firstToPlay, context); context.FirstPlayedCard = firstPlayerAction.Card; context.FirstPlayerAnnounce = firstPlayerAction.Announce; context.FirstPlayerRoundPoints = this.firstToPlay.RoundPoints; this.firstToPlay.Cards.Remove(firstPlayerAction.Card); // When player announces something he may immediately become round winner if (this.firstToPlay.RoundPoints >= this.gameRules.RoundPointsForGoingOut) { // Inform players for end turn this.firstToPlay.Player.EndTurn(context); this.secondToPlay.Player.EndTurn(context); return(this.firstToPlay); } // Second player var secondPlayerAction = GetPlayerAction(this.secondToPlay, context); context.SecondPlayedCard = secondPlayerAction.Card; this.secondToPlay.Cards.Remove(secondPlayerAction.Card); // Determine winner ICardWinnerLogic cardWinnerLogic = new CardWinnerLogic(); var winnerPosition = cardWinnerLogic.Winner( firstPlayerAction.Card, secondPlayerAction.Card, this.deck.TrumpCard.Suit); var winner = winnerPosition == PlayerPosition.FirstPlayer ? this.firstToPlay : this.secondToPlay; winner.TrickCards.Add(firstPlayerAction.Card); winner.TrickCards.Add(secondPlayerAction.Card); // Inform players for end turn context.FirstPlayerRoundPoints = this.firstToPlay.RoundPoints; context.SecondPlayerRoundPoints = this.secondToPlay.RoundPoints; this.firstToPlay.Player.EndTurn(context); this.secondToPlay.Player.EndTurn(context); return(winner); }