Skip to content

提供了一种自动获取储值电卡的实现#3

Open
luoyrair wants to merge 4 commits into
OneDragon-Anything:mainfrom
luoyrair:auto_obtain_prepaid_power_card
Open

提供了一种自动获取储值电卡的实现#3
luoyrair wants to merge 4 commits into
OneDragon-Anything:mainfrom
luoyrair:auto_obtain_prepaid_power_card

Conversation

@luoyrair
Copy link
Copy Markdown
Collaborator

@luoyrair luoyrair commented Apr 5, 2026

Summary by CodeRabbit

发布说明

  • 新功能
    • 新增自动获取储值电卡插件,支持从后勤商店、情报板商店和信号残响三个来源自动获取
    • 支持为每个商店来源单独配置启用状态和获取数量
    • 提供用户设置界面以自定义采购策略
    • 自动化完整的购买流程,包括导航、数量选择和支付确认

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

📝 Walkthrough

Walkthrough

新增一个完整的游戏插件,用于从后勤商店、情报板商店和信号残响自动获取储值电卡。包括配置系统、UI设置面板、三个专用操作流程及对应的屏幕检测定义。

Changes

Cohort / File(s) Summary
插件基础设施
auto_obtain_prepaid_power_card/__init__.py, auto_obtain_prepaid_power_card_const.py, auto_obtain_prepaid_power_card_config.py
定义插件常量(APP_ID、版本等)、配置类(含三个商店的开关及获取数量选项)、包文档。
应用与工厂
auto_obtain_prepaid_power_card_app.py, auto_obtain_prepaid_power_card_factory.py, auto_obtain_prepaid_power_card_run_record.py
实现主应用类及其图节点(配置检查、任务队列、三个商店操作节点、完成流程);工厂类负责实例化应用、配置及运行记录。
UI设置
auto_obtain_prepaid_power_card_app_setting.py, auto_obtain_prepaid_power_card_setting_flyout.py
设置提供者及Flyout面板,包含三个商店的开关卡片和数量选择下拉框,支持动态启用/禁用。
商店操作流程
operations/outpost_logistics_operation.py, operations/monthly_restock_operation.py, operations/fading_signal_operation.py
三个操作类,各自实现一个商店的完整购买流程(导航→计算最大数量→选择商品→检查库存→调整数量→确认购买→返回)。
屏幕配置
screen_info/auto_obtain_prepaid_power_card_common.yml, screen_info/function_menu.yml, screen_info/store.yml, screen_info/signal_shop.yml, screen_info/fading_signal.yml
YAML格式的UI区域定义,包含按钮、标签页、物品列表、货币显示等检测规则。

Sequence Diagram

sequenceDiagram
    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: 全部完成
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 67.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确描述了主要变更:实现自动获取储值电卡功能,与整个代码变更集的核心目标完全一致。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7276a6f and 1983670.

📒 Files selected for processing (13)
  • plugins/auto_obtain_prepaid_power_card/__init__.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app_setting.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_config.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_const.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_factory.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.py
  • plugins/auto_obtain_prepaid_power_card/operations/__init__.py
  • plugins/auto_obtain_prepaid_power_card/operations/common_areas.py
  • plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py
  • plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py
  • plugins/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__.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app_setting.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_const.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_factory.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_config.py
  • plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py
  • plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py
  • plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py
  • plugins/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: 其余操作流程逻辑正确

导航流程(返回大世界 → 打开菜单 → 商城 → 信源清单 → 信号残响)和购买流程设计合理,节点状态分支处理正确。

Comment thread plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py Outdated
Comment on lines +17 to +21
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

禁止使用相对导入

根据编码规范,插件代码禁止使用相对导入。应使用绝对导入路径。

🔧 建议修改
-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 AutoObtainPrepaidPowerCardConfig

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

luoyrair added 2 commits April 5, 2026 23:01
ps: 寄。忘了仓库中的是落后代码了。
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1983670 and c24c1c9.

📒 Files selected for processing (5)
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_app.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_run_record.py
  • plugins/auto_obtain_prepaid_power_card/auto_obtain_prepaid_power_card_setting_flyout.py
  • plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py
  • plugins/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.py
  • plugins/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)

Comment on lines +12 to +19
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ 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 AutoObtainPrepaidPowerCardConfig

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 AutoObtainPrepaidPowerCardConfig

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/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 AutoObtainPrepaidPowerCardConfig

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/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

📥 Commits

Reviewing files that changed from the base of the PR and between c24c1c9 and 5558ffb.

📒 Files selected for processing (8)
  • plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py
  • plugins/auto_obtain_prepaid_power_card/operations/monthly_restock_operation.py
  • plugins/auto_obtain_prepaid_power_card/operations/outpost_logistics_operation.py
  • plugins/auto_obtain_prepaid_power_card/screen_info/auto_obtain_prepaid_power_card_common.yml
  • plugins/auto_obtain_prepaid_power_card/screen_info/fading_signal.yml
  • plugins/auto_obtain_prepaid_power_card/screen_info/function_menu.yml
  • plugins/auto_obtain_prepaid_power_card/screen_info/signal_shop.yml
  • plugins/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.py
  • plugins/auto_obtain_prepaid_power_card/operations/fading_signal_operation.py
  • plugins/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 AutoObtainPrepaidPowerCardConfig

As per coding guidelines: "✅ 正确: from zzz_od.plugins.my_plugin import my_plugin_const ❌ 错误: from . import my_plugin_const (禁止相对导入)"。

Comment on lines +126 to +135
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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

Comment on lines +120 to +129
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

让增加按钮点击失败能真正触发重试。

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

Comment on lines +109 to +120
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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 -80

Repository: 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.

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.

1 participant