【自动粉爪 线路B】大厅到办公层线路:优化稳定性、适配浔#141
Conversation
优化大厅战斗的稳定性
全新大厅到LG1办公层线路,浔时停避战,理论正常11分12到办公层(实际耗时65s)
📝 WalkthroughWalkthroughHeistPathB 在 run_path() 中根据 avoider_strategy_index() 路由到三条 LG1 入口(原路、Sakiri、Hotori);重命名并重构 Sakiri 的大厅开门/交互判定,新增 Hotori 线路与 lobby_open_door_check();同时更新任务说明文本细节。 变更LG1 避战路线策略分支
Sequence Diagram(s)sequenceDiagram
participant run_path
participant goto_lg1_skip_Sakiri
participant goto_lg1_skip_Hotori
participant OCR
participant lobby_open_door_check
participant input_send_f
run_path->>goto_lg1_skip_Sakiri: idx == 0 路由
run_path->>goto_lg1_skip_Hotori: idx == 1 路由
goto_lg1_skip_Sakiri->>OCR: 单次 OCR 检测“开门”
OCR-->>goto_lg1_skip_Sakiri: 返回命中/未命中
goto_lg1_skip_Sakiri->>lobby_open_door_check: 未命中时调用重试检测(check_time)
lobby_open_door_check->>OCR: 循环 OCR 检测
lobby_open_door_check-->>input_send_f: 未命中时发送 `f`
input_send_f-->>lobby_open_door_check: 重试或返回检测结果
代码审查工作量估计🎯 4 (Complex) | ⏱️ ~45 minutes 可能相关的 PRs
诗
🚥 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: 2
🧹 Nitpick comments (1)
src/heist_path/HeistPathB.py (1)
235-253: ⚡ Quick win把这段重复输入收敛成循环。
这里连续硬编码了 10 次完全相同的
space节奏,后续调时很容易漏改。抽成循环可读性和可维护性都会更稳。♻️ 建议改法
- self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) - self.send_key('space', down_time=0.24) - self.sleep(0.64) + for _ in range(10): + self.send_key("space", down_time=0.24) + self.sleep(0.64)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/heist_path/HeistPathB.py` around lines 235 - 253, 这段在 HeistPathB.py 中重复调用 self.send_key('space', down_time=0.24) 与 self.sleep(0.64) 的逻辑应收敛为循环:用一个 for 循环运行 10 次调用 self.send_key('space', down_time=0.24) 并在每次(除了最后一次以保留当前行为)之后调用 self.sleep(0.64),以替换原来的十次硬编码,保留 down_time=0.24 与 sleep=0.64 的值并确保没有多余的尾随 sleep。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/heist_path/HeistPathB.py`:
- Around line 186-188: The current silent return inside goto_lg1_skip_Sakiri()
(when lobby_open_door_check() is false) only exits that function while
run_path() continues, causing the path to proceed from an invalid state; change
goto_lg1_skip_Sakiri() to return an explicit boolean success value (True on
success, False on failure) instead of doing a bare return, update
lobby_open_door_check() usage to propagate failure, and modify the caller
run_path() to check the boolean and abort or perform a reset/recovery when False
rather than continuing execution.
- Around line 322-326: The method signature for lobby_open_door_check currently
requires check_time causing a TypeError when called without args; change its
definition to accept an optional parameter (e.g., def
lobby_open_door_check(self, check_time=None):) and keep the existing fallback
logic to set check_time = 3 when check_time is None (or falsy), ensuring
existing callers that call lobby_open_door_check() without arguments no longer
fail; update any unit tests or call sites if they depended on positional-only
behavior.
---
Nitpick comments:
In `@src/heist_path/HeistPathB.py`:
- Around line 235-253: 这段在 HeistPathB.py 中重复调用 self.send_key('space',
down_time=0.24) 与 self.sleep(0.64) 的逻辑应收敛为循环:用一个 for 循环运行 10 次调用
self.send_key('space', down_time=0.24) 并在每次(除了最后一次以保留当前行为)之后调用
self.sleep(0.64),以替换原来的十次硬编码,保留 down_time=0.24 与 sleep=0.64 的值并确保没有多余的尾随 sleep。
🪄 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: 0246bf31-23aa-4cf7-9ffb-f9c67c0392d6
📒 Files selected for processing (1)
src/heist_path/HeistPathB.py
128191b to
76ba3dc
Compare
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/tasks/AutoHeistTask.py (1)
56-73:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win处理 RUF001 以避免文案改动触发静态检查告警。
这些中文文案包含全角标点,Ruff 在 Line 56、Line 66-73 会报 RUF001。若该规则在 CI 中为阻断,建议统一改半角标点,或对该多语言文案行做定向忽略(例如
# noqa: RUF001)以保持检查稳定。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tasks/AutoHeistTask.py` around lines 56 - 73, The Chinese strings in the _inst_line calls (e.g., the lines that call _inst_line and _inst_gap in AutoHeistTask.py) use fullwidth punctuation and trigger Ruff RUF001; fix by either replacing fullwidth punctuation with halfwidth equivalents in those string literals (e.g., convert “:”、“,”、“(”、“)” to ":" , "," , "(" , ")") for the lines under the two "路径" blocks, or if you must preserve the exact copy, append a per-line directive to ignore the linter (add "# noqa: RUF001" at the end of each offending _inst_line call) so CI won’t fail—apply this change to the calls invoking _inst_line that contain the multilingual text.
🧹 Nitpick comments (1)
src/heist_path/HeistPathB.py (1)
9-18: ⚡ Quick win把策略分发表收敛成一处。
现在入口路线和 LG1 的 WP4/WP5 各维护了一套
idx分支;后续再加/改策略时,很容易只改其中一处,导致“前半段路线”和“后半段行为”错配。建议把日志、入口方法、WP4、WP5 绑定到同一个策略映射里统一调度。♻️ 一个更稳的组织方式
+ strategies = { + -1: ( + "没有配置避战角色,全程使用原始线路(路线A)", + self.goto_lg1, + self.lg1_wp4, + self.lg1_wp5_avoid_combat_01, + ), + 0: ( + "配置避战角色狗哥,使用早雾避战(路线B)", + self.goto_lg1_skip_Sakiri, + self.lg1_wp4_buster, + self.lg1_wp5_buster, + ), + 1: ( + "配置避战角色浔,使用浔避战(路线B)", + self.goto_lg1_skip_Hotori, + self.lg1_wp4, + self.lg1_wp5_avoid_combat_03, + ), + } + msg, goto_lg1, wp4, wp5 = strategies[idx] + self.log_round_info(msg) + goto_lg1() ... + wp4() + wp5()Also applies to: 26-34
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/heist_path/HeistPathB.py` around lines 9 - 18, The code duplicates idx-based branching for entry route and later LG1 WP4/WP5 behavior; consolidate by creating a single strategy mapping keyed by avoider_strategy_index() that contains the log message and the unified action identifiers for entry and for WP4/WP5, then replace the inline if/elif branches in the entry (current use of avoider_strategy_index(), log_round_info, goto_lg1, goto_lg1_skip_Sakiri, goto_lg1_skip_Hotori) and the WP4/WP5 handlers to look up the strategy and invoke the mapped actions; ensure a default mapping for idx == -1 and that the mapping is the single source of truth so future changes only modify that map.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/tasks/AutoHeistTask.py`:
- Around line 56-73: The Chinese strings in the _inst_line calls (e.g., the
lines that call _inst_line and _inst_gap in AutoHeistTask.py) use fullwidth
punctuation and trigger Ruff RUF001; fix by either replacing fullwidth
punctuation with halfwidth equivalents in those string literals (e.g., convert
“:”、“,”、“(”、“)” to ":" , "," , "(" , ")") for the lines under the two "路径"
blocks, or if you must preserve the exact copy, append a per-line directive to
ignore the linter (add "# noqa: RUF001" at the end of each offending _inst_line
call) so CI won’t fail—apply this change to the calls invoking _inst_line that
contain the multilingual text.
---
Nitpick comments:
In `@src/heist_path/HeistPathB.py`:
- Around line 9-18: The code duplicates idx-based branching for entry route and
later LG1 WP4/WP5 behavior; consolidate by creating a single strategy mapping
keyed by avoider_strategy_index() that contains the log message and the unified
action identifiers for entry and for WP4/WP5, then replace the inline if/elif
branches in the entry (current use of avoider_strategy_index(), log_round_info,
goto_lg1, goto_lg1_skip_Sakiri, goto_lg1_skip_Hotori) and the WP4/WP5 handlers
to look up the strategy and invoke the mapped actions; ensure a default mapping
for idx == -1 and that the mapping is the single source of truth so future
changes only modify that map.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7ecb5f4a-b43b-4419-979e-cc4537bba35a
📒 Files selected for processing (2)
src/heist_path/HeistPathB.pysrc/tasks/AutoHeistTask.py
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/heist_path/HeistPathB.py (1)
9-18: ⚡ Quick win建议把路线选择从裸
-1/0/1分支改成显式映射。
avoider_strategy_index()的上游契约是“无避战 / 长按 shift / 长按攻击”,这里却把0/1直接解释成 Sakiri/Hotori 专线,并在 WP4/WP5 再写一遍同样分支。现在虽然能工作,但路线正确性被绑死在avoid_methods的顺序和“一个策略只对应一个角色”的假设上,后面只要新增或重排策略,就很容易静默跑错线。建议至少抽成一份显式映射,或在进入专线路线前校验当前避战角色是否匹配。Also applies to: 26-34
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/heist_path/HeistPathB.py` around lines 9 - 18, The branch logic in HeistPathB uses magic indices from avoider_strategy_index() (-1/0/1) to pick routes (goto_lg1, goto_lg1_skip_Sakiri, goto_lg1_skip_Hotori), which couples route choice to the ordering of avoid_methods; replace the numeric branching with an explicit mapping (e.g., a dict or enum) from avoider_strategy_index() → route handler and descriptive name, and before calling a route handler validate that the currently configured avoider role matches the expected role for that route (use log_round_info to surface mismatches); apply the same mapping/validation refactor where the same -1/0/1 branches appear later (WP4/WP5) so route selection is robust to reordering or new strategies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/heist_path/HeistPathB.py`:
- Around line 168-171: 当前流程里对方向键 "d" 调用 send_key_down("d") 后没有配对的
send_key_up("d"),导致在等待/交互或提前返回分支(wait_and_interact(...)/早退分支)时把 "d" 保持按下,影响后续
w/a/f 的移动。修复方法:在调用 send_key_down("d") 的每个分支后(包括正常路径在 wait_and_interact(...)
之后以及任何早退/错误分支)都插入对应的 send_key_up("d");检查并对另一个按下 "d" 的位置(代码中第二处
send_key_down("d"))做同样处理,确保无论哪条执行路径最终都会执行 send_key_up("d")。
---
Nitpick comments:
In `@src/heist_path/HeistPathB.py`:
- Around line 9-18: The branch logic in HeistPathB uses magic indices from
avoider_strategy_index() (-1/0/1) to pick routes (goto_lg1,
goto_lg1_skip_Sakiri, goto_lg1_skip_Hotori), which couples route choice to the
ordering of avoid_methods; replace the numeric branching with an explicit
mapping (e.g., a dict or enum) from avoider_strategy_index() → route handler and
descriptive name, and before calling a route handler validate that the currently
configured avoider role matches the expected role for that route (use
log_round_info to surface mismatches); apply the same mapping/validation
refactor where the same -1/0/1 branches appear later (WP4/WP5) so route
selection is robust to reordering or new strategies.
🪄 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: 382eccb7-b1ea-4ea9-bdac-8ee81b27410b
📒 Files selected for processing (2)
src/heist_path/HeistPathB.pysrc/tasks/AutoHeistTask.py
|
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/heist_path/HeistPathB.py (1)
168-171:⚠️ Potential issue | 🟠 Major | ⚡ Quick win方向键
d未释放,会导致后续移动偏移。此问题在之前的 review 中已提出且仍未解决:
- Line 168
send_key_down("d")后没有对应的send_key_up("d"),在 Line 171 释放w时d仍处于按下状态- Line 182
send_key_down('d')后,若 Line 188 抛出异常,d键将保持按下💡 建议修复
self.send_key_down("d") self.wait_and_interact(direction="d", is_lock=True, time_out=7.64) self.sleep(0.10) + self.send_key_up("d") self.send_key_up("w") if self.wait_ocr(x=0.60, y=0.52, to_x=0.70, to_y=0.57, match=re.compile("开门"), time_out=1.14):self.send_key_down('d') self.sleep(0.05) self.wait_and_interact(direction="d", is_lock=False, time_out=3.65) + self.send_key_up("d") if self.find_interac(): is_open_door = self.lobby_open_door_check() if not is_open_door: raise AbortException("timeout for wait_and_interact")Also applies to: 182-192
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/heist_path/HeistPathB.py` around lines 168 - 171, The code holds the "d" key down (send_key_down("d")) without guaranteed release, causing movement drift; wrap the block that calls send_key_down("d") and subsequent wait_and_interact(...) in a try/finally where the finally always calls send_key_up("d"), and add a matching send_key_up("d") immediately after the successful wait_and_interact call for the earlier occurrence; apply the same try/finally pattern to the other occurrence around send_key_down('d') (and ensure you don't accidentally release "w" instead of "d" by referencing the correct key name in send_key_up).
🧹 Nitpick comments (2)
src/tasks/AutoHeistTask.py (2)
73-73: 💤 Low value可简化冗余表述。
"浔(必须,设置为长按攻击避战)"可简化为"浔(必须,长按攻击避战)",去掉"设置为"使表述更简洁。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tasks/AutoHeistTask.py` at line 73, Update the redundant instruction string passed to _inst_line: locate the call _inst_line(" 避战角色: 浔(必须,设置为长按攻击避战)", indent=1) and change the inner text to " 避战角色: 浔(必须,长按攻击避战)" to remove the extra "设置为" wording for a more concise description.
72-72: 💤 Low value可简化冗余表述。
"随意(战斗角色随意,可塞安魂曲)"中"随意"一词重复出现,可简化为"战斗角色随意,可塞安魂曲"或"战斗角色:随意(可塞安魂曲)"以提升可读性。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tasks/AutoHeistTask.py` at line 72, Update the duplicated wording in the _inst_line call inside AutoHeistTask (the string " 战斗角色: 随意(战斗角色随意,可塞安魂曲) / 主角 / 哈尼娅") so it removes the repeated "随意" and reads more concisely (for example "战斗角色: 随意(可塞安魂曲) / 主角 / 哈尼娅" or "战斗角色: 随意,可塞安魂曲 / 主角 / 哈尼娅"); modify the string argument passed to _inst_line accordingly to preserve the same meaning but eliminate redundancy.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/heist_path/HeistPathB.py`:
- Line 188: 当前在 HeistPathB.py 中的 raise AbortException("timeout for
wait_and_interact") 会触发 NameError 因为 AbortException 未导入;在处理 wait_and_interact
超时分支时请改为:一是将 AbortException 提取到一个公共异常模块(例如 common_exceptions 或
exceptions),在该模块定义 AbortException 并在 HeistPathB
中导入以避免循环依赖;二是在不能立即重构时可在抛出前在该函数内部延迟导入原定义(从 AutoHeistTask 导入
AbortException),或改为抛出标准异常(如 RuntimeError)并记录上下文信息;同时确认在 wait_and_interact
超时分支中会先执行 send_key_up("d"),若不会请补上释放按键的清理逻辑以避免按键粘滞。
---
Duplicate comments:
In `@src/heist_path/HeistPathB.py`:
- Around line 168-171: The code holds the "d" key down (send_key_down("d"))
without guaranteed release, causing movement drift; wrap the block that calls
send_key_down("d") and subsequent wait_and_interact(...) in a try/finally where
the finally always calls send_key_up("d"), and add a matching send_key_up("d")
immediately after the successful wait_and_interact call for the earlier
occurrence; apply the same try/finally pattern to the other occurrence around
send_key_down('d') (and ensure you don't accidentally release "w" instead of "d"
by referencing the correct key name in send_key_up).
---
Nitpick comments:
In `@src/tasks/AutoHeistTask.py`:
- Line 73: Update the redundant instruction string passed to _inst_line: locate
the call _inst_line(" 避战角色: 浔(必须,设置为长按攻击避战)", indent=1) and change the inner
text to " 避战角色: 浔(必须,长按攻击避战)" to remove the extra "设置为" wording for a more
concise description.
- Line 72: Update the duplicated wording in the _inst_line call inside
AutoHeistTask (the string " 战斗角色: 随意(战斗角色随意,可塞安魂曲) / 主角 / 哈尼娅") so it removes
the repeated "随意" and reads more concisely (for example "战斗角色: 随意(可塞安魂曲) / 主角 /
哈尼娅" or "战斗角色: 随意,可塞安魂曲 / 主角 / 哈尼娅"); modify the string argument passed to
_inst_line accordingly to preserve the same meaning but eliminate redundancy.
🪄 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: d6d662cd-3f71-4247-bf78-5d38fc382ab5
📒 Files selected for processing (2)
src/heist_path/HeistPathB.pysrc/tasks/AutoHeistTask.py


1、大厅到办公层早雾避战线路:优化在进入战斗后的分支的稳定性;
2、全新大厅到办公层浔时停避战线路,理论正常11分12到办公层(实际耗时65s)。
Summary by CodeRabbit