Skip to content

fix(tracker): 恢复匿名牌堆洗牌后的暂停追踪#51

Merged
llsccm merged 2 commits into
devfrom
codex/fix-anonymous-pile-shuffle
Jul 22, 2026
Merged

fix(tracker): 恢复匿名牌堆洗牌后的暂停追踪#51
llsccm merged 2 commits into
devfrom
codex/fix-anonymous-pile-shuffle

Conversation

@llsccm

@llsccm llsccm commented Jul 22, 2026

Copy link
Copy Markdown
Owner

变更内容

  • 修复匿名负 ID 牌堆触发洗牌时,未定位牌面身份未恢复为暂停追踪的问题
  • 从 UNKNOWN 状态索引、未定位身份集合及 APPEARED 暗身份恢复洗牌候选;未物化身份先创建脱离区域的正 ID 实体
  • 仅使用较小的剩余牌堆建立身份排除集合,并在弃牌重置循环中统计匿名占位,避免对大弃牌堆计算差值或增加额外扫描
  • 仅在弃牌堆确实有牌并洗回牌堆时执行身份暂停分类;首次空弃牌堆洗牌不再触发
  • 新增匿名牌堆洗牌回归,覆盖玩家未定位手牌、弃牌回收、剩余负 ID 槽、APPEARED 暗身份分类和首次空弃牌堆场景

验证

  • pnpm test:tracker(33 个测试文件,260 项通过)
  • pnpm exec vitest run tests/tracker/anonymousPileSpike.test.ts tests/tracker/pileDisplayOrder.test.ts(33 项通过)
  • pnpm typecheck:tracker
  • pnpm lint
  • pnpm exec prettier --check src/tracker/Room.ts tests/tracker/anonymousPileSpike.test.ts tests/tracker/pileDisplayOrder.test.ts
  • pnpm build
  • pnpm build:prod
  • git diff --check

风险与备注

  • pileDisplayOrder.test.ts 现明确区分首次空弃牌堆洗牌和真实弃牌回收洗牌;匿名负 ID 及 APPEARED 暗身份回归仍集中在相关测试文件
  • 未修改依赖、构建配置或生成产物

Summary by CodeRabbit

  • Bug Fixes

    • 优化匿名牌堆洗牌后的身份追踪与暂停处理。
    • 改进牌堆数量不足时的状态统计与告警信息准确性。
  • Tests

    • 新增匿名牌堆洗牌场景验证,确保未定位身份正确挂起。
    • 确保玩家手牌槽位、匿名卡状态及未知卡数量在洗牌后保持一致。

匿名负 ID 牌堆洗牌时,从未定位身份和状态索引恢复暂停追踪实体。分类仅以小规模剩余牌堆排除身份,并在弃牌重置循环中统计匿名占位,避免对大弃牌堆计算差值。
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

重构 Room.shufflePile() 的匿名牌堆身份暂停追踪与约束清理逻辑,更新洗牌告警统计字段,并新增测试验证身份状态、公共候选牌及玩家匿名手牌槽位。

Changes

匿名牌堆洗牌追踪

Layer / File(s) Summary
洗牌身份分类与约束清理
src/tracker/Room.ts
按剩余牌堆中的正 ID 过滤候选身份,去重生成暂停身份牌,并分别清理剩余牌堆、回收牌和暂停身份牌的约束;洗牌告警改用直接统计值及拼接后的牌 ID。
匿名牌堆洗牌行为验证
tests/tracker/anonymousPileSpike.test.ts
验证未定位身份被暂停追踪、公共候选牌更新、玩家手牌槽位保持不变,以及匿名牌数量和位置状态符合预期。

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • llsccm/tracker#4:同样修改 Room.shufflePile() 中暂停身份牌的分类与清理流程。
  • llsccm/tracker#20:涉及相同洗牌路径中的身份暂停追踪和约束处理。
  • llsccm/tracker#45:关联匿名槽位模型及未解析身份在 Room.ts 和测试中的处理。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了该 PR 的核心修复:匿名牌堆洗牌后恢复暂停追踪。
✨ 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-anonymous-pile-shuffle

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

🧹 Nitpick comments (1)
tests/tracker/anonymousPileSpike.test.ts (1)

4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

测试逻辑正确,但未覆盖 APPEARED 状态暗身份恢复路径。

新增用例只构造了来自 unlocatedIdentities(UNKNOWN 状态)的候选身份,未覆盖 src/tracker/Room.tsappearedCards.forEach(APPEARED 状态暗身份,如木牛流马场景)这一分支。补充一个该场景的用例,可以同时验证分类正确性,并捕获该分支对应的 appearedHiddenIdentityCards 归类问题(已在 Room.ts 审阅中提出)。

Also applies to: 124-180

🤖 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 `@tests/tracker/anonymousPileSpike.test.ts` at line 4, 在
getPublicFieldCandidateCards 相关测试中补充一个 APPEARED 状态暗身份恢复场景:构造来自 Room.ts 的
appearedCards(例如木牛流马),而非仅使用 unlocatedIdentities 的 UNKNOWN 候选;断言恢复结果的分类正确,并覆盖
appearedHiddenIdentityCards 的归类路径。
🤖 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/tracker/Room.ts`:
- Around line 965-1036: Update the APPEARED-card handling in the
appearedCards.forEach block to pass appearedHiddenIdentityCards to
addSuspendedIdentity instead of neverAppearedCards. Keep the other candidate
sources writing to neverAppearedCards, so suspendedIdentityCards still combines
all entries while appearedHiddenIdentityCount and appearedHiddenIdentityCardIDs
accurately report APPEARED hidden identities.

---

Nitpick comments:
In `@tests/tracker/anonymousPileSpike.test.ts`:
- Line 4: 在 getPublicFieldCandidateCards 相关测试中补充一个 APPEARED 状态暗身份恢复场景:构造来自
Room.ts 的 appearedCards(例如木牛流马),而非仅使用 unlocatedIdentities 的 UNKNOWN
候选;断言恢复结果的分类正确,并覆盖 appearedHiddenIdentityCards 的归类路径。
🪄 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: 1039b06b-5f39-47e1-9b37-1fe62a6b0168

📥 Commits

Reviewing files that changed from the base of the PR and between 4297091 and 70dd4fd.

📒 Files selected for processing (2)
  • src/tracker/Room.ts
  • tests/tracker/anonymousPileSpike.test.ts

Comment thread src/tracker/Room.ts
将 CardCounter APPEARED 桶中的未明示正 ID 归入 appearedHiddenIdentityCards,并补充木牛流马暗标记洗牌回归,锁定暂停结果与诊断分类。
@llsccm
llsccm merged commit 1cbb4db into dev Jul 22, 2026
4 checks passed
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