Skip to content

fix(tracker): 完善天候牌顶消息同步#63

Open
llsccm wants to merge 2 commits into
devfrom
codex/fix-3903-tianhou-tracking
Open

fix(tracker): 完善天候牌顶消息同步#63
llsccm wants to merge 2 commits into
devfrom
codex/fix-3903-tianhou-tracking

Conversation

@llsccm

@llsccm llsccm commented Jul 26, 2026

Copy link
Copy Markdown
Owner

变更内容

  • 完善天候(SpellID 3903)GsCRoleOptTargetNtf 的 Type 28 / Type 29 参数解析。
  • 仅在发动者视角同步私有的牌顶三张信息,并忽略 Type 28 附带的主视角手牌片段。
  • 将其他角色收到的单牌同区展示精确归一为 noop,不确认牌面、不物化或重排牌堆。
  • 移除 3903 的 RANDOM-as-top 归一化,避免把展示牌错误固定为牌顶第一张。
  • 补充协议文档、索引与 handler / normalizer / Controller 回归测试。

原因

天候的有序牌顶信息只对发动者可见;其他角色只能看到牌顶三张中的一张,但协议无法确定它位于前三张中的具体位置。当前候选模型尚未表达“牌顶前三之一”,因此保守丢弃该单牌展示,避免污染牌堆顺序和身份状态。

验证

  • pnpm test:tracker(42 个测试文件、302 条用例)
  • pnpm typecheck:tracker
  • pnpm typecheck
  • pnpm lint
  • pnpm exec prettier --check ...
  • pnpm build
  • pnpm build:prod
  • git diff --check

Summary by CodeRabbit

  • 新功能
    • 支持天候技能的私有牌堆观看与单牌展示,并在其他视角下按公开候选范围进行牌位收敛与同步。
    • 当展示为公共区范围揭示时,更新对应的候选解析与渲染流程。
  • 问题修复
    • 避免无法确定具体位置的展示被错误物化或归类。
    • 修正天候相关同区展示下,随机位置的归一化与牌位语义处理。
  • 文档
    • 完整补充天候相关协议与字段/规则说明,并更新协议索引与表格格式。
  • 测试
    • 新增天候交换与事件归一化回归用例,覆盖多种展示命中/未命中场景。

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

本次变更新增 SpellID=3903 的 Type=28/29 私有牌堆解析,调整同区展示归一化与交换候选追踪,并补充公共候选揭示、协议文档和回归测试。

Changes

天候牌堆观看与展示处理

Layer / File(s) Summary
私有通知解析与牌堆同步
docs/protocols/GsCRoleOptTargetNtf-3903.md, docs/protocols/README.md, docs/agents/card_tracker.md, src/handler/GsCRoleOptTargetNtf.js, tests/tracker/roleOptTargetNtf.test.ts
Type=28/29 按新的 Params 布局和门控条件解析牌堆顶数据,并通过 revealTrackerCards 同步;相关协议索引、代理文档和测试同步更新。
歧义移动归一与状态保护
src/handler/PubGsCMoveCard.js, src/tracker/MoveEventNormalizer.ts, tests/tracker/pubGsCMoveCard.test.ts, tests/tracker/moveEventNormalizer.test.ts, tests/tracker/trackerController.test.ts
SpellID=3903 不再从 RANDOM 强制归一为 TOP;特定同区单牌展示返回 noop,并保持牌堆顺序与未定位身份分离。
交换候选装饰与公共范围揭示
src/tracker/skill/TianHou.ts, src/tracker/runtime/moveEventHandlers.ts, src/tracker/runtime/trackerController.ts, src/tracker/types.ts, tests/tracker/tianHouExchange.test.ts, tests/tracker/traversalBaseline.test.ts
新增天候交换状态机和公共候选揭示字段,处理候选范围收敛、最终展示、约束解析及增量遍历验证。

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: 解析约束并更新卡牌候选
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次对天候牌顶消息同步与相关追踪逻辑的修复完善,且简洁明确。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-3903-tianhou-tracking

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5e46d and 3ca209f.

📒 Files selected for processing (10)
  • docs/agents/card_tracker.md
  • docs/protocols/GsCRoleOptTargetNtf-3903.md
  • docs/protocols/README.md
  • src/handler/GsCRoleOptTargetNtf.js
  • src/handler/PubGsCMoveCard.js
  • src/tracker/MoveEventNormalizer.ts
  • tests/tracker/moveEventNormalizer.test.ts
  • tests/tracker/pubGsCMoveCard.test.ts
  • tests/tracker/roleOptTargetNtf.test.ts
  • tests/tracker/trackerController.test.ts

Comment thread docs/protocols/GsCRoleOptTargetNtf-3903.md
Comment thread src/handler/GsCRoleOptTargetNtf.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca209f and ee40449.

📒 Files selected for processing (13)
  • docs/agents/card_tracker.md
  • docs/protocols/GsCRoleOptTargetNtf-3903.md
  • docs/protocols/README.md
  • src/handler/GsCRoleOptTargetNtf.js
  • src/tracker/MoveEventNormalizer.ts
  • src/tracker/runtime/moveEventHandlers.ts
  • src/tracker/runtime/trackerController.ts
  • src/tracker/skill/TianHou.ts
  • src/tracker/types.ts
  • tests/tracker/moveEventNormalizer.test.ts
  • tests/tracker/tianHouExchange.test.ts
  • tests/tracker/trackerController.test.ts
  • tests/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant