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