Skip to content

feat: 大世界自律寻敌时间限制 (#490)#493

Merged
wess09 merged 8 commits into
devfrom
master
Jul 6, 2026
Merged

feat: 大世界自律寻敌时间限制 (#490)#493
wess09 merged 8 commits into
devfrom
master

Conversation

@wess09

@wess09 wess09 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary by Sourcery

为 OS 自动搜索引入可配置的时间限制与错误处理机制,并优化基于硬币与行动点补充的智能调度行为。

New Features:

  • 添加配置项,用于限制 OS 自动搜索的持续时间,并将超时运行视为卡死状态错误。
  • 支持基于目标硬币数量的智能调度,并提供可配置的回退阈值,用于恢复 Hazard 1 练级。

Bug Fixes:

  • 通过强制执行可配置时间限制,并在关键事件上重置相关计时器,防止 OS 自动搜索无限挂起。
  • 在资源不足场景下,优化通知消息,改为报告硬币补充目标值,而非原始保留值。

Enhancements:

  • 在智能调度中跟踪并区分基于硬币目标与基于行动点的补充阶段,并提供更清晰的日志与通知。
  • 在延迟智能调度或硬币任务时,调整行动点阈值比较方式,改为使用包含边界的判断。
  • 在战略搜索与巡逻流程中向上传递 GameStuckError 及相关可恢复异常,以便上层调度器进行处理。
  • 确保 timer.start() 返回 Timer 实例,以便实现链式调用。
Original summary in English

Summary by Sourcery

Introduce configurable time limit and error handling for OS auto-search, and refine smart scheduling behavior for coin and action point replenishment.

New Features:

  • Add configuration option to limit OS auto-search duration and treat overlong runs as a stuck-state error.
  • Support coin-target-based smart scheduling with a configurable return threshold for resuming Hazard 1 leveling.

Bug Fixes:

  • Prevent OS auto-search from hanging indefinitely by enforcing a configurable time limit and resetting relevant timers on key events.
  • Clarify notification messages to report coin replenish targets instead of raw preserve values in low-resource scenarios.

Enhancements:

  • Track and differentiate coin-target and action-point-based replenishment phases in smart scheduling, with clearer logging and notifications.
  • Adjust action point threshold comparisons to use inclusive bounds when delaying smart scheduling or coin tasks.
  • Propagate GameStuckError and related recoverable exceptions through strategic search and patrol flows so the upper scheduler can handle them.
  • Ensure timer.start() returns the Timer instance for fluent usage.

longer-sausage and others added 8 commits July 5, 2026 19:00
## Summary by Sourcery

Bug Fixes:
- 修复智能调度中高优先级任务切换不正确的问题,改为使用配置中的禁用标志而不是运行时任务状态。

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

## Summary by Sourcery

Bug Fixes:
- Fix incorrect smart scheduling high-priority task switching by using
the config disable flag instead of runtime task state.

</details>
## Summary by Sourcery

通过可配置的硬币目标调度以及在基于硬币和基于行动点补充之间更清晰的状态处理,改进智能调度的硬币补充行为。

新功能:
- 在智能调度中新增用于硬币目标调度和硬币补充返回阈值的配置开关。
- 引入硬币和行动点补充状态跟踪,以区分当前处于激活补充阶段以及对应的补充目标。

缺陷修复:
- 修正智能调度逻辑,使硬币补充能够基于目标阈值完成,然后再回到正常的 erosion-1 升级模式。
- 调整行动点比较条件,将“达到最低保留值”视为仍然不足,从而推迟智能调度的执行。
- 修复通知和日志,使其报告硬币目标阈值和补充状态,而不是只报告保留值。

增强改进:
- 优化智能调度在硬币/行动点不足时的日志与推送通知,更好地描述补充目标和补充阶段。
- 抽取辅助方法,用于封装硬币目标调度检查和补充目标计算,减少重复逻辑。

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

## Summary by Sourcery

Improve smart scheduling coin replenishment behavior with configurable
coin-target scheduling and clearer state handling between coin-based and
action-point-based replenishment.

New Features:
- Add configuration switches for coin-target scheduling and coin
replenishment return threshold in smart scheduling.
- Introduce coin and action-point replenishment state tracking to
distinguish active replenishment phases and targets.

Bug Fixes:
- Correct smart scheduling logic so coin replenishment completes based
on a target threshold before returning to normal erosion-1 leveling.
- Adjust action point comparison conditions to treat reaching the
minimum reserve as insufficient and delay smart scheduling accordingly.
- Fix notifications and logs to report coin-target thresholds and
replenishment status instead of only preserve values.

Enhancements:
- Refine smart scheduling logs and push notifications for insufficient
coins/action points to better describe replenishment targets and phases.
- Extract helper methods to encapsulate coin-target scheduling checks
and replenishment target calculation, reducing duplicated logic.

</details>
PS:移动端不知道为什么有点问题 不知道咋修
## Summary by Sourcery

为 OS 自动搜索添加可配置的时间上限,用于检测并中止卡死的运行,并在策略搜索和喵喵官(Meowfficer)养成流程中传播新的卡死相关异常。

新特性:
- 为 OS 地图引入可配置的自动搜索时间上限(单位:分钟),在超出时抛出卡死错误。

错误修复:
- 确保长时间运行或卡死的 OS 自动搜索能够被中止,而不是无限挂起。

增强优化:
- 更新策略搜索、巡逻扫描以及喵喵官养成逻辑,将 `GameStuckError` 和相关可恢复异常视为任务级信号。
- 使 `Timer.start()` 通过返回 `Timer` 实例实现可链式调用,并清理过时的自动搜索辅助逻辑。

构建:
- 在生成配置和参数配置中添加 `AutoSearchTimeLimit`,并设置校验边界,同时将其接入模板和 i18n 文件。

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

## Summary by Sourcery

Add a configurable time limit for OS auto-search to detect and abort
stuck runs, and propagate the new stuck-related exceptions through
strategic search and Meowfficer farming flows.

New Features:
- Introduce a configurable auto-search time limit (in minutes) for OS
maps that raises a stuck error when exceeded.

Bug Fixes:
- Ensure long-running or stuck OS auto-search runs are aborted instead
of hanging indefinitely.

Enhancements:
- Update strategic search, patrol scan, and Meowfficer farming logic to
treat GameStuckError and related recoverable exceptions as task-level
signals.
- Make Timer.start() chainable by returning the Timer instance and clean
up obsolete auto-search helper logic.

Build:
- Add AutoSearchTimeLimit to the generated and argument configuration,
with validation bounds, and wire it into templates and i18n files.

</details>
@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 bca61ed into dev Jul 6, 2026
10 of 12 checks passed
@sourcery-ai

sourcery-ai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

引入可配置的自动搜索时间限制,并优化智能调度中的硬币/AP(体力)补充逻辑,包括基于目标硬币数量的调度模式、新阈值,以及针对卡住/溢出状态的异常传播改进。

OS 自动搜索时间限制与 GameStuckError 传播的序列图

sequenceDiagram
    actor User
    participant OpsiScheduler as MeowfficerFarming
    participant OSMap
    participant Timer

    User->>OpsiScheduler: _meow_handle_stay_in_zone
    OpsiScheduler->>OSMap: run_strategic_search
    OSMap->>OSMap: run_auto_search
    OSMap->>Timer: start
    Note over OSMap,Timer: auto_search_time_limit_timer

    loop auto search loop
        OSMap->>OSMap: handle_os_auto_search_map_option
        OSMap->>OSMap: handle_retirement
        OSMap->>OSMap: combat_appear / handle_map_event
        OSMap->>Timer: reset
        OSMap->>Timer: reached
        alt Timer reached
            OSMap-->>OpsiScheduler: GameStuckError
        else not reached
            OSMap->>OSMap: continue loop
        end
    end

    OpsiScheduler->>OpsiScheduler: run_strategic_search
    OpsiScheduler-->>User: propagate GameStuckError
Loading

更新后的智能调度硬币/AP 补充的序列图

sequenceDiagram
    participant Scheduler as OpsiMeowfficerFarming
    participant Config
    participant CoinTask

    Scheduler->>Scheduler: run_smart_scheduling_once
    Scheduler->>Scheduler: _get_smart_scheduling_operation_coins_preserve
    Scheduler->>Scheduler: _get_effective_cl1_ap_preserve
    Scheduler->>Scheduler: _get_coin_task_action_point_preserve
    Scheduler->>Scheduler: _is_coin_target_scheduling_enabled
    Scheduler->>Scheduler: _is_coin_replenish_active / _is_ap_replenish_active

    alt coin_target_scheduling
        Scheduler->>Scheduler: _get_coin_replenish_target
        alt yellow_coins >= coin_target
            Scheduler->>Scheduler: _clear_coin_replenish_target
            Scheduler->>Scheduler: _run_scheduled_hazard1_leveling
        else yellow_coins < coin_target
            alt total_ap <= meow_ap_preserve
                Scheduler->>Scheduler: _handle_smart_scheduling_no_task
                Scheduler-->>Config: task_delay
            else total_ap > meow_ap_preserve
                Scheduler->>Scheduler: _dispatch_coin_task
                Scheduler-->>CoinTask: proxy coin farming
            end
        end
    else ap_based_scheduling
        alt not _is_ap_replenish_active
            Scheduler->>Scheduler: _set_ap_replenish_active
        end
        alt total_ap <= meow_ap_preserve
            Scheduler->>Scheduler: _clear_ap_replenish_active
            Scheduler->>Scheduler: _handle_smart_scheduling_no_task
        else total_ap > meow_ap_preserve
            Scheduler->>Scheduler: _dispatch_coin_task
        end
    end

    alt total_ap <= cl1_ap_preserve
        Scheduler->>Scheduler: _delay_smart_scheduling_for_ap_limit
        Scheduler-->>Config: task_delay
    else total_ap > cl1_ap_preserve
        Scheduler->>Scheduler: _run_scheduled_hazard1_leveling
    end
Loading

File-Level Changes

Change Details Files
重构智能调度以支持带回合阈值的基于硬币目标的补充模式,并引入独立的 AP 驱动补充逻辑,收紧 AP 上限比较并更新通知。
  • 添加用于硬币回合阈值的配置键,以及用于检查是否启用硬币目标调度的辅助函数。
  • 按轮次追踪硬币补充起始值,并将目标计算为“保留值 + 阈值”,同时提供用于清除状态的辅助函数。
  • 在禁用硬币目标调度时,引入基于 AP 的补充状态标记及对应逻辑。
  • 将 AP 和硬币的上限比较从“严格小于”改为“小于或等于”以进行限制检查。
  • 更新通知辅助函数和无任务处理逻辑,使其报告硬币目标/阈值,而非原始保留值。
module/os/tasks/scheduling.py
为 OS 自动搜索添加时间限制,在相关事件上重置计时,并在超时时抛出特定的卡住错误;同时简化自动搜索函数。
  • 基于新的配置值创建自动搜索时间限制计时器,并在地图选项处理、退役、战斗以及地图事件时重置它。
  • 当计时器达到上限时抛出 GameStuckError,以指示自动搜索停滞。
  • 移除专用的 os_auto_search_daemon_until_combat 辅助函数,将其行为合并到现有自动搜索流程中。
module/os/map.py
将 GameStuckError 以及其他可恢复异常从战略搜索、固定巡逻扫描和 meowfficer 农场向调度器上层传播。
  • 在战略搜索、固定巡逻重新扫描、巡逻扫描中的自动搜索,以及 meowfficer 农场中,将 GameStuckError、GameTooManyClickError 和 RequestHumanTakeover 纳入重新抛出的异常列表。
  • 确保这些异常绕过本地恢复逻辑,由上层任务调度统一处理。
module/os/map.py
module/os/tasks/meowfficer_farming.py
暴露新的 AutoSearchTimeLimit 配置选项,并确保 Timer.start 返回 Timer 实例以支持链式调用。
  • 在 OpsiGeneral 参数中添加 AutoSearchTimeLimit,设定默认值和校验范围,并生成对应配置字段。
  • 更新 i18n 和配置模板/参数 JSON 以包含该新选项。
  • 为 Timer.start 注解返回类型为 Timer,使调用端可以进行链式调用。
module/config/argument/argument.yaml
module/config/config_generated.py
module/base/timer.py
config/template.json
module/config/argument/args.json
module/config/i18n/en-US.json
module/config/i18n/ja-JP.json
module/config/i18n/zh-CN.json
module/config/i18n/zh-MIAO.json
module/config/i18n/zh-TW.json

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 摘要。也可以在 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 以触发新的评审!

Customizing Your Experience

访问你的 dashboard 来:

  • 启用或禁用评审特性,例如 Sourcery 生成的 Pull Request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审指引。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Introduce a configurable auto-search time limit and refine smart scheduling coin/AP replenishment logic, including coin-target-based scheduling mode, new thresholds, and improved exception propagation for stuck/overflow states.

Sequence diagram for OS auto-search time limit and GameStuckError propagation

sequenceDiagram
    actor User
    participant OpsiScheduler as MeowfficerFarming
    participant OSMap
    participant Timer

    User->>OpsiScheduler: _meow_handle_stay_in_zone
    OpsiScheduler->>OSMap: run_strategic_search
    OSMap->>OSMap: run_auto_search
    OSMap->>Timer: start
    Note over OSMap,Timer: auto_search_time_limit_timer

    loop auto search loop
        OSMap->>OSMap: handle_os_auto_search_map_option
        OSMap->>OSMap: handle_retirement
        OSMap->>OSMap: combat_appear / handle_map_event
        OSMap->>Timer: reset
        OSMap->>Timer: reached
        alt Timer reached
            OSMap-->>OpsiScheduler: GameStuckError
        else not reached
            OSMap->>OSMap: continue loop
        end
    end

    OpsiScheduler->>OpsiScheduler: run_strategic_search
    OpsiScheduler-->>User: propagate GameStuckError
Loading

Sequence diagram for updated smart scheduling coin/AP replenishment

sequenceDiagram
    participant Scheduler as OpsiMeowfficerFarming
    participant Config
    participant CoinTask

    Scheduler->>Scheduler: run_smart_scheduling_once
    Scheduler->>Scheduler: _get_smart_scheduling_operation_coins_preserve
    Scheduler->>Scheduler: _get_effective_cl1_ap_preserve
    Scheduler->>Scheduler: _get_coin_task_action_point_preserve
    Scheduler->>Scheduler: _is_coin_target_scheduling_enabled
    Scheduler->>Scheduler: _is_coin_replenish_active / _is_ap_replenish_active

    alt coin_target_scheduling
        Scheduler->>Scheduler: _get_coin_replenish_target
        alt yellow_coins >= coin_target
            Scheduler->>Scheduler: _clear_coin_replenish_target
            Scheduler->>Scheduler: _run_scheduled_hazard1_leveling
        else yellow_coins < coin_target
            alt total_ap <= meow_ap_preserve
                Scheduler->>Scheduler: _handle_smart_scheduling_no_task
                Scheduler-->>Config: task_delay
            else total_ap > meow_ap_preserve
                Scheduler->>Scheduler: _dispatch_coin_task
                Scheduler-->>CoinTask: proxy coin farming
            end
        end
    else ap_based_scheduling
        alt not _is_ap_replenish_active
            Scheduler->>Scheduler: _set_ap_replenish_active
        end
        alt total_ap <= meow_ap_preserve
            Scheduler->>Scheduler: _clear_ap_replenish_active
            Scheduler->>Scheduler: _handle_smart_scheduling_no_task
        else total_ap > meow_ap_preserve
            Scheduler->>Scheduler: _dispatch_coin_task
        end
    end

    alt total_ap <= cl1_ap_preserve
        Scheduler->>Scheduler: _delay_smart_scheduling_for_ap_limit
        Scheduler-->>Config: task_delay
    else total_ap > cl1_ap_preserve
        Scheduler->>Scheduler: _run_scheduled_hazard1_leveling
    end
Loading

File-Level Changes

Change Details Files
Refactor smart scheduling to support coin-target-based replenishment mode with return thresholds and separate AP-driven replenishment, tightening AP limit comparisons and updating notifications.
  • Add config key for coin return threshold and helper to check if coin-target scheduling is enabled.
  • Track per-round coin replenish start value and compute target as preserve+threshold, with state-clear helpers.
  • Introduce AP-based replenish state flags and logic when coin-target scheduling is disabled.
  • Change AP and coin comparisons from strict less-than to less-than-or-equal for limit checks.
  • Update notification helpers and no-task handler to report coin targets/thresholds instead of raw preserve values.
module/os/tasks/scheduling.py
Add an auto-search time limit for OS auto search, resetting on relevant events and raising a specific stuck error when exceeded; simplify auto-search functions.
  • Create an auto-search time limit timer based on new config value and reset it on map option handling, retirement, combat, and map events.
  • Raise GameStuckError when the timer reaches its limit to signal an auto-search stall.
  • Remove the dedicated os_auto_search_daemon_until_combat helper and fold behavior into existing auto-search flow.
module/os/map.py
Propagate GameStuckError and other recoverable exceptions up to the scheduler from strategic search, fixed patrol scan, and meowfficer farming.
  • Include GameStuckError, GameTooManyClickError, and RequestHumanTakeover in the re-raised exception list for strategic search, fixed patrol rescan, auto search in patrol scan, and meowfficer farming.
  • Ensure these exceptions bypass local recovery logic and are handled by upper-level task scheduling.
module/os/map.py
module/os/tasks/meowfficer_farming.py
Expose a new AutoSearchTimeLimit configuration option and ensure Timer.start returns the Timer instance for fluent usage.
  • Add AutoSearchTimeLimit to OpsiGeneral arguments with default value and validation range, and generate a corresponding config field.
  • Update i18n and config templates/args JSON to include the new option.
  • Annotate Timer.start to return Timer, enabling chaining in call sites.
module/config/argument/argument.yaml
module/config/config_generated.py
module/base/timer.py
config/template.json
module/config/argument/args.json
module/config/i18n/en-US.json
module/config/i18n/ja-JP.json
module/config/i18n/zh-CN.json
module/config/i18n/zh-MIAO.json
module/config/i18n/zh-TW.json

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 - 我发现了 1 个问题

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="module/os/tasks/scheduling.py" line_range="816-825" />
<code_context>
+                    )
+                    return
+
+            if not coin_target_scheduling and (yellow_coins < cl1_preserve or ap_replenish_active):
+                if not ap_replenish_active:
+                    self._set_ap_replenish_active()
</code_context>
<issue_to_address>
**issue (bug_risk):** 基于 AP 的黄币补充分支可能会继续向下执行,把仍然低于阈值的黄币当成“充足”。

在基于 AP 的补充路径(`not coin_target_scheduling`)中,当 `yellow_coins < cl1_preserve``ap_replenish_active` 为 True 时,我们会进入补充逻辑块,但如果 `total_ap > meow_ap_preserve`,我们不会在此处退出,执行会继续到:

```python
if total_ap <= cl1_ap_preserve:
    self._delay_smart_scheduling_for_ap_limit(...)

logger.info(f'黄币充足 ({yellow_coins} >= {cl1_preserve}),执行侵蚀1练级')
self._run_scheduled_hazard1_leveling(...)
```

这样会在 `yellow_coins < cl1_preserve``ap_replenish_active` 已被设置的情况下,错误地把黄币视为“充足”,并继续执行侵蚀1练级。请在这里添加一个提前 `return`(类似黄币目标调度分支中的逻辑),或者通过其他方式确保在黄币低于 `cl1_preserve` 或补充处于激活状态时,永远不会进入“黄币充足”这条执行路径。
</issue_to_address>

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="module/os/tasks/scheduling.py" line_range="816-825" />
<code_context>
+                    )
+                    return
+
+            if not coin_target_scheduling and (yellow_coins < cl1_preserve or ap_replenish_active):
+                if not ap_replenish_active:
+                    self._set_ap_replenish_active()
</code_context>
<issue_to_address>
**issue (bug_risk):** AP-based coin replenishment branch can fall through and treat coins as "充足" while still below threshold.

