def test_collect_blinds(self):
     initial_stack = 1000
     small_blind_size = 5
     big_blind_size = small_blind_size * 2
     button_player = self.setup_new_player("Button", initial_stack)
     player2 = self.setup_new_player("SmallBlind", initial_stack)
     player3 = self.setup_new_player("BigBlind", initial_stack)
     seating = Seating([button_player, player2, player3])
     deck = Deck()
     dealer = Dealer(deck, seating)
     dealer.pot = Pot()
     dealer.collect_blinds(small_blind_size)
     self.assertEqual(initial_stack, button_player.stack)
     self.assertEqual(initial_stack - small_blind_size, player2.stack)
     self.assertEqual(initial_stack - big_blind_size, player3.stack)
     self.assertEqual(big_blind_size + small_blind_size,
                      dealer.pot.total_count())
     dealer.move_button()
     dealer.pot = Pot()
     dealer.collect_blinds(small_blind_size)
     self.assertEqual(initial_stack - big_blind_size, button_player.stack)
     self.assertEqual(initial_stack - small_blind_size, player2.stack)
     self.assertEqual(initial_stack - big_blind_size - small_blind_size,
                      player3.stack)
     self.assertEqual(big_blind_size + small_blind_size,
                      dealer.pot.total_count())
     self.assertTrue(button_player in dealer.pot.chips_per_player)
     self.assertTrue(player3 in dealer.pot.chips_per_player)
Exemple #2
0
    def test_player_calls__when_players_allin_with_stack_that_is_too_small__side_pot_is_formed(self):
        player1 = Player("Player1", 1000)
        player2 = Player("Player2", 90)
        player3 = Player("Player3", 80)
        pot = Pot()
        pot.player_calls(player1, 100)
        pot.player_calls(player2, 90)
        pot.player_calls(player3, 80)

        pots = pot.get_all_pots()
        self.assertEqual(3, len(pots))
        main_pot = pots[0]
        self.assertEqual(240, main_pot.pot_size())
        self.assertTrue(player1 in main_pot.chips_per_player)
        self.assertTrue(player2 in main_pot.chips_per_player)
        self.assertTrue(player3 in main_pot.chips_per_player)

        side_pot = pots[1]
        self.assertEqual(20, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 in side_pot.chips_per_player)
        self.assertTrue(player3 not in side_pot.chips_per_player)

        side_pot = pots[2]
        self.assertEqual(10, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 not in side_pot.chips_per_player)
        self.assertTrue(player3 not in side_pot.chips_per_player)
Exemple #3
0
    def test_player_calls__when_players_allin_after_placing_blinds(self):
        player1 = Player("Player1", 1000)
        player2 = Player("Player2", 600)
        player3 = Player("Player3", 200)
        pot = Pot()
        pot.player_calls(player2, 5)
        pot.player_calls(player3, 200)
        pot.player_calls(player1, 1000)
        pot.player_calls(player2, 600)

        pots = pot.get_all_pots()
        self.assertEqual(3, len(pots))
        main_pot = pots[0]
        self.assertEqual(600, main_pot.pot_size())
        self.assertTrue(player1 in main_pot.chips_per_player)
        self.assertTrue(player2 in main_pot.chips_per_player)
        self.assertTrue(player3 in main_pot.chips_per_player)

        side_pot = pots[1]
        self.assertEqual(800, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 in side_pot.chips_per_player)
        self.assertTrue(player3 not in side_pot.chips_per_player)

        side_pot = pots[2]
        self.assertEqual(400, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 not in side_pot.chips_per_player)
        self.assertTrue(player3 not in side_pot.chips_per_player)
Exemple #4
0
 def play_preflop(self, small_blind_size):
     self.big_blind_size = small_blind_size * 2
     self.pot = Pot()
     self.collect_blinds(small_blind_size)
     self.deal_cards_to_players()
     bb_player = self.seating.big_blind_player()
     amount_to_match = small_blind_size * 2
     return self.ask_players_for_actions(bb_player, amount_to_match, True)
 def test_collect_blinds__when_player_dont_have_enough_chips(self):
     initial_stack = 100
     small_blind_size = 5
     big_blind_size = small_blind_size * 2
     button_player = self.setup_new_player("Button", 100)
     player2 = self.setup_new_player("SmallBlind", small_blind_size - 1)
     player3 = self.setup_new_player("BigBlind", big_blind_size - 1)
     seating = Seating([button_player, player2, player3])
     deck = Deck()
     dealer = Dealer(deck, seating)
     dealer.pot = Pot()
     dealer.collect_blinds(small_blind_size)
     self.assertEqual(initial_stack, button_player.stack)
     self.assertEqual(0, player2.stack)
     self.assertEqual(0, player3.stack)
     self.assertEqual(13, dealer.pot.total_count())
     self.assertTrue(player2 in dealer.pot.chips_per_player)
     self.assertTrue(player3 in dealer.pot.chips_per_player)
Exemple #6
0
    def test_player_calls__when_three_players_allin_with_stacks_that_are_too_small__three_side_pots_are_formed(self):
        player1 = Player("Player1", 1000)
        player2 = Player("Player2", 600)
        player3 = Player("Player3", 200)
        player4 = Player("Player4", 50)
        pot = Pot()
        pot.player_calls(player1, 999)
        pot.player_calls(player2, 600)
        pot.player_calls(player3, 200)
        pot.player_calls(player4, 50)

        pots = pot.get_all_pots()
        self.assertEqual(4, len(pots))
        main_pot = pots[0]
        self.assertEqual(200, main_pot.pot_size())
        self.assertTrue(player1 in main_pot.chips_per_player)
        self.assertTrue(player2 in main_pot.chips_per_player)
        self.assertTrue(player3 in main_pot.chips_per_player)
        self.assertTrue(player4 in main_pot.chips_per_player)

        side_pot = pots[1]
        self.assertEqual(450, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 in side_pot.chips_per_player)
        self.assertTrue(player3 in side_pot.chips_per_player)
        self.assertTrue(player4 not in side_pot.chips_per_player)

        side_pot = pots[2]
        self.assertEqual(800, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 in side_pot.chips_per_player)
        self.assertTrue(player3 not in side_pot.chips_per_player)
        self.assertTrue(player4 not in side_pot.chips_per_player)

        side_pot = pots[3]
        self.assertEqual(399, side_pot.pot_size())
        self.assertTrue(player1 in side_pot.chips_per_player)
        self.assertTrue(player2 not in side_pot.chips_per_player)
        self.assertTrue(player3 not in side_pot.chips_per_player)
        self.assertTrue(player4 not in side_pot.chips_per_player)