@@ -94,7 +94,7 @@ def find_fish_bite(self) -> tuple[bool, tuple]:
9494 def find_fish_chance (self ) -> tuple [bool , tuple ]:
9595 """查找 fish_chance 图标(授渔以鱼),返回 (found, center)"""
9696 CHANCE_THRESHOLD = 0.8 # fish_chance 匹配阈值
97- fish_chance_box = self .box_of_screen_scaled (3840 , 2160 , 3467 , 1797 , 3703 , 2033 , name = "fish_chance" )
97+ fish_chance_box = self .box_of_screen_scaled (3840 , 2160 , 3269 , 1672 , 3505 , 1908 , name = "fish_chance" )
9898 box = self .find_one ("fish_chance" , box = fish_chance_box , threshold = CHANCE_THRESHOLD )
9999 if box :
100100 return True , (box .x + box .width // 2 , box .y + box .height // 2 )
@@ -238,10 +238,7 @@ def phase_start(self) -> bool:
238238 # ensure foreground handled by framework interaction activation
239239 start_deadline = time .monotonic () + cfg .get ("MAX_START_SEC" , 20.0 )
240240
241- has_cast_icon , _ = self .find_fish_cast ()
242- self .stats ["last_cast_icon_found" ] = has_cast_icon
243-
244- # 检测是否有授渔以鱼机会
241+ # 检测是否有授渔以鱼机会 (优先执行且短路,减少不必要的对比开销)
245242 has_chance_icon , _ = self .find_fish_chance ()
246243 if has_chance_icon :
247244 logger .info ("检测到fish_chance(授渔以鱼)-> 按下E键使用授渔以鱼抛竿" )
@@ -253,13 +250,16 @@ def phase_start(self) -> bool:
253250 self .info_set ("完成轮数" , self .stats ["rounds_completed" ])
254251 logger .info (f"上一轮的鱼作为鱼饵,轮数调整为: { self .stats ['rounds_completed' ]} " )
255252 self .send_key ("e" , down_time = 0.06 )
256- elif not has_cast_icon :
257- logger .info ("开始阶段未找到fish_cast,尝试按空格抛竿并等待fish_bite出现" )
258- # press space to cast
259- self .send_key ("space" , down_time = 0.06 )
260253 else :
261- logger .info ("找到fish_cast -> 按下空格抛竿" )
262- self .send_key ("space" , down_time = 0.06 )
254+ has_cast_icon , _ = self .find_fish_cast ()
255+ self .stats ["last_cast_icon_found" ] = has_cast_icon
256+ if not has_cast_icon :
257+ logger .info ("开始阶段未找到fish_cast,尝试按空格抛竿并等待fish_bite出现" )
258+ # press space to cast
259+ self .send_key ("space" , down_time = 0.06 )
260+ else :
261+ logger .info ("找到fish_cast -> 按下空格抛竿" )
262+ self .send_key ("space" , down_time = 0.06 )
263263
264264 logger .info ("等待fish_bite出现..." )
265265 ret = self .wait_until (lambda : self .find_fish_bite ()[0 ], time_out = start_deadline , raise_if_not_found = False )
@@ -447,25 +447,42 @@ def phase_end(self) -> bool:
447447 logger .info (f"等待 { cfg .get ('END_WAIT_SPACE' , 7.0 )} s 结束鱼信息展示..." )
448448 self .sleep (cfg .get ("END_WAIT_SPACE" , 7.0 ))
449449
450- logger .info ("收线 (Space)" )
451- self .send_key ("space" , down_time = 0.06 )
452-
453450 # wait and verify
454451 confirm_deadline = time .monotonic () + cfg .get ("MAX_END_SEC" , 20.0 )
452+
453+ # 抛竿图标连续稳定确认机制
454+ stable_confirm_time = 0.5
455+ cast_appeared_time = None
456+
455457 while time .monotonic () < confirm_deadline :
456- has_cast_icon , _ = self .find_fish_cast ()
457- has_bite_icon , _ = self .find_fish_bite ()
458- has_chance_icon , _ = self .find_fish_chance ()
459- self .stats ["last_cast_icon_found" ] = has_cast_icon
460- self .stats ["last_bite_icon_found" ] = has_bite_icon
461- if has_cast_icon or has_bite_icon or has_chance_icon :
462- if has_chance_icon :
463- logger .info ("确认已回到挥杆界面(检测到授渔以鱼)" )
464- else :
465- logger .info ("确认已回到挥杆界面" )
458+ has_chance = self .find_fish_chance ()[0 ]
459+ if has_chance :
460+ logger .info ("确认已回到挥杆界面(检测到授渔以鱼)" )
466461 return True
467- self .send_key ("space" , down_time = 0.06 )
468- self .sleep (1.0 )
462+
463+ has_bite = self .find_fish_bite ()[0 ]
464+ if has_bite :
465+ logger .info ("确认已回到挥杆界面(检测到鱼咬钩被遗留)" )
466+ return True
467+
468+ has_cast = self .find_fish_cast ()[0 ]
469+ self .stats ["last_cast_icon_found" ] = has_cast
470+ if has_cast :
471+ if cast_appeared_time is None :
472+ # 记录第一次看见抛竿图标的时间
473+ cast_appeared_time = time .monotonic ()
474+ elif time .monotonic () - cast_appeared_time >= stable_confirm_time :
475+ # 第二次确认:抛竿图标连续显示,非画面闪现
476+ logger .info ("界面稳定,确认已回到抛竿界面" )
477+ return True
478+ else :
479+ # 抛竿图标消失,重置判定计时
480+ cast_appeared_time = None
481+
482+ # 继续保持点击屏幕左侧用来关闭那些可能无法单纯靠时间等待关闭的层叠UI
483+ self .click_relative_random (0.05 , 0.3 , 0.4 , 0.7 )
484+ self .sleep (0.5 )
485+
469486 logger .info ("结束阶段确认失败" )
470487 return False
471488
@@ -553,9 +570,6 @@ def do_run(self):
553570 logger .info (f" 剩余轮数: { remaining } " )
554571 logger .info ("=" * 50 )
555572
556- # 继续下一轮
557- self .sleep (1.0 )
558- self .sleep (1.0 )
559573 except TaskDisabledException :
560574 raise
561575 except Exception as e :
0 commit comments