refactor: extract runtime story npc support

This commit is contained in:
2026-04-22 18:17:21 +08:00
parent 81e59f90ce
commit 468b88b105
4 changed files with 249 additions and 230 deletions

View File

@@ -257,3 +257,18 @@ server-rs/crates/api-server/src/
- `game_state.rs`:快照态读写与 NPC / inventory / equipment 状态桥
后续再继续迁 `trade / gift / companion` 时,目标就不再是单纯减少行数,而是把 compat bridge 逐步收束成“动作编排壳 + 多个纯规则模块”的明确结构。
在此基础上,同日又继续把 NPC 交互侧的一批纯 helper 收到独立模块:
1. `compat` 新增 [npc_support.rs](D:/Genarrative/server-rs/crates/api-server/src/runtime_story/compat/npc_support.rs)。
2. 已迁入的内容包括:
- 赠礼好感收益与赠礼结果文本
- 交易价格、折扣档位、货币文本、数量后缀
- 队伍招募与满员换队 helper
3. [compat.rs](D:/Genarrative/server-rs/crates/api-server/src/runtime_story/compat.rs) 现在对 `npc_trade / npc_gift / npc_recruit` 仍只保留动作编排,不再承担底层价格计算和队伍变换逻辑。
4. 到这一步,`compat.rs` 的主要职责已经更接近:
- route handler / snapshot bridge
- action orchestration
- 少量尚未迁出的共享 glue code
这为后续把“无 HTTP / 无 `AppState`”的剩余 glue code 再往下收,提供了更明确的拆分方向。