yEs1do 2 лет назад
Родитель
Сommit
3d50c0a271
3 измененных файлов с 58 добавлено и 9 удалено
  1. 4 0
      tasks/WantedQuests/assets.py
  2. 18 0
      tasks/WantedQuests/ocr.json
  3. 36 9
      tasks/WantedQuests/script_task.py

+ 4 - 0
tasks/WantedQuests/assets.py

@@ -30,6 +30,10 @@ class WantedQuestsAssets:
 	O_WQ_NUM_1 = RuleOcr(roi=(32,260,72,27), area=(32,260,72,27), mode="DigitCounter", method="Default", keyword="", name="wq_num_1")
 	O_WQ_NUM_1 = RuleOcr(roi=(32,260,72,27), area=(32,260,72,27), mode="DigitCounter", method="Default", keyword="", name="wq_num_1")
 	# Ocr-description 
 	# Ocr-description 
 	O_WQ_NUM_2 = RuleOcr(roi=(34,406,65,24), area=(34,406,65,24), mode="DigitCounter", method="Default", keyword="", name="wq_num_2")
 	O_WQ_NUM_2 = RuleOcr(roi=(34,406,65,24), area=(34,406,65,24), mode="DigitCounter", method="Default", keyword="", name="wq_num_2")
+	# 备用识别1 
+	O_WQ_NUM_UNKNOWN_1 = RuleOcr(roi=(32,260,72,27), area=(32,260,72,27), mode="Digit", method="Default", keyword="", name="wq_num_unknown_1")
+	# 备用识别2 
+	O_WQ_NUM_UNKNOWN_2 = RuleOcr(roi=(34,406,65,24), area=(34,406,65,24), mode="Digit", method="Default", keyword="", name="wq_num_unknown_2")
 	# Ocr-description 
 	# Ocr-description 
 	O_WQ_TYPE_1 = RuleOcr(roi=(544,238,55,36), area=(544,238,55,36), mode="Single", method="Default", keyword="", name="wq_type_1")
 	O_WQ_TYPE_1 = RuleOcr(roi=(544,238,55,36), area=(544,238,55,36), mode="Single", method="Default", keyword="", name="wq_type_1")
 	# Ocr-description 
 	# Ocr-description 

+ 18 - 0
tasks/WantedQuests/ocr.json

@@ -53,6 +53,24 @@
     "keyword": "",
     "keyword": "",
     "description": "Ocr-description"
     "description": "Ocr-description"
   },
   },
