Files
Fishdice/analysis/FishDice/design-highlights.html
2026-06-25 10:46:23 +08:00

55 lines
3.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FishDice 设计精妙点</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main class="shell">
<div class="topbar"><a href="index.html">← 返回总览</a><span class="brand">设计精妙点</span></div>
<section class="hero">
<h1>框架设计中值得保留的精妙部分</h1>
<p class="subtitle">这些亮点都来自源码证据,不是泛泛的架构赞美。它们共同服务一个目标:让 Lucky Dice 的核心闭环可测、可扩展、可追踪。</p>
</section>
<section>
<h2>亮点列表</h2>
<div class="grid-2">
<div class="card"><h3>1. Runtime 纯 C#</h3><p><code>noEngineReferences: true</code> 把 Unity 生命周期、场景和资源从核心中剥离,极大降低测试成本。</p></div>
<div class="card"><h3>2. 两套骰子语义隔离</h3><p><code>DiceSetType.Normal</code><code>DiceSetType.Lucky</code> 分开,<code>ComboFactBuilder</code> 明确拒绝 Lucky 结果进入普通组合事实。</p></div>
<div class="card"><h3>3. 先事实化再匹配</h3><p><code>ComboFacts</code> 生成 normalized key、ordered key、face count、number sum避免 matcher 直接读“左骰/右骰”。</p></div>
<div class="card"><h3>4. 按类型注册扩展</h3><p>Matcher 按 <code>MatcherType</code>Action 按 <code>ActionType</code> 注册,扩展点清晰。</p></div>
<div class="card"><h3>5. 随机源可注入</h3><p><code>IRandomSource</code> 让 Roll 和 Lucky Dice 权重随机都能用固定序列测试。</p></div>
<div class="card"><h3>6. 配置先校验再运行</h3><p><code>LuckyDiceConfigValidator</code> 提前捕获未知 matcher、未知 action、重复 id、坏候选和缺失 target mode。</p></div>
<div class="card"><h3>7. Trace 贯穿链路</h3><p><code>RollTrace</code> 用同一个 session 记录决策链,便于复盘线上问题。</p></div>
<div class="card"><h3>8. Demo 和核心解耦</h3><p>DemoRunner 和 Controller 只消费核心结果,证明表现层可以替换。</p></div>
</div>
</section>
<section>
<h2>最关键的架构判断</h2>
<div class="note good">框架没有急着做“完整玩法管理器”,而是先把最容易膨胀的部分拆成事实、规则、行为、候选和模式解析。这让第一版虽然小,但变化方向是可控的。</div>
</section>
<section>
<h2>为什么这些设计对游戏框架重要</h2>
<p>游戏玩法框架最怕两类增长:一类是组合数量增长导致 if/else 爆炸另一类是表现层倒灌核心导致每次改动画都影响规则。FishDice 当前通过规则配置、Action 分发和纯核心边界,把这两类风险先压住了。</p>
</section>
<section class="evidence">
<h2>证据</h2>
<ul>
<li><span class="path">ComboFactBuilder.cs:14-24</span>:拒绝 Lucky set 和 dice count 不一致。</li>
<li><span class="path">ComboFactBuilder.cs:26-36</span>:构建统计事实和 normalized key。</li>
<li><span class="path">ComboRuleMatcher.cs:26-45</span>:按优先级匹配并支持 StopAfterMatched。</li>
<li><span class="path">DiceRollService.cs:5-16</span><code>IRandomSource</code> 抽象。</li>
<li><span class="path">LuckyDiceConfigValidator.cs:13-154</span>配置校验覆盖规则、候选、target mode、注册表。</li>
<li><span class="path">LuckyDiceCoreFlowTests.cs:26-63</span>:完整 Lucky Dice 到 target mode 的链路测试。</li>
</ul>
</section>
</main>
</body>
</html>