コード例 #1
0
    def test_can_create_standard_52_cards(self):
        cards = Card.create_standard_52_cards()
        self.assertEqual(len(cards), 52)

        self.assertEqual(cards[0], Card(rank="2", suit="Hearts"))

        self.assertEqual(cards[-1], Card(rank="Ace", suit="Diamonds"))
コード例 #2
0
 def test_create_52_cards(self):
     cards = Card.create_standard_52_cards()
     self.assertEqual(len(cards), 52)
     self.assertEqual(cards[0], Card(rank='2', suit='Hearts'))
     self.assertEqual(cards[-1], Card(rank='Ace', suit='Diamonds'))
コード例 #3
0
ファイル: main.py プロジェクト: leorrib/texas_holdem_poker
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]