In the AP-based replenishment path (`not coin_target_scheduling`), when `yellow_coins < cl1_preserve` or `ap_replenish_active` is True, we enter the replenishment block, but if `total_ap > meow_ap_preserve` we don’t exit and execution continues to:

```python
if total_ap <= cl1_ap_preserve:
    self._delay_smart_scheduling_for_ap_limit(...)

logger.info(f'黄币充足 ({yellow_coins} >= {cl1_preserve}),执行侵蚀1练级')
self._run_scheduled_hazard1_leveling(...)
```

This can incorrectly treat coins as “充足” and run 侵蚀1练级 while `yellow_coins < cl1_preserve` or `ap_replenish_active` is set. Please add an early `return` (like the coin-target branch) or otherwise ensure we never reach the “黄币充足” path when coins are below `cl1_preserve` or replenishment is active.
</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 +816 to +825
if not coin_target_scheduling and (yellow_coins < cl1_preserve or ap_replenish_active):
if not ap_replenish_active:
self._set_ap_replenish_active()
logger.info(
f'【智能调度检查】体力调度补黄币中: 黄币={yellow_coins}, '
f'黄币阈值={cl1_preserve}, 总行动力={total_ap}, 行动力阈值={meow_ap_preserve}'
)
if total_ap <= meow_ap_preserve:
logger.info(f'行动力已达到体力调度阈值 ({total_ap} <= {meow_ap_preserve}),停止补黄币')
self._clear_ap_replenish_active()

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): 基于 AP 的黄币补充分支可能会继续向下执行,把仍然低于阈值的黄币当成“充足”。

