68 lines
4.5 KiB
HTML
68 lines
4.5 KiB
HTML
<!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>一次 Roll 的完整生命周期</h1>
|
||
<p class="subtitle">框架生命周期不是 Unity 场景级生命周期,而是玩法请求级生命周期:一次 <code>RollFlowRequest</code> 进入核心服务,沿着 Roll、Facts、Rules、Actions、LuckySelection、TargetMode 和 Trace 形成闭环。</p>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>主链路</h2>
|
||
<pre>RollFlowRequest
|
||
-> DiceRollService.Roll
|
||
-> ComboFactBuilder.Build
|
||
-> ComboRuleMatcher.Match
|
||
-> RollActionDispatcher.Execute
|
||
-> LuckyDiceFlowService.Select [只有触发 Lucky Dice 时]
|
||
-> TargetModeResolver.Resolve [只有选中 Lucky Dice 候选时]
|
||
-> RollFlowResult + RollTrace</pre>
|
||
<p><code>LuckyDiceRollFlowService.Execute</code> 是整个核心生命周期的编排点。它创建 <code>RollTrace</code>,执行普通骰子 Roll,把结果转成组合事实,再匹配规则和分发 action。如果 action 结果中包含 <code>LuckyDiceRequestedEffect</code>,才进入 Lucky Dice 选择和目标玩法解析。</p>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>生命周期所有权</h2>
|
||
<table>
|
||
<tr><th>阶段</th><th>所有者</th><th>输入</th><th>输出</th></tr>
|
||
<tr><td>请求校验</td><td><code>LuckyDiceRollFlowService</code></td><td><code>RollFlowRequest</code></td><td>有效 session、dice set、trigger source。</td></tr>
|
||
<tr><td>骰子产生</td><td><code>DiceRollService</code></td><td><code>DiceSetConfig</code>、随机源</td><td><code>DiceRollResult</code>。</td></tr>
|
||
<tr><td>事实提取</td><td><code>ComboFactBuilder</code></td><td>普通骰子结果</td><td><code>ComboFacts</code>,含无序 key、计数、点数。</td></tr>
|
||
<tr><td>规则命中</td><td><code>ComboRuleMatcher</code></td><td>facts、combo rules</td><td>按优先级排列的 <code>ComboRuleMatch</code>。</td></tr>
|
||
<tr><td>行为执行</td><td><code>RollActionDispatcher</code></td><td>action list、context</td><td><code>RewardEffect</code>、<code>MultiplierEffect</code>、<code>LuckyDiceRequestedEffect</code> 等。</td></tr>
|
||
<tr><td>特殊骰子选择</td><td><code>LuckyDiceFlowService</code></td><td>候选池、请求上下文、Lucky Dice set</td><td>选中候选、slot count、fallback 类型。</td></tr>
|
||
<tr><td>目标玩法解析</td><td><code>TargetModeResolver</code></td><td>选中候选、请求、倍率、mode definitions</td><td><code>TargetModeEntry</code> 或失败原因。</td></tr>
|
||
</table>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>Unity Demo 生命周期</h2>
|
||
<p>Demo 层通过 <code>LuckyDiceDemoController.Awake</code> 构建 UI 并显示初始状态。用户点击按钮后,<code>StartRoll</code> 启动 coroutine,先做普通骰子动画,再调用 <code>LuckyDiceDemoRunner.RunRandom</code> 获取核心结果,并根据结果展示普通奖励、Clover Bonus 或 Lucky Dice 目标玩法。</p>
|
||
<div class="note warning">这里的 UI 动画不是核心生命周期的一部分。核心已经在 <code>RunRandom</code> 调用时一次性算完,UI 只是消费结果并播放表现。</div>
|
||
</section>
|
||
|
||
<section>
|
||
<h2>可观测生命周期</h2>
|
||
<p><code>RollTrace</code> 贯穿同一个 <code>RollSessionId</code>,记录普通骰面、组合 key、命中规则、执行 action、Lucky Dice 候选数量、随机值、选中结果、解析出的模式和最终 outcome。这是定位“为什么进了某个玩法”的主线。</p>
|
||
</section>
|
||
|
||
<section class="evidence">
|
||
<h2>证据</h2>
|
||
<ul>
|
||
<li><span class="path">LuckyDiceRollFlowService.cs:32-103</span>:一次 Roll 的完整编排。</li>
|
||
<li><span class="path">LuckyDiceFlowService.cs:16-49</span>:Lucky Dice 候选筛选、权重随机、兜底和 slot count。</li>
|
||
<li><span class="path">TargetModeResolver.cs:9-33</span>:选中结果到目标玩法模式的映射。</li>
|
||
<li><span class="path">RollTrace.cs:43-115</span>:生命周期关键字段记录。</li>
|
||
<li><span class="path">LuckyDiceDemoController.cs:30-74</span>:Demo 的 Awake、StartRoll、PlayRollFlow。</li>
|
||
</ul>
|
||
</section>
|
||
</main>
|
||
</body>
|
||
</html>
|