Skip to content

fix(tracker): 修复观虚牌堆顶展示与张数守恒#38

Merged
llsccm merged 3 commits into
devfrom
feat/guanxu
Jul 18, 2026
Merged

fix(tracker): 修复观虚牌堆顶展示与张数守恒#38
llsccm merged 3 commits into
devfrom
feat/guanxu

Conversation

@llsccm

@llsccm llsccm commented Jul 18, 2026

Copy link
Copy Markdown
Owner

变更

  • 适配黄承彦观虚(SpellID=987/988)的 GsCRoleOptTargetNtf 与配套 PubGsCMoveCard 同区展示。
  • 修复观虚牌堆顶展示:同区 showCards 会重排到协议端点,不再只确认牌面。
  • 修复暗占位回补盖住牌顶明牌的问题。
  • 修复正 ID 被玩家区实体占用时无法上牌顶、以及错误 createExternal 导致牌堆 5+123 多一张的问题:优先与牌堆未知实体交换,保持张数守恒。
  • 新增协议文档 docs/protocols/GsCRoleOptTargetNtf-987.md,并清理废弃权变花色残留。

原因

观虚协议会声明牌堆顶正 ID,但本地可能:

  1. 同区展示不重排牌顶;
  2. 揭手牌时把暗占位 add 回牌顶,盖住刚展示的明牌;
  3. 正 ID 被玩家区实体占用时直接 skip;
  4. 回收占用身份时新建匿名占位导致牌堆净增 1。

影响

观虚后牌顶序列与牌堆数量应正确:观看 5 张后为 5 明 + 剩余暗,不会再出现 5+123。玩家区随机转移约束在身份回收时通过 replaceCardInConstraintGroups 迁移,不主动打散。

验证

  • pnpm test:tracker
  • pnpm typecheck:tracker
  • pnpm lint
  • pnpm build

Summary by CodeRabbit

  • 新功能
    • 支持“观虚”场景同时展示牌堆顶牌与目标座位手牌明牌。
    • 优化同区展示时的牌堆顺序与可见牌段处理。
  • 问题修复
    • 修复牌堆明牌展示时暗牌占位覆盖明牌的问题。
    • 改善玩家区域与公共牌区身份冲突时的牌面恢复,避免产生错误占位。
    • 提升重复同步和复杂展示场景下的数据一致性。
  • 文档
    • 新增“观虚”协议说明、字段规则、示例及相关行为对比。

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@llsccm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 34a800de-bbd2-49da-aa98-56937bec079b

📥 Commits

Reviewing files that changed from the base of the PR and between d59941c and f338874.

📒 Files selected for processing (3)
  • src/handler/PubGsCMoveCard.js
  • tests/tracker/pileDisplayOrder.test.ts
  • tests/tracker/trackerController.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/guanxu

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: 4

🤖 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 `@src/handler/PubGsCMoveCard.js`:
- Around line 68-70: 在包含 SpellID 判断的条件中先将 SpellID 归一化为数字,再使用 [7011, 987,
988].includes 进行匹配,确保字符串形式的 ID 也能命中;修改该条件附近的 SpellID 处理,保留现有分支逻辑不变。

In `@tests/tracker/pileDisplayOrder.test.ts`:
- Around line 657-660: 补强 placeholders.forEach 相关断言,除验证占位牌位于 pile 外,还要验证其在
pile.cards 中紧接明牌段之后,保持占位回补到明牌段正下方的顺序契约;不要仅检查牌堆归属。

In `@tests/tracker/pubGsCMoveCard.test.ts`:
- Around line 83-107: 参数化观虚相关测试,使 SpellID=987 和 988 都覆盖相同的预期行为:在
tests/tracker/pubGsCMoveCard.test.ts 的对应测试中分别验证同区展示的来源和目标位置归一为牌顶;在
tests/tracker/roleOptTargetNtf.test.ts 对两者分别验证牌堆段与目标手牌段解析;在
tests/tracker/trackerController.test.ts 对两者分别验证牌序重排及重复消息幂等性。使用现有测试结构复用断言,避免仅覆盖
987。

In `@tests/tracker/trackerController.test.ts`:
- Around line 147-148: 强化 trackerController 测试中针对 pile.cards
的断言,先明确验证目标占位卡存在,再断言其 isKnown 不为 true;不要使用会让 undefined
通过的可选链断言,确保占位实体缺失或牌堆数量不足时测试失败。
🪄 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: 5bc95505-0735-4975-a18f-941c2ca39234

📥 Commits

Reviewing files that changed from the base of the PR and between bf4fc3e and d59941c.

📒 Files selected for processing (11)
  • docs/protocols/GsCRoleOptTargetNtf-987.md
  • src/handler/GsCRoleOptTargetNtf.js
  • src/handler/PubGsCMoveCard.js
  • src/logic.js
  • src/tracker/gameState.ts
  • src/tracker/roomMovement/sources.ts
  • src/tracker/runtime/trackerController.ts
  • tests/tracker/pileDisplayOrder.test.ts
  • tests/tracker/pubGsCMoveCard.test.ts
  • tests/tracker/roleOptTargetNtf.test.ts
  • tests/tracker/trackerController.test.ts

Comment thread src/handler/PubGsCMoveCard.js Outdated
Comment thread tests/tracker/pileDisplayOrder.test.ts
Comment thread tests/tracker/pubGsCMoveCard.test.ts
Comment thread tests/tracker/trackerController.test.ts Outdated
* 把占位回补位置断言到明牌段正下方

* 不让占位实体缺失时断言通过

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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