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

Merge pull request #327 from roarhill/dev

fix(Dokan): remove useless assets which may cause errors
huangrunheng 2 лет назад
Родитель
Сommit
f95b859e72
4 измененных файлов с 28 добавлено и 49 удалено
  1. 7 11
      tasks/Dokan/assets.py
  2. 1 1
      tasks/Dokan/res/click.json
  3. 8 26
      tasks/Dokan/res/image.json
  4. 12 11
      tasks/Dokan/script_task.py

+ 7 - 11
tasks/Dokan/assets.py

@@ -15,7 +15,7 @@ class DokanAssets:
 	C_DOKAN_RANDOM_CLICK_AREA = RuleClick(roi_front=(142,294,107,555), roi_back=(142,294,107,555), name="dokan_random_click_area")
 	C_DOKAN_RANDOM_CLICK_AREA = RuleClick(roi_front=(142,294,107,555), roi_back=(142,294,107,555), name="dokan_random_click_area")
 	# 道馆随机点击安全区域1:竂友突破信息 
 	# 道馆随机点击安全区域1:竂友突破信息 
 	C_DOKAN_RANDOM_CLICK_AREA1 = RuleClick(roi_front=(42,594,10,100), roi_back=(42,594,10,100), name="dokan_random_click_area1")
 	C_DOKAN_RANDOM_CLICK_AREA1 = RuleClick(roi_front=(42,594,10,100), roi_back=(42,594,10,100), name="dokan_random_click_area1")
-	# 道馆随机点击安全区域2:切换查看队伍模式 
+	# 道馆随机点击安全区域2:切换查看队伍模式。初步测试下来这个地方最安全,除了庭院、町中、逢魔外其他各场景都可用。 
 	C_DOKAN_RANDOM_CLICK_AREA2 = RuleClick(roi_front=(1122,360,10,40), roi_back=(1122,360,10,40), name="dokan_random_click_area2")
 	C_DOKAN_RANDOM_CLICK_AREA2 = RuleClick(roi_front=(1122,360,10,40), roi_back=(1122,360,10,40), name="dokan_random_click_area2")
 	# 道馆随机点击安全区域3 
 	# 道馆随机点击安全区域3 
 	C_DOKAN_RANDOM_CLICK_AREA3 = RuleClick(roi_front=(333,44,107,20), roi_back=(333,44,107,20), name="dokan_random_click_area3")
 	C_DOKAN_RANDOM_CLICK_AREA3 = RuleClick(roi_front=(333,44,107,20), roi_back=(333,44,107,20), name="dokan_random_click_area3")
@@ -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_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 
 	# 状态:集结等待中。检查右下角的挑战是不是灰色的。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")
 	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")
 	# 状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗 
 	# 状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗 
