fix: Code Review — CheckTing完全断裂 + 座位顺序 + FanValue硬编码
🔴 Critical: CheckTing逻辑完全错误 - 旧: testHand.RemoveAt(i) → 13张 → CheckWin守卫拒绝(≠14) → 听牌检测永远false - 新: 遍历所有可摸牌(27-34种), CheckWin(hand, newTile:tile) → 正确检测听牌 - 新增2个听牌测试 🟡 Medium: HandleDiscardReactions 同优先级顺序 - 旧: OrderByDescending取第一个,不保证座位顺序 - 新: 按座位顺序遍历,高优先级覆盖,同优先级先到先得 🟡 Medium: ScoreEngine.FanValue 硬编码番值 - 旧: switch expression 仅5种番型 - 新: 优先从 _fanConfig(DSL)读取,fallback到硬编码 🟢 Low: 删除硬编码的258将事件(非武汉也输出)
This commit is contained in:
@ -13,11 +13,14 @@ public class MahjongScoreEngine
|
||||
{
|
||||
private readonly ScoringConfig _config;
|
||||
private readonly MeldsSolver _solver;
|
||||
private readonly Dictionary<string, FanConfig> _fanConfig;
|
||||
|
||||
public MahjongScoreEngine(ScoringConfig config, MeldsSolver solver)
|
||||
public MahjongScoreEngine(ScoringConfig config, MeldsSolver solver,
|
||||
Dictionary<string, FanConfig> fanConfig)
|
||||
{
|
||||
_config = config;
|
||||
_solver = solver;
|
||||
_fanConfig = fanConfig;
|
||||
}
|
||||
|
||||
public void Settle(MahjongGameState state, string winner, MeldsResult result, bool isSelfDraw)
|
||||
@ -77,13 +80,19 @@ public class MahjongScoreEngine
|
||||
}
|
||||
}
|
||||
|
||||
private int FanValue(string fan) => fan switch
|
||||
private int FanValue(string fan)
|
||||
{
|
||||
"清一色" => 4,
|
||||
"对对胡" => 2,
|
||||
"暗七对" => 4,
|
||||
"带幺九" => 2,
|
||||
"十三幺" => 88,
|
||||
_ => 1
|
||||
};
|
||||
if (_fanConfig.TryGetValue(fan, out var def))
|
||||
return def.BaseFan;
|
||||
// Fallback for fan names not in config
|
||||
return fan switch
|
||||
{
|
||||
"清一色" => 4,
|
||||
"对对胡" => 2,
|
||||
"暗七对" => 4,
|
||||
"带幺九" => 2,
|
||||
"十三幺" => 88,
|
||||
_ => 1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user