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

60 lines
4.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>宏观看 FishDice 的结构和分层</h1>
<p class="subtitle">当前框架把真正的玩法决策放在 <code>Runtime/LuckyDice</code>,把 Unity 场景、按钮、Canvas、Editor 菜单和演示逻辑隔离在 Demo 层。这是非常明确的“核心域模型先行”结构。</p>
</section>
<section>
<h2>目录分层</h2>
<table>
<tr><th>层级</th><th>位置</th><th>职责</th><th>依赖判断</th></tr>
<tr><td>Runtime 核心</td><td><span class="path">Assets/FishDice/Runtime/LuckyDice</span></td><td>骰子配置、Roll、组合事实、规则、Action、Lucky Dice 候选、TargetMode、Trace。</td><td>纯 C#asmdef 不引用 UnityEngine。</td></tr>
<tr><td>Demo 表现</td><td><span class="path">Assets/FishDice/Demo</span></td><td>运行核心流程,格式化结果,构建一个可交互 UGUI 演示。</td><td>引用 <code>FishDice.Runtime</code><code>UnityEngine.UI</code></td></tr>
<tr><td>DemoEditor</td><td><span class="path">Assets/FishDice/DemoEditor</span></td><td>通过菜单创建 LuckyDiceDemo 场景,并加入 Build Settings。</td><td>依赖 UnityEditor只服务编辑器构建。</td></tr>
<tr><td>Tests</td><td><span class="path">Assets/FishDice/Tests/EditMode/LuckyDice</span></td><td>验证核心链路、配置校验、扩展注册、Demo 输出。</td><td>用固定随机源验证可回放行为。</td></tr>
<tr><td>Docs</td><td><span class="path">Docs</span></td><td>需求、规格、ADR、架构蓝图和资源交接资料。</td><td>当前实现与文档目标大体一致,但以源码为准。</td></tr>
</table>
</section>
<section>
<h2>核心内部切分</h2>
<div class="flow">
<div class="flow-row"><div class="flow-key">Data</div><div class="flow-val">只放不可变或近似不可变的数据结构:<code>DiceFace</code><code>DiceRollResult</code><code>ComboFacts</code><code>RollFlowResult</code>、各种 Effect。</div></div>
<div class="flow-row"><div class="flow-key">Config</div><div class="flow-val">默认配置、配置定义行、定义加载、配置校验和错误类型。</div></div>
<div class="flow-row"><div class="flow-key">Services</div><div class="flow-val"><code>DiceRollService</code><code>ComboFactBuilder</code> 处理基础 Roll 与事实提取。</div></div>
<div class="flow-row"><div class="flow-key">Rules</div><div class="flow-val"><code>ComboRuleMatcher</code> 按优先级和 MatcherType 匹配规则。</div></div>
<div class="flow-row"><div class="flow-key">Actions</div><div class="flow-val"><code>RollActionDispatcher</code> 按 ActionType 分发,避免组合 key 直接绑定方法。</div></div>
<div class="flow-row"><div class="flow-key">LuckySelection</div><div class="flow-val"><code>LuckyDiceFlowService</code> 筛选候选、权重随机、兜底和结果槽数量。</div></div>
<div class="flow-row"><div class="flow-key">TargetMode</div><div class="flow-val"><code>TargetModeResolver</code> 把选中的 Lucky Dice 结果映射到具体目标玩法模式。</div></div>
</div>
</section>
<section>
<h2>依赖方向</h2>
<p>依赖方向基本是单向的Demo 依赖 RuntimeRuntime 内部由 <code>LuckyDiceRollFlowService</code> 编排各个小服务。核心服务只接收结构化输入并返回结构化结果不调用场景、Canvas、Prefab 或 MonoBehaviour。</p>
<div class="note good">这意味着核心玩法可以在 EditMode 测试中直接运行,不需要打开 Unity 场景,也不需要模拟 UI 动画。</div>
</section>
<section class="evidence">
<h2>证据</h2>
<ul>
<li><span class="path">FishDice.Runtime.asmdef:13</span>Runtime 设置 <code>noEngineReferences: true</code></li>
<li><span class="path">FishDice.Demo.asmdef:7-16</span>Demo 引用 <code>FishDice.Runtime</code><code>UnityEngine.UI</code></li>
<li><span class="path">LuckyDiceRuntimeFactory.cs:51-58</span>RuntimeFactory 装配 Roll、Rule、Action、LuckySelection、TargetMode。</li>
<li><span class="path">LuckyDiceCoreFlowTests.cs:512-516</span>:测试显式断言 Runtime asmdef 禁止 Engine 引用。</li>
</ul>
</section>
</main>
</body>
</html>