Пример #1
0
    def test_shuffles_card_in_random_order(self, mock_shuffle):
        deck = Deck()

        cards = [Card(rank="2", suit="Clubs"), Card(rank="Ace", suit="Spades")]

        deck.add_cards(cards)
        deck.shuffle()
        mock_shuffle.assert_called_once_with(cards)
Пример #2
0
    def test_adds_cards_to_its_collection(self):
        card = Card(rank= "Ace",suit="Spades")
        deck = Deck()
        deck.add_cards([card])

        self.assertEqual(
            deck.cards,
            [card]
        )
    def test_adds_cards_to_its_collections(self):
        card1 = Card(rank = "Ace", suit = "Spades")
        card2 = Card(rank = "Jack", suit = "Diamonds")
        deck = Deck()
        deck.add_cards([card1, card2])

        self.assertEqual(
            deck._cards,
            [card1, card2]
        )
Пример #4
0
    def test_remove_specified_number_of_card_from_deck(self):
        ace = Card(rank="Ace", suit="Spades")
        eight = Card(rank="8", suit="Diamonds")
        cards = [ace, eight]

        deck = Deck()
        deck.add_cards(cards)

        self.assertEqual(deck.remove_card(1), [ace])

        self.assertEqual(deck.cards, [eight])
Пример #5
0
    def test_deck_shuffles_the_cards(self, mock_shuffle):

        deck = Deck()

        cards = [
            Card(rank="Ace", suite="clubs"),
            Card(rank="8", suite="clubs")
        ]
        deck.add_cards(cards)
        deck.shuffle()

        mock_shuffle.assert_called_once_with(cards)
Пример #6
0
    def test_removes_specified_number_of_cards_from_deck(self):
        two = Card(rank="2", suit="Clubs"),
        ace = Card(rank="Ace", suit="Spades")
        cards = [two, ace]

        deck = Deck()

        deck.add_cards(cards)

        self.assertEqual(deck.remove_cards(1), [two])

        self.assertEqual(deck.cards, [ace])
Пример #7
0
    def test_to_remove_number_of_cards_from_deck(self):

        deck = Deck()
        ace = Card(rank="Ace", suite="spades")
        eight = Card(rank="8", suite="diamonds")

        cards = [ace, eight]

        deck.add_cards(cards)

        self.assertEqual(deck.remove_cards(1), [ace])

        self.assertEqual(deck.cards, [eight])
Пример #8
0
from poker.card import Card
from poker.deck import Deck
from poker.game import Game
from poker.hand import Hand
from poker.player import Player

deck = Deck()
cards = Card.create_standard_52_cards()
deck.add_cards(cards)

hand1 = Hand()
hand2 = Hand()
hand3 = Hand()

player1 = Player(name="Leo", hand=hand1)
player2 = Player(name="Rodrigo", hand=hand2)
player3 = Player(name="Diego", hand=hand3)
players = [player1, player2, player3]

game = Game(deck=deck, players=players)
game.play()

for player in players:
    index, hand_name, hand_cards = player.best_hand()
    hand_cards_strings = [str(card) for card in hand_cards]
    hand_cards_string = " and ".join(hand_cards_strings)
    print(
        f"{player.name} has a {hand_name} with the following hand: {hand_cards_string}."
    )

winners_list_name = [max(players).name]
Пример #9
0
    def test_add_cards_to_deck(self):
        card = Card(rank="2", suite="clubs")
        deck = Deck()
        deck.add_cards([card])

        self.assertEqual(deck.cards, [card])