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

Merge pull request #296 from runhey/duel

Duel
huangrunheng 2 лет назад
Родитель
Сommit
6e7051469f

+ 6 - 2
tasks/Duel/assets.py

@@ -23,9 +23,9 @@ class DuelAssets:
 	# 观战 
 	I_D_VISIT = RuleImage(roi_front=(1045,613,53,55), roi_back=(1045,613,53,55), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_visit.png")
 	# description 
-	I_D_BATTLE = RuleImage(roi_front=(1143,566,100,100), roi_back=(1143,566,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle.png")
+	I_D_BATTLE = RuleImage(roi_front=(1153,573,100,100), roi_back=(1123,537,154,177), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle.png")
 	# 战斗带保护的 
-	I_D_BATTLE_PROTECT = RuleImage(roi_front=(1145,563,100,100), roi_back=(1145,563,100,100), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle_protect.png")
+	I_D_BATTLE_PROTECT = RuleImage(roi_front=(1153,578,100,100), roi_back=(1118,553,155,149), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle_protect.png")
 	# 预选点击确认 
 	I_D_CONFIRM = RuleImage(roi_front=(1097,517,139,156), roi_back=(1097,517,139,156), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_confirm.png")
 	# 自动上阵 
@@ -50,6 +50,10 @@ class DuelAssets:
 	I_D_CELEB_STAR = RuleImage(roi_front=(586,456,30,32), roi_back=(574,444,53,54), threshold=0.75, method="Template matching", file="./tasks/Duel/duel/duel_d_celeb_star.png")
 	# 名士专属 
 	I_D_CELEB_HONOR = RuleImage(roi_front=(665,531,25,30), roi_back=(652,517,52,53), threshold=0.75, method="Template matching", file="./tasks/Duel/duel/duel_d_celeb_honor.png")
+	# 练 
+	I_BATTLE_WITH_TRAIN = RuleImage(roi_front=(1161,588,78,81), roi_back=(1114,547,163,172), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_battle_with_train.png")
+	# 活动的战斗按钮 
+	I_D_BATTLE2 = RuleImage(roi_front=(1171,592,69,78), roi_back=(1119,566,154,143), threshold=0.8, method="Template matching", file="./tasks/Duel/duel/duel_d_battle2.png")
 
 
 	# Ocr Rule Assets

BIN
tasks/Duel/duel/duel_battle_with_train.png


BIN
tasks/Duel/duel/duel_d_battle2.png


+ 22 - 4
tasks/Duel/duel/image.json

@@ -29,8 +29,8 @@
   {
     "itemName": "d_battle",
     "imageName": "duel_d_battle.png",
-    "roiFront": "1143,566,100,100",
-    "roiBack": "1143,566,100,100",
+    "roiFront": "1153,573,100,100",
+    "roiBack": "1123,537,154,177",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -38,8 +38,8 @@
   {
     "itemName": "d_battle_protect",
     "imageName": "duel_d_battle_protect.png",
-    "roiFront": "1145,563,100,100",
-    "roiBack": "1145,563,100,100",
+    "roiFront": "1153,578,100,100",
+    "roiBack": "1118,553,155,149",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "战斗带保护的"
@@ -151,5 +151,23 @@
     "method": "Template matching",
     "threshold": 0.75,
     "description": "名士专属"
+  },
+  {
+    "itemName": "battle_with_train",
+    "imageName": "duel_battle_with_train.png",
+    "roiFront": "1161,588,78,81",
+    "roiBack": "1114,547,163,172",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "练"
+  },
+  {
+    "itemName": "d_battle2",
+    "imageName": "duel_d_battle2.png",
+    "roiFront": "1171,592,69,78",
+    "roiBack": "1119,566,154,143",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "活动的战斗按钮"
   }
 ]

+ 16 - 2
tasks/Duel/script_task.py

@@ -5,7 +5,7 @@ from time import sleep
 from datetime import time, datetime, timedelta
 
 from module.logger import logger
-from module.exception import TaskEnd
+from module.exception import TaskEnd, RequestHumanTakeover
 from module.base.timer import Timer
 
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
@@ -106,7 +106,17 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
                 logger.info('You are already a celeb')
                 return None
             current_score = self.O_D_SCORE.ocr(self.device.image)
-            if current_score < 1200 or current_score > 3000:
+            if current_score < 1200:
+                # 分太低了
+                logger.warning('Score is too low')
+                logger.error('Please enhance your score')
+                raise RequestHumanTakeover
+            elif current_score > 10000:
+                # 识别错误分数超过一万, 去掉最高位
+                logger.warning('Recognition error, score is too high')
+                logger.warning('Remove the highest digit')
+                current_score = int(str(current_score)[1:])
+            elif current_score > 3000:
                 continue
             return current_score if current_score <= target else None
 
@@ -125,6 +135,10 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
                 break
             if self.appear_then_click(self.I_D_BATTLE, interval=1):
                 continue
+            if self.appear_then_click(self.I_D_BATTLE2, interval=1):
+                continue
+            if self.appear_then_click(self.I_BATTLE_WITH_TRAIN, interval=1):
+                continue
             if self.appear_then_click(self.I_D_BATTLE_PROTECT, interval=1.6):
                 continue
         # 点击斗技 开始匹配对手