def setup_dealer_and_play_preflop_where_everybody_calls( self, players, small_blind_size): for player in players: player.act = self.action_check_call() seating = Seating(players) dealer = Dealer(None, seating) dealer.setup_deck() winner = dealer.play_preflop(small_blind_size) print("# Preflop concluded") self.assertEqual(False, winner) return dealer
def setup_3_player_preflop_where_everybody_folds(self, initial_stack): button_player = self.setup_new_player("Button", initial_stack) sb_player = self.setup_new_player("SmallBlind", initial_stack) bb_player = self.setup_new_player("BigBlind", initial_stack) button_player.act = self.action_fold() sb_player.act = self.action_fold() bb_player.act = self.action_fold() seating = Seating([button_player, sb_player, bb_player]) dealer = Dealer(None, seating) dealer.setup_deck() return dealer
def test_preflop_round__when_player_raises__all_calls(self): initial_stack = 100 bet_size = 50 raise_size = bet_size + 10 small_blind_size = 5 button_player = self.setup_new_player("Button", initial_stack) sb_player = self.setup_new_player("SmallBlind", initial_stack) bb_player = self.setup_new_player("BigBlind", initial_stack) def call_raise(player_name): def call_raise_action(amount): if amount == small_blind_size * 2: print(player_name + " calls " + str(amount)) return Action.ACTION_CALL, amount print(player_name + " raises to " + str(raise_size)) return Action.ACTION_RAISE, raise_size return call_raise_action button_player.act = call_raise("Button") def raise_call(player_name): def raise_call_action(amount): if amount == small_blind_size * 2: print(player_name + " raises to " + str(bet_size)) return Action.ACTION_RAISE, bet_size print(player_name + " calls " + str(amount)) return Action.ACTION_CALL, amount return raise_call_action sb_player.act = raise_call("SmallBlind") bb_player.act = self.action_check_call() seating = Seating([button_player, sb_player, bb_player]) dealer = Dealer(None, seating) dealer.setup_deck() winner = dealer.play_preflop(small_blind_size) self.assertEqual(False, winner) self.assertTrue(button_player in dealer.pot.chips_per_player) self.assertTrue(sb_player in dealer.pot.chips_per_player) self.assertTrue(bb_player in dealer.pot.chips_per_player) self.assertEqual(initial_stack - raise_size, button_player.stack) self.assertEqual(initial_stack - raise_size, sb_player.stack) self.assertEqual(initial_stack - raise_size, bb_player.stack) self.assertEqual(raise_size * 3, dealer.pot.total_count())
def test_preflop_round__when_first_player_bets__all_calls(self): initial_stack = 100 bet_size = 50 small_blind_size = 5 button_player = self.setup_new_player("Button", initial_stack) sb_player = self.setup_new_player("SmallBlind", initial_stack) bb_player = self.setup_new_player("BigBlind", initial_stack) button_player.act = self.action_raise(bet_size) sb_player.act = self.action_check_call() bb_player.act = self.action_check_call() seating = Seating([button_player, sb_player, bb_player]) dealer = Dealer(None, seating) dealer.setup_deck() winner = dealer.play_preflop(small_blind_size) self.assertEqual(False, winner) self.assertTrue(button_player in dealer.pot.chips_per_player) self.assertTrue(sb_player in dealer.pot.chips_per_player) self.assertTrue(bb_player in dealer.pot.chips_per_player) self.assertEqual(initial_stack - bet_size, button_player.stack) self.assertEqual(initial_stack - bet_size, sb_player.stack) self.assertEqual(initial_stack - bet_size, bb_player.stack) self.assertEqual(bet_size * 3, dealer.pot.total_count())