在基于 AP 的补充路径(not coin_target_scheduling)中,当 yellow_coins < cl1_preserveap_replenish_active 为 True 时,我们会进入补充逻辑块,但如果 total_ap > meow_ap_preserve,我们不会在此处退出,执行会继续到:

if total_ap <= cl1_ap_preserve:
    self._delay_smart_scheduling_for_ap_limit(...)

logger.info(f'黄币充足 ({yellow_coins} >= {cl1_preserve}),执行侵蚀1练级')
self._run_scheduled_hazard1_leveling(...)

这样会在 yellow_coins < cl1_preserveap_replenish_active 已被设置的情况下,错误地把黄币视为“充足”,并继续执行侵蚀1练级。请在这里添加一个提前 return(类似黄币目标调度分支中的逻辑),或者通过其他方式确保在黄币低于 cl1_preserve 或补充处于激活状态时,永远不会进入“黄币充足”这条执行路径。

Original comment in English

issue (bug_risk): AP-based coin replenishment branch can fall through and treat coins as "充足" while still below threshold.

In the AP-based replenishment path (not coin_target_scheduling), when yellow_coins < cl1_preserve or ap_replenish_active is True, we enter the replenishment block, but if total_ap > meow_ap_preserve we don’t exit and execution continues to:

if total_ap <= cl1_ap_preserve:
    self._delay_smart_scheduling_for_ap_limit(...)

