Browse Source

Merge pull request #643 from ChengRanORZ/soultidy

fix(Soultidy) 优化
huangrunheng 1 year ago
parent
commit
29de691030

+ 6 - 0
tasks/SoulsTidy/assets.py

@@ -42,6 +42,12 @@ class SoulsTidyAssets:
 	I_ST_DONATE = RuleImage(roi_front=(813,628,126,68), roi_back=(813,628,126,68), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_donate.png")
 	# 神赐 
 	I_ST_GOD_PRESENT = RuleImage(roi_front=(578,234,131,73), roi_back=(542,117,204,219), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_god_present.png")
+	# 已弃置被选中 
+	I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(20,110,140,50), roi_back=(20,110,140,50), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
+	# 第一个御魂是+0的 
+	I_ST_LEVEL_0 = RuleImage(roi_front=(85,235,45,30), roi_back=(85,235,45,30), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_level_0.png")
+	# 御魂奉纳后获得的金币 
+	I_ST_GOLD = RuleImage(roi_front=(170,100,950,500), roi_back=(170,100,950,500), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_gold.png")
 
 
 	# Long Click Rule Assets

+ 34 - 34
tasks/SoulsTidy/script_task.py

@@ -14,6 +14,7 @@ from tasks.GameUi.page import page_main, page_shikigami_records
 from tasks.SoulsTidy.assets import SoulsTidyAssets
 from tasks.SoulsTidy.config import SimpleTidy
 
+
 class ScriptTask(GameUi, SoulsTidyAssets):
     def run(self):
         self.ui_get_current_page()
@@ -89,6 +90,12 @@ class ScriptTask(GameUi, SoulsTidyAssets):
             if self.appear_then_click(self.I_ST_BONGNA, interval=1, threshold=0.6):
                 continue
         logger.hr('Enter bongna')
+        # 进入已弃置界面
+        while True:
+            if not self.appear(self.I_ST_ABANDONED_SELECTED):
+                self.click(self.I_ST_ABANDONED_SELECTED, interval=2)
+                continue
+            break
         # 确保是按照等级来排序的
         while 1:
             self.screenshot()
@@ -105,27 +112,37 @@ class ScriptTask(GameUi, SoulsTidyAssets):
         logger.info('Sort by level')
         # 开始奉纳
         while 1:
+            self.wait_until_appear(self.I_ST_LEVEL_0, wait_time=2)
             self.screenshot()
+            # 非+0的不弃置 双保险
+            if not self.appear(self.I_ST_LEVEL_0):
+                logger.info("First Orichi isn't Level 0,quit")
+                break
             firvel = self.O_ST_FIRSET_LEVEL.ocr(self.device.image)
+            if firvel is None or firvel == '':
+                logger.info('ocr result is Null')
+                continue
             if firvel != '古':
                 # 问就是 把 +0 识别成了 古
                 logger.info('No zero level, bongna done')
                 break
+
             # !!!!!!  这里没有检查金币是否足够
             # 长按
-            while 1:
-                self.screenshot()
-                self.click(self.L_ONE, interval=2.5)
-                gold_amount = self.O_ST_GOLD.ocr(self.device.image)
-                if not isinstance(gold_amount, int):
-                    logger.warning('Gold amount not int, skip')
-                    continue
-                if gold_amount > 0:
-                    break
+            self.click(self.L_ONE, interval=2.5)
+            self.screenshot()
+            gold_amount = self.O_ST_GOLD.ocr(self.device.image)
+            if not isinstance(gold_amount, int):
+                logger.warning('Gold amount not int, skip')
+                continue
+            if gold_amount == 0:
+                continue
+
             # 点击奉纳收取奖励
             if not self.appear(self.I_ST_DONATE):
                 logger.warning('Donate button not appear, skip')
                 continue
+            # 点击奉纳 及收取奖励
             while 1:
                 self.screenshot()
                 if self.appear_then_click(self.I_UI_CONFIRM, interval=0.5):
@@ -136,42 +153,25 @@ class ScriptTask(GameUi, SoulsTidyAssets):
                 # 出现神赐, 就点击然后消失,
                 if self.appear(self.I_ST_GOD_PRESENT):
                     logger.info('God present appear')
-                    sleep(0.5)
-                    self.screenshot()
-                    if not self.appear(self.I_ST_GOD_PRESENT):
-                        continue
-                    while 1:
-                        self.screenshot()
-                        if not self.appear(self.I_ST_GOD_PRESENT):
-                            logger.info('God present disappear')
-                            break
-                        if self.click(self.C_ST_GOD_PRSENT, interval=1):
-                            continue
-                    sleep(0.5)
-                    break
+                    self.click(self.C_ST_GOD_PRSENT, interval=2)
+                    continue
                 if self.appear_then_click(self.I_ST_DONATE, interval=5.5):
+                    self.wait_until_appear(self.I_ST_GOLD, True, wait_time=5)
                     continue
+                if not self.appear(self.I_ST_GOLD):
+                    break
             logger.info('Donate one')
 
         logger.info('Bongna done')
 
 
-
-
-
-
-
-
-
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device
+
     c = Config('oas1')
     d = Device(c)
     t = ScriptTask(c, d)
-    t.screenshot()
-
-
-    # t.greed_maneki()
-    t.run()
 
+    t.greed_maneki()
+    # t.run()

+ 27 - 0
tasks/SoulsTidy/simple/image.json

@@ -106,5 +106,32 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "神赐"
+  },
+  {
+    "itemName": "st_abandoned_selected",
+    "imageName": "simple_st_abandoned_selected.png",
+    "roiFront": "20,110,140,50",
+    "roiBack": "20,110,140,50",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "已弃置被选中"
+  },
+  {
+    "itemName": "st_level_0",
+    "imageName": "simple_st_level_0.png",
+    "roiFront": "85,235,45,30",
+    "roiBack": "85,235,45,30",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "第一个御魂是+0的"
+  },
+  {
+    "itemName": "st_gold",
+    "imageName": "simple_st_gold.png",
+    "roiFront": "170,100,950,500",
+    "roiBack": "170,100,950,500",
+    "method": "Template matching",
+    "threshold": 0.9,
+    "description": "御魂奉纳后获得的金币"
   }
 ]

BIN
tasks/SoulsTidy/simple/simple_st_abandoned_selected.png


BIN
tasks/SoulsTidy/simple/simple_st_gold.png


BIN
tasks/SoulsTidy/simple/simple_st_level_0.png