Skip to content

Fix emotion calculation and enhance island supply logic - #642

Merged
wess09 merged 5 commits into
masterfrom
dev
Jul 27, 2026
Merged

Fix emotion calculation and enhance island supply logic#642
wess09 merged 5 commits into
masterfrom
dev

Conversation

@wess09

@wess09 wess09 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

改进 CDN 构建的 SEO 输出,修复连续情绪恢复与联盟“scuttle”情绪处理问题,并优化岛屿好友来访流程和设备输入手势。

New Features:

  • 为 git-over-cdn 构建新增可配置的规范站点 URL 和 CDN 镜像列表,并生成对应的 sitemap 和 robots 元数据。
  • 引入共享的好友岛屿访问和退出辅助工具,被岛屿珍珠交易和每日空投流程复用。

Bug Fixes:

  • 修正联盟“scuttle”情绪削减逻辑,使其在每个阶段仅扣减一次,避免在所有结果等级上出现多次额外扣减。
  • 修复情绪恢复逻辑,使其能够计算随时间变化的情绪小数再生,并仅在情绪整数值变化时持久化更新的时间戳。
  • 改进岛屿好友访问检测和超时机制,避免在加载过程中出现误判,并能够更优雅地处理无法访问的好友。
  • 确保空投岛屿运行通过标准的好友岛屿退出逻辑退出,并通过短延迟稳定交易次数的调整。
  • 修复 minitouch 拖拽手势,确保正确发送 pointer up 事件,并简化岛屿滑动长按行为。

Enhancements:

  • 丰富 git-over-cdn 索引页面内容,加入镜像列表、结构化数据、alternate 链接以及更多 SEO 元数据。
  • 统一珍珠商店与空投模块中的岛屿好友访问逻辑,并在成功进入地图时增加更清晰的日志记录。
Original summary in English

Summary by Sourcery

Improve CDN build SEO outputs, fix continuous emotion recovery and coalition scuttle mood handling, and refine island friend-visit workflows and device input gestures.

New Features:

  • Add configurable canonical site URL and CDN mirror list for git-over-cdn builds with generated sitemap and robots metadata.
  • Introduce shared friend-island visit and exit helpers reused by island pearl trading and daily air-drop flows.

Bug Fixes:

  • Correct coalition scuttle emotion reduction to only charge once per stage and avoid extra deductions on all result grades.
  • Fix emotion recovery to account for fractional regeneration over time and persist updated timestamps only when integer mood changes.
  • Improve island friend visit detection and timeouts to avoid false positives during loading and handle inaccessible friends cleanly.
  • Ensure air-drop island runs exit via standard friend-island exit logic and stabilize trade count adjustments with short delays.
  • Fix minitouch drag gesture to properly send pointer up events and streamline island swipe hold behavior.

Enhancements:

  • Enrich git-over-cdn index page with mirror list, structured data, alternate links and additional SEO metadata.
  • Unify island friend visit logic across pearl shop and air-drop modules and add clearer logging on successful map entry.

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

## 由 Sourcery 提供的摘要

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

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

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

<details>
<summary>Original summary in English</summary>

## Summary by Sourcery

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

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

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

<details>
<summary>Original summary in English</summary>

## 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.

</details>

</details>
1. 每日补给合并为使用珍珠采购中的逻辑进入离开好友岛屿, 修复进入较慢时的`Too many click`报错;
2. 访问岛屿添加1s的二次状态检测, 避免加载过程中UI一闪而过时, 被误识别为进入, 同时确保岛屿状态稳定, 避免后续移动丢失;
3. 退出好友岛屿的检测条件`ISLAND_ACCESS_MAP`(好友岛屿)->`ISLAND_GOTO_MAP`(自己岛屿),
超时时间20->30s;
4. 在地图切换成功、补给领取、打开珍珠售卖之后添加额外的等待, 确保状态稳定,避免吞后续触控操作;
5. minitouch的`drag_minitouch()`: 还原疑似在#218, #228 中被误删除的的触摸抬起; 