logger.info(f'黄币充足 ({yellow_coins} >= {cl1_preserve}),执行侵蚀1练级')
self._run_scheduled_hazard1_leveling(...)

This can incorrectly treat coins as “充足” and run 侵蚀1练级 while yellow_coins < cl1_preserve or ap_replenish_active is set. Please add an early return (like the coin-target branch) or otherwise ensure we never reach the “黄币充足” path when coins are below cl1_preserve or replenishment is active.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an auto-search time limit configuration to detect game freezes during auto-search, raising a GameStuckError when exceeded, and enhances the smart scheduling system with support for both coin-target and action-point-based scheduling. Key feedback includes resetting the auto-search stuck timer when not on the map to prevent false positives during combat or loading screens, adding a check in the action-point scheduling branch to verify if yellow coins are already replenished, and using a string literal for the Timer.start() return type annotation to ensure compatibility with older Python versions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread module/os/map.py
Comment on lines +1032 to +1033
if auto_search_time_limit_timer.reached():
raise GameStuckError('自律寻敌卡死')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

auto_search_time_limit_timerself.is_in_map()False 时(例如在战斗中、加载界面或剧情对话中)不会被重置。如果单次战斗或加载时间超过了 AutoSearchTimeLimit(用户可以设置为 1 分钟),计时器就会超时并抛出误报的 GameStuckError。为了避免这种情况,建议在非地图界面时重置该计时器,使其仅在地图上卡死时生效。

