Skip to content

新增协议文档索引并完善技能回复、牌堆定位及交换批次逻辑#41

Merged
llsccm merged 8 commits into
mainfrom
dev
Jul 19, 2026
Merged

新增协议文档索引并完善技能回复、牌堆定位及交换批次逻辑#41
llsccm merged 8 commits into
mainfrom
dev

Conversation

@llsccm

@llsccm llsccm commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • 新功能
    • 支持整手牌通过交换区互换,并更准确保留明牌、暗牌及候选信息。
  • 改进 / 问题修复
    • 优化观看牌堆、观看手牌与多类技能回复的展示定位与顺序处理;加强占位回补与重复同步稳定性。
    • 收紧调试日志输出,减少无关信息。
  • 文档
    • 新增协议文档索引,并补充多份协议说明,便于快速检索。
  • 样式
    • 调整长名称花色字形字号,并优化暗牌数量显示。

llsccm and others added 5 commits July 18, 2026 08:30
* feat(tracker): 支持整手牌经交换区互易

补齐 MoveType=11 的 5↔10 整手交换协议模式:按 SpellID+FromID 登记批次,
允许己方正 CardIDs,并覆盖对侧全暗互换回归。

* fix(tracker): 收紧整手交换账本与手牌扫描

统一协议文档对正 CardIDs 的接管说明,进区复用一次手牌收集并改走 player 快照,回手只读查询避免空账本残留。

* fix(tracker): 完善整手交换候选与占位同步

* fix :已观测手牌数优先于不完整实体快照
* feat: 适配权变鹰视

* chore: 清理权变空间代码
* fix(tracker): 修复观虚牌堆顶展示与张数守恒

* fix: 补强断言

* 把占位回补位置断言到明牌段正下方

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

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* chore: 将数组抽出成模块级常量

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* feat(tracker): 完善诫厉观看阶段目标通知适配

同步 3483 Params 中的牌堆顶与目标手牌片段,handCount 恰好整手时 fullHand;补充交换序列协议文档并暂不挂上 decorateJieLi。

* fix: apply CodeRabbit auto-fixes

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

* docs: 增加协议索引并缩短整手交换文档名

新增 docs/protocols/README.md 作为 className/SpellID 定位入口,并将 PubGsCMoveCard-spell-121-hand-exchange.md 重命名为 hand-exchange.md,同步更新引用。

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
* fix(tracker): 修复嚣翻牌底被误放到牌顶

协议 pos 与 Zone 端点约定一致,normalizeProtocolZoneTarget 不应再做顶底互换。

* chore: 简化代码
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6689244d-8945-4b66-b590-01480a8b69ee

📥 Commits

Reviewing files that changed from the base of the PR and between 269ca12 and ac41259.

📒 Files selected for processing (3)
  • src/tracker/Card.ts
  • src/tracker/skill/HandExchange.ts
  • tests/tracker/handExchange.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/tracker/Card.ts
  • src/tracker/skill/HandExchange.ts
  • tests/tracker/handExchange.test.ts

📝 Walkthrough

Walkthrough

新增协议文档索引和多份技能协议说明,重构技能回复与牌堆明牌处理,统一公共区落点及占位回收,并实现整手牌交换的批次账本、候选置换和事件装饰逻辑,配套新增多组测试。

Changes

协议追踪与状态同步

