Exemple #1
0
    def test_overtrumping_the_opponent_is_mandatory_if_teammate_is_not_leading(
            self) -> None:
        players = [Player(), Player(), Player(), Player()]
        players[0].hand = {Card(suit=Suit.HEARTS, rank=Rank.KING)}
        players[1].hand = {Card(suit=Suit.DIAMONDS, rank=Rank.TEN)}
        players[2].hand = {Card(suit=Suit.SPADES, rank=Rank.QUEEN)}
        players[3].hand = {
            Card(suit=Suit.DIAMONDS, rank=Rank.ACE),
            Card(suit=Suit.SPADES, rank=Rank.EIGHT),
            Card(suit=Suit.SPADES, rank=Rank.JACK),
        }

        deal = Deal(players=players,
                    bidder_index=0,
                    trump_suit=Suit.SPADES,
                    rules=RuleSet.ROTTERDAM)
        trick = Trick(deal=deal, leading_player_index=0)
        trick.play(Card(suit=Suit.HEARTS, rank=Rank.KING))
        trick.play(Card(suit=Suit.DIAMONDS, rank=Rank.TEN))
        trick.play(Card(suit=Suit.SPADES, rank=Rank.QUEEN))

        self.assertEqual({
            Card(suit=Suit.SPADES, rank=Rank.JACK),
        }, trick.legal_cards)

        # No matter whether this game is Rotterdam or Amsterdam style, the trump is the only legitimate option.
        deal.rules = RuleSet.AMSTERDAM
        self.assertEqual({
            Card(suit=Suit.SPADES, rank=Rank.JACK),
        }, trick.legal_cards)
Exemple #2
0
    def test_overtrumping_your_teammate_is_not_mandatory_in_amsterdam_deals_if_teammate_is_winning(
            self) -> None:
        players = [Player(), Player(), Player(), Player()]
        players[0].hand = {Card(suit=Suit.HEARTS, rank=Rank.KING)}
        players[1].hand = {Card(suit=Suit.SPADES, rank=Rank.TEN)}
        players[2].hand = {Card(suit=Suit.HEARTS, rank=Rank.NINE)}
        players[3].hand = {
            Card(suit=Suit.DIAMONDS, rank=Rank.ACE),
            Card(suit=Suit.SPADES, rank=Rank.EIGHT),
            Card(suit=Suit.SPADES, rank=Rank.JACK),
        }

        deal = Deal(players=players,
                    bidder_index=0,
                    trump_suit=Suit.SPADES,
                    rules=RuleSet.AMSTERDAM)
        trick = Trick(deal=deal, leading_player_index=0)
        trick.play(Card(suit=Suit.HEARTS, rank=Rank.KING))
        trick.play(Card(suit=Suit.SPADES, rank=Rank.TEN))
        trick.play(Card(suit=Suit.HEARTS, rank=Rank.NINE))

        # Playing a higher trump is legal, but not necessary. The player may also drop the ace.
        # Note however that playing a lower trump is still illegal.
        self.assertEqual(
            {
                Card(suit=Suit.DIAMONDS, rank=Rank.ACE),
                Card(suit=Suit.SPADES, rank=Rank.JACK),
            }, trick.legal_cards)

        # In an Amsterdam deal, the player is forced to play the higher trump card.
        deal.rules = RuleSet.ROTTERDAM
        self.assertEqual({
            Card(suit=Suit.SPADES, rank=Rank.JACK),
        }, trick.legal_cards)