Skip to content

fix(tracker): 牌底占位与木马全明快照收敛#50

Merged
llsccm merged 3 commits into
devfrom
codex/fix-pile-muniu
Jul 22, 2026
Merged

fix(tracker): 牌底占位与木马全明快照收敛#50
llsccm merged 3 commits into
devfrom
codex/fix-pile-muniu

Conversation

@llsccm

@llsccm llsccm commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • 修复确定明牌离开牌堆后暗占位顶回原槽(MoveType=18 暗拿再出现)污染牌底/牌顶确认段。
  • 修复木马装备迁座后主视角全明快照无法收敛弱候选:目标 mark 匿名槽物化,并按协议 CardIDs 收敛。
  • 回归测试不再预置快照明牌为已知 mark,覆盖首次揭示路径。

Commits

  1. fix(tracker): 确定明牌离开牌堆时占位不顶回原槽
  2. fix(tracker): 木马迁座后全明快照收敛弱候选

Test plan

  • pnpm test:tracker
  • pnpm typecheck:tracker
  • pnpm lint
  • 实战复核:牌底明牌 + MoveType 18 再出现
  • 实战复核:木马迁座后主视角 mark 全明快照弱候选回手

Summary by CodeRabbit

  • Bug Fixes
    • 改进隐藏牌与可见标记的解析/收敛,避免已知牌或匿名来源候选静默短少。
    • 修复玩家来源明牌残留回补时的占位处理,按残留类型与保留策略调整落点,提升后续状态收敛准确性。
    • 修复牌堆明牌连续段相关的匿名占位回补逻辑,避免顶端顺序被破坏。
  • Tests
    • 增加并更新隐藏标记候选收敛、来源揭示与可见标记校验相关用例。
    • 增加牌堆回补顺序/占位落点不覆盖明牌的断言,并完善参数化测试期望。

llsccm added 2 commits July 22, 2026 20:02
MoveType=18 暗拿后明牌再出现时,暗占位不得 replaceCard 污染牌底/牌顶已确认段;
恢复 insertUnknownPlaceholderIntoPile,公共区残留回补与 swap 路径对齐。
装备容器迁座后 FromID 可能仍是旧座位,首次揭示明牌时用目标 mark 匿名槽物化;
全明快照按协议 CardIDs 收敛弱候选。测试不再预置快照明牌为已知 mark。
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

本次更新调整全明标记快照下的候选牌收敛、玩家来源缺失牌补建和空已知牌恢复流程,并改变公共区残留占位在牌堆中的回补位置;相关测试覆盖候选索引与牌堆顺序。

Changes

房间移动候选与占位回补

Layer / File(s) Summary
全明快照候选解析
src/tracker/roomMovement.ts, src/tracker/roomMovement/hiddenMarks.ts
根据 markSpellIDknownIDscardCount 生成匿名候选,补建符合条件的玩家来源缺失牌,并在空已知牌场景恢复隐藏标记候选。
公共区占位回补
src/tracker/roomMovement.ts, src/tracker/roomMovement/sources.ts
keepPreviousPosition 和公共区类型处理残留占位;牌堆占位插入连续顶部明牌段下方。
移动行为回归验证
tests/tracker/hiddenMarkCandidates.test.ts, tests/tracker/pileDisplayOrder.test.ts
验证可见牌的标记索引状态、结构化揭示事件及不同占位回补场景下的牌堆顺序。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RoomMovement
  participant HiddenMarks
  participant RoomMovementSourceMethods
  participant PublicZone
  RoomMovement->>HiddenMarks: 使用 knownIDs 收敛隐藏标记候选
  HiddenMarks-->>RoomMovement: 返回候选收敛结果
  RoomMovement->>RoomMovementSourceMethods: 恢复公共区残留占位
  RoomMovementSourceMethods->>PublicZone: 按牌堆明牌段插入占位
Loading

Possibly related PRs

  • llsccm/tracker#38:同样涉及牌堆未知占位回补与顶部连续明牌段处理。
  • llsccm/tracker#45:涉及匿名槽、knownIDs 与占位牌物化模型,与本次来源候选及回补逻辑相关。
  • llsccm/tracker#4:修改了相同的隐藏标记候选收敛和公共区占位回补链路。
🚥 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 标题准确概括了本次修复的两个核心点:牌底占位回补和木马全明快照收敛。
✨ 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-pile-muniu

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.

🧹 Nitpick comments (3)
src/tracker/roomMovement/sources.ts (1)

518-548: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

insertUnknownPlaceholderIntoPile 顺序变换逻辑正确;建议复用真实 Zone 类型而非内联结构类型(可选)。

