Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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])
Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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")
Esempio 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")
 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)
 def test_decides_to_continue_or_fold(self):
     player = Player(name="Aaron", hand=Hand())
     self.assertEqual(player.wants_to_fold(), False)
Esempio 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
     )
Esempio 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
Esempio n. 17
0
    def test_figures_out_no_cards_is_best_rank(self):
        hand = Hand()

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