Files
shortdeck/shortdeck_server/tests/test_game.py
2025-10-09 15:28:34 +08:00

35 lines
992 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
from shortdeck_server.arena_adapter import ArenaGame
def test_join_and_actions():
g = ArenaGame(starting_stack=100, max_players=3, small_blind=1, big_blind=2)
pid0 = g.join_game("aa")
pid1 = g.join_game("bb")
assert pid0 == 0
assert pid1 == 1
state = g.info()
# 在短牌扑克中,玩家加入后盲注已自动扣除
# 小盲(pid0): 100-1=99, 大盲(pid1): 100-2=98
assert state["stacks"] == [99, 98]
# 验证轮次管理heads-up时小盲先行动
assert g.current_turn == 0
# 测试错误的玩家尝试行动
try:
g.apply_action(1, "fold")
except ValueError as e:
assert "not your turn" in str(e)
# 小盲玩家call (跟注到大盲)
g.apply_action(0, "call")
assert g.current_turn == 1
# 大盲玩家加注
g.apply_action(1, "bet", 10)
assert g.pot >= 10 # 底池至少包含加注金额
assert g.history[-1]["action"] == "bet"