[之前提交的diff](b9b4c92#diff-248e172f4a9d9021e4f1ab3b368c73babe15e22ce5da11c4e8ecc8352658d01aR719)
6. minitouch的`island_swipe_hold_minitouch()`:
合并`builder.wait(hold_time)`到前一次操作, 避免重复打印`Command list empty, sending it
may cause unexpected behaviour: w {hold_time}`的警告

## Summary by Sourcery

在每日补给和珍珠购买流程中统一好友岛屿的进入与退出逻辑,并加入更严格的状态检查和等待机制,以提升在低性能设备上的可靠性。

New Features:
- 引入共享的好友岛屿访问辅助方法,在继续执行操作前先验证场景是否完全加载。

Bug Fixes:
- 修复好友岛屿进入与退出检测不稳定的问题,该问题会在低性能设备上导致超时、错误地将问题归类为访问错误,以及触控操作被吞掉。
- 恢复在 minitouch 拖拽操作中的缺失“触控释放”动作,防止滑动操作卡住或表现不一致。
- 移除多余的 minitouch 滑动按住命令,避免触发“Command list empty”警告。

Enhancements:
- 在岛屿地图切换、每日补给交互以及珍珠交易对话框周围加入二次状态校验和更长的超时时间,确保在执行后续操作前 UI 状态稳定。

<details>
<summary>Original summary in English</summary>

## Summary by Sourcery

Unify friend island visit and exit logic across daily supply and pearl
purchasing flows, adding more robust state checks and waits to improve
reliability on slower devices.

New Features:
- Introduce a shared friend island visit helper that validates full
scene load before proceeding.

Bug Fixes:
- Fix unreliable friend island entry and exit detection that caused
timeouts, misclassification of access errors, and swallowed touch
actions on slower devices.
- Restore missing touch release in minitouch drag operations to prevent
stuck or inconsistent swipe behaviour.
- Eliminate redundant minitouch swipe hold commands that triggered
"Command list empty" warnings.

Enhancements:
- Add secondary state verification and extended timeouts around island
map transitions, daily supply interactions, and pearl trade dialogs to
ensure UI stability before subsequent actions.

</details>
@wess09
wess09 requested a review from quankong1551 July 27, 2026 11:08
@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.

@wess09
wess09 merged commit e2729bb into master Jul 27, 2026
8 checks passed
@sourcery-ai

sourcery-ai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Reviewer's Guide

优化 Git-over-CDN 站点元数据生成与 CDN 镜像处理,修正联盟沉船情绪(士气)扣减以匹配游戏服务器行为(包括多战阶段),修复持续情绪恢复数学逻辑以保留小数级恢复值,并合并/修复岛屿好友访问与空投补给的导航逻辑,使用更可靠的进入/退出检测和触控处理。

联盟沉船多战情绪处理的时序图

sequenceDiagram
  participant CoalitionScuttleRun
  participant Emotion as EmotionManager
  participant CoalitionScuttleCombat

  CoalitionScuttleRun->>Emotion: check_reduce(battle=1)
  Emotion-->>CoalitionScuttleRun: [ok or ScriptEnd]
  CoalitionScuttleRun->>CoalitionScuttleRun: enter_map(event, stage, mode)
  CoalitionScuttleRun->>CoalitionScuttleCombat: coalition_combat()
  loop per_battle
    CoalitionScuttleCombat->>CoalitionScuttleCombat: combat_preparation(emotion_reduce=False)
    CoalitionScuttleCombat->>CoalitionScuttleCombat: auto_search_combat_execute(emotion_reduce=(battle_count==0), fleet_index=1, expected_end=auto_search_combat_end)
    alt first_battle
      CoalitionScuttleCombat->>Emotion: reduce(fleet_index)
    else later_battles
      CoalitionScuttleCombat-->>Emotion: [no_reduce]
    end
    CoalitionScuttleCombat->>CoalitionScuttleCombat: [handle battle result A/B/S/D]
    CoalitionScuttleCombat-->>Emotion: [no shipwreck extra reduce]
  end
  CoalitionScuttleCombat-->>CoalitionScuttleRun: [CampaignEnd or normal]
Loading

File-Level Changes

Change Details Files
为 Git-over-CDN 构建脚本添加可配置的规范站点 URL、镜像列表处理以及 sitemap/robots 生成,包括更丰富的 SEO 元数据和 index.html 中的镜像表。
  • 引入 CDN_SITE_URLS 默认值,增加 normalizeSiteUrl/parseUrlList/uniqueUrls 辅助函数,以及用于资源链接的 resolveAssetUrl。
  • 扩展 CLI/环境变量选项,支持 --site-url 和 GOC_SITE_URL/GOC_MIRROR_URLS,从默认值与环境覆盖合并计算 options.siteUrl 和 options.mirrorUrls。
  • 使用镜像 URL 和生成时间创建 sitemap.xml 和 robots.txt,并在构建结束时记录新的站点/镜像信息日志。
  • 更新 index.html 生成逻辑,以使用可配置的规范 URL,包含 sitemap 链接、结构化数据中的 sameAs/relatedLink、备用镜像链接和镜像表,并在信息区域显示 CDN 首页与 sitemap。
.github/scripts/build_git_over_cdn_eo_esa.mjs
将联盟沉船(联盟沉船)情绪扣减和停止条件与服务器端行为对齐,仅按阶段收取一次士气,不按内部战斗或评分重复扣减。
  • 修改 auto_search_combat_execute,使其仅在联盟阶段的首战扣减情绪,移除 A/B/S 评级的额外沉船相关扣减,并澄清注释和文档字符串。
  • 调整 coalition_combat,在第 0 场战斗时才以 emotion_reduce 调用 auto_search_combat_execute,并在循环中保持 _is_shipwreck 的重置,以符合按阶段计费的语义。
  • 重写 CoalitionScuttleRun.coalition_execute_once,将情绪成本估算为一次战斗,使用单舰队调整情绪控制,并确保按阶段的舰队模式覆盖逻辑。
  • 更新 triggered_stop_condition 以忽略 triggered_normal_end,使联盟沉船运行次数而非舰船损失来决定终止语义及其文档说明。
module/coalition/coalition_scuttle.py
修复持续情绪恢复,通过在多次 record() 调用间保留小数级恢复值,并记录当前值而非最后一次持久化值。
  • 修改 FleetEmotion.update,使用浮点型 time_diff,按 speed * seconds / 360 计算恢复量,存储剩余的秒数小数部分,并避免对时间戳进行整数截断。
  • 重构 Emotion.record,仅在士气整数值变化时更新时间戳,同时将 Record 时间回溯 fractional_seconds,以在公共和逐舰队模式下跨多次更新保留子点恢复。
  • 调整 Emotion.show,在公共与单舰队视图中显示 fleet.current(实时值)而非 fleet.value(最后持久化值)。
module/combat/emotion.py
统一各岛屿模块的好友岛访问/退出逻辑,提升检测准确性并避免加载过渡期间的误判,同时对贸易与空投的时序做小幅调整。
  • 新增 island.check_visit_friend_island,用于点击访问按钮并通过在额外延迟后二次检查 is_in_friend_island 来确认进入好友岛,处理 CANT_ACCESS 和超时场景;新增 island.exit_friend_island 以提供统一的退出行为。
  • 在 island_pearl_sell(visit_friend_by_rank)与 island_air_drop(find_air_drop/run_and_get)中使用新的好友岛进入/退出通用辅助函数,移除重复的 click_rank_visit/check_visit 和 island_access_map_check 实现。
  • 改进岛屿目的地进入日志与稳定性,在确认好友岛地图进入前短暂等待,并在调整珍珠贸易数量之前及触发多个空投按钮之后增加小幅睡眠。
  • 调整 island run_and_get,改为通过 exit_friend_island 退出,而不是直接点击 AIR_DROP_RUN_AWAY,以实现更健壮的状态清理。
module/island/island.py
module/island/island_pearl_sell.py
module/island/island_air_drop.py
收紧 minitouch 拖拽行为以确保触控释放事件被发送,并简化岛屿滑动按住手势的帧发送。
  • 更新 drag_minitouch,在拖拽完成后显式发送 up() 事件并提交/发送。
  • 移除 island_swipe_hold_minitouch 中按住之前的多余 send(),在仍然发送最终帧与 up() 的同时减少冗余命令并保持原有行为。
module/device/method/minitouch.py

Tips and commands

Interacting with 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 总结。也可以评论 @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 以触发新的审查!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用审查功能,例如 Sourcery 自动生成的 pull request 总结、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

Getting Help

Original review guide in English

Reviewer's Guide

Refines Git-over-CDN site metadata generation and CDN mirror handling, corrects coalition scuttle emotion (morale) reduction to match game server behavior including multi-battle stages, fixes continuous emotion recovery math to preserve fractional regeneration, and consolidates/fixes island friend-visit and air-drop supply navigation using more reliable enter/exit detection and touch handling.

Sequence diagram for coalition scuttle multi-battle emotion handling

sequenceDiagram
  participant CoalitionScuttleRun
  participant Emotion as EmotionManager
  participant CoalitionScuttleCombat

  CoalitionScuttleRun->>Emotion: check_reduce(battle=1)
  Emotion-->>CoalitionScuttleRun: [ok or ScriptEnd]
  CoalitionScuttleRun->>CoalitionScuttleRun: enter_map(event, stage, mode)
  CoalitionScuttleRun->>CoalitionScuttleCombat: coalition_combat()
  loop per_battle
    CoalitionScuttleCombat->>CoalitionScuttleCombat: combat_preparation(emotion_reduce=False)
    CoalitionScuttleCombat->>CoalitionScuttleCombat: auto_search_combat_execute(emotion_reduce=(battle_count==0), fleet_index=1, expected_end=auto_search_combat_end)
    alt first_battle
      CoalitionScuttleCombat->>Emotion: reduce(fleet_index)
    else later_battles
      CoalitionScuttleCombat-->>Emotion: [no_reduce]
    end
    CoalitionScuttleCombat->>CoalitionScuttleCombat: [handle battle result A/B/S/D]
    CoalitionScuttleCombat-->>Emotion: [no shipwreck extra reduce]
  end
  CoalitionScuttleCombat-->>CoalitionScuttleRun: [CampaignEnd or normal]
Loading

File-Level Changes

Change Details Files
Add configurable canonical site URL, mirror list handling, and sitemap/robots generation to Git-over-CDN build script, including richer SEO metadata and mirror table in index.html.
  • Introduce CDN_SITE_URLS defaults, normalizeSiteUrl/parseUrlList/uniqueUrls helpers, and resolveAssetUrl for asset links.
  • Extend CLI/env options with --site-url and GOC_SITE_URL/GOC_MIRROR_URLS, computing options.siteUrl and options.mirrorUrls from defaults plus env overrides.
  • Generate sitemap.xml and robots.txt using mirror URLs and generation time, and log new site/mirror info at the end of the build.
  • Update index.html generation to use configurable canonical URL, include sitemap link, structured data sameAs/relatedLink, alternate mirror links and table, and display CDN home & sitemap in the info section.
.github/scripts/build_git_over_cdn_eo_esa.mjs
Align coalition scuttle (联盟沉船) emotion deduction and stop conditions with server-side behavior by charging morale once per stage and not per internal battle or rating.
  • Change auto_search_combat_execute to only reduce emotion on first battle of a coalition stage, remove extra shipwreck-related reductions for A/B/S ranks, and clarify comments/docstrings.
  • Modify coalition_combat to call auto_search_combat_execute with emotion_reduce only on battle 0 and keep _is_shipwreck resets per loop, matching per-stage cost semantics.
  • Override CoalitionScuttleRun.coalition_execute_once to estimate emotion cost as one battle, adjust emotion control with single fleet, and ensure stage-specific fleet mode overrides.
  • Update triggered_stop_condition to ignore triggered_normal_end so coalition scuttle run count, not ship losses, determines termination semantics and documentation.
module/coalition/coalition_scuttle.py
Fix continuous emotion recovery by preserving fractional regeneration across record() calls and logging current values instead of last-saved ones.
  • Change FleetEmotion.update to use floating-point time_diff, compute recovery as speed * seconds / 360, store fractional seconds remainder, and avoid int timestamp truncation.
  • Rework Emotion.record to only update timestamps when integer morale changes, back-dating Record time by fractional_seconds to preserve sub-point recovery across updates for public and per-fleet modes.
  • Adjust Emotion.show to display fleet.current (live value) instead of fleet.value (last persisted) for both public and individual fleets.
module/combat/emotion.py
Unify friend island visit/exit logic across island modules, improving detection and avoiding false positives during loading transitions, plus minor timing tweaks for trading and air drops.
  • Add island.check_visit_friend_island to click visit buttons and confirm friend island entry by double-checking is_in_friend_island with an extra delay, handling CANT_ACCESS and timeouts; add island.exit_friend_island for consistent exit behavior.
  • Use the new shared friend-island enter/exit helpers in island_pearl_sell (visit_friend_by_rank) and island_air_drop (find_air_drop/run_and_get), removing duplicate click_rank_visit/check_visit and island_access_map_check implementations.
  • Improve island destination entry logging and stabilization by sleeping briefly before confirming friend island map entry, and add small sleeps before adjusting pearl trade counts and after triggering multiple air-drop buttons.
  • Adjust island run_and_get to exit using exit_friend_island instead of directly clicking AIR_DROP_RUN_AWAY for more robust state cleanup.
module/island/island.py
module/island/island_pearl_sell.py
module/island/island_air_drop.py
Tighten minitouch drag behavior to ensure touch release events are sent, and simplify island swipe hold gesture framing.
  • Update drag_minitouch to send an explicit up() event with commit/send after the drag completes.
  • Remove an extra send() before the hold in island_swipe_hold_minitouch while still sending final frames and up(), reducing redundant commands while preserving behavior.
module/device/method/minitouch.py

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.

Hey - 我发现了 3 个问题,并给出了一些高层反馈:

  • Emotion.record 中,回算 record_time 使用的是 fractional * 360 / fleet.speed;如果 fleet.speed 有可能为 0(例如恢复被禁用或配置错误),这里会抛出 ZeroDivisionError——建议在应用该调整前,对 speed 非正值进行保护。
  • island_swipe_hold_minitouch 中,将 builder.send() 移动到所有 move 和 wait(hold_time) 之前,会改变手势的语义(现在是在真正发出任何事件之前就发生了“按住”);如果你的意图是滑动完成后再进行按住,建议在等待 hold 之前先发送 down/move 序列。
面向 AI Agent 的提示
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 zero (e.g., disabled or misconfigured recovery), this will raise a ZeroDivisionError—consider guarding against non-positive `speed` before applying the adjustment.
- In `island_swipe_hold_minitouch`, moving the `builder.send()` so that all moves and the `wait(hold_time)` happen before the first send changes the semantics of the gesture (the hold now occurs before any events are actually sent); if the intention is to hold after the swipe is applied, consider sending the down/move sequence before the hold wait.

## Individual Comments

### Comment 1
<location path=".github/scripts/build_git_over_cdn_eo_esa.mjs" line_range="149-152" />
<code_context>
   if (!Number.isInteger(options.history) || options.history < 1) {
     throw new Error(`--history 必须是正整数:${options.history}`);
   }
+  options.mirrorUrls = uniqueUrls([
+    options.siteUrl,
+    ...CDN_SITE_URLS,
+    ...parseUrlList(env.GOC_MIRROR_URLS),
+  ]);

</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against invalid URLs in GOC_MIRROR_URLS crashing the build.

`uniqueUrls` currently calls `normalizeSiteUrl`, which does `new URL(...)`. Any malformed value in `GOC_MIRROR_URLS` will throw and terminate the build. Since this comes from user/env config, consider handling this defensively (e.g. try/catch in `uniqueUrls` with logging + skipping invalid entries, or validating in `parseUrlList` before normalization) so a single bad URL doesn’t fail the entire build.
</issue_to_address>

### Comment 2
<location path="module/combat/emotion.py" line_range="176-183" />
<code_context>
-        (如联盟沉船每2分钟调用一次),恢复永远无法累积。
-        改为按实际秒数计算恢复量,与游戏服务端行为一致。
-        """
-        time_diff = int(current_time().timestamp()) - int(self.record.timestamp())
+        使用连续时间恢复计算,保留浮点恢复量以累积分数部分。
+        游戏服务端按实际经过时间精确计算恢复,每6分钟恢复speed点。
+        旧方法用 int() 截断恢复量,每次 record() 重置时间戳后,
+        未满1点的恢复余数被丢弃,长时间运行导致严重低估。
+        现改为 floor() 取整保留整数部分,同时 record() 仅在整数变化时
+        重置时间戳并回扣分数秒,确保余数可跨次累积。
+        """
+        time_diff = current_time().timestamp() - self.record.timestamp()
         time_diff = max(time_diff, 0)
         # speed 为每360秒的恢复量,换算为每秒恢复 speed/360 点
         recovery = self.speed * time_diff / 360
         self.current = min(max(self.value, 0) + int(recovery), self.max)
+        # 保留未满1点的恢复余数对应的秒数,用于 record() 回扣
+        self._fractional_seconds = recovery - int(recovery)

     def get_recovered(self, expected_reduce=0):
</code_context>
<issue_to_address>
**issue (bug_risk):** Handle `speed == 0` and guard fractional-seconds backoff math.

`record()` later does `timedelta(seconds=fractional * 360 / fleet.speed)`, so a `speed` of 0 (or ≤ 0) will raise `ZeroDivisionError`. Please guard this by short‑circuiting when `fleet.speed <= 0` (e.g., skip fractional backoff and log) or by enforcing a minimum positive speed, so the new fractional logic doesn’t introduce a hard failure in unusual configurations.
</issue_to_address>

### Comment 3
<location path="module/island/island_air_drop.py" line_range="162" />
<code_context>
                 visit_button = self.calculate_visit_position(
                     air_drop_button_x, air_drop_button_y
                 )
-                result = self.check_visit(visit_button)
-                if result == "skip":
-                    logger.info("[岛屿-每日补给] 无法访问,跳过当前补给")
+                if not self.check_visit_friend_island(visit_button):
                     continue
-                elif result == "success":
</code_context>
<issue_to_address>
**issue (bug_risk):** Preserve explicit timeout/error handling when visiting air-drop targets.

Previously `check_visit` differentiated `skip` vs `timeout`, and timeouts set `self.island_error = True` and aborted. Now `check_visit_friend_island` collapses all failures into a simple `continue`, so repeated timeouts never raise `island_error` and the loop just keeps scanning. If timeouts still signal a serious issue, have `check_visit_friend_island` return a structured result (e.g. success / cant_access / timeout) so `find_air_drop` can still set `island_error` and exit on timeout as before.
</issue_to_address>

Sourcery 对开源项目是免费的——如果你喜欢我们的评审,请考虑分享它们 ✨
帮我变得更有用!请对每条评论点击 👍 或 👎,我会利用这些反馈来改进后续的评审。
Original comment in English

Hey - I've found 3 issues, and 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 zero (e.g., disabled or misconfigured recovery), this will raise a ZeroDivisionError—consider guarding against non-positive speed before applying the adjustment.
  • In island_swipe_hold_minitouch, moving the builder.send() so that all moves and the wait(hold_time) happen before the first send changes the semantics of the gesture (the hold now occurs before any events are actually sent); if the intention is to hold after the swipe is applied, consider sending the down/move sequence before the hold wait.
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 zero (e.g., disabled or misconfigured recovery), this will raise a ZeroDivisionError—consider guarding against non-positive `speed` before applying the adjustment.
- In `island_swipe_hold_minitouch`, moving the `builder.send()` so that all moves and the `wait(hold_time)` happen before the first send changes the semantics of the gesture (the hold now occurs before any events are actually sent); if the intention is to hold after the swipe is applied, consider sending the down/move sequence before the hold wait.

## Individual Comments

### Comment 1
<location path=".github/scripts/build_git_over_cdn_eo_esa.mjs" line_range="149-152" />
<code_context>
   if (!Number.isInteger(options.history) || options.history < 1) {
     throw new Error(`--history 必须是正整数:${options.history}`);
   }
+  options.mirrorUrls = uniqueUrls([
+    options.siteUrl,
+    ...CDN_SITE_URLS,
+    ...parseUrlList(env.GOC_MIRROR_URLS),
+  ]);

</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against invalid URLs in GOC_MIRROR_URLS crashing the build.

`uniqueUrls` currently calls `normalizeSiteUrl`, which does `new URL(...)`. Any malformed value in `GOC_MIRROR_URLS` will throw and terminate the build. Since this comes from user/env config, consider handling this defensively (e.g. try/catch in `uniqueUrls` with logging + skipping invalid entries, or validating in `parseUrlList` before normalization) so a single bad URL doesn’t fail the entire build.
</issue_to_address>

### Comment 2
<location path="module/combat/emotion.py" line_range="176-183" />
<code_context>
-        (如联盟沉船每2分钟调用一次),恢复永远无法累积。
-        改为按实际秒数计算恢复量,与游戏服务端行为一致。
-        """
-        time_diff = int(current_time().timestamp()) - int(self.record.timestamp())
+        使用连续时间恢复计算,保留浮点恢复量以累积分数部分。
+        游戏服务端按实际经过时间精确计算恢复,每6分钟恢复speed点。
+        旧方法用 int() 截断恢复量,每次 record() 重置时间戳后,
+        未满1点的恢复余数被丢弃,长时间运行导致严重低估。
+        现改为 floor() 取整保留整数部分,同时 record() 仅在整数变化时
+        重置时间戳并回扣分数秒,确保余数可跨次累积。
+        """
+        time_diff = current_time().timestamp() - self.record.timestamp()
         time_diff = max(time_diff, 0)
         # speed 为每360秒的恢复量,换算为每秒恢复 speed/360 点
         recovery = self.speed * time_diff / 360
         self.current = min(max(self.value, 0) + int(recovery), self.max)
+        # 保留未满1点的恢复余数对应的秒数,用于 record() 回扣
+        self._fractional_seconds = recovery - int(recovery)

     def get_recovered(self, expected_reduce=0):
</code_context>
<issue_to_address>
**issue (bug_risk):** Handle `speed == 0` and guard fractional-seconds backoff math.

`record()` later does `timedelta(seconds=fractional * 360 / fleet.speed)`, so a `speed` of 0 (or ≤ 0) will raise `ZeroDivisionError`. Please guard this by short‑circuiting when `fleet.speed <= 0` (e.g., skip fractional backoff and log) or by enforcing a minimum positive speed, so the new fractional logic doesn’t introduce a hard failure in unusual configurations.
</issue_to_address>

### Comment 3
<location path="module/island/island_air_drop.py" line_range="162" />
<code_context>
                 visit_button = self.calculate_visit_position(
                     air_drop_button_x, air_drop_button_y
                 )
-                result = self.check_visit(visit_button)
-                if result == "skip":
-                    logger.info("[岛屿-每日补给] 无法访问,跳过当前补给")
+                if not self.check_visit_friend_island(visit_button):
                     continue
-                elif result == "success":
</code_context>
<issue_to_address>
**issue (bug_risk):** Preserve explicit timeout/error handling when visiting air-drop targets.

Previously `check_visit` differentiated `skip` vs `timeout`, and timeouts set `self.island_error = True` and aborted. Now `check_visit_friend_island` collapses all failures into a simple `continue`, so repeated timeouts never raise `island_error` and the loop just keeps scanning. If timeouts still signal a serious issue, have `check_visit_friend_island` return a structured result (e.g. success / cant_access / timeout) so `find_air_drop` can still set `island_error` and exit on timeout as before.
</issue_to_address>

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.

Comment on lines +149 to +152
options.mirrorUrls = uniqueUrls([
options.siteUrl,
...CDN_SITE_URLS,
...parseUrlList(env.GOC_MIRROR_URLS),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): 需要防止 GOC_MIRROR_URLS 中的非法 URL 导致构建崩溃。

uniqueUrls 当前会调用 normalizeSiteUrl,而后者内部执行 new URL(...)。任何在 GOC_MIRROR_URLS 中的非法值都会抛出异常并终止构建。由于这一配置来自用户/环境变量,建议在这里做防御性处理(例如在 uniqueUrls 中用 try/catch 记录日志并跳过非法条目,或者在 parseUrlList 中先做合法性校验再归一化),以避免单个错误 URL 就导致整个构建失败。

Original comment in English

issue (bug_risk): Guard against invalid URLs in GOC_MIRROR_URLS crashing the build.

uniqueUrls currently calls normalizeSiteUrl, which does new URL(...). Any malformed value in GOC_MIRROR_URLS will throw and terminate the build. Since this comes from user/env config, consider handling this defensively (e.g. try/catch in uniqueUrls with logging + skipping invalid entries, or validating in parseUrlList before normalization) so a single bad URL doesn’t fail the entire build.

Comment thread module/combat/emotion.py
Comment on lines -176 to 183
time_diff = int(current_time().timestamp()) - int(self.record.timestamp())
使用连续时间恢复计算,保留浮点恢复量以累积分数部分。
游戏服务端按实际经过时间精确计算恢复,每6分钟恢复speed点。
旧方法用 int() 截断恢复量,每次 record() 重置时间戳后,
未满1点的恢复余数被丢弃,长时间运行导致严重低估。
现改为 floor() 取整保留整数部分,同时 record() 仅在整数变化时
重置时间戳并回扣分数秒,确保余数可跨次累积。
"""
time_diff = current_time().timestamp() - self.record.timestamp()
time_diff = max(time_diff, 0)
# speed 为每360秒的恢复量,换算为每秒恢复 speed/360 点
recovery = self.speed * time_diff / 360
self.current = min(max(self.value, 0) + int(recovery), self.max)
# 保留未满1点的恢复余数对应的秒数,用于 record() 回扣
self._fractional_seconds = recovery - int(recovery)

def get_recovered(self, expected_reduce=0):
"""计算情绪恢复到控制阈值的时间。

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): 需要处理 speed == 0 并保护分数秒回退的计算逻辑。

record() 之后会调用 timedelta(seconds=fractional * 360 / fleet.speed),因此当 speed 为 0(或 ≤ 0)时会抛出 ZeroDivisionError。请在 fleet.speed <= 0 时直接短路返回(例如跳过分数部分回退并记录日志),或者强制保证一个最小的正 speed,以避免新的分数逻辑在异常配置下引入硬错误。

Original comment in English

issue (bug_risk): Handle speed == 0 and guard fractional-seconds backoff math.

record() later does timedelta(seconds=fractional * 360 / fleet.speed), so a speed of 0 (or ≤ 0) will raise ZeroDivisionError. Please guard this by short‑circuiting when fleet.speed <= 0 (e.g., skip fractional backoff and log) or by enforcing a minimum positive speed, so the new fractional logic doesn’t introduce a hard failure in unusual configurations.

visit_button = self.calculate_visit_position(
air_drop_button_x, air_drop_button_y
)
result = self.check_visit(visit_button)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): 访问空投目标时需要保留原有的超时/错误显式处理。

之前的 check_visit 会区分 skiptimeout,并且在超时时设置 self.island_error = True 并终止。现在 check_visit_friend_island 将所有失败都折叠为简单的 continue,因此重复的超时不会再触发 island_error,循环只会持续扫描。如果超时仍然意味着严重问题,建议让 check_visit_friend_island 返回结构化结果(例如 success / cant_access / timeout),这样 find_air_drop 仍然可以在超时时设置 island_error 并按之前的行为退出。

Original comment in English

issue (bug_risk): Preserve explicit timeout/error handling when visiting air-drop targets.

Previously check_visit differentiated skip vs timeout, and timeouts set self.island_error = True and aborted. Now check_visit_friend_island collapses all failures into a simple continue, so repeated timeouts never raise island_error and the loop just keeps scanning. If timeouts still signal a serious issue, have check_visit_friend_island return a structured result (e.g. success / cant_access / timeout) so find_air_drop can still set island_error and exit on timeout as before.

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.

3 participants