Conversation
There was a problem hiding this comment.
Pull request overview
This is a version 2.0.1 maintenance release that includes several improvements and bug fixes:
Changes:
- Refactored imports in example files to use cleaner paths through
autowsgr.opsmodule - Added support for external fleet specification in event and normal fight operations
- Improved event page difficulty detection using pixel signatures instead of color matching
- Removed debug image saving calls from production code paths
- Updated log directory configuration from "log" to "logs"
- Enhanced game startup logic to handle unknown page states
- Removed deprecated user_settings.yaml configuration file
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| autowsgr/init.py | Version bump from 2.0.0 to 2.0.1 |
| examples/usersettings.full.yaml | Changed log root directory from "log" to "logs" |
| examples/user_settings.yaml | Removed deprecated configuration file (replaced by usersettings.yaml) |
| examples/normal_fight.py | Updated import to use autowsgr.ops module directly |
| examples/exercise.py | Updated import to use autowsgr.ops module directly |
| examples/event_fight.py | Updated import, added fleet_id parameter example, updated times from 3 to 5 |
| examples/decisive.py | Updated import to use autowsgr.ops module directly |
| examples/campaign.py | Updated import to use autowsgr.ops module directly |
| autowsgr/ui/event/event_page.py | Improved difficulty detection with pixel signatures, added skip_check parameter, repositioned difficulty toggle button |
| autowsgr/ui/decisive/map_controller.py | Removed debug save_image calls |
| autowsgr/ui/decisive/fleet_ocr.py | Removed debug save_image calls and unused DecisiveConfig import |
| autowsgr/ops/startup.py | Enhanced ensure_game_ready to restart when page is unrecognized |
| autowsgr/ops/normal_fight.py | Added fleet_id and fleet parameters for external fleet specification, updated destroy_ships call signature |
| autowsgr/ops/event_fight.py | Added fleet and fleet_id parameters, optimized repeated executions by skipping checks, removed unnecessary navigation |
| autowsgr/ops/decisive/handlers.py | Removed debug save_image calls |
| autowsgr/infra/logger.py | Changed default image directory from None to "logs/images" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| event_page = BaseEventPage(self._ctx) | ||
| entrance: Literal["alpha", "beta"] | None = self._entrance # type: ignore[assignment] | ||
| event_page.start_fight(self._map_code, entrance=entrance) | ||
| event_page.start_fight(self._map_code, entrance, self._skip_check) |
There was a problem hiding this comment.
The third argument self._skip_check should be passed as a keyword argument skip_check=self._skip_check to match the function signature of start_fight which defines it as a keyword-only parameter.
| event_page.start_fight(self._map_code, entrance, self._skip_check) | |
| event_page.start_fight(self._map_code, entrance, skip_check=self._skip_check) |
| _log.info( | ||
| "[OPS] 常规战: {}-{} ({})", | ||
| self._plan.chapter, | ||
| self._plan.map_id, | ||
| self._plan.name, | ||
| self._fleet_id, | ||
| self._fleet, | ||
| ) |
There was a problem hiding this comment.
The log statement has 5 format placeholders but only 3 arguments are provided after the format string. This will cause a runtime error. The fleet_id and fleet values should be included in the log message format or removed from the placeholder list.
| for i in range(times): | ||
| _log.info("[OPS] 常规战第 {}/{} 次", i + 1, times) | ||
| result = self.run() | ||
| result = self.run(**kwargs) |
There was a problem hiding this comment.
The run() method is called with **kwargs but it doesn't accept any keyword arguments in its signature. The run() method should either accept **kwargs in its signature if they need to be passed through, or this call should not pass **kwargs.
| if identify_current_page(ctx) is None: | ||
| _log.info("[Startup] 游戏已在运行但页面未知,正在重启…") | ||
| restart_game(ctrl, package, startup_timeout=startup_timeout) | ||
| _log.info("[Startup] 游戏已在运行") |
There was a problem hiding this comment.
The log message "[Startup] 游戏已在运行" on line 285 will execute even when the game is restarted (when the page is unknown). This message should only be logged when the game is already running AND on a recognized page. Consider wrapping line 285 in an else block or restructuring the logic.
| _log.info("[Startup] 游戏已在运行") | |
| else: | |
| _log.info("[Startup] 游戏已在运行") |
| target_dir = str(img_dir or _image_dir) | ||
| target_dir = Path(target_dir) | ||
| if target_dir is None: | ||
| return None | ||
| raise ValueError("未配置图片保存目录,请在 setup_logger 中设置 log_dir 并启用 save_images") |
There was a problem hiding this comment.
After converting img_dir or _image_dir to a string and then to a Path object, the condition if target_dir is None on line 387 can never be True. A Path object will never be None. This check should be performed before the conversion to Path, or the logic needs to be restructured to check if _image_dir is None before conversion.
| # 2. 执行活动战 — 只需传策略名称, 支持外部指定舰队 | ||
| results = run_event_fight_from_yaml(ctx, 'E5ADE夜战', times=5, fleet_id=2) |
There was a problem hiding this comment.
The module docstring at line 3 states "执行 3 次活动战斗" (execute 3 times), but the code now executes 5 times (times=5). The docstring should be updated to match the code or changed to not specify a specific number.
No description provided.