Skip to content

fix(hotfix): 抽方法降 BattleRules.Simulate 认知复杂度 - #538

Merged
AlianBlank merged 1 commit into
mainfrom
feature/auto-server-source-worker-run-9818-20261010T1220
Oct 10, 2026
Merged

AlianBlank merged 1 commit into
mainfrom
feature/auto-server-source-worker-run-9818-20261010T1220

Conversation

@AlianBlank

@AlianBlank AlianBlank commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Linear: GFX-886

Summary by CodeRabbit

  • 修复
    • 调整战斗回合战力判定,保留重试次数上限、超限后的交替判定及平局重掷规则。
    • 随机数序列耗尽时使用默认值,避免后续判定中断。

消除 Sonar S3776(AaElsTY1oSiIXNEp0lag):Simulate 认知复杂度 23 超阈值 15。
沿用主方法 + 私有 helper 约定(C141/C142/C181):单回合战力求解(平局重掷
与护栏奇偶交替)抽为 ResolveRoundPower,rolls 取数兜底抽为 NextRoll,
拆分后 Simulate=4、helper=8/1;rolls 消费顺序、尝试计数、护栏语义与
回合记录零变更,现有 BattleRulesTests 全量通过。

Linear: GFX-886
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0adb1c4-a8de-4c28-8d02-17b3dd19045e

📥 Commits

Reviewing files that changed from the base of the PR and between 878c5f5 and dbf840e.


📒 Files selected for processing (1)
  • GameFrameX.Hotfix/Logic/ServerRole/Battle/BattleRules.cs

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

Walkthrough

单回合战力计算移至 ResolveRoundPower。新增 NextRoll 统一读取随机数,并在随机序列耗尽时返回 0.5。后续胜负判定和回合记录逻辑保持不变。

Changes

战斗回合战力判定

Layer / File(s) Summary
回合战力计算与随机数读取
GameFrameX.Hotfix/Logic/ServerRole/Battle/BattleRules.cs
Simulate 改为调用 ResolveRoundPower。该方法保留重掷、尝试次数上限及超限后的奇偶交替判定。NextRoll 在随机序列耗尽时返回 0.5,并递增游标。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor


Merge Risk: ⚪ Minimal · up to dbf84

The refactor preserves the observed battle outcomes and is ready to merge after normal checks.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了主要变更:通过提取方法降低 BattleRules.Simulate 的认知复杂度。标题具体、简洁,且与 PR 目标一致。
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@sonarqubecloud

Copy link
Copy Markdown

@AlianBlank
AlianBlank merged commit 3cab86a into main Oct 10, 2026
3 checks passed
@AlianBlank
AlianBlank deleted the feature/auto-server-source-worker-run-9818-20261010T1220 branch October 10, 2026 12:34
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