ソースを参照

fix(RichMan): Handle purchase limits and sold-out store items #25

- Clear add-button click records during large quantity purchases
- Track guild store swipe progress after successful swipes
- Detect sold-out items while scanning the special store

(cherry picked from commit b2f9e0329b7d3b7aa97d4bec20b47be80e2b9d6b)
blylana 14 時間 前
親
コミット
f3c70dd2df

+ 8 - 1
tasks/Component/Buy/buy.py

@@ -115,13 +115,20 @@ class Buy(BaseTask, BuyAssets):
         else:
             # 四次截图数字都一样,就可以退出了
             number_record = []
+            add_click_count = 0
+            clear_add_click_record = number > 10
             ocr_timer = Timer(0.8)
             ocr_timer.start()
             while 1:
                 self.screenshot()
 
                 if self.appear_then_click(self.I_BUY_ADD, interval=0.8):
-                    continue
+                    if not clear_add_click_record:
+                        continue
+                    add_click_count += 1
+                    if add_click_count >= 7:
+                        self.device.click_record_remove(self.I_BUY_ADD)
+                        add_click_count = 0
 
                 if not ocr_timer.reached():
                     continue

+ 2 - 0
tasks/RichMan/assets.py

@@ -322,6 +322,8 @@ class RichManAssets:
 	I_SP_BUY_LOW = RuleImage(roi_front=(176,148,144,108), roi_back=(128,142,902,449), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/special/special_sp_buy_low.png")
 	# 判断是否滑动到底 
 	I_SP_SWIPE_CHECK = RuleImage(roi_front=(900,164,42,61), roi_back=(173,144,840,379), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/special/special_sp_swipe_check.png")
+	# 售罄 
+	I_SOLD_OUT = RuleImage(roi_front=(442,344,54,32), roi_back=(142,312,876,290), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/special/special_sold_out.png")
 
 
 	# Ocr Rule Assets

+ 1 - 1
tasks/RichMan/guild.py

@@ -94,11 +94,11 @@ class Guild(Buy, GameUi, RichManAssets):
                 time.sleep(1)
                 continue
             # 连续多次滑动都没有买到东西, 防止无限滑动触发点击保护
-            swipe_no_progress += 1
             if swipe_no_progress >= 8:
                 logger.warning(f'Swipe {swipe_no_progress} times without buying, stop guild store')
                 break
             if self.swipe(self.S_GUILD_STORE, interval=1.5):
+                swipe_no_progress += 1
                 time.sleep(2)
                 continue
 

+ 1 - 1
tasks/RichMan/mall/special.py

@@ -41,7 +41,7 @@ class Special(Buy, MallNavbar):
             if totem_bought and medium_bought and low_bought:
                 logger.info('All bought')
                 break
-            if self.appear(self.I_SP_SWIPE_CHECK):
+            if self.appear(self.I_SP_SWIPE_CHECK) or self.appear(self.I_SOLD_OUT):
                 # 如果滑动到底了
                 logger.info('Swipe to bottom')
                 break

+ 9 - 0
tasks/RichMan/mall/special/image.json

@@ -34,5 +34,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "判断是否滑动到底"
+  },
+  {
+    "itemName": "sold_out",
+    "imageName": "special_sold_out.png",
+    "roiFront": "442,344,54,32",
+    "roiBack": "142,312,876,290",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "售罄"
   }
 ]

BIN
tasks/RichMan/mall/special/special_sold_out.png