@@ -66,10 +66,6 @@ class DokanAssets:
 	I_RYOU_DOKAN_BATTLE_OVER = RuleImage(roi_front=(571,503,106,49), roi_back=(571,503,106,49), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_battle_over.png")
 	I_RYOU_DOKAN_BATTLE_OVER = RuleImage(roi_front=(571,503,106,49), roi_back=(571,503,106,49), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_battle_over.png")
 	# 状态:战斗中,左上角的加油图标 
 	# 状态:战斗中,左上角的加油图标 
 	I_RYOU_DOKAN_FIGHTING = RuleImage(roi_front=(232,36,42,19), roi_back=(232,36,42,19), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_fighting.png")
 	I_RYOU_DOKAN_FIGHTING = RuleImage(roi_front=(232,36,42,19), roi_back=(232,36,42,19), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_fighting.png")
-	# 状态:加油中,左下角有鼓 
-	I_RYOU_DOKAN_CHEERING = RuleImage(roi_front=(68,597,69,33), roi_back=(68,597,69,33), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cheering.png")
-	# 状态:加油中,左下角有鼓,灰色的鼓 
-	I_RYOU_DOKAN_CHEERING_GRAY = RuleImage(roi_front=(59,600,81,38), roi_back=(59,600,81,38), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_cheering_gray.png")
 	# 状态:道馆已经结束 
 	# 状态:道馆已经结束 
 	I_RYOU_DOKAN_FINISHED = RuleImage(roi_front=(658,649,91,27), roi_back=(658,649,91,27), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_finished.png")
 	I_RYOU_DOKAN_FINISHED = RuleImage(roi_front=(658,649,91,27), roi_back=(658,649,91,27), threshold=0.8, method="Template matching", file="./tasks/Dokan/res/res_ryou_dokan_finished.png")
 	# 状态:道馆挑战失败,投票NO 
 	# 状态:道馆挑战失败,投票NO 

+ 1 - 1
tasks/Dokan/res/click.json

@@ -15,7 +15,7 @@
     "itemName": "dokan_random_click_area2",
     "itemName": "dokan_random_click_area2",
     "roiFront": "1122,360,10,40",
     "roiFront": "1122,360,10,40",
     "roiBack": "1122,360,10,40",
     "roiBack": "1122,360,10,40",
-    "description": "道馆随机点击安全区域2:切换查看队伍模式"
+    "description": "道馆随机点击安全区域2:切换查看队伍模式。初步测试下来这个地方最安全,除了庭院、町中、逢魔外其他各场景都可用。"
   },
   },
   {
   {
     "itemName": "dokan_random_click_area3",
     "itemName": "dokan_random_click_area3",

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

@@ -46,16 +46,16 @@
   },
   },
   {
   {
     "itemName": "ryou_dokan_attack_priority",
     "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",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "优先攻击选项"
     "description": "优先攻击选项"
   },
   },
   {
   {
     "itemName": "ryou_dokan_attack_priority_0",
     "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",
     "roiFront": "98,170,94,43",
     "roiBack": "98,170,94,43",
     "roiBack": "98,170,94,43",
     "method": "Template matching",
     "method": "Template matching",
@@ -64,7 +64,7 @@
   },
   },
   {
   {
     "itemName": "ryou_dokan_attack_priority_1",
     "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",
     "roiFront": "342,175,96,42",
     "roiBack": "342,175,96,42",
     "roiBack": "342,175,96,42",
     "method": "Template matching",
     "method": "Template matching",
@@ -73,7 +73,7 @@
   },
   },
   {
   {
     "itemName": "ryou_dokan_attack_priority_2",
     "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",
     "roiFront": "585,175,89,35",
     "roiBack": "585,175,89,35",
     "roiBack": "585,175,89,35",
     "method": "Template matching",
     "method": "Template matching",
@@ -82,7 +82,7 @@
   },
   },
   {
   {
     "itemName": "ryou_dokan_attack_priority_3",
     "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",
     "roiFront": "830,175,88,41",
     "roiBack": "830,175,88,41",
     "roiBack": "830,175,88,41",
     "method": "Template matching",
     "method": "Template matching",
@@ -91,7 +91,7 @@
   },
   },
   {
   {
     "itemName": "ryou_dokan_attack_priority_4",
     "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",
     "roiFront": "1072,178,94,39",
     "roiBack": "1072,178,94,39",
     "roiBack": "1072,178,94,39",
     "method": "Template matching",
     "method": "Template matching",
@@ -193,24 +193,6 @@
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "状态:战斗中,左上角的加油图标"
     "description": "状态:战斗中,左上角的加油图标"
   },
   },
-  {
-    "itemName": "ryou_dokan_cheering",
-    "imageName": "res_ryou_dokan_cheering.png",
-    "roiFront": "68,597,69,33",
-    "roiBack": "68,597,69,33",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "状态:加油中,左下角有鼓"
-  },
-  {
-    "itemName": "ryou_dokan_cheering_gray",
-    "imageName": "res_ryou_dokan_cheering_gray.png",
-    "roiFront": "59,600,81,38",
-    "roiBack": "59,600,81,38",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "状态:加油中,左下角有鼓,灰色的鼓"
-  },
   {
   {
     "itemName": "ryou_dokan_finished",
     "itemName": "ryou_dokan_finished",
     "imageName": "res_ryou_dokan_finished.png",
     "imageName": "res_ryou_dokan_finished.png",

+ 12 - 11
tasks/Dokan/script_task.py

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