Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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"))