def test_normal_pot(monkeypatch): monkeypatch.setattr(game, "random", Random(0)) test_players = [ PlayerInHand(session_id="ls", bet=0, eligibility=5, has_option=False), PlayerInHand(session_id="w", bet=0, eligibility=5, has_option=False), PlayerInHand(session_id="lb", bet=0, eligibility=5, has_option=False), ] finished_game = Game( players=test_players, stage=Stage.RIVER, pot=max(tp.eligibility for tp in test_players), deck=_make_deck(len(test_players)), ) room = MockRoom() room.players = { "ls": Player(balance=10, name="loser", pending_balance=0), "w": Player(balance=20, name="winner", pending_balance=0), "lb": Player(balance=40, name="alsoloser", pending_balance=0), } finished_game.pay_winners(room) assert room.players["ls"].balance == 10 assert room.players["w"].balance == 25 assert room.players["lb"].balance == 40
def test_showdown_no_show(): test_players = [ PlayerInHand(session_id="ls", bet=0, eligibility=None, has_option=False), # Want this player to win first PlayerInHand(session_id="w", bet=0, eligibility=20, has_option=False), PlayerInHand(session_id="lb", bet=0, eligibility=None, has_option=False), ] finished_game = Game( players=test_players, stage=Stage.RIVER, pot=max(tp.eligibility or 0 for tp in test_players), # ls w wb lb community deck=("2H3D" "AHAS" "ADAC" "XDXS" "3C9S5DJSQC"), ) room = MockRoom() room.players = { "ls": Player(balance=7, name="loser", pending_balance=0), "w": Player(balance=0, name="winner", pending_balance=0), "lb": Player(balance=12, name="alsoloser", pending_balance=0), } finished_game.pay_winners(room) assert room.players["ls"].balance == 7 assert room.players["w"].balance == 20 assert room.players["lb"].balance == 12 assert finished_game.pot == 0 assert set(room.log[0].players.keys()) == set(("w",)) # Should not have shown down assert room.log[0].players["w"].hand is None
def test_sidepot_random(monkeypatch): monkeypatch.setattr(game, "random", Random(0)) test_players = [ PlayerInHand(session_id="ls", bet=0, eligibility=3, has_option=False), # Want this player to win first PlayerInHand(session_id="w", bet=0, eligibility=5, has_option=False), # But then these players split because hilarious raisins PlayerInHand(session_id="wb", bet=0, eligibility=8, has_option=False), PlayerInHand(session_id="lb", bet=0, eligibility=8, has_option=False), ] finished_game = Game( players=test_players, stage=Stage.RIVER, pot=max(tp.eligibility for tp in test_players), deck=_make_deck(len(test_players)), ) room = MockRoom() room.players = { "ls": Player(balance=0, name="loser", pending_balance=0), "w": Player(balance=0, name="winner", pending_balance=0), "lb": Player(balance=12, name="alsoloser", pending_balance=0), "wb": Player(balance=10, name="bigwinner", pending_balance=0), } finished_game.pay_winners(room) assert room.players["w"].balance == 5 # Should split between wb and lb assert room.players["wb"].balance == 11 assert room.players["lb"].balance == 13 # Should leave 1 chip in the pot for the next round assert finished_game.pot == 1 assert set(room.log[0].players.keys()) == set(("w", "lb", "wb"))
def test_sidepot_1(): test_players = [ PlayerInHand(session_id="ls", bet=0, eligibility=None, has_option=False), # Want w and wb to split the pot PlayerInHand(session_id="w", bet=0, eligibility=10, has_option=False), PlayerInHand(session_id="wb", bet=0, eligibility=20, has_option=False), # This player should unevenly lose their chips PlayerInHand(session_id="lb", bet=0, eligibility=20, has_option=False), ] finished_game = Game( players=test_players, stage=Stage.RIVER, pot=max(tp.eligibility or 0 for tp in test_players), # ls w wb lb community deck=("2H3D" "AHAS" "ADAC" "XDXS" "3C9S5DJSQC"), ) room = MockRoom() room.players = { "ls": Player(balance=7, name="loser", pending_balance=0), "w": Player(balance=0, name="winner", pending_balance=0), "lb": Player(balance=12, name="alsoloser", pending_balance=0), "wb": Player(balance=10, name="bigwinner", pending_balance=0), } finished_game.pay_winners(room) assert room.players["ls"].balance == 7 assert room.players["w"].balance == 5 assert room.players["wb"].balance == 25 assert room.players["lb"].balance == 12 assert finished_game.pot == 0