feat: P25 conditional routing, nextScene supports Choice[] with conditions

This commit is contained in:
2026-06-13 00:50:48 +08:00
parent db4f06883d
commit e949a84171
7 changed files with 108 additions and 10 deletions

View File

@@ -75,6 +75,54 @@ Web 版不打包视频文件,用户手动选择超清/高清/标清,系统
- [ ] 验证:浏览器 `window.__ELECTRON__` = undefined设置面板显示画质下拉
- [ ] 验证:`pack:html` 产物不包含 `videos/` 目录
### P25 条件路由 — nextScene 支持条件数组 ✅ 已完成 2026-06-12
目标:`nextScene` 从单一场景 ID 扩展为条件路由数组。第一个满足条件的场景自动跳转,
否则 fallback 到末尾无条件的默认场景。不局限于 QTE所有场景均可使用。
**场景数据设计:**
```json
{
"id": "combat_router",
"nextScene": [
{ "conditions": [{ "variable": "enemy_hp", "op": "<=", "value": 0 }], "targetScene": "victory" },
{ "conditions": [{ "variable": "player_hp", "op": "<=", "value": 0 }], "targetScene": "defeat" },
{ "targetScene": "combat" }
]
}
```
**引擎行为:**
```
onVideoEnd(scene)
├── nextScene 是 string→ 现存逻辑不变
├── nextScene 是 Choice[]
│ → 遍历数组,第一个满足 conditions 的 → 跳转到它的 targetScene
│ → 都不满足 → endGame()
└── 无 nextScene → 现有逻辑不变
```
**使用场景:**
```
QTE 成功 → effects: enemy_hp -= 25
→ successScene = "combat_router"
├── enemy_hp <= 0 → victory 场景
├── player_hp <= 0 → defeat 场景
└── 否则 → 回到 QTE 场景(循环)
```
**实现清单:**
- [x] `engine/types.ts``SceneNode.nextScene` 类型改为 `string | Choice[]`
- [x] `engine/core/Engine.ts``onVideoEnd` 中加数组判断,遍历 conditions 跳转
- [x] `engine/core/SceneManager.ts``getCandidateTargetIds` 支持数组 nextScene
- [x] `src/components/StoryGallery.vue` — BFS 遍历 + `buildPlayerTree` 支持数组 nextScene
- [x] `public/scenes/demo.json` — 新增 `combat_router` 条件路由示例
- [x] 验证TypeScript + Vite build 通过
## 已完成
P0~P23 全部实现(除 P18。详见 [CHANGELOG.md](CHANGELOG.md)。