提供了一种自动获取储值电卡的实现#3
Conversation
📝 WalkthroughWalkthrough新增一个完整的游戏插件,用于从后勤商店、情报板商店和信号残响自动获取储值电卡。包括配置系统、UI设置面板、三个专用操作流程及对应的屏幕检测定义。 Changes
Sequence DiagramsequenceDiagram
participant App as 自动获取储值电卡应用
participant Config as 配置系统
participant Op as 商店操作<br/>(物流/情报/信号)
participant UI as 游戏UI<br/>(屏幕检测)
participant Game as 游戏引擎
App->>Config: 加载配置
Config-->>App: 返回启用商店列表
App->>App: 构建任务队列
loop 处理每个启用的商店
App->>Op: 创建操作实例
Op->>Game: 返回正常世界
Game-->>Op: 确认返回
Op->>UI: 导航(菜单/商城)
UI->>Game: 获取屏幕截图
Game-->>UI: 返回截图
UI-->>Op: 导航成功
Op->>UI: OCR识别货币数量
Game-->>UI: 屏幕信息
UI-->>Op: 最大购买数量
Op->>UI: 选择商品
UI->>Game: 检测/点击商品
Game-->>UI: 反馈
UI-->>Op: 商品已选
alt 检查库存状态
Op->>UI: 搜索"已售罄"标记
UI-->>Op: 已售罄
else
Op->>UI: 调整购买数量
UI->>Game: 重复点击增加按钮
Game-->>UI: 数量已调整
Op->>UI: 确认购买
UI->>Game: 点击确认按钮
Game-->>UI: 购买完成
end
Op->>Game: 返回正常世界
Game-->>Op: 返回成功
Op-->>App: 操作完成
end
App->>Game: 执行完成流程
Game-->>App: 全部完成
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py`:
- Around line 110-113: The fading_signal node only accepts incoming transitions
from '检查配置' and '情报板商店', but outpost_logistics may return the same state name
'信号残响' (from the '后勤商店' path), causing the flow to break; update the
fading_signal decorator to also accept transitions from '后勤商店' (add
`@node_from`(from_name='后勤商店', status='信号残响') or include '后勤商店' in the existing
`@node_from` list) so fading_signal() will be invoked when outpost_logistics()
returns '信号残响'.
In
`@plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.py`:
- Around line 12-16: The call to AppRunRecord.__init__ uses a positional app_id
(auto_obtain_prepaid_power_card_const.APP_ID) which is inconsistent with the
keyword usage elsewhere and may raise TypeError; change the invocation to pass
app_id=auto_obtain_prepaid_power_card_const.APP_ID and keep
instance_idx=instance_idx and game_refresh_hour_offset=game_refresh_hour_offset
as keywords so AppRunRecord.__init__ is always called with named parameters
(match the pattern used in example_plugin_run_record.py).
In
`@plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.py`:
- Around line 14-16: Fix three import/name issues: change the config import to
use a single-dot relative import (from .auto_obtain_prepaid_power_card_config
import AutoObtainPrepaidPowerCardConfig, OutpostLogisticsObtainNumber,
MonthlyRestockObtainNumber, FadingSignalObtainNumber), add the missing base
class import (import AppSettingFlyout from one_dragon_qt), and rename/adjust the
class declaration so the class defined in this file is class
AutoObtainPrepaidPowerCardSettingFlyout(AppSettingFlyout): instead of
AutoObtainPrepaidPowerCardDialog so it matches the consumer
auto_obtain_prepaid_power_card_app_setting.py and correctly inherits the
AppSettingFlyout base.
In
`@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py`:
- Around line 18-22: The file uses a relative import "from .common_areas import
CommonCoordinate, FadingSignalCoordinate"; change this to an absolute import so
relative imports are avoided—import CommonCoordinate and FadingSignalCoordinate
from the package module (e.g.
plugins.auto_obtain_prepaid_power_card.operations.common_areas) and update any
TYPE_CHECKING imports similarly to absolute paths to match the project's
no-relative-import rule.
- Around line 140-149: In select_quantity on class FadingSignalOperation the
code reads self.config.outpost_logistics_obtain_number but the correct config
field is fading_signal_obtain_number; update the reference in select_quantity to
use self.config.fading_signal_obtain_number when computing clicks (keeping the
existing max_clicks logic), so the UI-configured fading_signal_obtain_number
controls the number of increases; ensure no other references to
outpost_logistics_obtain_number remain in this method.
In
`@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py`:
- Around line 149-153: The code reads the wrong config field: replace
self.config.outpost_logistics_obtain_number with
self.config.monthly_restock_obtain_number so the monthly restock flow uses the
correct configured quantity; keep the existing logic using self._max_quantity,
clicks = min(..., max_clicks), and call to self._click_increase_button(clicks)
and preserve the round_retry branch.
In
`@plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py`:
- Around line 17-21: The import uses a relative import for CommonCoordinate and
OutpostLogisticsCoordinate; replace it with an absolute import using the full
package path (e.g., import the classes from
zzz_od.plugins.auto_obtain_prepaid_power_card.common_areas or the actual
top-level module that defines them) so change "from .common_areas import
CommonCoordinate, OutpostLogisticsCoordinate" to the equivalent absolute import;
update any TYPE_CHECKING forward imports similarly to use absolute paths
(ZContext and AutoObtainPrepaidPowerCardConfig) to comply with the
no-relative-import rule.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 148a1854-2c4b-49d8-9d82-c2ad30ed156d
📒 Files selected for processing (13)
plugins/auto_obtain_prepaid_power_card/__init__.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app_setting.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_config.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_const.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_factory.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.pyplugins/auto_obtain_prepaid_power_card/operations/__init__.pyplugins/auto_obtain_prepaid_power_card/operations/common_areas.pyplugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.pyplugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.pyplugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_obtain_prepaid_power_card/__init__.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app_setting.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_const.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_factory.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_config.pyplugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.pyplugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.pyplugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.pyplugins/auto_obtain_prepaid_power_card/operations/common_areas.py
🪛 Ruff (0.15.9)
plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app_setting.py
[warning] 14-14: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.py
[error] 23-23: Undefined name AppSettingFlyout
(F821)
plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_const.py
[warning] 9-9: Comment contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF003)
plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py
[warning] 53-53: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py
[warning] 67-67: Docstring contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF002)
[warning] 67-67: Docstring contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF002)
plugins/auto_obtain_prepaid_power_card/operations/common_areas.py
[warning] 19-19: Comment contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF003)
[warning] 19-19: Comment contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF003)
🔇 Additional comments (4)
plugins/auto_obtain_prepaid_power_card/__init__.py (1)
1-4: 文档说明清晰,改动可接受。该段仅为模块级说明文本,不涉及执行逻辑,未发现严重逻辑错误、死循环、潜在运行时崩溃或资源泄漏风险。
As per coding guidelines "审查重点 (只关注这些): 严重的逻辑错误 / 死循环 / 潜在的运行时崩溃 (Runtime Error) / 资源泄漏 (如未关闭的文件句柄)"。
plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py (1)
32-157: 操作流程逻辑正确整体操作流程设计合理:返回大世界 → 前往作战 → 进入商店 → 计算数量 → 选择物品 → 检查售罄 → 选择数量 → 确认购买 → 返回。节点间的状态分支(如"零号业绩不足"、"已售罄")处理得当。
plugins/auto_obtain_prepaid_power_card/operations/common_areas.py (1)
1-56: 坐标常量定义清晰将各商店的屏幕坐标统一定义在枚举类中,便于维护和复用。
plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py (1)
33-182: 其余操作流程逻辑正确导航流程(返回大世界 → 打开菜单 → 商城 → 信源清单 → 信号残响)和购买流程设计合理,节点状态分支处理正确。
| from .common_areas import CommonCoordinate, OutpostLogisticsCoordinate | ||
|
|
||
| if TYPE_CHECKING: | ||
| from zzz_od.context.zzz_context import ZContext | ||
| from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig |
There was a problem hiding this comment.
禁止使用相对导入
根据编码规范,插件代码禁止使用相对导入。应使用绝对导入路径。
🔧 建议修改
-from .common_areas import CommonCoordinate, OutpostLogisticsCoordinate
+from zzz_od.plugins.auto_obtain_prepaid_power_card.operations.common_areas import CommonCoordinate, OutpostLogisticsCoordinate
if TYPE_CHECKING:
from zzz_od.context.zzz_context import ZContext
- from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig
+ from zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfigAs per coding guidelines: "✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const ❌ 错误: from . import my_plugin_const (禁止相对导入)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py`
around lines 17 - 21, The import uses a relative import for CommonCoordinate and
OutpostLogisticsCoordinate; replace it with an absolute import using the full
package path (e.g., import the classes from
zzz_od.plugins.auto_obtain_prepaid_power_card.common_areas or the actual
top-level module that defines them) so change "from .common_areas import
CommonCoordinate, OutpostLogisticsCoordinate" to the equivalent absolute import;
update any TYPE_CHECKING forward imports similarly to use absolute paths
(ZContext and AutoObtainPrepaidPowerCardConfig) to comply with the
no-relative-import rule.
ps: 寄。忘了仓库中的是落后代码了。
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py (1)
18-22: 🛠️ Refactor suggestion | 🟠 Major继续改成绝对导入
Line 18-22 仍在使用相对导入,这和上一轮指出的问题一致。这里请统一改成
zzz_od.plugins.auto_obtain_prepaid_power_card...的绝对导入,包含TYPE_CHECKING里的配置导入。As per coding guidelines, "✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const❌ 错误:from . import my_plugin_const(禁止相对导入)".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py` around lines 18 - 22, 当前文件对 CommonCoordinate 和 FadingSignalCoordinate 以及 TYPE_CHECKING 中的 ZContext 和 AutoObtainPrepaidPowerCardConfig 使用了相对导入;请将这些改为绝对导入,改为从 zzz_od.plugins.auto_obtain_prepaid_power_card.operations.fading_signal_operation 所在包的绝对模块路径导入相应符号(即把 from .common_areas 导入替换为以 zzz_od.plugins.auto_obtain_prepaid_power_card... 开头的绝对导入,同样把 TYPE_CHECKING 中的相对导入替换为 zzz_od.plugins.auto_obtain_prepaid_power_card... 的绝对路径,确保引用的类名 CommonCoordinate、FadingSignalCoordinate、ZContext、AutoObtainPrepaidPowerCardConfig 保持不变)。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py`:
- Around line 12-19: Replace the relative imports with absolute imports using
the plugin package prefix; specifically change imports that reference
auto_obtain_prepaid_power_card_const, FadingSignalOperation,
MonthlyRestockOperation, OutpostLogisticsOperation to use
zzz_od.plugins.auto_obtain_prepaid_power_card.<module> paths, and update the
TYPE_CHECKING branch so ZContext and AutoObtainPrepaidPowerCardConfig are
imported from their absolute locations (e.g., zzz_od.context.zzz_context and
zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config)
to comply with the no-relative-import rule.
---
Duplicate comments:
In
`@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py`:
- Around line 18-22: 当前文件对 CommonCoordinate 和 FadingSignalCoordinate 以及
TYPE_CHECKING 中的 ZContext 和 AutoObtainPrepaidPowerCardConfig
使用了相对导入;请将这些改为绝对导入,改为从
zzz_od.plugins.auto_obtain_prepaid_power_card.operations.fading_signal_operation
所在包的绝对模块路径导入相应符号(即把 from .common_areas 导入替换为以
zzz_od.plugins.auto_obtain_prepaid_power_card... 开头的绝对导入,同样把 TYPE_CHECKING
中的相对导入替换为 zzz_od.plugins.auto_obtain_prepaid_power_card... 的绝对路径,确保引用的类名
CommonCoordinate、FadingSignalCoordinate、ZContext、AutoObtainPrepaidPowerCardConfig
保持不变)。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d9a92e55-3837-448f-bf7a-d6e402816b07
📒 Files selected for processing (5)
plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.pyplugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.pyplugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py
🚧 Files skipped from review as they are similar to previous changes (3)
- plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.py
- plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py
- plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.pyplugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py
🪛 Ruff (0.15.9)
plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py
[warning] 53-53: Docstring contains ambiguous , (FULLWIDTH COMMA). Did you mean , (COMMA)?
(RUF002)
| from . import auto_obtain_prepaid_power_card_const | ||
| from .operations.fading_signal_operation import FadingSignalOperation | ||
| from .operations.monthly_restock_operation import MonthlyRestockOperation | ||
| from .operations.outpost_logistics_operation import OutpostLogisticsOperation | ||
|
|
||
| if TYPE_CHECKING: | ||
| from zzz_od.context.zzz_context import ZContext | ||
| from .auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
统一改用绝对导入
Line 12-19 的 . 相对导入不符合插件规范,建议一次性改成 zzz_od.plugins.auto_obtain_prepaid_power_card... 的绝对路径,包含 TYPE_CHECKING 分支里的配置导入。
建议修改
-from . import auto_obtain_prepaid_power_card_const
-from .operations.fading_signal_operation import FadingSignalOperation
-from .operations.monthly_restock_operation import MonthlyRestockOperation
-from .operations.outpost_logistics_operation import OutpostLogisticsOperation
+from zzz_od.plugins.auto_obtain_prepaid_power_card import auto_obtain_prepaid_power_card_const
+from zzz_od.plugins.auto_obtain_prepaid_power_card.operations.fading_signal_operation import FadingSignalOperation
+from zzz_od.plugins.auto_obtain_prepaid_power_card.operations.monthly_restock_operation import MonthlyRestockOperation
+from zzz_od.plugins.auto_obtain_prepaid_power_card.operations.outpost_logistics_operation import OutpostLogisticsOperation
@@
- from .auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig
+ from zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfigAs per coding guidelines, "✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const ❌ 错误: from . import my_plugin_const (禁止相对导入)".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py`
around lines 12 - 19, Replace the relative imports with absolute imports using
the plugin package prefix; specifically change imports that reference
auto_obtain_prepaid_power_card_const, FadingSignalOperation,
MonthlyRestockOperation, OutpostLogisticsOperation to use
zzz_od.plugins.auto_obtain_prepaid_power_card.<module> paths, and update the
TYPE_CHECKING branch so ZContext and AutoObtainPrepaidPowerCardConfig are
imported from their absolute locations (e.g., zzz_od.context.zzz_context and
zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config)
to comply with the no-relative-import rule.
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (3)
plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py (1)
119-128:⚠️ Potential issue | 🔴 Critical配置属性引用错误仍未修复(🔴 Critical)
尽管先前评论标注为“已在 commit d851939 中解决”,但当前 Line 125 仍然使用
self.config.outpost_logistics_obtain_number,应改为self.config.fading_signal_obtain_number。否则 UI 中“信号残响获取数量”的设置对本操作完全无效,用户无法独立控制该商店的购买数量——会直接复用后勤商店的配置,导致实际行为与设置不符。🔧 建议修改
`@node_from`(from_name='检查获取条件', status="可获取") `@operation_node`(name='选择获取数量') def select_quantity(self) -> OperationRoundResult: """选择获取数量""" time.sleep(0.5) max_clicks = self._max_quantity - 1 - clicks = min(self.config.outpost_logistics_obtain_number, max_clicks) + clicks = min(self.config.fading_signal_obtain_number, max_clicks) if clicks > 0 and not self._click_increase_button(clicks): return self.round_retry(status='未找到数量增加按钮', wait=1) return self.round_success()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py` around lines 119 - 128, The select_quantity method wrongly reads self.config.outpost_logistics_obtain_number instead of the fading-signal-specific setting; update select_quantity to use self.config.fading_signal_obtain_number when computing clicks (still capping with self._max_quantity - 1) and keep the existing click logic via self._click_increase_button and round_retry/round_success flows so the UI "信号残响获取数量" setting actually controls this operation.plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py (1)
117-122:⚠️ Potential issue | 🔴 Critical这里仍然读取了错误的数量配置字段。
select_quantity()属于情报板商店流程,但 Line 119 使用的是后勤商店配置,导致“情报板商店获取数量”设置不生效。建议修正
time.sleep(0.5) max_clicks = self._max_quantity - 1 - clicks = min(self.config.outpost_logistics_obtain_number, max_clicks) + clicks = min(self.config.monthly_restock_obtain_number, max_clicks) if clicks > 0 and not self._click_increase_button(clicks): return self.round_retry(status='未找到数量增加按钮', wait=1)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py` around lines 117 - 122, The code is using the wrong config field: replace references to self.config.outpost_logistics_obtain_number when computing clicks in monthly_restock_operation.py with the intelligence-board/shop quantity setting (the config field used by the select_quantity flow, e.g. self.config.intel_board_obtain_number or the equivalent select quantity config), so that clicks = min(<intel-quantity-config>, max_clicks) before calling _click_increase_button; keep the existing max_clicks, clicks, and _click_increase_button usage but point it at the intel-board quantity config.plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py (1)
16-18: 🛠️ Refactor suggestion | 🟠 Major改为插件绝对导入。
Line 18 仍使用相对导入,插件代码规范要求使用
zzz_od.plugins...形式的绝对导入。🔧 建议修改
if TYPE_CHECKING: from zzz_od.context.zzz_context import ZContext - from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig + from zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfigAs per coding guidelines: "✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const❌ 错误:from . import my_plugin_const(禁止相对导入)"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py` around lines 16 - 18, The TYPE_CHECKING block uses a relative import for AutoObtainPrepaidPowerCardConfig; change the relative import "from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig" to the absolute plugin path (e.g. "from zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig") so the TYPE_CHECKING imports follow the project rule against relative imports while keeping the same symbol name.
🧹 Nitpick comments (1)
plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py (1)
14-16: 改为绝对导入配置类型。这里仍然使用了相对导入;即使只在
TYPE_CHECKING下,也和插件导入规范不一致。建议修正
if TYPE_CHECKING: from zzz_od.context.zzz_context import ZContext - from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig + from zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfigAs per coding guidelines, “导入规范 (重要!) ✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const❌ 错误:from . import my_plugin_const(禁止相对导入)”.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py` around lines 14 - 16, 当前在 TYPE_CHECKING 分支中对配置类型使用了相对导入,需改为绝对导入以符合插件导入规范;在包含 TYPE_CHECKING 的块中把相对导入的 AutoObtainPrepaidPowerCardConfig 替换为其完整模块路径的绝对导入(保持对 ZContext 的 import 不变),确保引用的符号为 AutoObtainPrepaidPowerCardConfig 并且修改发生在 monthly_restock_operation.py 的 TYPE_CHECKING 导入段。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py`:
- Around line 126-135: The helper _click_increase_button always returns True so
the caller's check (if not self._click_increase_button(clicks)) can never
trigger; change _click_increase_button to return a real success boolean by
inspecting the result of each round_by_click_area("自动获取储值电卡-通用", "按钮-增加") call
(and abort/return False if any click fails), or aggregate results and return
False when no successful clicks occurred; update _click_increase_button(number:
int) to propagate that boolean so the caller using
round_retry(status='未找到数量增加按钮') can work correctly.
In
`@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py`:
- Around line 120-129: The helper _click_increase_button currently always
returns True so failures never trigger the retry path in the caller; change
_click_increase_button to detect and propagate click failures by checking the
result of round_by_click_area (or catching exceptions) on each iteration and
return False immediately if a click fails, otherwise return True after all
clicks; ensure the caller flow that calls _click_increase_button (which then
calls round_retry or round_success) will now observe False and execute
round_retry when clicks cannot be performed.
In
`@plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py`:
- Around line 109-120: The _click_increase_button currently always returns True
even if round_by_click_area failed; change _click_increase_button(number: int)
to check the return value of round_by_click_area("自动获取储值电卡-通用", "按钮-增加") on each
iteration and if any call returns False (or indicates failure) immediately
return False (avoid sleeping after a failed click); only return True after all
clicks succeed so the caller (the clicks > 0 check) can correctly call
round_retry when clicks couldn't be increased.
---
Duplicate comments:
In
`@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py`:
- Around line 119-128: The select_quantity method wrongly reads
self.config.outpost_logistics_obtain_number instead of the
fading-signal-specific setting; update select_quantity to use
self.config.fading_signal_obtain_number when computing clicks (still capping
with self._max_quantity - 1) and keep the existing click logic via
self._click_increase_button and round_retry/round_success flows so the UI
"信号残响获取数量" setting actually controls this operation.
In
`@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py`:
- Around line 117-122: The code is using the wrong config field: replace
references to self.config.outpost_logistics_obtain_number when computing clicks
in monthly_restock_operation.py with the intelligence-board/shop quantity
setting (the config field used by the select_quantity flow, e.g.
self.config.intel_board_obtain_number or the equivalent select quantity config),
so that clicks = min(<intel-quantity-config>, max_clicks) before calling
_click_increase_button; keep the existing max_clicks, clicks, and
_click_increase_button usage but point it at the intel-board quantity config.
In
`@plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py`:
- Around line 16-18: The TYPE_CHECKING block uses a relative import for
AutoObtainPrepaidPowerCardConfig; change the relative import "from
..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig"
to the absolute plugin path (e.g. "from
zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config
import AutoObtainPrepaidPowerCardConfig") so the TYPE_CHECKING imports follow
the project rule against relative imports while keeping the same symbol name.
---
Nitpick comments:
In
`@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py`:
- Around line 14-16: 当前在 TYPE_CHECKING 分支中对配置类型使用了相对导入,需改为绝对导入以符合插件导入规范;在包含
TYPE_CHECKING 的块中把相对导入的 AutoObtainPrepaidPowerCardConfig 替换为其完整模块路径的绝对导入(保持对
ZContext 的 import 不变),确保引用的符号为 AutoObtainPrepaidPowerCardConfig 并且修改发生在
monthly_restock_operation.py 的 TYPE_CHECKING 导入段。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3c18c703-1ca0-4986-a218-c9f102a1bc1c
📒 Files selected for processing (8)
plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.pyplugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.pyplugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.pyplugins/auto_obtain_prepaid_power_card/screen_info/auto_obtain_prepaid_power_card_common.ymlplugins/auto_obtain_prepaid_power_card/screen_info/fading_signal.ymlplugins/auto_obtain_prepaid_power_card/screen_info/function_menu.ymlplugins/auto_obtain_prepaid_power_card/screen_info/signal_shop.ymlplugins/auto_obtain_prepaid_power_card/screen_info/store.yml
✅ Files skipped from review due to trivial changes (5)
- plugins/auto_obtain_prepaid_power_card/screen_info/function_menu.yml
- plugins/auto_obtain_prepaid_power_card/screen_info/auto_obtain_prepaid_power_card_common.yml
- plugins/auto_obtain_prepaid_power_card/screen_info/store.yml
- plugins/auto_obtain_prepaid_power_card/screen_info/fading_signal.yml
- plugins/auto_obtain_prepaid_power_card/screen_info/signal_shop.yml
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
plugins/**/*.py
⚙️ CodeRabbit configuration file
plugins/**/*.py: ## 项目背景
这是 ZZZ-OneDragon (绝区零一条龙) 的插件仓库。
插件会被安装到主仓库的zzz_od/plugins/目录下运行。代码规范 (Coding Standards)
- Python 版本: 3.11+
- 使用现代类型注解:
list[str]而非List[str],X | None而非Optional[X]- 所有函数和方法必须有类型注解
- 路径处理优先使用
pathlib- 字符串格式化使用 f-string
- 避免不必要的 try-catch
插件开发规范
文件命名
- 工厂文件必须以
_factory.py结尾- 常量文件必须以
_const.py结尾必需常量 (xxx_const.py)
APP_ID: 插件唯一标识APP_NAME: 插件显示名称DEFAULT_GROUP: 是否出现在一条龙列表推荐元数据 (xxx_const.py)
PLUGIN_AUTHOR: 作者名PLUGIN_HOMEPAGE: 项目主页PLUGIN_VERSION: 版本号PLUGIN_DESCRIPTION: 描述导入规范 (重要!)
✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const
❌ 错误:from . import my_plugin_const(禁止相对导入)审查指南
环境假设
- 目标平台: 1080p 分辨率 + PC
- 允许硬编码像素坐标 (基于 1080p)
- 允许硬编码键盘按键 (如 '`', 'esc')
审查重点 (只关注这些)
- 严重的逻辑错误
- 死循环
- 潜在的运行时崩溃 (Runtime Error)
- 资源泄漏 (如未关闭的文件句柄)
忽略/不要建议
- 缩进、空行、空格等格式问题 (由 Ruff 处理)
- 简单逻辑中的 Magic Number
- 分辨率适配或控制器类型检查
- 过度工程化的"最佳实践"
- 非必要的抽象
Files:
plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.pyplugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.pyplugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py
🪛 Ruff (0.15.10)
plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py
[warning] 64-64: Docstring contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF002)
[warning] 64-64: Docstring contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF002)
🔇 Additional comments (1)
plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py (1)
17-19: 仍存在相对导入,未完全修复虽然之前
from .common_areas ...的相对导入已被移除,但 Line 19 中from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig依然是相对导入,违反项目规范。🔧 建议修改
if TYPE_CHECKING: from zzz_od.context.zzz_context import ZContext - from ..auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfig + from zzz_od.plugins.auto_obtain_prepaid_power_card.auto_obtain_prepaid_power_card_config import AutoObtainPrepaidPowerCardConfigAs per coding guidelines: "✅ 正确:
from zzz_od.plugins.my_plugin import my_plugin_const❌ 错误:from . import my_plugin_const(禁止相对导入)"。
| if clicks > 0 and not self._click_increase_button(clicks): | ||
| return self.round_retry(status='未找到数量增加按钮', wait=1) | ||
| return self.round_success() | ||
|
|
||
| def _click_increase_button(self, number: int) -> bool: | ||
| """点击增加按钮""" | ||
| for _ in range(number): | ||
| self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加") | ||
| time.sleep(0.2) | ||
| return True |
There was a problem hiding this comment.
_click_increase_button 的失败分支是死代码
_click_increase_button 始终无条件返回 True(Line 135),因此 Line 126 中 not self._click_increase_button(clicks) 永远为 False,“未找到数量增加按钮”的重试逻辑永远不会触发。要么让该方法基于 round_by_click_area 的返回结果真实判断成功/失败,要么直接去掉错误处理以免误导后续维护者。
🔧 建议修改(返回真实点击结果)
def _click_increase_button(self, number: int) -> bool:
"""点击增加按钮"""
for _ in range(number):
- self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加")
+ result = self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加")
+ if not result.is_success:
+ return False
time.sleep(0.2)
return True🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py`
around lines 126 - 135, The helper _click_increase_button always returns True so
the caller's check (if not self._click_increase_button(clicks)) can never
trigger; change _click_increase_button to return a real success boolean by
inspecting the result of each round_by_click_area("自动获取储值电卡-通用", "按钮-增加") call
(and abort/return False if any click fails), or aggregate results and return
False when no successful clicks occurred; update _click_increase_button(number:
int) to propagate that boolean so the caller using
round_retry(status='未找到数量增加按钮') can work correctly.
| if clicks > 0 and not self._click_increase_button(clicks): | ||
| return self.round_retry(status='未找到数量增加按钮', wait=1) | ||
| return self.round_success() | ||
|
|
||
| def _click_increase_button(self, number: int) -> bool: | ||
| """点击增加按钮""" | ||
| for _ in range(number): | ||
| self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加") | ||
| time.sleep(0.2) | ||
| return True |
There was a problem hiding this comment.
让增加按钮点击失败能真正触发重试。
_click_increase_button() 当前无条件返回 True,所以 Line 120 的失败分支永远不会执行;如果按钮未找到或点击失败,流程仍会继续确认购买。
建议修正
if clicks > 0 and not self._click_increase_button(clicks):
return self.round_retry(status='未找到数量增加按钮', wait=1)
return self.round_success()
def _click_increase_button(self, number: int) -> bool:
"""点击增加按钮"""
for _ in range(number):
- self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加")
+ result = self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加")
+ if not result.is_success:
+ return False
time.sleep(0.2)
return True🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py`
around lines 120 - 129, The helper _click_increase_button currently always
returns True so failures never trigger the retry path in the caller; change
_click_increase_button to detect and propagate click failures by checking the
result of round_by_click_area (or catching exceptions) on each iteration and
return False immediately if a click fails, otherwise return True after all
clicks; ensure the caller flow that calls _click_increase_button (which then
calls round_retry or round_success) will now observe False and execute
round_retry when clicks cannot be performed.
| max_clicks = self._max_quantity - 1 | ||
| clicks = min(self.config.outpost_logistics_obtain_number, max_clicks) | ||
| if clicks > 0 and not self._click_increase_button(clicks): | ||
| return self.round_retry(status='未找到数量增加按钮', wait=1) | ||
| return self.round_success() | ||
|
|
||
| def _click_increase_button(self, number: int) -> bool: | ||
| """点击增加按钮""" | ||
| for _ in range(number): | ||
| self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加") | ||
| time.sleep(0.2) | ||
| return True |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: 确认后勤商店数量枚举值,以及 round_by_click_area 是否返回带 is_success 的结果对象。
rg -n -C 5 'class\s+OutpostLogisticsObtainNumber|OutpostLogisticsObtainNumber|outpost_logistics_obtain_number' --iglob '*.py'
rg -n -C 5 'def\s+round_by_click_area\s*\(' --iglob '*.py'Repository: OneDragon-Anything/ZZZ-OneDragon-Plugins
Length of output: 14539
🏁 Script executed:
# 查看完整的数量枚举定义
cat plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_config.py | head -50
# 查找 round_by_click_area 方法定义及其返回类型
rg -n -A 10 'def\s+round_by_click_area\s*\(' --iglob '*.py' | head -60
# 检查是否有返回值对象定义 is_success
rg -n 'class.*Result|is_success' --iglob '*.py' -C 2 | head -80Repository: OneDragon-Anything/ZZZ-OneDragon-Plugins
Length of output: 9334
检查 _click_increase_button() 的点击结果是否成功。
_click_increase_button() 无条件返回 True,即使 round_by_click_area() 未能找到按钮也会返回成功。这导致第 111 行的重试分支 (if clicks > 0 and not self._click_increase_button(clicks)) 永远无法触发。
🐛 建议修改
def _click_increase_button(self, number: int) -> bool:
"""点击增加按钮"""
for _ in range(number):
- self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加")
+ result = self.round_by_click_area("自动获取储值电卡-通用", "按钮-增加")
+ if not result.is_success:
+ return False
time.sleep(0.2)
return True🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py`
around lines 109 - 120, The _click_increase_button currently always returns True
even if round_by_click_area failed; change _click_increase_button(number: int)
to check the return value of round_by_click_area("自动获取储值电卡-通用", "按钮-增加") on each
iteration and if any call returns False (or indicates failure) immediately
return False (avoid sleeping after a failed click); only return True after all
clicks succeed so the caller (the clicks > 0 check) can correctly call
round_retry when clicks couldn't be increased.
Summary by CodeRabbit
发布说明