自动委托: 更快地点击跳过#2150
Hidden character warning
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough更改委托助手对话/剧情控制流:起始节点改为“委托助手”;引入灰度掩码检测、低延迟点击路径与有界选项历史;新增教程检测与“未知画面”等待节点;更新屏幕区域定义与界面配置项(sleep_after_empty_screen)。 Changes
Sequence Diagram(s)sequenceDiagram
participant App as CommissionAssistantApp
participant OCR as OCR服务
participant Clicker as 控制器(PcController)
participant UI as 游戏界面
App->>OCR: 检测 对话框内容 / 玩法引导 / 跳过 文本(色筛 + 灰度掩码)
OCR-->>App: 返回识别结果
alt 检测到“跳过”
App->>Clicker: click(跳过位置, low_delay?)
Clicker-->>UI: 执行跳过点击
App->>App: 标记 is_skip_in_main_story;清空 chosen_opt_history
App->>OCR: 检测 对话框确认
App->>Clicker: click(对话框确认, low_delay?)
Clicker-->>UI: 点击确认
else 未检测到跳过
App->>App: 调用 _do_dialog_click(check_center_words=True/False)
App->>OCR: 识别右侧选项文字(可带 color_range)
App->>App: 基于灰度判定决定是否点击中心或选项;使用 chosen_opt_history 避免重复
App->>Clicker: click(目标, low_delay?)
Clicker-->>UI: 执行点击
alt 空屏或无进展
App->>App: sleep_after_empty_screen_func(等待 self.config.sleep_after_empty_screen)
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 397-400: The code unconditionally sets self.is_skip_in_main_story
= True after calling round_by_ocr_and_click_by_priority(['菜单','自动'], ...) which
treats clicking '自动' (used to exit auto-play) as entering the main-story skip
flow; change this so the flag is only set when the clicked button is actually
the menu/skip entry (e.g., check result.status == '菜单' before setting
self.is_skip_in_main_story) or alternatively record the last_clicked button
instead of a boolean; update the block around
round_by_ocr_and_click_by_priority, the check that sets is_skip_in_main_story,
and any logic that relies on it (including the following round_wait call) to use
the refined condition.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d9485496-a848-4cf6-929a-3facac46e516
📒 Files selected for processing (1)
src/zzz_od/application/commission_assistant/commission_assistant_app.py
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 113-117: The branch that handles the '对话框确认' detection currently
calls round_wait(result.status, wait=0) which can busy-loop if the dialog
persists; change the wait argument to a small non-zero delay (e.g., 0.03–0.1s)
to throttle polling and reduce CPU usage while keeping the same behavior. Locate
the call site where round_by_find_area(self.last_screenshot, '委托助手', '对话框确认',
crop_first=False) returns result and replace round_wait(result.status, wait=0)
with round_wait(result.status, wait=0.05) (or a similar small value) to resolve
the busy-polling risk.
- Around line 381-389: The OCR click uses round_by_ocr_and_click with
success_wait=0.1 but because its result isn't immediately returned the
success_wait isn't effective, and is_skip_in_main_story is cleared too early
before confirming the dialog; change the flow so that if
round_by_ocr_and_click(self.last_screenshot, '跳过', area=area, success_wait=0.1)
returns success you immediately honor its success_wait behavior (i.e., return or
await the wait) before proceeding, and only clear self.is_skip_in_main_story
after a successful confirmation click in
round_by_find_and_click_area(self.screenshot(), '委托助手', '对话框确认', ...);
specifically update the block handling result from round_by_ocr_and_click and
the subsequent use of round_by_find_and_click_area to preserve
is_skip_in_main_story until the confirmation succeeds and ensure success_wait is
applied.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 63cacb7e-1a8f-4a77-a08e-dfebd645ddf9
📒 Files selected for processing (1)
src/zzz_od/application/commission_assistant/commission_assistant_app.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 340-343: The call to ctx.ocr_service.get_ocr_result_map in
commission_assistant_app.py changed behavior by dropping the crop_first
parameter (so it now uses default True); restore consistent behavior with other
calls by explicitly passing crop_first=False (i.e., call
get_ocr_result_map(image=self.last_screenshot, rect=area.rect,
crop_first=False)) so ocr_result_map is produced the same way as the other sites
that set crop_first=False; update the call site where ocr_result_map is assigned
and run tests or verify OCR results to confirm intended behavior.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9d1667a4-eb18-4400-b629-67258dabcca8
📒 Files selected for processing (1)
src/zzz_od/application/commission_assistant/commission_assistant_app.py
|
还能优化。。我先测个几周看看 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/zzz_od/application/commission_assistant/commission_assistant_app.py (1)
200-216:⚠️ Potential issue | 🟠 Major潜在 Bug:所有选项被过滤后仍会调用
click(None)当所有 OCR 识别到的选项都因历史记录检查(lines 200-203)被跳过时,
to_click将保持为None。此时:
- Line 214 会对
None调用click()- Line 215 会将
None追加到历史记录- Line 216 会返回
True,但实际上没有点击任何选项🐛 建议修复
self.ctx.controller.click(to_click) + if to_click is None: + return False self.chosen_opt_history.append(to_choose_opt) return True或者更清晰的写法:
- self.ctx.controller.click(to_click) - self.chosen_opt_history.append(to_choose_opt) - return True + if to_click is not None: + self.ctx.controller.click(to_click) + self.chosen_opt_history.append(to_choose_opt) + return True + return False🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py` around lines 200 - 216, The loop can leave to_click/to_choose_opt as None when all OCR options are skipped; update the method in commission_assistant_app.py to check after the loop whether to_click is None and, if so, avoid calling self.ctx.controller.click(None), avoid appending None to self.chosen_opt_history, and return False (or an appropriate failure value) instead of True; ensure the check occurs immediately before self.ctx.controller.click(to_click) and uses the existing symbols (self.chosen_opt_history, chosen_opt_history_max_len, is_same_opts, mr.data, to_click, to_choose_opt, self.ctx.controller.click) so normal clicking and history appending only happen when to_click is not None.
🧹 Nitpick comments (2)
src/zzz_od/gui/view/game_assistant/commission_assistant_interface.py (1)
7-7: 未使用的导入:Column
Column被导入但在此文件中未被使用,应移除该导入。💡 建议修改
-from one_dragon_qt.widgets.column import Column🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/gui/view/game_assistant/commission_assistant_interface.py` at line 7, Remove the unused import Column from the top-level imports in this module: delete the line importing Column (from one_dragon_qt.widgets.column import Column) so the file no longer imports the unused symbol Column; verify no other references to Column exist in functions or classes in this file (e.g., any usage in UI setup or class methods) before committing.src/zzz_od/application/commission_assistant/commission_assistant_app.py (1)
51-53: 缺少类型提示:chosen_opt_history根据编码规范,所有属性应包含类型提示。
💡 建议修改
self.chosen_opt_history_max_len: int = 8 - self.chosen_opt_history: deque = deque(maxlen=self.chosen_opt_history_max_len) # 如果一直卡在选择选项, 记录选择的对话选项历史记录 + self.chosen_opt_history: deque[str | None] = deque(maxlen=self.chosen_opt_history_max_len) # 如果一直卡在选择选项, 记录选择的对话选项历史记录🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py` around lines 51 - 53, Annotate the attribute self.chosen_opt_history with an explicit type hint (e.g., Deque[Any] or Deque[str] depending on element type) and update imports accordingly; for example, add "from typing import Deque, Any" (or the specific element type) and change the attribute to chosen_opt_history: Deque[Any] = deque(maxlen=self.chosen_opt_history_max_len) so the class (commission_assistant_app / the attribute chosen_opt_history and chosen_opt_history_max_len) follows the code style requiring typed attributes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 200-216: The loop can leave to_click/to_choose_opt as None when
all OCR options are skipped; update the method in commission_assistant_app.py to
check after the loop whether to_click is None and, if so, avoid calling
self.ctx.controller.click(None), avoid appending None to
self.chosen_opt_history, and return False (or an appropriate failure value)
instead of True; ensure the check occurs immediately before
self.ctx.controller.click(to_click) and uses the existing symbols
(self.chosen_opt_history, chosen_opt_history_max_len, is_same_opts, mr.data,
to_click, to_choose_opt, self.ctx.controller.click) so normal clicking and
history appending only happen when to_click is not None.
---
Nitpick comments:
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 51-53: Annotate the attribute self.chosen_opt_history with an
explicit type hint (e.g., Deque[Any] or Deque[str] depending on element type)
and update imports accordingly; for example, add "from typing import Deque, Any"
(or the specific element type) and change the attribute to chosen_opt_history:
Deque[Any] = deque(maxlen=self.chosen_opt_history_max_len) so the class
(commission_assistant_app / the attribute chosen_opt_history and
chosen_opt_history_max_len) follows the code style requiring typed attributes.
In `@src/zzz_od/gui/view/game_assistant/commission_assistant_interface.py`:
- Line 7: Remove the unused import Column from the top-level imports in this
module: delete the line importing Column (from one_dragon_qt.widgets.column
import Column) so the file no longer imports the unused symbol Column; verify no
other references to Column exist in functions or classes in this file (e.g., any
usage in UI setup or class methods) before committing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2f541ef5-51f8-4ab0-a542-a712ef9a0695
📒 Files selected for processing (3)
src/zzz_od/application/commission_assistant/commission_assistant_app.pysrc/zzz_od/application/commission_assistant/commission_assistant_config.pysrc/zzz_od/gui/view/game_assistant/commission_assistant_interface.py
似乎没什么大问题了 |
|
@coderabbitai review |
| def win_click(self, pos: Point = None, press_time: float = 0, primary: bool = True, low_delay: bool = False): | ||
| """点击鼠标。 | ||
|
|
||
| Args: | ||
| pos: 屏幕坐标 | ||
| press_time: 按住时间 | ||
| primary: 是否点击鼠标主要按键(通常是左键) | ||
| low_delay: todo 去除按键延迟 (pyautogui几乎所有操作都有延迟, 默认为0.1s) | ||
| """ | ||
| btn = pyautogui.PRIMARY if primary else pyautogui.SECONDARY | ||
| if pos is None: | ||
| pos = get_current_mouse_pos() | ||
|
|
||
| if low_delay: | ||
| pyautogui.PAUSE = 0.001 | ||
|
|
||
| def win_click(pos: Point = None, press_time: float = 0, primary: bool = True): | ||
| """点击鼠标。 | ||
| if press_time > 0: | ||
| # 处理点击延迟 | ||
| pyautogui.moveTo(pos.x, pos.y) | ||
| pyautogui.mouseDown(button=btn) | ||
| time.sleep(press_time) | ||
| pyautogui.mouseUp(button=btn) | ||
| else: | ||
| pyautogui.click(pos.x, pos.y, button=btn) | ||
|
|
||
| Args: | ||
| pos: 屏幕坐标 | ||
| press_time: 按住时间 | ||
| primary: 是否点击鼠标主要按键(通常是左键) | ||
| """ | ||
| btn = pyautogui.PRIMARY if primary else pyautogui.SECONDARY | ||
| if pos is None: | ||
| pos = get_current_mouse_pos() | ||
| if press_time > 0: | ||
| pyautogui.moveTo(pos.x, pos.y) | ||
| pyautogui.mouseDown(button=btn) | ||
| time.sleep(press_time) | ||
| pyautogui.mouseUp(button=btn) | ||
| else: | ||
| pyautogui.click(pos.x, pos.y, button=btn) | ||
| if low_delay: | ||
| pyautogui.PAUSE = self.pyautogui_pause |
There was a problem hiding this comment.
这边对前台模式下点击鼠标的函数拓展了个参数 low_delay, 能够使点击的延迟小于0.1s.
但是这个函数很多人在用, 故目前没有改参数 press_time, 只加了个todo.
@ShadowLemoon 看看这样改是否合理
|
@coderabbitai resume |
|
🧠 Learnings used✅ Actions performedReviews resumed. Review triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/one_dragon/base/controller/pc_controller_base.py`:
- Around line 525-551: In win_click, save the current global pyautogui.PAUSE
into a local variable at method start and, if you set pyautogui.PAUSE = 0.001
for low_delay, wrap the click logic in a try/finally where the finally always
restores pyautogui.PAUSE from that saved local value (do not restore from
self.pyautogui_pause); let any exceptions propagate after restoring so the
global pause is never left altered.
In `@src/one_dragon/utils/cv2_utils.py`:
- Around line 1263-1281: After calling crop_image(img, rect) add an immediate
empty-image guard: if the returned img has img.size == 0 then short-circuit and
return False (or the function's appropriate falsy/invalid result) to avoid
computing total, performing count/total and misclassifying out-of-bounds crops;
place this check right after the crop_image(...) call that assigns img and
crop_rect and before computing total/percent.
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 264-266: The branch that calls
self.ctx.withered_domain.init_before_run() fails to set the guard flag, so
init_before_run() may run every cycle; after calling init_before_run() inside
the if not self.withered_domain_inited: block, set self.withered_domain_inited =
True (or the appropriate state flag) to mark initialization complete, ensuring
subsequent runs skip re-initialization; update any related teardown/reset logic
if needed to flip the flag when the domain should be reinitialized.
- Around line 228-230: The code appends to self.chosen_opt_history before
checking if to_click is None, causing None to be recorded and polluting
duplicate-suppression; move the append so it only runs after you confirm a real
click target (i.e., check to_click is not None first), updating the logic in the
method that uses chosen_opt_history / to_choose_opt / to_click to append only
when a valid to_click exists and the click action will proceed.
🪄 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: 3fbfd5d6-3d16-4820-a270-5f09fae3feb8
📒 Files selected for processing (9)
assets/game_data/screen_info/_od_merged.ymlassets/game_data/screen_info/commission_assistant.ymlsrc/one_dragon/base/controller/controller_base.pysrc/one_dragon/base/controller/pc_controller_base.pysrc/one_dragon/utils/cv2_utils.pysrc/zzz_od/application/commission_assistant/commission_assistant_app.pysrc/zzz_od/application/commission_assistant/commission_assistant_config.pysrc/zzz_od/gui/view/game_assistant/commission_assistant_interface.pysrc/zzz_od/hollow_zero/event/hollow_event_utils.py
💤 Files with no reviewable changes (1)
- src/zzz_od/hollow_zero/event/hollow_event_utils.py
🚧 Files skipped from review as they are similar to previous changes (2)
- src/zzz_od/application/commission_assistant/commission_assistant_config.py
- src/zzz_od/gui/view/game_assistant/commission_assistant_interface.py
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/one_dragon/utils/cv2_utils.py (1)
1263-1268: 已处理裁剪后空图检测,但存在未使用变量。Line 1267-1268 的空图检测逻辑正确解决了潜在的除零问题。但 Line 1265 的
crop_rect变量从未使用,应改为_以符合 Python 惯例。💡 建议修改
# 裁剪图片 if rect is not None: - img, crop_rect = crop_image(img, rect) + img, _ = crop_image(img, rect)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/one_dragon/utils/cv2_utils.py` around lines 1263 - 1268, The variable crop_rect returned from crop_image in the block inside cv2_utils.py is never used; update the unpacking to use a throwaway name (e.g., change "img, crop_rect = crop_image(img, rect)" to "img, _ = crop_image(img, rect)") so it follows Python conventions and avoids an unused-variable warning while keeping the existing post-crop empty-image check (the code involving crop_image and the subsequent img is None or img.size check should remain unchanged).src/zzz_od/application/commission_assistant/commission_assistant_app.py (1)
149-149: 未使用变量center_rect。裁剪结果的
center_rect未被使用,建议改为_占位符。💡 建议修改
- center_image, center_rect = cv2_utils.crop_image(self.last_screenshot, center_area.rect) + center_image, _ = cv2_utils.crop_image(self.last_screenshot, center_area.rect)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py` at line 149, The variable center_rect returned from cv2_utils.crop_image is unused; change the unpack to use a placeholder underscore to signal an intentionally ignored value (e.g., replace "center_image, center_rect = cv2_utils.crop_image(self.last_screenshot, center_area.rect)" with "center_image, _ = cv2_utils.crop_image(self.last_screenshot, center_area.rect)"), updating the occurrence in the method of CommissionAssistantApp where self.last_screenshot and center_area.rect are passed.src/one_dragon/base/controller/pc_controller_base.py (1)
538-552: try/finally 已实现,但恢复值来源仍有风险。异常安全已通过 try/finally 处理,这很好。但当前从
self.pyautogui_pause(初始化时保存的值)恢复,而非方法入口时保存的当前值。若运行期间pyautogui.PAUSE被其他代码修改,此处会覆盖那些调整。💡 建议修改
def win_click(self, pos: Point = None, press_time: float = 0, primary: bool = True, low_delay: bool = False): btn = pyautogui.PRIMARY if primary else pyautogui.SECONDARY if pos is None: pos = get_current_mouse_pos() + previous_pause = pyautogui.PAUSE if low_delay: pyautogui.PAUSE = 0.001 try: if press_time > 0: pyautogui.moveTo(pos.x, pos.y) pyautogui.mouseDown(button=btn) time.sleep(press_time) pyautogui.mouseUp(button=btn) else: pyautogui.click(pos.x, pos.y, button=btn) finally: if low_delay: - pyautogui.PAUSE = self.pyautogui_pause + pyautogui.PAUSE = previous_pause🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/one_dragon/base/controller/pc_controller_base.py` around lines 538 - 552, The current finally block restores pyautogui.PAUSE from self.pyautogui_pause which can overwrite any changes made by other code during this method's execution; instead capture the current value of pyautogui.PAUSE at the start of the method (e.g., orig_pause = pyautogui.PAUSE) before you change it when low_delay is true, then in the finally restore pyautogui.PAUSE = orig_pause; update the logic around the low_delay branch that sets pyautogui.PAUSE and the finally that restores it, leaving self.pyautogui_pause untouched.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/one_dragon/base/controller/pc_controller_base.py`:
- Around line 538-552: The current finally block restores pyautogui.PAUSE from
self.pyautogui_pause which can overwrite any changes made by other code during
this method's execution; instead capture the current value of pyautogui.PAUSE at
the start of the method (e.g., orig_pause = pyautogui.PAUSE) before you change
it when low_delay is true, then in the finally restore pyautogui.PAUSE =
orig_pause; update the logic around the low_delay branch that sets
pyautogui.PAUSE and the finally that restores it, leaving self.pyautogui_pause
untouched.
In `@src/one_dragon/utils/cv2_utils.py`:
- Around line 1263-1268: The variable crop_rect returned from crop_image in the
block inside cv2_utils.py is never used; update the unpacking to use a throwaway
name (e.g., change "img, crop_rect = crop_image(img, rect)" to "img, _ =
crop_image(img, rect)") so it follows Python conventions and avoids an
unused-variable warning while keeping the existing post-crop empty-image check
(the code involving crop_image and the subsequent img is None or img.size check
should remain unchanged).
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Line 149: The variable center_rect returned from cv2_utils.crop_image is
unused; change the unpack to use a placeholder underscore to signal an
intentionally ignored value (e.g., replace "center_image, center_rect =
cv2_utils.crop_image(self.last_screenshot, center_area.rect)" with
"center_image, _ = cv2_utils.crop_image(self.last_screenshot,
center_area.rect)"), updating the occurrence in the method of
CommissionAssistantApp where self.last_screenshot and center_area.rect are
passed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 55ffde55-155f-4103-a3eb-38bba801260f
📒 Files selected for processing (3)
src/one_dragon/base/controller/pc_controller_base.pysrc/one_dragon/utils/cv2_utils.pysrc/zzz_od/application/commission_assistant/commission_assistant_app.py
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/one_dragon/utils/cv2_utils.py (1)
1240-1240: 参数缺少类型标注
threshold、rgb_diff_threshold和percent_rate参数虽然有默认值,但缺少显式类型标注。按照编码规范,所有函数参数都应包含类型提示。💡 建议修改
-def is_in_gray_mask(img: MatLike, rect: Rect | None = None, threshold=55, rgb_diff_threshold=20, percent_rate=0.9) -> bool: +def is_in_gray_mask(img: MatLike, rect: Rect | None = None, threshold: int = 55, rgb_diff_threshold: int = 20, percent_rate: float = 0.9) -> bool:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/one_dragon/utils/cv2_utils.py` at line 1240, The function is_in_gray_mask is missing explicit type annotations for parameters threshold, rgb_diff_threshold, and percent_rate; update the signature of is_in_gray_mask to add types (use int for threshold and rgb_diff_threshold, float for percent_rate) so it becomes def is_in_gray_mask(img: MatLike, rect: Rect | None = None, threshold: int = 55, rgb_diff_threshold: int = 20, percent_rate: float = 0.9) -> bool; ensure any references in the function body or its docstring remain consistent with these types.src/zzz_od/application/commission_assistant/commission_assistant_app.py (2)
53-54: 类型标注可以更精确
deque的类型标注可以更具体,明确指定元素类型。💡 建议修改
- self.chosen_opt_history: deque = deque(maxlen=self.chosen_opt_history_max_len) + self.chosen_opt_history: deque[str] = deque(maxlen=self.chosen_opt_history_max_len)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py` around lines 53 - 54, The type annotation for chosen_opt_history is too generic; make it specific by annotating the deque element type (e.g., deque[str] or typing.Deque[str]) so callers and linters know what element type is stored. Update the declaration that sets chosen_opt_history and its max len (symbols: chosen_opt_history_max_len and chosen_opt_history) to use the concrete generic type and import typing.Deque or use collections.deque[...] accordingly.
159-165:check_main_story()每次调用都执行 OCR,可能影响性能在
_do_dialog_click中调用check_main_story()会触发一次 OCR 操作。如果_do_dialog_click被高频调用,可能会影响性能。但考虑到作者已经在check_story_mode中做了性能优化(使用crop_first=True),此处也已使用了裁剪后的区域,影响应该可控。如果后续发现性能瓶颈,可以考虑缓存
check_main_story()的结果在当前截图周期内复用。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py` around lines 159 - 165, The call to check_main_story() inside _do_dialog_click triggers OCR each time and can be cached for the current screenshot cycle; implement a lightweight cache on the CommissionAssistantApp instance (e.g., attributes like _cached_check_main_story_result and _cached_check_main_story_screenshot_id) and have check_main_story() or _do_dialog_click check and reuse the cached result when self.last_screenshot (or its unique id/hash/timestamp) hasn’t changed, and invalidate/update the cache whenever a new screenshot is captured so subsequent _do_dialog_click calls in the same cycle use the cached boolean instead of re-running OCR.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/one_dragon/utils/cv2_utils.py`:
- Line 1240: The function is_in_gray_mask is missing explicit type annotations
for parameters threshold, rgb_diff_threshold, and percent_rate; update the
signature of is_in_gray_mask to add types (use int for threshold and
rgb_diff_threshold, float for percent_rate) so it becomes def
is_in_gray_mask(img: MatLike, rect: Rect | None = None, threshold: int = 55,
rgb_diff_threshold: int = 20, percent_rate: float = 0.9) -> bool; ensure any
references in the function body or its docstring remain consistent with these
types.
In `@src/zzz_od/application/commission_assistant/commission_assistant_app.py`:
- Around line 53-54: The type annotation for chosen_opt_history is too generic;
make it specific by annotating the deque element type (e.g., deque[str] or
typing.Deque[str]) so callers and linters know what element type is stored.
Update the declaration that sets chosen_opt_history and its max len (symbols:
chosen_opt_history_max_len and chosen_opt_history) to use the concrete generic
type and import typing.Deque or use collections.deque[...] accordingly.
- Around line 159-165: The call to check_main_story() inside _do_dialog_click
triggers OCR each time and can be cached for the current screenshot cycle;
implement a lightweight cache on the CommissionAssistantApp instance (e.g.,
attributes like _cached_check_main_story_result and
_cached_check_main_story_screenshot_id) and have check_main_story() or
_do_dialog_click check and reuse the cached result when self.last_screenshot (or
its unique id/hash/timestamp) hasn’t changed, and invalidate/update the cache
whenever a new screenshot is captured so subsequent _do_dialog_click calls in
the same cycle use the cached boolean instead of re-running OCR.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3131dd42-ac6c-415a-8544-72c7e688f105
📒 Files selected for processing (2)
src/one_dragon/utils/cv2_utils.pysrc/zzz_od/application/commission_assistant/commission_assistant_app.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/one_dragon/utils/cv2_utils.py`:
- Around line 1258-1260: The Returns docstring for function is_in_gray_mask is
incorrect (it says True means color and False means gray) — update the Returns
section to accurately state that the function returns a bool where True
indicates the image is in the gray mask (i.e., mostly black/white/gray) and
False indicates it is not; keep the return type as bool and adjust the Chinese
description to reflect this behavior so callers reading the docstring (and the
call site that uses if not cv2_utils.is_in_gray_mask(...): return False) are not
misled.
🪄 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: 7363a85c-c2f6-4ae8-bacd-1a4cbf1a9112
📒 Files selected for processing (2)
src/one_dragon/utils/cv2_utils.pysrc/zzz_od/application/commission_assistant/commission_assistant_app.py
|
pyautogui的那个延迟是什么情况?框架本身有pre_delay 考虑不改签名直接把pyautogui的延迟去掉 |

一直觉得自动委托点击延迟太高有点鸡肋,不如手动触发按键精灵宏迅速
火锅活动b对话太多了,就想着改一下
支持主线和支线
改善点击延迟并且减少误触
Summary by CodeRabbit
新功能
修复 / 行为优化