Skip to content

fix: 修正赌枪与无懈可击,支持负数积分结算 - #14

Merged
17hwliao merged 1 commit into
lec-org:mainfrom
17hwliao:review/platform-20261016
Oct 28, 2026
Merged

17hwliao merged 1 commit into
lec-org:mainfrom
17hwliao:review/platform-20261016

Conversation

@17hwliao

@17hwliao 17hwliao commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

赌枪原来只有扣时或无事发生,无懈可击会拦截队友增益,部分转移仍只读取独立娱乐余额。本次调整卡牌结算,并让综合时长和抽卡积分的负差额直接显示。

变化

  • 赌枪改为50%获得30分钟、50%扣除30分钟;负面结果可被仁王盾或名刀抵挡,获益不消耗防御卡。
  • 无懈可击只免疫他人负面效果,正常接收加时和额外抽卡机会,保留24小时及跨周到期规则。
  • 综合时长直接合计有效考勤、管理员净调整和卡牌效果;积分额度向下取整,余额减去已消费积分,均允许负数。消费记录保留,后续加时先抵扣差额,原始签到签退和审计流水不改写。
  • 慈善家、万箭穿心按正综合时长计算比例;神偷奶爸固定转移30分钟,允许供给方负数,经防御后实际扣除才转赠。保留作用范围与防御顺序。
  • 负积分仍能使用免费/赠送机会,付费十连须足额;修复零费用十连被负余额误禁用。同步词条、规则弹窗和负余额提示。
  • 问号卡、基础概率、30/70保底、十连明光及周一重置规则保持原设定;旧回执和已结算考核不重写。

例如综合时长为-30分钟、已消费60积分时,显示余额-90;后续增加30分钟后余额为-60。免费/赠送机会可继续使用,但不能赊账付费抽卡。

验证

  • 完整API 542/542:启用独立localhost Mongo随机测试库,包含CAS并发扣时、十连、归档中断恢复和幂等,无skip。
  • 完整Web 211/211;本阶段最终定向API 206/206、卡牌页38/38。
  • API/Web构建、类型检查、shared源工件防线、git diff --check通过。
  • 小范围Review未发现新增业务缺陷,增加10项交叉回归;将“新抽到防御卡立即挡住攻击”与“余额竞争”拆开验证,避免随机测试误报。
  • 本地运行API已核对新词条及cards/points余额一致。未操作生产环境,未执行本次部署。

Follow-up to #13.

Summary by CodeRabbit

  • New Features
    • Weekly time totals, point allowances, and balances can now be negative. Future added time offsets deficits; free and gifted draws remain available.
    • Card effects now use combined time for applicable transfers and deductions. Charity, fixed 30-minute theft, and 50/50 gamble outcomes follow updated rules.
    • Weekly protection blocks other players’ harmful effects while still allowing beneficial effects.
  • Updates
    • Card draw rules now explain negative time and balances, draw eligibility, and updated card effects.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c63c3725-edbe-48a4-8826-782d969508a1
Commits

Reviewing files that changed from the base of the PR and between 71078c1 and 13e8ba1.

Files selected for processing: 15
  • apps/api/src/common/utils/weekly-economy.spec.ts
  • apps/api/src/modules/assessment/assessment-engine.spec.ts
  • apps/api/src/modules/cards/card-catalog.ts
  • apps/api/src/modules/cards/card-complete-review.spec.ts
  • apps/api/src/modules/cards/card-engine.spec.ts
  • apps/api/src/modules/cards/card-engine.ts
  • apps/api/src/modules/cards/card-storage.integration.spec.ts
  • apps/api/src/modules/cards/cards.service.spec.ts
  • apps/api/src/modules/points/points.service.spec.ts
  • apps/api/src/modules/stats/stats.service.spec.ts
  • apps/web/src/features/cards/DrawRulesDialog.tsx
  • apps/web/src/pages/cards/CardsPage.test.tsx
  • apps/web/src/pages/cards/CardsPage.tsx
  • deploy/cards-assessment.md
  • packages/shared/src/utils/weekly-economy.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Weekly duration and point calculations now preserve negative values. Card effects, draw eligibility, and displayed rules use signed totals and balances. Tests cover these accounting changes and the updated card behavior.

Changes: Weekly economy and card behavior

Layer / File(s) Summary
Signed duration and point accounting
packages/shared/src/utils/weekly-economy.ts, apps/api/src/common/utils/weekly-economy.spec.ts, apps/api/src/modules/points/points.service.spec.ts, apps/api/src/modules/cards/card-storage.integration.spec.ts, apps/api/src/modules/cards/cards.service.spec.ts, apps/api/src/modules/assessment/assessment-engine.spec.ts, apps/api/src/modules/stats/stats.service.spec.ts
Comprehensive duration and point calculations no longer clamp negative values to zero. The tests cover signed adjustments, balances, and assessment totals.
Card effects and draw resolution
apps/api/src/modules/cards/card-catalog.ts, apps/api/src/modules/cards/card-engine.ts, apps/api/src/modules/cards/card-engine.spec.ts, apps/api/src/modules/cards/card-complete-review.spec.ts, apps/api/src/modules/cards/card-storage.integration.spec.ts
Card effects use signed comprehensive duration. Immunity blocks harmful effects from other players but permits beneficial effects. Updated rules cover gamble, charity, thief, and arrows behavior, with tests for defenses, transfers, draws, and persistence.
Draw interface and published rules
apps/web/src/pages/cards/CardsPage.tsx, apps/web/src/pages/cards/CardsPage.test.tsx, apps/web/src/features/cards/DrawRulesDialog.tsx, deploy/cards-assessment.md
The cards page displays negative balances and keeps free or gifted draws available when the balance is negative. The dialog and assessment document describe signed totals and updated card rules.

Priority: Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant CardEngine
  participant resolveTarget
  participant change
  participant weeklyDrawPoints
  CardEngine->>resolveTarget: Check harmful-effect immunity
  CardEngine->>change: Apply signed time delta
  change->>weeklyDrawPoints: Calculate signed point balance
  weeklyDrawPoints-->>change: Return validated point balance
  change-->>CardEngine: Store updated balance
Loading

Possibly related PRs

  • lec-org/LecPunch#13: Changes the same weekly-economy and card-engine rules, including duration clamping, balances, and immunity.
  • lec-org/LecPunch#12: Introduces the weekly card engine and accounting rules that this pull request updates.
Merge Risk: Minimal · up to 13e8b

The changed rules consistently allow negative balances while retaining paid-draw checks. No specific issue requiring a fix before merge is established; normal validation remains appropriate.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main changes: correcting 赌枪 and 无懈可击 behavior and supporting negative point settlement.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 14 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/api/src/common/utils/weekly-economy.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/api/src/modules/assessment/assessment-engine.spec.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

apps/api/src/modules/cards/card-catalog.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 11 others

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.

@17hwliao
17hwliao merged commit 3bcf1ee into lec-org:main Oct 28, 2026
2 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