Просмотр исходного кода

Merge pull request #530 from yEs1do/feat(DE_box)

逢魔宝箱买 50 勾玉蓝票
huangrunheng 2 лет назад
Родитель
Сommit
96b30e1bd6

+ 4 - 1
tasks/DemonEncounter/assets.py

@@ -73,7 +73,10 @@ class DemonEncounterAssets:
 	I_DE_SHI_RECORDS = RuleImage(roi_front=(789,639,48,48), roi_back=(789,639,48,48), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_shi_records.png")
 	I_DE_SHI_RECORDS = RuleImage(roi_front=(789,639,48,48), roi_back=(789,639,48,48), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_shi_records.png")
 	# 左下角小指针 
 	# 左下角小指针 
 	I_DE_LOCATION = RuleImage(roi_front=(26,653,44,47), roi_back=(26,653,44,47), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_location.png")
 	I_DE_LOCATION = RuleImage(roi_front=(26,653,44,47), roi_back=(26,653,44,47), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_location.png")
-
+	# 逢魔蓝票 
+	I_BLUE_PIAO = RuleImage(roi_front=(420,226,444,262), roi_back=(420,226,444,262), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/blue_piao.png")
+	# 50勾玉购买 
+	I_JADE_50 = RuleImage(roi_front=(420,226,444,262), roi_back=(420,226,444,262), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/jade_50.png")
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# 右侧的气球 
 	# 右侧的气球 

BIN
tasks/DemonEncounter/demon/blue_piao.png


+ 18 - 0
tasks/DemonEncounter/demon/image.json

@@ -52,5 +52,23 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "左下角小指针"
     "description": "左下角小指针"
+  },
+  {
+    "itemName": "blue_piao",
+    "imageName": "blue_piao.png",
+    "roiFront": "420,226,444,262",
+    "roiBack": "420,226,444,262",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "逢魔蓝票"
+  },
+  {
+    "itemName": "jade_50",
+    "imageName": "jade_50.png",
+    "roiFront": "420,226,444,262",
+    "roiBack": "420,226,444,262",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "50勾玉购买"
   }
   }
 ]
 ]

BIN
tasks/DemonEncounter/demon/jade_50.png


+ 21 - 7
tasks/DemonEncounter/script_task.py

@@ -200,7 +200,7 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
             lantern_type = self.check_lantern(i)
             lantern_type = self.check_lantern(i)
             match lantern_type:
             match lantern_type:
                 case LanternClass.BOX:
                 case LanternClass.BOX:
-                    self._box()
+                    self._box(match_click[i])
                 case LanternClass.MAIL:
                 case LanternClass.MAIL:
                     self._mail(match_click[i])
                     self._mail(match_click[i])
                 case LanternClass.REALM:
                 case LanternClass.REALM:
@@ -267,9 +267,23 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
             logger.info(f'Lantern {index} is battle')
             logger.info(f'Lantern {index} is battle')
             return LanternClass.BATTLE
             return LanternClass.BATTLE
 
 
-    def _box(self):
-        # 宝箱不领
-        pass
+    def _box(self, target_click):
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_JADE_50):
+                break
+            if self.click(target_click, interval=1):
+                continue
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_BLUE_PIAO):
+                if self.click(self.I_JADE_50):
+                    logger.info('Buy a mystery amulet for 50 jade')
+                    continue
+            if not self.appear(self.I_BLUE_PIAO):
+                if self.appear_then_click(self.I_DE_FIND, interval=2.5):
+                    break
+
 
 
     def _mail(self, target_click):
     def _mail(self, target_click):
         # 答题,还没有碰到过答题的
         # 答题,还没有碰到过答题的
@@ -446,9 +460,9 @@ if __name__ == '__main__':
     from module.device.device import Device
     from module.device.device import Device
     from memory_profiler import profile
     from memory_profiler import profile
 
 
-    c = Config('oas1')
+    c = Config('du')
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
-    # t.run()
-    t.battle_wait(True)
+    t.run()
+    # t.battle_wait(True)