fix(emotion,coalition): 修复情绪计算和联盟沉船心情扣减逻辑 - #641
Merged
Conversation
1. 重构情绪恢复计算逻辑,使用浮点值保留恢复余数,跨record调用累积 2. 调整联盟沉船心情扣减规则,仅关卡进入时扣减一次,不再按战斗次数额外扣减 3. 优化record方法,仅在情绪整数变化时更新时间戳并回扣余数秒数 4. 修复情绪显示逻辑,显示实时恢复值而非缓存值
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
🧙 Sourcery 已完成对你的 Pull Request 的审查! 提示与命令与 Sourcery 交互
自定义你的体验访问你的控制面板以:
获取帮助Original review guide in English🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嗨,我在下面给了一些整体性的反馈:
- 在
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()` 中再被转换回秒数;建议重命名这个属性,或者在设置它的地方添加一段简短注释,说明它的计量单位,以避免未来被误用。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进后续的审查。
Original comment in English
Hey - I've left some high level feedback:
- In
Emotion.record, the back-calculation ofrecord_timeusesfractional * 360 / fleet.speed; iffleet.speedcan 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 forspeed == 0. - The
_fractional_secondsfield on the fleet actually stores a fractional recovery amount rather than seconds, and is then converted back to seconds inrecord(); 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
由 Sourcery 提供的摘要
使情绪恢复和联合战役自沉时的情绪扣减与游戏服务器的实际行为保持一致,并提升情绪追踪的精确度。
Bug 修复:
record()时的情绪恢复问题:通过随时间累积小数部分的恢复量,而不是每次都将其截断。功能改进:
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:
Enhancements: