Ejemplo n.º 1
0
    def test_figures_out_high_card_is_best_rank(self):
        cards = [Card(rank="Ace", suit="Spades"), Card(rank="6", suit="Clubs")]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "High Card")
Ejemplo n.º 2
0
    def test_figures_out_best_rank_when_flush(self):
        cards = [
            Card(rank=rank, suit="Hearts")
            for rank in ["2", "5", "8", "10", "Ace"]
        ]
        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Flush")
Ejemplo n.º 3
0
    def test_shows_all_its_cards_in_technical_representation(self):
        cards = [
            Card(rank="Ace", suit="Diamonds"),
            Card(rank="7", suit="Clubs")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(repr(hand), "7 of Clubs, Ace of Diamonds")
Ejemplo n.º 4
0
    def test_does_not_return_two_consecutive_cards_as_straight(self):
        cards = [
            Card(rank="6", suit="Hearts"),
            Card(rank="7", suit="Diamonds")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "High Card")
Ejemplo n.º 5
0
    def test_recieves_and_stores_cards(self):
        ace_of_spades = Card(rank="Ace", suit="Spades")
        six_of_spades = Card(rank="6", suit="Clubs")

        cards = [ace_of_spades, six_of_spades]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.cards, [six_of_spades, ace_of_spades])
Ejemplo n.º 6
0
    def test_figures_out_straight_is_best_rank(self):
        cards = [
            Card(rank="6", suit="Hearts"),
            Card(rank="7", suit="Diamonds"),
            Card(rank="8", suit="Spades"),
            Card(rank="9", suit="Clubs"),
            Card(rank="10", suit="Clubs")
        ]
        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Straight")
Ejemplo n.º 7
0
    def test_figures_out_royal_flush_is_best_rank(self):
        cards = [
            Card(rank="10", suit="Clubs"),
            Card(rank="Jack", suit="Clubs"),
            Card(rank="Queen", suit="Clubs"),
            Card(rank="King", suit="Clubs"),
            Card(rank="Ace", suit="Clubs")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Royal Flush")
Ejemplo n.º 8
0
    def test_figures_out_straight_flush_is_best_rank(self):
        cards = [
            Card(rank="3", suit="Clubs"),
            Card(rank="4", suit="Clubs"),
            Card(rank="5", suit="Clubs"),
            Card(rank="6", suit="Clubs"),
            Card(rank="7", suit="Clubs")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Straight Flush")
Ejemplo n.º 9
0
    def test_figures_out_four_of_a_kind_is_best_rank(self):
        cards = [
            Card(rank="3", suit="Clubs"),
            Card(rank="3", suit="Hearts"),
            Card(rank="3", suit="Spades"),
            Card(rank="3", suit="Diamonds"),
            Card(rank="9", suit="Spades")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Four of a Kind")
Ejemplo n.º 10
0
    def test_figures_out_full_house_is_best_rank(self):
        cards = [
            Card(rank="3", suit="Clubs"),
            Card(rank="3", suit="Hearts"),
            Card(rank="3", suit="Spades"),
            Card(rank="9", suit="Diamonds"),
            Card(rank="9", suit="Spades")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Full House")
Ejemplo n.º 11
0
    def test_figures_out_three_of_a_kind_is_best_rank(self):
        cards = [
            Card(rank="King", suit="Clubs"),
            Card(rank="King", suit="Hearts"),
            Card(rank="King", suit="Diamonds"),
            Card(rank="Ace", suit="Spades"),
            Card(rank="5", suit="Clubs")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Three of a Kind")
Ejemplo n.º 12
0
    def test_figures_out_two_pair_is_best_rank(self):
        cards = [
            Card(rank="Ace", suit="Spades"),
            Card(rank="5", suit="Clubs"),
            Card(rank="Ace", suit="Clubs"),
            Card(rank="King", suit="Hearts"),
            Card(rank="King", suit="Diamonds")
        ]

        hand = Hand()
        hand.add_cards(cards)

        self.assertEqual(hand.best_rank(), "Two Pair")
Ejemplo n.º 13
0
 def test_stores_name_and_hand(self):
     hand = Hand()
     player = Player(name="Ron", hand=hand)
     self.assertEqual(player.name, "Ron")
     self.assertEqual(player.hand, hand)
Ejemplo n.º 14
0
 def test_decides_to_continue_or_fold(self):
     player = Player(name="Aaron", hand=Hand())
     self.assertEqual(player.wants_to_fold(), False)
Ejemplo n.º 15
0
 def test_decides_to_continue_or_drop_out_of_the_game(self):
     player = Player(name = "Sharon", hand = Hand())
     self.assertEqual(
         player.wants_to_fold(),
         False
     )
Ejemplo n.º 16
0
from Poker.card import Card
from Poker.deck import Deck
from Poker.game_round import GameRound
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()

player1 = Player(name="Boris", hand=hand1)
player2 = Player(name="Bobby", hand=hand2)
players = [player1, player2]

game_round = GameRound(deck=deck, players=players)
game_round.play()

print(player1.hand)
print(player1.best_hand())
print(player2.hand)
print(player2.best_hand())

#From main import deck, cards, game_round,hand1,hand2,player1,player2
Ejemplo n.º 17
0
    def test_figures_out_no_cards_is_best_rank(self):
        hand = Hand()

        self.assertEqual(hand.best_rank(), "No Cards")
Ejemplo n.º 18
0
 def test_starts_out_with_no_cards(self):
     hand = Hand()
     self.assertEqual(hand.cards, [])