Repository navigation
feat(Script): 关闭游戏支持时段闸门,并补上 stay_there 枚举 #1921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,10 @@ | |
| class WhenTaskQueueEmpty(str, Enum): | ||
| GOTO_MAIN = 'goto_main' | ||
| CLOSE_GAME = 'close_game' | ||
| # GUI(argument.yaml) 早已提供 stay_there 选项, 但枚举缺少该值, | ||
| # 导致用户选中后被 pydantic 拒绝 / 或走过 _wait_stay_there 的 fallback 分支。 | ||
| # 补上后 _wait_stay_there() 才可达。 | ||
| STAY_THERE = 'stay_there' | ||
|
sourcery-ai[bot] marked this conversation as resolved.
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| class ScheduleRule(str, Enum): | ||
| FILTER = 'Filter' # 默认的基于过滤器,(按照开发者设定的调度规则进行调度) | ||
|
|
@@ -27,6 +31,13 @@ class Optimization(BaseModel): | |
| description='when_task_queue_empty_help') | ||
| close_game_wait_duration: Time = Field(default=Time(minute=0), | ||
| description='close_game_wait_duration_help') | ||
| # 仅在 [night_start, night_end) 这个时段内才允许「关闭游戏」。 | ||
| # 默认 00:00 - 07:00: 白天/晚上把游戏留在原地, 方便同一台设备随时手动接手玩; | ||
| # 若 start == end 表示不做时段限制 (维持旧行为)。 | ||
| close_game_night_start: Time = Field(default=Time(hour=0, minute=0), | ||
| description='close_game_night_start_help') | ||
| close_game_night_end: Time = Field(default=Time(hour=7, minute=0), | ||
| description='close_game_night_end_help') | ||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 中 · GUI 配置中缺少时间窗口设置 当用户通过 GUI 配置新窗口,而不是直接编辑配置文件时, 请将两个时间窗口字段添加到 面向 AI 代理的提示在 `tasks/Script/config_optimization.py` 第 37-40 行:
**GUI 配置中缺少时间窗口设置**
当用户通过 GUI 配置新窗口,而不是直接编辑配置文件时,`module/config/argument/argument.yaml` 的 `Optimization` 部分中缺少新的时间窗口字段;该部分为 GUI 提供优化参数。通过 GUI 配置脚本的用户无法设置任一边界,除非直接编辑配置文件,否则只能使用默认值。
请将两个时间窗口字段添加到 `module/config/argument/argument.yaml` 的 `Optimization` 部分,并提供合适的默认值和时间输入元数据。Original comment in English🟡 Medium · Time-window settings missing from GUI config When users configure the new window through the GUI rather than editing config files directly, the new time-window fields are absent from the Add both time-window fields to the Prompt for AI agentsIn `tasks/Script/config_optimization.py` at lines 37-40:
**Time-window settings missing from GUI config**
When users configure the new window through the GUI rather than editing config files directly, the new time-window fields are absent from the `Optimization` section of `module/config/argument/argument.yaml`, which supplies the GUI’s optimization arguments. Users configuring the script through that GUI cannot set either boundary and are stuck with the defaults unless they edit the config file directly.
Add both time-window fields to the `Optimization` section of `module/config/argument/argument.yaml` with suitable defaults and time input metadata. |
||
| close_emulator_wait_duration: Time = Field(default=Time(minute=0), | ||
| description='close_emulator_wait_duration_help') | ||
| emulator_startup_lead_time: Time = Field(default=Time(minute=2), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: runhey/OnmyojiAutoScript
Length of output: 17977
将时段闸门置于关闭模拟器分支之前。
当
close_emulator_wait_duration大于 0 且距离下一个任务足够久时,代码会先执行self.device.emulator_stop()。此时窗口外仍会关闭模拟器,时段闸门不会生效。请在该分支中复用时段判断,或将完整的时段闸门移到该分支之前。🐛 建议修改
close_emulator_wait_duration = self.config.script.optimization.close_emulator_wait_duration close_emulator_wait = self._time_to_timedelta(close_emulator_wait_duration) + night_start = self._time_to_timedelta( + self.config.script.optimization.close_game_night_start) + night_end = self._time_to_timedelta( + self.config.script.optimization.close_game_night_end) - if close_emulator_wait > timedelta(0) and next_run > datetime.now() + close_emulator_wait: + if (close_emulator_wait > timedelta(0) + and next_run > datetime.now() + close_emulator_wait + and (night_start == night_end + or self._in_close_game_window(night_start, night_end))): logger.info("Close emulator during wait") self.device.emulator_stop() self._emulator_down = True @@ - night_start = self._time_to_timedelta( - self.config.script.optimization.close_game_night_start) - night_end = self._time_to_timedelta( - self.config.script.optimization.close_game_night_end) if night_start != night_end and not self._in_close_game_window(night_start, night_end):🤖 Prompt for AI Agents