1
1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from src.engine.utils import try_win,is_terminal_tile
|
||||
from collections import Counter
|
||||
|
||||
def is_basic_win(hand):
|
||||
# 将手牌转换为列表并按花色和数值排序
|
||||
@@ -124,3 +125,41 @@ def is_full_request(hand, melds, winning_tile):
|
||||
# 符合全求人
|
||||
return 6
|
||||
|
||||
def is_dragon_seven_pairs(hand, melds):
|
||||
"""
|
||||
判断是否符合龙七对的番型,并返回番数和剩余根数。
|
||||
|
||||
条件:
|
||||
- 玩家手牌为七对(14张,包含7个对子)。
|
||||
- 没有碰过或者杠过牌(melds为空)。
|
||||
- 至少一个对子升级为四张牌。
|
||||
|
||||
参数:
|
||||
- hand: Hand 对象,表示玩家当前的手牌。
|
||||
- melds: 明牌列表(碰、杠等),必须为空。
|
||||
|
||||
返回:
|
||||
- (int, int): 如果符合龙七对,返回 (12, -1) 表示 12 番和减去 1 根;否则返回 (0, 0)。
|
||||
"""
|
||||
if melds: # 如果有明牌(碰或杠),不符合条件
|
||||
return 0, 0
|
||||
|
||||
# 获取手牌中每张牌的数量
|
||||
tile_counts = Counter(hand.tiles)
|
||||
|
||||
# 统计对子和四张牌的数量
|
||||
pairs_count = 0
|
||||
four_of_a_kind_found = False
|
||||
|
||||
for count in tile_counts.values():
|
||||
if count == 2:
|
||||
pairs_count += 1
|
||||
elif count == 4:
|
||||
four_of_a_kind_found = True
|
||||
pairs_count += 1
|
||||
|
||||
# 检查是否符合龙七对的条件
|
||||
if pairs_count == 7 and four_of_a_kind_found:
|
||||
return 12, -1 # 龙七对计为 12 番,并减少 1 根
|
||||
return 0, 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user