fix(tracker): 牌底占位与木马全明快照收敛#50
Conversation
MoveType=18 暗拿后明牌再出现时,暗占位不得 replaceCard 污染牌底/牌顶已确认段; 恢复 insertUnknownPlaceholderIntoPile,公共区残留回补与 swap 路径对齐。
装备容器迁座后 FromID 可能仍是旧座位,首次揭示明牌时用目标 mark 匿名槽物化; 全明快照按协议 CardIDs 收敛弱候选。测试不再预置快照明牌为已知 mark。
📝 WalkthroughWalkthrough本次更新调整全明标记快照下的候选牌收敛、玩家来源缺失牌补建和空已知牌恢复流程,并改变公共区残留占位在牌堆中的回补位置;相关测试覆盖候选索引与牌堆顺序。 Changes房间移动候选与占位回补
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: 按牌堆明牌段插入占位
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
🧹 Nitpick comments (3)
src/tracker/roomMovement/sources.ts (1)
518-548: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
insertUnknownPlaceholderIntoPile顺序变换逻辑正确;建议复用真实Zone类型而非内联结构类型(可选)。结合
tests/tracker/pileDisplayOrder.test.ts674-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===0时unknownCount===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
📒 Files selected for processing (5)
src/tracker/roomMovement.tssrc/tracker/roomMovement/hiddenMarks.tssrc/tracker/roomMovement/sources.tstests/tracker/hiddenMarkCandidates.test.tstests/tracker/pileDisplayOrder.test.ts
去掉重复 missingIDs 与 knownIDs 校验,insertUnknownPlaceholderIntoPile 改用 Zone 类型。
Summary
Commits
fix(tracker): 确定明牌离开牌堆时占位不顶回原槽fix(tracker): 木马迁座后全明快照收敛弱候选Test plan
pnpm test:trackerpnpm typecheck:trackerpnpm lintSummary by CodeRabbit