This commit is contained in:
2024-11-30 19:15:24 +08:00
parent 2a5680fae9
commit 9f7a22be7f
4 changed files with 54 additions and 22 deletions

View File

@@ -67,13 +67,23 @@ def is_seven_pairs(hand):
return sum(1 for count in hand if count == 2) == 7
def is_cleared(hand):
def is_cleared(hand, melds):
"""
检查手牌是否是清一色。
"""
suits = [tile // 36 for tile, count in enumerate(hand) if count > 0]
return len(set(suits)) == 1
检查手牌和明牌是否是清一色。
参数:
- hand: 当前胡牌的手牌长度为108的列表表示每张牌的数量
- melds: 碰杠等明牌列表。
返回:
- bool: 是否为清一色。
"""
# 获取所有牌的花色
all_tiles = hand + [tile for meld in melds for tile in meld]
suits = [tile // 36 for tile in all_tiles if tile > 0]
# 检查是否有多种花色
return len(set(suits)) == 1
def is_big_pairs(hand):
"""