shortdeck1.1

This commit is contained in:
2025-09-30 18:26:06 +08:00
parent ee95b8e049
commit 7071eaa12b
14 changed files with 665 additions and 59 deletions

View File

@@ -4,23 +4,31 @@ from shortdeck_server.arena_adapter import ArenaGame
def test_join_and_actions():
g = ArenaGame(starting_stack=100, max_players=3)
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()
assert state["stacks"] == [100, 100]
# 在短牌扑克中,玩家加入后盲注已自动扣除
# 小盲(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)
g.apply_action(0, "check")
# 小盲玩家call (跟注到大盲)
g.apply_action(0, "call")
assert g.current_turn == 1
g.apply_action(1, "bet", 10)
assert g.pot == 10
assert g.stacks[1] == 90
# 大盲玩家加注
g.apply_action(1, "bet", 10)
assert g.pot >= 10 # 底池至少包含加注金额
assert g.history[-1]["action"] == "bet"