- Added BattleState class to manage battle flow, including turn management and event handling. - Introduced BuffInstance class to represent buffs applied to combatants. - Created CardInstance class to handle card definitions and cost calculations. - Developed CombatantState class to manage combatant attributes and actions. - Implemented EffectRegistry to apply effects based on event specifications. - Added various handlers (BlockHandler, DamageHandler, DrawHandler, etc.) to process specific events. - Created IntentPlanner and IntentState classes to manage enemy actions and intents. - Established a queue system for handling battle events with BattleEventQueue and BattleEventTask. - Introduced triggers for applying effects based on game events (e.g., OnCardDrawnGainBlockTrigger). - Added necessary UID files for new scripts to ensure proper resource management.
87 lines
2.9 KiB
Markdown
87 lines
2.9 KiB
Markdown
# 战斗系统统一事件内核重构交接文档
|
|
|
|
## 1. 背景
|
|
当前项目规模较小,团队决定采用激进重构:
|
|
1. 一次性切换到统一事件队列执行模型。
|
|
2. 不再保留旧执行路径作为长期主线。
|
|
3. 先保证架构正确,再扩展玩法细节。
|
|
|
|
## 2. 最终目标
|
|
1. 卡牌效果和 Buff 效果统一为事件生产者。
|
|
2. 所有战斗效果统一经 BattleEventQueue 执行。
|
|
3. 出牌器和抽牌器可在单点位置切换。
|
|
4. 新增普通卡仅需一个 CardDef 资源文件。
|
|
|
|
## 3. 强制约束
|
|
1. 命令层禁止直改 hp/block/strength/weak。
|
|
2. 二次触发事件必须追加队尾。
|
|
3. 触发顺序固定:速度/权重 -> acquire_index。
|
|
4. 策略返回空动作时不自动结束回合。
|
|
|
|
## 4. 重构阶段
|
|
### Phase 1 文档先行
|
|
1. 更新架构文档术语与流程。
|
|
2. 交付本交接文档给团队统一口径。
|
|
|
|
### Phase 2 事件内核
|
|
1. 新建 BattleEventType/BattleEventPayload/BattleEventTask/BattleEventQueue。
|
|
2. 建立队列执行循环和防循环机制。
|
|
|
|
### Phase 3 处理器
|
|
1. 落地 Damage/Block/Weak/Draw/Discard 处理器。
|
|
2. BattleState 收敛为状态容器与原子操作。
|
|
|
|
### Phase 4 Buff触发器
|
|
1. Buff 改为 TriggerSubscriber + BuffInstance。
|
|
2. 增加常见触发器模板:抽牌、伤害、出牌、弃牌、回合。
|
|
|
|
### Phase 5 命令事件化
|
|
1. PlayCardCommand 只发 CARD_PLAY_REQUESTED。
|
|
2. EndTurnCommand 只发 TURN_END_REQUESTED 和敌方行动请求。
|
|
|
|
### Phase 6 策略化与单点切换
|
|
1. 引入 BattleRuleProvider 作为唯一规则入口。
|
|
2. 引入 AutoPlayPolicy 和 DrawPolicy。
|
|
3. 预置四种出牌策略和一种标准抽牌策略。
|
|
|
|
### Phase 7 内容模型
|
|
1. CardDef 补齐卡面、稀有度、描述、目标和效果。
|
|
2. EffectSpec 改为事件模板。
|
|
3. ConditionSpec 变可执行过滤器。
|
|
|
|
### Phase 8 测试与验收
|
|
1. 建立队列顺序、防循环、触发器、策略切换测试。
|
|
2. 建立单卡单文件新增可用性测试。
|
|
|
|
## 5. 代码落点
|
|
1. Game/Presentation/Battle/Scripts/BattleController.gd
|
|
2. Game/Application/Commands/PlayCardCommand.gd
|
|
3. Game/Application/Commands/EndTurnCommand.gd
|
|
4. Game/Runtime/BattleState.gd
|
|
5. Game/Runtime/CombatantState.gd
|
|
6. Game/Infrastructure/BattleEventBus.gd
|
|
7. Game/Content/Cards/CardDef.gd
|
|
8. Game/Content/Cards/EffectSpec.gd
|
|
9. Game/Content/Cards/ConditionSpec.gd
|
|
|
|
新增目录建议:
|
|
1. Game/Runtime/Queue
|
|
2. Game/Runtime/Handlers
|
|
3. Game/Runtime/Triggers
|
|
4. Game/Runtime/Buffs
|
|
5. Game/Runtime/AutoPlay
|
|
6. Game/Runtime/Draw
|
|
7. Game/Runtime/Rules
|
|
|
|
## 6. 验收清单
|
|
1. 命令层不存在直改战斗属性。
|
|
2. 所有效果执行都经过 BattleEventQueue。
|
|
3. 触发顺序规则稳定并可复现。
|
|
4. 仅改 BattleRuleProvider 可切换策略。
|
|
5. 新增普通卡只需一个 CardDef 文件。
|
|
|
|
## 7. 团队协作建议
|
|
1. 事件内核、处理器、策略层分工并行。
|
|
2. 每个 Phase 独立验收后再合并。
|
|
3. 禁止跨 Phase 混改,防止回归定位困难。
|