Update test_chengdu_mahjong_states.py

dev
wangsiyuan 2024-12-01 02:05:48 +08:00
parent 3d87d3850f
commit 1562f784bf
1 changed files with 32 additions and 1 deletions

View File

@ -481,3 +481,34 @@ def test_can_win_with_small_seven_pairs():
# 调用 can_win 方法并断言胡牌
assert state.can_win(state.hands[0], state.melds[0], missing_suit), "测试失败:小七对应该可以胡牌"
print("测试通过:小七对胡牌成功!")
def test_can_win_with_jin_gou_diao():
"""测试金钩吊胡牌"""
hand = Hand()
# 添加仅剩的一张牌
hand.add_tile(MahjongTile("", 3))
# 初始化游戏状态
state = ChengduMahjongState()
state.hands[0] = hand
state.melds[0] = [
Meld(MahjongTile("", 8), ""), # 8筒碰
Meld(MahjongTile("", 7), ""), # 7筒碰
Meld(MahjongTile("", 9), ""), # 9筒杠
Meld(MahjongTile("", 3), "") # 3筒碰
]
# 设置缺门为 "条",因为手牌和明牌中没有 "条"
missing_suit = ""
# 打印当前玩家状态
state.print_game_state(player_index=0)
# 模拟别人打出一张 "筒3",胡牌
winning_tile = MahjongTile("", 3)
state.hands[0].add_tile(winning_tile)
# 调用 can_win 方法并断言胡牌
can_win = state.can_win(state.hands[0], state.melds[0], missing_suit)
assert can_win, f"测试失败:金钩吊未能胡 {winning_tile}"
print("测试通过:金钩吊胡牌成功!")