结合 tests/tracker/pileDisplayOrder.test.ts 674-715 的用例手工推导(remove 顶部已知段 → add 占位 → 反转后 add 已知段),最终顺序与该用例断言的 [6,5,4]/占位位于已知段下方/[4,5,6] 完全一致,逻辑正确。

zone 参数使用了内联的结构类型(仅声明 cards/add/remove),而不是复用项目中已有的 Zone 类实际类型。这样在 Zone 接口演进时容易与本处脱节,建议直接引用 Zone 类型。

♻️ 建议的类型引用方式
-  insertUnknownPlaceholderIntoPile(
-    zone: {
-      cards: Card[]
-      add: (cards: Card | Card[], position?: typeof POSITION_TOP) => void
-      remove: (count: number, position?: typeof POSITION_TOP) => Card[]
-    },
-    placeholder: Card
-  ): void {
+  insertUnknownPlaceholderIntoPile(zone: Zone, placeholder: Card): void {
🤖 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/roomMovement/sources.ts` around lines 518 - 548, Update
insertUnknownPlaceholderIntoPile to use the project’s existing Zone type for its
zone parameter instead of the inline cards/add/remove structure, preserving the
current insertion and ordering logic unchanged.
src/tracker/roomMovement/hiddenMarks.ts (1)

897-911: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

新增 cardCount <= 0 前置校验有意义;knownIDs.length !== cardCount 重复校验可以去掉(可选)。

getObservedEquipmentMarkSnapshot 已经校验过 context.knownIDs.length !== context.cardCount(第 876 行),此处 snapshot 非空即隐含该条件已满足,重复判断是冗余代码。新增的 cardCount <= 0 判断则确实补上了 getObservedEquipmentMarkSnapshot 未覆盖的边界(cardCount===0 && knownIDs.length===0unknownCount===0 仍可返回非空快照),是有效修复。

🤖 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/roomMovement/hiddenMarks.ts` around lines 897 - 911, 在
resolveHiddenMarkCandidatesFromObservedMarkSnapshot 中移除对 context.knownIDs.length
!== context.cardCount 的重复前置校验,保留 snapshot 非空判断与新增的 context.cardCount <= 0
边界校验;继续依赖 getObservedEquipmentMarkSnapshot 的校验结果。
src/tracker/roomMovement.ts (1)

232-237: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

装备容器全明快照缺牌补建条件扩展合理,可去除冗余判断(可选)。

canCreatePlayerSourceMissingCards 的第二个分支内已包含 missingIDs.length > 0,外层 if 又重复判断了一次,逻辑无误但存在轻微冗余。

🤖 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/roomMovement.ts` around lines 232 - 237, Remove the redundant
missingIDs.length > 0 check from the outer if in the
canCreatePlayerSourceMissingCards flow, since that condition is already enforced
within the flag’s second branch. Preserve the existing behavior for missing
seats and full-known mark snapshots.
🤖 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/roomMovement.ts`:
- Around line 232-237: Remove the redundant missingIDs.length > 0 check from the
outer if in the canCreatePlayerSourceMissingCards flow, since that condition is
already enforced within the flag’s second branch. Preserve the existing behavior
for missing seats and full-known mark snapshots.

In `@src/tracker/roomMovement/hiddenMarks.ts`:
- Around line 897-911: 在 resolveHiddenMarkCandidatesFromObservedMarkSnapshot
中移除对 context.knownIDs.length !== context.cardCount 的重复前置校验,保留 snapshot 非空判断与新增的
context.cardCount <= 0 边界校验;继续依赖 getObservedEquipmentMarkSnapshot 的校验结果。

In `@src/tracker/roomMovement/sources.ts`:
- Around line 518-548: Update insertUnknownPlaceholderIntoPile to use the
project’s existing Zone type for its zone parameter instead of the inline
cards/add/remove structure, preserving the current insertion and ordering logic
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 942ce93c-cfa1-4ac0-b279-b8394d37aca8

📥 Commits

Reviewing files that changed from the base of the PR and between d781a04 and 7c8af5b.

📒 Files selected for processing (5)
  • src/tracker/roomMovement.ts
  • src/tracker/roomMovement/hiddenMarks.ts
  • src/tracker/roomMovement/sources.ts
  • tests/tracker/hiddenMarkCandidates.test.ts
  • tests/tracker/pileDisplayOrder.test.ts

去掉重复 missingIDs 与 knownIDs 校验,insertUnknownPlaceholderIntoPile 改用 Zone 类型。
@llsccm
llsccm merged commit 4297091 into dev Jul 22, 2026
5 of 6 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