Browse Source

fix(Dokan): assets file name issue

jackyhwei 2 years ago
parent
commit
b25f6fec8c
3 changed files with 22 additions and 21 deletions
  1. 6 6
      tasks/Dokan/assets.py
  2. 8 8
      tasks/Dokan/res/image.json
  3. 8 7
      tasks/Dokan/script_task.py

+ 6 - 6
tasks/Dokan/assets.py

@@ -35,17 +35,17 @@ class DokanAssets:
 	# 是否已经成功进入道馆,上面中间的“道馆突破”文字 
 	I_RYOU_DOKAN_CHECK = RuleImage(roi_front=(567,15,144,42), roi_back=(567,15,144,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_check.png")
 	# 优先攻击选项 
-	I_RYOU_DOKAN_ATTACK_PRIORITY = RuleImage(roi_front=(567,15,144,42), roi_back=(567,15,144,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority.png")
+	I_RYOU_DOKAN_ATTACK_PRIORITY = RuleImage(roi_front=(666,672,58,25), roi_back=(666,672,58,25), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority.png")
 	# 优先攻击: 见习 
-	I_RYOU_DOKAN_ATTACK_PRIORITY_0 = RuleImage(roi_front=(98,170,94,43), roi_back=(98,170,94,43), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_0.png")
+	I_RYOU_DOKAN_ATTACK_PRIORITY_0 = RuleImage(roi_front=(98,170,94,43), roi_back=(98,170,94,43), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_0.png")
 	# 优先攻击: 初级 
-	I_RYOU_DOKAN_ATTACK_PRIORITY_1 = RuleImage(roi_front=(342,175,96,42), roi_back=(342,175,96,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_1.png")
+	I_RYOU_DOKAN_ATTACK_PRIORITY_1 = RuleImage(roi_front=(342,175,96,42), roi_back=(342,175,96,42), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_1.png")
 	# 优先攻击: 中级 
-	I_RYOU_DOKAN_ATTACK_PRIORITY_2 = RuleImage(roi_front=(585,175,89,35), roi_back=(585,175,89,35), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_2.png")
+	I_RYOU_DOKAN_ATTACK_PRIORITY_2 = RuleImage(roi_front=(585,175,89,35), roi_back=(585,175,89,35), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_2.png")
 	# 优先攻击: 高级 
-	I_RYOU_DOKAN_ATTACK_PRIORITY_3 = RuleImage(roi_front=(830,175,88,41), roi_back=(830,175,88,41), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_3.png")
+	I_RYOU_DOKAN_ATTACK_PRIORITY_3 = RuleImage(roi_front=(830,175,88,41), roi_back=(830,175,88,41), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_3.png")
 	# 优先攻击: 黑脸 
-	I_RYOU_DOKAN_ATTACK_PRIORITY_4 = RuleImage(roi_front=(1072,178,94,39), roi_back=(1072,178,94,39), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_attack_priority_4.png")
+	I_RYOU_DOKAN_ATTACK_PRIORITY_4 = RuleImage(roi_front=(1072,178,94,39), roi_back=(1072,178,94,39), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_priority_4.png")
 	# 状态:集结等待中。检查右下角的挑战是不是灰色的。FIXME 黄色和灰色的挑战截图总是傻傻分不清,先改用OCR 
 	I_RYOU_DOKAN_GATHERING = RuleImage(roi_front=(653,76,46,26), roi_back=(653,76,46,26), threshold=0.85, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_gathering.png")
 	# 状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗 

+ 8 - 8
tasks/Dokan/res/image.json

@@ -46,16 +46,16 @@
   },
   {
     "itemName": "ryou_dokan_attack_priority",
-    "imageName": "res_ryou_dokan_attack_priority.png",
-    "roiFront": "567,15,144,42",
-    "roiBack": "567,15,144,42",
+    "imageName": "res_ryou_dokan_priority.png",
+    "roiFront": "666,672,58,25",
+    "roiBack": "666,672,58,25",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "优先攻击选项"
   },
   {
     "itemName": "ryou_dokan_attack_priority_0",
-    "imageName": "res_ryou_dokan_attack_priority_0.png",
+    "imageName": "res_ryou_dokan_priority_0.png",
     "roiFront": "98,170,94,43",
     "roiBack": "98,170,94,43",
     "method": "Template matching",
@@ -64,7 +64,7 @@
   },
   {
     "itemName": "ryou_dokan_attack_priority_1",
-    "imageName": "res_ryou_dokan_attack_priority_1.png",
+    "imageName": "res_ryou_dokan_priority_1.png",
     "roiFront": "342,175,96,42",
     "roiBack": "342,175,96,42",
     "method": "Template matching",
@@ -73,7 +73,7 @@
   },
   {
     "itemName": "ryou_dokan_attack_priority_2",
-    "imageName": "res_ryou_dokan_attack_priority_2.png",
+    "imageName": "res_ryou_dokan_priority_2.png",
     "roiFront": "585,175,89,35",
     "roiBack": "585,175,89,35",
     "method": "Template matching",
@@ -82,7 +82,7 @@
   },
   {
     "itemName": "ryou_dokan_attack_priority_3",
-    "imageName": "res_ryou_dokan_attack_priority_3.png",
+    "imageName": "res_ryou_dokan_priority_3.png",
     "roiFront": "830,175,88,41",
     "roiBack": "830,175,88,41",
     "method": "Template matching",
@@ -91,7 +91,7 @@
   },
   {
     "itemName": "ryou_dokan_attack_priority_4",
-    "imageName": "res_ryou_dokan_attack_priority_4.png",
+    "imageName": "res_ryou_dokan_priority_4.png",
     "roiFront": "1072,178,94,39",
     "roiBack": "1072,178,94,39",
     "method": "Template matching",

+ 8 - 7
tasks/Dokan/script_task.py

@@ -142,12 +142,13 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
                 if not self.attack_priority_selected:
                     self.dokan_choose_attack_priority(attack_priority=attack_priority)
                     self.attack_priority_selected = True
+                    continue
             # 场景状态:等待馆主战开始
             elif current_scene == DokanScene.RYOU_DOKAN_SCENE_BOSS_WAITING:
                 logger.debug(f"Ryou DOKAN boss battle waiting...")
             # 场景状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
             elif current_scene == DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE:
-                self.appear_then_click(self.I_RYOU_DOKAN_START_CHALLENGE, 1.2)
+                self.appear_then_click(self.I_RYOU_DOKAN_START_CHALLENGE, interval=1.2)
             # 场景状态:进入战斗,待开始
             elif current_scene == DokanScene.RYOU_DOKAN_SCENE_IN_FIELD:
                 # 战斗
@@ -166,9 +167,9 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
             # 场景状态:战斗中,左上角的加油图标
             elif current_scene == DokanScene.RYOU_DOKAN_SCENE_FIGHTING:
                 logger.info("Battle undergoing")
-            # 场景状态:加油中
-            elif current_scene == DokanScene.RYOU_DOKAN_SCENE_CHEERING:
-                self.appear_then_click(self.I_RYOU_DOKAN_CHEERING)
+            # # 场景状态:加油中
+            # elif current_scene == DokanScene.RYOU_DOKAN_SCENE_CHEERING:
+            #     self.appear_then_click(self.I_RYOU_DOKAN_CHEERING)
             # 场景状态:道馆已经结束
             elif current_scene == DokanScene.RYOU_DOKAN_SCENE_FINISHED:
                 logger.info("Dokan challenge finished, exit Dokan")
@@ -217,12 +218,11 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
             time.sleep(3)
 
         # 等待准备按钮的出现
-        logger.debug("等待准备按钮的出现")
         self.wait_until_appear(self.I_PREPARE_HIGHLIGHT)
 
         # 点击准备
         if self.appear_then_click(self.I_PREPARE_HIGHLIGHT, interval=1.5):
-            logger.info("点击准备")
+            logger.info("Prepare")
 
             # 绿标式神, should we check there's a green marked role?
             if not self.green_mark_done and self.is_in_battle(False):
@@ -426,7 +426,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
 
                 pos = self.O_DOKAN_MAP.ocr_full(image)
                 if pos == (0, 0, 0, 0):
-                    logger.info("failed to find {self.O_DOKAN_MAP.keyword}")
+                    logger.info(f"failed to find {self.O_DOKAN_MAP.keyword}")
                 else:
                     # 取中间
                     x = pos[0] + pos[2] / 2
@@ -478,6 +478,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DokanAssets):
         # 状态:达到失败次数,CD中
         if self.appear(self.I_RYOU_DOKAN_CD, threshold=0.8):
             return True, DokanScene.RYOU_DOKAN_SCENE_CD
+        
         # # 状态:加油中,左下角有鼓
         # if self.appear_then_click(self.I_RYOU_DOKAN_CHEERING, threshold=0.8) or self.appear(
         #         self.I_RYOU_DOKAN_CHEERING_GRAY, threshold=0.8):