fix(tracker): 完善天候牌顶消息同步#63
Conversation
📝 WalkthroughWalkthrough本次变更新增 SpellID=3903 的 Type=28/29 私有牌堆解析,调整同区展示归一化与交换候选追踪,并补充公共候选揭示、协议文档和回归测试。 Changes天候牌堆观看与展示处理
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant GsCRoleOptTargetNtf
participant handleRoleOptTargetNtf
participant MoveEventNormalizer
participant decorateTianHou
participant TrackerController
GsCRoleOptTargetNtf->>handleRoleOptTargetNtf: Type=28/29 私有通知
handleRoleOptTargetNtf->>handleRoleOptTargetNtf: 校验 Param 与 targetSeatID
handleRoleOptTargetNtf->>TrackerController: 同步牌堆顶牌子集
MoveEventNormalizer->>decorateTianHou: 传递 3903 交换与展示事件
decorateTianHou->>TrackerController: 写入公共候选范围
TrackerController->>TrackerController: 解析约束并更新卡牌候选
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/protocols/GsCRoleOptTargetNtf-3903.md`:
- Line 49: 更新 Type = 29 标题,将“发动者私有展示牌顶三牌”改为“发动者私有展示牌顶三张牌”,补充正确量词并保持其余标题内容不变。
In `@src/handler/GsCRoleOptTargetNtf.js`:
- Around line 180-194: 在 GsCRoleOptTargetNtf.js 的 Type 28/29 解析前增加本地主视角门控:仅当
SrcSeatID 与 Game.myID 一致时继续执行
revealPileCards;其他来源直接跳过私有牌顶处理。若现有开发环境绕过机制要求保留,请通过该机制实现并覆盖非主视角场景。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5af07c02-d86b-4d15-aa59-87020ef0aed1
📒 Files selected for processing (10)
docs/agents/card_tracker.mddocs/protocols/GsCRoleOptTargetNtf-3903.mddocs/protocols/README.mdsrc/handler/GsCRoleOptTargetNtf.jssrc/handler/PubGsCMoveCard.jssrc/tracker/MoveEventNormalizer.tstests/tracker/moveEventNormalizer.test.tstests/tracker/pubGsCMoveCard.test.tstests/tracker/roleOptTargetNtf.test.tstests/tracker/trackerController.test.ts
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/tracker/runtime/moveEventHandlers.ts (1)
140-141: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value复用
TIAN_HOU_SPELL_ID常量替代两处硬编码 3903。
TianHou.ts已导出该常量,且本文件已从中导入默认导出,避免 SpellID 在三处(含TianHou.ts内部门控)各自硬编码。♻️ 建议修改
-import decorateTianHou from '../skill/TianHou' +import decorateTianHou, { TIAN_HOU_SPELL_ID } from '../skill/TianHou'// 天候的部分手牌交换需要同时区分牌堆批次与手牌批次,不能落入整手交换账本。 - if (spellID === 3903) return event + if (spellID === TIAN_HOU_SPELL_ID) return event// 周群【天候】:其他视角的匿名换牌批次及最终单牌范围揭示。 - room.registerMoveEventHandler(3903, decorateTianHou) + room.registerMoveEventHandler(TIAN_HOU_SPELL_ID, decorateTianHou)Also applies to: 415-416
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tracker/runtime/moveEventHandlers.ts` around lines 140 - 141, 将 moveEventHandlers.ts 中两处用于判断天候法术的硬编码 3903 替换为已从 TianHou.ts 导入的 TIAN_HOU_SPELL_ID 常量,保持现有分支行为不变并确保所有相关判断统一复用该常量。src/tracker/skill/TianHou.ts (1)
196-210: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win中断批次的临时候选缺少兜底清理路径。
decorateHandStage()会在knownHandCards上添加exchange公共候选,但只有后续后续天候协议到达才会在pile-staged、返回牌堆或最终揭示时清理/升级。如果3903序列停在hand-staged,这些临时候选会一直附着在手牌上;建议新增一个回合/房间级清理钩子并在销毁前避免使用同一房间实例残留候选(例如用destroy()前手动清理hand-staged临时候选)。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tracker/skill/TianHou.ts` around lines 196 - 210, 为 decorateHandStage 创建的 hand-staged 临时候选增加回合或房间级清理路径,确保 3903 序列中断时也能移除 knownHandCards 上的 exchange 公共候选。在房间销毁前调用该清理逻辑,避免复用同一 room 实例时残留候选;正常进入 pile-staged、返还牌堆或最终揭示流程的行为保持不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/tracker/runtime/moveEventHandlers.ts`:
- Around line 140-141: 将 moveEventHandlers.ts 中两处用于判断天候法术的硬编码 3903 替换为已从
TianHou.ts 导入的 TIAN_HOU_SPELL_ID 常量,保持现有分支行为不变并确保所有相关判断统一复用该常量。
In `@src/tracker/skill/TianHou.ts`:
- Around line 196-210: 为 decorateHandStage 创建的 hand-staged 临时候选增加回合或房间级清理路径,确保
3903 序列中断时也能移除 knownHandCards 上的 exchange 公共候选。在房间销毁前调用该清理逻辑,避免复用同一 room
实例时残留候选;正常进入 pile-staged、返还牌堆或最终揭示流程的行为保持不变。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c8c77e88-1814-4fde-b934-45e633b11c8c
📒 Files selected for processing (13)
docs/agents/card_tracker.mddocs/protocols/GsCRoleOptTargetNtf-3903.mddocs/protocols/README.mdsrc/handler/GsCRoleOptTargetNtf.jssrc/tracker/MoveEventNormalizer.tssrc/tracker/runtime/moveEventHandlers.tssrc/tracker/runtime/trackerController.tssrc/tracker/skill/TianHou.tssrc/tracker/types.tstests/tracker/moveEventNormalizer.test.tstests/tracker/tianHouExchange.test.tstests/tracker/trackerController.test.tstests/tracker/traversalBaseline.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- tests/tracker/moveEventNormalizer.test.ts
- docs/protocols/GsCRoleOptTargetNtf-3903.md
- src/tracker/MoveEventNormalizer.ts
- src/handler/GsCRoleOptTargetNtf.js
变更内容
GsCRoleOptTargetNtf的 Type 28 / Type 29 参数解析。noop,不确认牌面、不物化或重排牌堆。原因
天候的有序牌顶信息只对发动者可见;其他角色只能看到牌顶三张中的一张,但协议无法确定它位于前三张中的具体位置。当前候选模型尚未表达“牌顶前三之一”,因此保守丢弃该单牌展示,避免污染牌堆顺序和身份状态。
验证
pnpm test:tracker(42 个测试文件、302 条用例)pnpm typecheck:trackerpnpm typecheckpnpm lintpnpm exec prettier --check ...pnpm buildpnpm build:prodgit diff --checkSummary by CodeRabbit