Suggested change
if auto_search_time_limit_timer.reached():
raise GameStuckError('自律寻敌卡死')
if not self.is_in_map():
auto_search_time_limit_timer.reset()
if auto_search_time_limit_timer.reached():
raise GameStuckError('自律寻敌卡死')

Comment on lines +816 to 828
if not coin_target_scheduling and (yellow_coins < cl1_preserve or ap_replenish_active):
if not ap_replenish_active:
self._set_ap_replenish_active()
logger.info(
f'【智能调度检查】体力调度补黄币中: 黄币={yellow_coins}, '
f'黄币阈值={cl1_preserve}, 总行动力={total_ap}, 行动力阈值={meow_ap_preserve}'
)
if total_ap <= meow_ap_preserve:
logger.info(f'行动力已达到体力调度阈值 ({total_ap} <= {meow_ap_preserve}),停止补黄币')
self._clear_ap_replenish_active()
self._handle_smart_scheduling_no_task(
yellow_coins,
total_ap,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

在非黄币目标调度(即体力调度 not coin_target_scheduling)的分支中,没有检查黄币是否已经补足(即 yellow_coins >= cl1_preserve)。

如果 ap_replenish_activeTrue,但此时黄币已经达到或超过了 cl1_preserve,代码仍会进入该分支:

  1. 如果 total_ap <= meow_ap_preserve,它会清除 ap_replenish_active 并调用 _handle_smart_scheduling_no_task(这会延迟任务或执行短猫),而不会继续向下执行去运行 OpsiHazard1Leveling(即使我们有足够的黄币和足够的体力!)。
  2. 如果 total_ap > meow_ap_preserve,它会调用 _dispatch_coin_task 继续去刷黄币,即使黄币已经足够了。

建议像 coin_target_scheduling 分支一样,在进入该分支时先检查 if yellow_coins >= cl1_preserve:。如果已补足,则清除 ap_replenish_active 并允许代码向下运行(不 return)。

            if not coin_target_scheduling and (yellow_coins < cl1_preserve or ap_replenish_active):
                if yellow_coins >= cl1_preserve:
                    logger.info(f'黄币已补足 ({yellow_coins} >= {cl1_preserve}),恢复侵蚀1练级')
                    self._clear_ap_replenish_active()
                else:
                    if not ap_replenish_active:
                        self._set_ap_replenish_active()
                    logger.info(
                        f'【智能调度检查】体力调度补黄币中: 黄币={yellow_coins}, '
                        f'黄币阈值={cl1_preserve}, 总行动力={total_ap}, 行动力阈值={meow_ap_preserve}'
                    )
                    if total_ap <= meow_ap_preserve:
                        logger.info(f'行动力已达到体力调度阈值 ({total_ap} <= {meow_ap_preserve}),停止补黄币')
                        self._clear_ap_replenish_active()
                        self._handle_smart_scheduling_no_task(
                            yellow_coins,
                            total_ap,

Comment thread module/base/timer.py
return cls(limit, count=count)

def start(self):
def start(self) -> Timer:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Timer 类内部直接使用 -> Timer 作为返回值类型标注,如果文件顶部没有 from __future__ import annotations,在 Python 3.11 以下版本中导入该模块时会抛出 NameError: name 'Timer' is not defined 错误。为了确保在所有 Python 版本中的兼容性,建议使用字符串字面量 -> "Timer"

Suggested change
def start(self) -> Timer:
def start(self) -> "Timer":

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