Layer / File(s) Summary
协议文档与检索索引
AGENTS.md, docs/agents/card_tracker.md, docs/protocols/*
新增协议索引、牌堆观看协议、整手交换协议及相关技能的字段、顺序和适配说明。
协议消息处理与位置归一
src/handler/*, src/logic.js, src/tracker/gameState.ts, tests/tracker/roleSpellOptRep.test.ts, tests/tracker/roleOptTargetNtf.test.ts, tests/tracker/pubGsCMoveCard.test.ts
抽离技能回复处理,更新 987/988、3483、7011 等协议的牌堆与手牌同步,并统一同区展示的位置归一规则。
公共区明牌与占位回收
src/tracker/runtime/trackerController.ts, src/tracker/roomMovement/sources.ts, tests/tracker/trackerController.test.ts, tests/tracker/pileDisplayOrder.test.ts
统一公共区明牌落点处理,支持牌顶/牌底重定位、玩家区身份回收和连续明牌段下方的占位回补。
整手交换装饰与批次账本
src/tracker/skill/HandExchange.ts, src/tracker/runtime/moveEventHandlers.ts, src/tracker/candidate/*, src/tracker/roomMovement*, src/tracker/types.ts, src/tracker/Card.ts, tests/tracker/handExchange.test.ts
实现整手交换的批次登记、候选暂存与恢复、明暗牌拆分、嵌套交换处理及 handMoveCount 传递。
界面与辅助状态调整
html/iframe.html, src/index.js, src/tracker/skill/JieLi.ts, src/tracker/view/cardButton.ts
过滤特定调试消息,调整暗牌占位文案、长牌花色字形尺寸及诫厉追踪注释。

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProtocolMessage
  participant Handler
  participant TrackerController
  participant RoomMovement
  ProtocolMessage->>Handler: parse skill or target notification
  Handler->>TrackerController: reveal and position public cards
  TrackerController->>RoomMovement: recover identities and placeholders
  RoomMovement-->>TrackerController: corrected card locations
  TrackerController-->>Handler: synchronized tracker state
Loading
sequenceDiagram
  participant MoveEventHandlers
  participant HandExchange
  participant RoomSkillState
  participant TrackerRoom
  MoveEventHandlers->>HandExchange: receive exchange-zone move
  HandExchange->>RoomSkillState: register or consume batch
  HandExchange->>TrackerRoom: update card candidates and movement counts
  TrackerRoom-->>MoveEventHandlers: decorated move event
Loading

Possibly related PRs

  • llsccm/tracker#36:围绕同一整手牌交换装饰器、运行时接入、测试与文档链路。
  • llsccm/tracker#37:涉及 handleRoleSpellOptRep 抽离及牌堆观看、同区展示归一化。
  • llsccm/tracker#39:涉及 SpellID=3483 的参数切片、expectedPileCountfullHand 同步。
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.69% 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.
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.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.
✨ 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 dev

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 changed the title @pr 新增协议文档索引并完善技能回复、牌堆定位及交换批次逻辑 Jul 18, 2026

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

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

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

使用 Vite 路径别名。

根据项目编码规范,应统一使用 @ 作为指向 src/ 的别名,避免使用跨层级的长相对路径。本文件在第 2 行已经成功使用了该别名。

♻️ 建议的修复
-vi.mock('../../src/tracker/runtime/browser', () => ({
+vi.mock('`@/tracker/runtime/browser`', () => ({
   tracker: {
     syncTrackerMove
   }
 }))
 
-vi.mock('../../src/handler/gameFlowState', () => ({
+vi.mock('`@/handler/gameFlowState`', () => ({
   handleGameFlowState: vi.fn()
 }))
 
-vi.mock('../../src/handler/specialZones', () => ({
+vi.mock('`@/handler/specialZones`', () => ({
   handleSpecialZones: vi.fn(() => ({ handled: false }))
 }))
 
-vi.mock('../../src/handler/spellEffects', () => ({
+vi.mock('`@/handler/spellEffects`', () => ({
   applySpellEffect: vi.fn()
 }))
 
-import { handleMoveCard } from '../../src/handler/PubGsCMoveCard'
+import { handleMoveCard } from '`@/handler/PubGsCMoveCard`'
🤖 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/pubGsCMoveCard.test.ts` around lines 8 - 26, Update all imports
and mocks in the test around handleMoveCard to use the project’s @ alias for src
paths instead of ../../src relative paths, matching the existing alias usage on
the referenced line while preserving the mocked modules and behavior.

Source: Coding guidelines

🤖 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/CGsRoleSpellOptRep.js`:
- Around line 1-3: Update the imports in CGsRoleSpellOptRep.js to use the Vite @
alias for src-based modules instead of relative paths, while preserving the
existing Game, POSITION_BOTTOM, and tracker imports.

In `@src/index.js`:
- Around line 30-38: Update the debug logging condition in the visible logging
block so non-object messages, including strings and formatted logs, are passed
to console.info when window._debug is enabled. Only suppress messages that are
objects with className equal to decodeSSCChatmsgNtf; preserve the existing
console.info(...args) behavior for all other values.

In `@src/tracker/roomMovement/sources.ts`:
- Around line 574-581: 在 swapKnownCardWithPublicSourcePlaceholder 相关的
replacement 置换流程中移除对 replacement.isKnown 的强制设为
false,保留来源端点已有的已知状态;其余候选清理、挂起状态、移动区域和替换逻辑保持不变。

In `@src/tracker/runtime/trackerController.ts`:
- Around line 537-540: 更新 recoverPlayerOccupiedIdentityForPublicReveal
及其调用方,传入当前揭示端点 position;POSITION_TOP 从尾部反向选择并保护顶部明牌段,POSITION_BOTTOM
从头部选择并保护底部明牌段,避免牌底揭示影响牌顶顺序。补充牌底揭示命中玩家身份时的占用身份测试。

In `@src/tracker/skill/HandExchange.ts`:
- Around line 495-509: The interrupted-batch path in buildExchangePatch must
move only entities still present in the exchange. Use stagedCards.length as the
entity cardCount after filtering departed members, while preserving the protocol
hand-size change separately in handMoveCount; do not let protocolCardCount
inflate the source-card movement. Add a regression test covering batch members
leaving the exchange early and verifying other batches are not moved.
- Around line 66-87: 调整 HandExchangeRoomState、HandExchangeCandidateRecord
及相关批次处理,避免 candidateRecords 保存可写的 alternatives 候选副本;始终以 Card.locationCandidates
作为唯一候选模型,并让批次令牌进入该模型或仅记录不包含候选集合的批次元数据。同步修改 projectCandidateRecord 及其调用方,回手时基于当前
Card.locationCandidates 恢复,不能用旧快照覆盖期间已消除的候选。

In `@tests/tracker/roleSpellOptRep.test.ts`:
- Around line 16-17: Update the imports in roleSpellOptRep.test.ts to use the
configured @ alias for both handleRoleSpellOptRep and Game from src, matching
the existing `@/tracker/candidate/cardPositions` import and removing the relative
../../src paths.

---

Nitpick comments:
In `@tests/tracker/pubGsCMoveCard.test.ts`:
- Around line 8-26: Update all imports and mocks in the test around
handleMoveCard to use the project’s @ alias for src paths instead of ../../src
relative paths, matching the existing alias usage on the referenced line while
preserving the mocked modules and behavior.
🪄 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: 283dc4a8-b9a0-449e-9aa5-4c42e451c205

📥 Commits

Reviewing files that changed from the base of the PR and between fb9badc and 2b6164f.

📒 Files selected for processing (31)
  • AGENTS.md
  • docs/agents/card_tracker.md
  • docs/protocols/CGsRoleSpellOptRep.md
  • docs/protocols/GsCRoleOptTargetNtf-3483.md
  • docs/protocols/GsCRoleOptTargetNtf-7011.md
  • docs/protocols/GsCRoleOptTargetNtf-987.md
  • docs/protocols/README.md
  • docs/protocols/hand-exchange.md
  • html/iframe.html
  • src/handler/CGsRoleSpellOptRep.js
  • src/handler/GsCRoleOptTargetNtf.js
  • src/handler/PubGsCMoveCard.js
  • src/handler/index.js
  • src/index.js
  • src/logic.js
  • src/tracker/gameState.ts
  • src/tracker/roomMovement.ts
  • src/tracker/roomMovement/sources.ts
  • src/tracker/roomMovement/types.ts
  • src/tracker/runtime/moveEventHandlers.ts
  • src/tracker/runtime/trackerController.ts
  • src/tracker/skill/HandExchange.ts
  • src/tracker/skill/JieLi.ts
  • src/tracker/types.ts
  • src/tracker/view/cardButton.ts
  • tests/tracker/handExchange.test.ts
  • tests/tracker/pileDisplayOrder.test.ts
  • tests/tracker/pubGsCMoveCard.test.ts
  • tests/tracker/roleOptTargetNtf.test.ts
  • tests/tracker/roleSpellOptRep.test.ts
  • tests/tracker/trackerController.test.ts

Comment thread src/handler/CGsRoleSpellOptRep.js Outdated
Comment thread src/index.js
Comment thread src/tracker/roomMovement/sources.ts Outdated
Comment thread src/tracker/runtime/trackerController.ts
Comment thread src/tracker/skill/HandExchange.ts Outdated
Comment thread src/tracker/skill/HandExchange.ts
Comment thread tests/tracker/roleSpellOptRep.test.ts Outdated
llsccm and others added 2 commits July 18, 2026 23:49
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@llsccm
llsccm marked this pull request as ready for review July 18, 2026 17:00
- candidateRecords 从房间级下沉进 HandExchangeSpellState,与批次一样按
  SpellID 隔离,消除两个交换技能并发时的候选串扰隐患
- 回手先恢复候选再清账(clearSpellExchangeStateIfEmpty),避免过早删账
  连带丢弃尚未回手的候选令牌
- 整批揭示删空候选全部位置时在 DEV 下告警,暴露协议矛盾/上游观测错误
- 移除只写字段 batch.cardCount,补充模块不变式注释与 Card.ts 读面契约交叉引用
- 新增非 121 技能的候选隔离回归测试;runTwoSeatExchange 支持自定义 spellID

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@llsccm
llsccm merged commit 450705e into main Jul 19, 2026
8 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