@@ -23,12 +23,14 @@ class AutoSellFish(CustomAction):
2323 sell_button_img = image_dir / "sell_button.png"
2424 confirm_sell_img = image_dir / "confirm_sell.png"
2525 sell_success_img = image_dir / "sell_success.png"
26+ sell_fail_img = image_dir / "sell_fail.png"
2627 sell_option_template = cv2 .imread (str (sell_option_img ), cv2 .IMREAD_COLOR )
2728 sell_option_selected_template = cv2 .imread (str (sell_option_selected_img ), cv2 .IMREAD_COLOR )
2829 no_fish_to_sell_template = cv2 .imread (str (no_fish_to_sell_img ), cv2 .IMREAD_COLOR )
2930 sell_button_template = cv2 .imread (str (sell_button_img ), cv2 .IMREAD_COLOR )
3031 confirm_sell_template = cv2 .imread (str (confirm_sell_img ), cv2 .IMREAD_COLOR )
3132 sell_success_template = cv2 .imread (str (sell_success_img ), cv2 .IMREAD_COLOR )
33+ sell_fail_template = cv2 .imread (str (sell_fail_img ), cv2 .IMREAD_COLOR )
3234
3335 def run (self , context : Context , argv : CustomAction .RunArg ) -> CustomAction .RunResult :
3436 print ("=== Autofish Action Started ===" )
@@ -43,6 +45,8 @@ def run(self, context: Context, argv: CustomAction.RunArg) -> CustomAction.RunRe
4345 sell_button_region = [665 , 635 , 92 , 23 ]
4446 confirm_sell_region = [756 , 461 , 48 , 21 ]
4547 sell_success_region = [565 , 628 , 149 , 21 ]
48+ sell_fail_region = [739 , 349 , 202 , 24 ]
49+ no_valid_fish_region = [509 , 350 , 261 , 22 ]
4650
4751 while True :
4852 img = get_image (controller )
@@ -84,13 +88,18 @@ def run(self, context: Context, argv: CustomAction.RunArg) -> CustomAction.RunRe
8488
8589 img = get_image (controller )
8690 found_confirm_sell , _ , _ , _ = match_template_in_region (img , confirm_sell_region , self .confirm_sell_template , 0.8 )
91+ sell_fail , _ , _ , _ = match_template_in_region (img , sell_fail_region , self .sell_fail_template , 0.8 )
8792 if found_confirm_sell :
8893 print ("Confirm sell button detected. Clicking to confirm selling fish." )
8994 for _ in range (3 ):
9095 click_rect (controller , confirm_sell_region )
9196 time .sleep (0.1 )
9297 time .sleep (1 )
9398 break
99+ elif sell_fail :
100+ print ("no fish to sell, closing fish shop." )
101+ controller .post_click_key (KEY_ESC ).wait ()
102+ return CustomAction .RunResult (success = True )
94103 else :
95104 time .sleep (0.1 )
96105 break
0 commit comments