Skip to content

fix(emotion,coalition): 修复情绪计算和联盟沉船心情扣减逻辑 - #641

Merged
wess09 merged 1 commit into
wess09:devfrom
Beatrice-betty:dev
Jul 27, 2026
Merged

fix(emotion,coalition): 修复情绪计算和联盟沉船心情扣减逻辑#641
wess09 merged 1 commit into
wess09:devfrom
Beatrice-betty:dev

Conversation

@Beatrice-betty

@Beatrice-betty Beatrice-betty commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator
  1. 重构情绪恢复计算逻辑,使用浮点值保留恢复余数,跨record调用累积
  2. 调整联盟沉船心情扣减规则,仅关卡进入时扣减一次,不再按战斗次数额外扣减
  3. 优化record方法,仅在情绪整数变化时更新时间戳并回扣余数秒数
  4. 修复情绪显示逻辑,显示实时恢复值而非缓存值

由 Sourcery 提供的摘要

使情绪恢复和联合战役自沉时的情绪扣减与游戏服务器的实际行为保持一致,并提升情绪追踪的精确度。

Bug 修复:

  • 修复在频繁调用 record() 时的情绪恢复问题:通过随时间累积小数部分的恢复量,而不是每次都将其截断。
  • 修正联合战役自沉时的情绪扣减逻辑,使情绪只在每次进入关卡时扣减一次,而不是在每场内部战斗或每个战斗评分时都扣减。
  • 修复情绪显示问题,使其展示实时恢复后的情绪值,而不是最后一次持久化保存的数值。

功能改进:

  • 调整情绪记录逻辑,仅在情绪的整数值发生变化时更新时间戳,并在多次更新之间保留(继承)情绪恢复的小数部分。
  • 更新联合战役自沉流程,将情绪消耗估算为每个关卡一次战斗,并在统计有效出击次数时不再忽略战舰沉没(shipwreck)结果。
Original summary in English

Summary by Sourcery

使情绪恢复和联盟破坏(coalition scuttle)的情绪消耗行为与游戏服务器保持一致,从而提升情绪追踪的准确性以及阶段成本估算的精度。

Bug Fixes:

  • 修复在频繁调用 record() 时的情绪恢复问题,允许小数恢复值在多次更新中累积。
  • 确保联盟破坏阶段在每次进入阶段时只减少一次情绪,而不是在每次内部战斗或评分时都减少。
  • 修正情绪显示逻辑,改为展示实时恢复后的情绪值,而不是最后一次持久化的记录值。

Enhancements:

  • 优化情绪记录的持久化逻辑,仅在整数情绪值发生变化时更新时间戳,并保留累积的小数恢复时间。
  • 调整联盟破坏执行逻辑,将情绪成本估算为每个阶段一次战斗,并将所有战斗(包括沉船结果)都视为有效运行。
Original summary in English

Summary by Sourcery

Align emotion recovery and coalition scuttle emotion consumption with game server behavior, improving accuracy of mood tracking and stage cost estimation.

Bug Fixes:

  • Fix emotion recovery under frequent record() calls by allowing fractional recovery to accumulate across updates.
  • Ensure coalition scuttle stages only reduce emotion once per stage entry instead of per internal battle or rating.
  • Correct emotion display to show the live recovered value rather than the last persisted record.

Enhancements:

  • Refine emotion record persistence to update timestamps only when the integer mood value changes and to carry over fractional recovery time.
  • Adjust coalition scuttle execution to estimate emotion cost as a single battle per stage and to treat all battles, including shipwreck results, as valid runs.

1. 重构情绪恢复计算逻辑,使用浮点值保留恢复余数,跨record调用累积
2. 调整联盟沉船心情扣减规则,仅关卡进入时扣减一次,不再按战斗次数额外扣减
3. 优化record方法,仅在情绪整数变化时更新时间戳并回扣余数秒数
4. 修复情绪显示逻辑,显示实时恢复值而非缓存值
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai

sourcery-ai Bot commented Jul 27, 2026

Copy link
Copy Markdown

🧙 Sourcery 已完成对你的 Pull Request 的审查!


提示与命令

与 Sourcery 交互

  • 触发新审查: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub Issue: 通过回复某条审查评论,让 Sourcery 从该评论创建一个 Issue。你也可以在审查评论下回复 @sourcery-ai issue 来从该评论创建一个 Issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中的任意位置写上 @sourcery-ai 即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 描述正文中的任意位置写上 @sourcery-ai summary,即可在你想要出现的地方随时生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可标记所有 Sourcery 评论为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 撤销所有 Sourcery 审查: 在 Pull Request 中评论 @sourcery-ai dismiss,即可撤销所有现有的 Sourcery 审查。特别适用于你想从一次全新的审查开始时——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 Pull Request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨,我在下面给了一些整体性的反馈:

  • Emotion.record 中,record_time 的反向计算使用的是 fractional * 360 / fleet.speed;如果 fleet.speed 有可能为 0(例如没有恢复状态时),这里会触发除以零错误,因此最好在 speed == 0 时做保护或提前返回。
  • 车队上的 _fractional_seconds 字段实际上存储的是一个分数形式的“恢复量”,而不是秒数,然后在 record() 中再被转换回秒数;建议重命名这个属性,或者在设置它的地方添加一段简短注释,说明它的计量单位,以避免未来被误用。
给 AI Agent 的提示
请根据这次代码审查中的评论进行修改:

## 总体评论
-`Emotion.record` 中,`record_time` 的反向计算使用的是 `fractional * 360 / fleet.speed`;如果 `fleet.speed` 有可能为 0(例如没有恢复状态时),这里会触发除以零错误,因此最好在 `speed == 0` 时做保护或提前返回。
- 车队上的 `_fractional_seconds` 字段实际上存储的是一个分数形式的“恢复量”,而不是秒数,然后在 `record()` 中再被转换回秒数;建议重命名这个属性,或者在设置它的地方添加一段简短注释,说明它的计量单位,以避免未来被误用。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进后续的审查。
Original comment in English

Hey - I've left some high level feedback:

  • In Emotion.record, the back-calculation of record_time uses fractional * 360 / fleet.speed; if fleet.speed can ever be 0 (e.g., no recovery state), this will raise a division-by-zero error, so it would be safer to guard or short-circuit for speed == 0.
  • The _fractional_seconds field on the fleet actually stores a fractional recovery amount rather than seconds, and is then converted back to seconds in record(); consider renaming this attribute or adding a brief comment where it is set to clarify its units and avoid future misuse.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Emotion.record`, the back-calculation of `record_time` uses `fractional * 360 / fleet.speed`; if `fleet.speed` can ever be 0 (e.g., no recovery state), this will raise a division-by-zero error, so it would be safer to guard or short-circuit for `speed == 0`.
- The `_fractional_seconds` field on the fleet actually stores a fractional *recovery* amount rather than seconds, and is then converted back to seconds in `record()`; consider renaming this attribute or adding a brief comment where it is set to clarify its units and avoid future misuse.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@wess09
wess09 merged commit 5213d20 into wess09:dev Jul 27, 2026
3 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.

联盟沉船设置出击次数没有效果 “联盟沉船”功能一队心情计算有误

2 participants