refactor: _wildcards static→实例级 WildcardRegistry
Root cause: static HashSet跨测试/跨变体污染+硬编码名→编码映射 Changes: - WildcardRegistry: 实例级wildcard管理(IsWildcard/CountWildcards/Clone) - GameState: 新增Wildcards属性(含Clone) - MahjongTile: 移除static_wildcards,IsWildcard仅查编码50-59 +ToString(tile,wildcards)重载用于游戏上下文显示 - MeldsSolver: _wildcards字段→构造函数注入(WildcardRegistry?) - PhaseMachine: _wildcards字段+构造注入 - Deal(): State.Wildcards.Clear()+AddRange替代static ConfigureWildcards +NameToEncoding查表替代switch硬编码 - RandomMahjongAI/HumanMahjongPlayer: state.Wildcards替代static调用 - HumanMahjongPlayer.CheckTing: 补wildcardCount参数(之前遗漏) - ExecuteWinClaim: IsFinished=true→Settle()(之前Phase漏设) Test: CoreTests清理ConfigureWildcards()→WildcardRegistry测试 Impact: 零static state→不同变体/测试完全隔离,未来支持随机宝牌
This commit is contained in:
@ -39,6 +39,14 @@ public class MahjongTileTests
|
||||
public void IsWildcard_50_True() => Assert.True(MahjongTile.IsWildcard(50));
|
||||
[Fact]
|
||||
public void IsWildcard_普通牌_False() => Assert.False(MahjongTile.IsWildcard(1));
|
||||
|
||||
[Fact]
|
||||
public void ToString_配置wildcard_显示癞子标记()
|
||||
{
|
||||
var wc = new WildcardRegistry();
|
||||
wc.Add(35);
|
||||
Assert.Equal("🀫中", MahjongTile.ToString(35, wc));
|
||||
}
|
||||
}
|
||||
|
||||
public class DeckTests
|
||||
@ -84,12 +92,6 @@ public class MeldsSolverTests
|
||||
{
|
||||
private readonly MeldsSolver _solver = new(new Dictionary<string, FanConfig>());
|
||||
|
||||
public MeldsSolverTests()
|
||||
{
|
||||
// Reset wildcards to avoid contamination from integration tests
|
||||
MahjongTile.ConfigureWildcards([]);
|
||||
}
|
||||
|
||||
// === 标准胡牌 ===
|
||||
[Fact]
|
||||
public void 标准胡_4面子1对_ShouldWin()
|
||||
|
||||
Reference in New Issue
Block a user