1
This commit is contained in:
2024-12-01 01:51:51 +08:00
parent fbfb4b89e1
commit 729f1bf7a1
3 changed files with 205 additions and 1 deletions

View File

@@ -42,6 +42,21 @@ class ChengduMahjongState:
raise ValueError("缺门设置无效")
self.missing_suits[player] = missing_suit
def print_game_state(self, player_index: int):
"""
打印指定玩家的手牌、暗牌、明牌和缺门信息。
:param player_index: 要打印的玩家索引0-3
"""
hand = self.hands[player_index]
melds = self.melds[player_index]
missing_suit = self.missing_suits[player_index]
# 打印日志,所有信息在一行
logger.info(
f"玩家索引: {player_index}, 手牌: {hand}, 明牌: {melds}, 总牌数: {len(hand.tiles) + sum(meld.count for meld in melds)}, 缺门: {missing_suit}"
)
def can_win(self, hand: Hand, melds: list[Meld], missing_suit: str):
"""
判断玩家是否能胡牌。