fix: GetLegalActions从硬编码改为读DSL+条件求值+wildcard计数修正

子代理审查MED级bug修复:

1. GetLegalActions硬编码忽略DSL action列表
   →从play phase的SelfActions/OthersReactions读取允许的action
   →DSL可禁用an_kong/bu_kong/pung等操作

2. action condition字符串完全未求值
   →CheckCondition()支持:can_win/can_chi/has_two_same等10种条件
   →国标can_win_tumo_and_fan_ge_8条件被评估

3. wildcard bonus仅计缺口填充
   →改为统计赢家手牌+副露中全部癞子(per_wildcard_in_win语义)

4. PhaseMachine两处wildcard计数从静态IsWildcard改为_wildcards实例

6个文件:PhaseMachine+ScoreEngine(核心)+MahjongRoom(WildcardRegistry引用)
This commit is contained in:
xiaoou
2026-07-04 20:37:13 +08:00
parent d5973fd2bc
commit b038d5e2da
2 changed files with 98 additions and 37 deletions

View File

@ -37,9 +37,18 @@ public class MahjongScoreEngine
int baseFan = ComputeTotalFans(result.Fans);
// Wildcard bonus: e.g. Wuhan 每癞子+1番
if (_config.PerWildcardBonus > 0 && result.WildcardsUsed > 0)
baseFan += result.WildcardsUsed * _config.PerWildcardBonus;
// Wildcard bonus: count ALL wildcards in winner's hand (not just gap-fill)
if (_config.PerWildcardBonus > 0)
{
int totalWildInHand = 0;
if (state.Hands.TryGetValue(winner, out var hand))
totalWildInHand += state.Wildcards.CountWildcards(hand);
if (state.Exposed.TryGetValue(winner, out var exposed))
foreach (var m in exposed)
totalWildInHand += state.Wildcards.CountWildcards(m.Tiles);
if (totalWildInHand > 0)
baseFan += totalWildInHand * _config.PerWildcardBonus;
}
// Flower bonus: e.g. Guangdong 每花牌+1分 + 配对花牌额外分
if (_config.FlowerNormalScore > 0 && state.FlowerPool.TryGetValue(winner, out var flowers) && flowers.Count > 0)