+  {
+    "itemName": "wq_num_unknown_1",
+    "roiFront": "32,260,72,27",
+    "roiBack": "32,260,72,27",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "备用识别1"
+  },
+  {
+    "itemName": "wq_num_unknown_2",
+    "roiFront": "34,406,65,24",
+    "roiBack": "34,406,65,24",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "备用识别2"
+  },
   {
   {
     "itemName": "wq_type_1",
     "itemName": "wq_type_1",
     "roiFront": "544,238,55,36",
     "roiFront": "544,238,55,36",

+ 36 - 9
tasks/WantedQuests/script_task.py

@@ -30,6 +30,11 @@ from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 
 
 class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
 class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
     want_strategy_excluding: list[list] = []  # 不需要执行的
     want_strategy_excluding: list[list] = []  # 不需要执行的
+    # 可加入特殊处理悬赏
+    custom_strategy = {
+        "道成夙怨·壹",
+        "特殊地点B",
+    }
 
 
     def run(self):
     def run(self):
         con = self.config.model.wanted_quests
         con = self.config.model.wanted_quests
@@ -64,8 +69,12 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             if self.ocr_appear(self.O_WQ_TEXT_1, interval=1):
             if self.ocr_appear(self.O_WQ_TEXT_1, interval=1):
                 cu, re, total = self.O_WQ_NUM_1.ocr(self.device.image)
                 cu, re, total = self.O_WQ_NUM_1.ocr(self.device.image)
                 if cu == re == total == 0:
                 if cu == re == total == 0:
-                    logger.warning('OCR failed and skip this round')
+                    logger.warning('OCR failed and have a try')
                     ocr_error_count += 1
                     ocr_error_count += 1
+                    # 尝试打一次
+                    unknown_num = self.O_WQ_NUM_UNKNOWN_1.ocr(self.device.image)
+                    if unknown_num > 14:
+                        self.execute_mission(self.O_WQ_TEXT_1, 1, number_challenge)
                 if cu > total:
                 if cu > total:
                     logger.warning('Current number of wanted quests is greater than total number')
                     logger.warning('Current number of wanted quests is greater than total number')
                     cu = cu % 10
                     cu = cu % 10
@@ -75,8 +84,12 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             if self.ocr_appear(self.O_WQ_TEXT_2, interval=1):
             if self.ocr_appear(self.O_WQ_TEXT_2, interval=1):
                 cu, re, total = self.O_WQ_NUM_2.ocr(self.device.image)
                 cu, re, total = self.O_WQ_NUM_2.ocr(self.device.image)
                 if cu == re == total == 0:
                 if cu == re == total == 0:
-                    logger.warning('OCR failed and skip this round')
+                    logger.warning('OCR failed and have a try')
                     ocr_error_count += 1
                     ocr_error_count += 1
+                    # 尝试打一次
+                    unknown_num = self.O_WQ_NUM_UNKNOWN_2.ocr(self.device.image)
+                    if unknown_num > 14:
+                        self.execute_mission(self.O_WQ_TEXT_2, 1, number_challenge)
                 if cu > total:
                 if cu > total:
                     logger.warning('Current number of wanted quests is greater than total number')
                     logger.warning('Current number of wanted quests is greater than total number')
                     cu = cu % 10
                     cu = cu % 10
@@ -177,7 +190,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             :return:
             :return:
             (type, destination, number, goto_button)
             (type, destination, number, goto_button)
             (类型, 地点层级,可以打败的数量,前往按钮)
             (类型, 地点层级,可以打败的数量,前往按钮)
-            类型: 探索0, 挑战1, 秘闻2
+            类型: 挑战0, 探索1, 秘闻2
             """
             """
             result = [-1, '', -1, GOTO_BUTTON[index]]
             result = [-1, '', -1, GOTO_BUTTON[index]]
             type_wq = OCR_WQ_TYPE[index].ocr(self.device.image)
             type_wq = OCR_WQ_TYPE[index].ocr(self.device.image)
@@ -191,10 +204,10 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             wq_number = int(match.group(2))
             wq_number = int(match.group(2))
             result[1] = wq_destination
             result[1] = wq_destination
             result[2] = wq_number
             result[2] = wq_number
-            if type_wq == '探索':
-                result[0] = 0
-            elif type_wq == '挑战':
-                result[0] = 1 if num_challenge >= 10 else -1
+            if type_wq == '挑战':
+                result[0] = 0 if num_challenge >= 10 else -1
+            elif type_wq == '探索':
+                result[0] = 1
             elif type_wq == '秘闻':
             elif type_wq == '秘闻':
                 result[0] = 2
                 result[0] = 2
             logger.info(f'[Wanted Quests] type: {type_wq} destination: {wq_destination} number: {wq_number} ')
             logger.info(f'[Wanted Quests] type: {type_wq} destination: {wq_destination} number: {wq_number} ')
@@ -222,6 +235,20 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         if not info_wq_list:
         if not info_wq_list:
             logger.warning('No wanted quests can be challenged')
             logger.warning('No wanted quests can be challenged')
             return False
             return False
+        # 检查特殊悬赏
+        for i in range(4):
+            best_type, destination, once_number, goto_button = info_wq_list[i]
+            if destination in self.custom_strategy:
+                logger.info("Start running a custom strategy")
+                do_number = 1 if once_number >= num_want else num_want // once_number + (1 if num_want % once_number > 0 else 0)
+                match best_type:
+                    case 0:
+                        self.challenge(goto_button, do_number)
+                    case 1:
+                        self.explore(goto_button, do_number)
+                    case 2:
+                        self.secret(goto_button, do_number)
+                return True
         # sort
         # sort
         info_wq_list.sort(key=lambda x: x[0])
         info_wq_list.sort(key=lambda x: x[0])
         best_type, destination, once_number, goto_button = info_wq_list[0]
         best_type, destination, once_number, goto_button = info_wq_list[0]
@@ -229,9 +256,9 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         try:
         try:
             match best_type:
             match best_type:
                 case 0:
                 case 0:
-                    self.explore(goto_button, do_number)
-                case 1:
                     self.challenge(goto_button, do_number)
                     self.challenge(goto_button, do_number)
+                case 1:
+                    self.explore(goto_button, do_number)
                 case 2:
                 case 2:
                     self.secret(goto_button, do_number)
                     self.secret(goto_button, do_number)
                 case _:
                 case _: