Update chengdu_mahjong_engine.py
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
from .game_state import ChengduMahjongState
|
||||
from .utils import get_suit
|
||||
|
||||
|
||||
class ChengduMahjongEngine:
|
||||
def __init__(self):
|
||||
self.state = ChengduMahjongState()
|
||||
@@ -40,6 +44,7 @@ class ChengduMahjongEngine:
|
||||
else:
|
||||
raise ValueError("杠牌条件不满足")
|
||||
|
||||
# 设置缺门
|
||||
def set_missing_suit(player, missing_suit):
|
||||
# 确定玩家的缺门
|
||||
valid_suits = ["条", "筒", "万"]
|
||||
@@ -48,11 +53,13 @@ def set_missing_suit(player, missing_suit):
|
||||
player.missing_suit = missing_suit
|
||||
|
||||
|
||||
# 判断是否可以流局
|
||||
def check_blood_battle(self):
|
||||
if len(self.winners) >= 3 or self.state.remaining_tiles == 0:
|
||||
self.game_over = True
|
||||
|
||||
|
||||
# 判断是否可以胡牌
|
||||
def can_win(hand):
|
||||
# 判断是否满足胡牌条件(四组+一对)
|
||||
from collections import Counter
|
||||
@@ -77,7 +84,7 @@ def can_win(hand):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
# 计算番数
|
||||
def calculate_fan(hand, melds, is_self_draw, is_cleared):
|
||||
fan = 1 # 基本胡
|
||||
if is_cleared:
|
||||
|
||||
Reference in New Issue
Block a user