Update scoring.py
parent
6e0c8a80f3
commit
c041963b97
|
|
@ -1,52 +1,32 @@
|
|||
def calculate_score(fan: int, base_score: int, is_self_draw: bool, is_dealer: bool) -> dict:
|
||||
def calculate_score(fan: int, base_score: int, is_self_draw: bool) -> dict:
|
||||
"""
|
||||
根据规则计算得分。
|
||||
根据成都麻将规则计算得分(不区分庄家和闲家)。
|
||||
|
||||
参数:
|
||||
- fan: 总番数。
|
||||
- base_score: 底分。
|
||||
- is_self_draw: 是否为自摸。
|
||||
- is_dealer: 是否为庄家。
|
||||
|
||||
返回:
|
||||
- scores: 字典,包含赢家得分和输家扣分。
|
||||
"""
|
||||
# 翻倍计算基础分
|
||||
total_score = base_score * (2 ** fan)
|
||||
# 计算总分
|
||||
multiplier = 2 ** fan # 根据番数计算倍率
|
||||
total_score = base_score * multiplier
|
||||
|
||||
if is_self_draw:
|
||||
# 自摸,其他三家平摊
|
||||
if is_dealer:
|
||||
# 庄家自摸:每家付单倍总分
|
||||
per_loser_score = -total_score
|
||||
winner_score = total_score * 3 # 三家支付的总和
|
||||
return {
|
||||
"winner": winner_score,
|
||||
"loser": [per_loser_score] * 3
|
||||
}
|
||||
else:
|
||||
# 闲家自摸:庄家付双倍,其他两家付单倍
|
||||
dealer_loss = -total_score * 2
|
||||
other_loss = -total_score
|
||||
winner_score = -dealer_loss + 2 * -other_loss # 庄家和两闲家支付总和
|
||||
return {
|
||||
"winner": winner_score,
|
||||
"loser": [dealer_loss, other_loss, other_loss]
|
||||
}
|
||||
# 自摸:三家平摊分数
|
||||
per_loser_score = -total_score
|
||||
winner_score = total_score * 3 # 总赢家得分
|
||||
return {
|
||||
"winner": winner_score,
|
||||
"loser": [per_loser_score] * 3
|
||||
}
|
||||
else:
|
||||
# 点炮,点炮者独付
|
||||
# 点炮:点炮者独付
|
||||
loser_score = -total_score
|
||||
winner_score = total_score
|
||||
if is_dealer:
|
||||
# 庄家点炮
|
||||
return {
|
||||
"winner": winner_score,
|
||||
"loser": [loser_score, 0, 0]
|
||||
}
|
||||
else:
|
||||
# 闲家点炮
|
||||
return {
|
||||
"winner": winner_score,
|
||||
"loser": [loser_score, 0, 0]
|
||||
}
|
||||
|
||||
return {
|
||||
"winner": winner_score,
|
||||
"loser": [loser_score, 0, 0]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue