Преглед изворни кода

Merge pull request #1539 from LGG686/dev-ui

Dev UI
huangrunheng пре 6 месеци
родитељ
комит
c36c51150f

+ 4 - 4
tasks/EvoZone/assets.py

@@ -12,7 +12,7 @@ class EvoZoneAssets:
 
 	# Image Rule Assets
 	# 火麒麟进入 
-	I_FIRE_KIRIN = RuleImage(roi_front=(104,120,217,406), roi_back=(104,120,217,406), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_fire_kirin.png")
+	I_FIRE_KIRIN = RuleImage(roi_front=(104,120,217,325), roi_back=(104,120,217,325), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_fire_kirin.png")
 	# 组队 
 	I_FORM_TEAM = RuleImage(roi_front=(959,580,100,100), roi_back=(916,572,156,130), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_form_team.png")
 	# description 
@@ -26,11 +26,11 @@ class EvoZoneAssets:
 	# 小小宠物,发现宝藏 
 	I_PET_PRESENT = RuleImage(roi_front=(873,184,62,147), roi_back=(873,184,62,147), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_pet_present.png")
 	# 风麒麟进入 
-	I_WIND_KIRIN = RuleImage(roi_front=(410,116,225,320), roi_back=(410,116,225,320), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_wind_kirin.png")
+	I_WIND_KIRIN = RuleImage(roi_front=(423,116,201,250), roi_back=(423,116,201,250), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_wind_kirin.png")
 	# 水麒麟进入 
-	I_WATER_KIRIN = RuleImage(roi_front=(705,115,224,378), roi_back=(705,115,224,378), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_water_kirin.png")
+	I_WATER_KIRIN = RuleImage(roi_front=(728,115,201,342), roi_back=(728,115,201,342), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_water_kirin.png")
 	# 雷麒麟进入 
-	I_LIGHTNING_KIRIN = RuleImage(roi_front=(1005,99,229,326), roi_back=(1005,99,229,326), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_lightning_kirin.png")
+	I_LIGHTNING_KIRIN = RuleImage(roi_front=(1016,99,218,270), roi_back=(1016,99,218,270), threshold=0.8, method="Template matching", file="./tasks/EvoZone/o/o_lightning_kirin.png")
 
 
 	# List Rule Assets

+ 8 - 8
tasks/EvoZone/o/image.json

@@ -2,8 +2,8 @@
   {
     "itemName": "fire_kirin",
     "imageName": "o_fire_kirin.png",
-    "roiFront": "104,120,217,406",
-    "roiBack": "104,120,217,406",
+    "roiFront": "104,120,217,325",
+    "roiBack": "104,120,217,325",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "火麒麟进入"
@@ -65,8 +65,8 @@
   {
     "itemName": "wind_kirin",
     "imageName": "o_wind_kirin.png",
-    "roiFront": "410,116,225,320",
-    "roiBack": "410,116,225,320",
+    "roiFront": "423,116,201,250",
+    "roiBack": "423,116,201,250",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "风麒麟进入"
@@ -74,8 +74,8 @@
   {
     "itemName": "water_kirin",
     "imageName": "o_water_kirin.png",
-    "roiFront": "705,115,224,378",
-    "roiBack": "705,115,224,378",
+    "roiFront": "728,115,201,342",
+    "roiBack": "728,115,201,342",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "水麒麟进入"
@@ -83,8 +83,8 @@
   {
     "itemName": "lightning_kirin",
     "imageName": "o_lightning_kirin.png",
-    "roiFront": "1005,99,229,326",
-    "roiBack": "1005,99,229,326",
+    "roiFront": "1016,99,218,270",
+    "roiBack": "1016,99,218,270",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "雷麒麟进入"

BIN
tasks/EvoZone/o/o_fire_kirin.png


BIN
tasks/EvoZone/o/o_lightning_kirin.png


BIN
tasks/EvoZone/o/o_water_kirin.png


BIN
tasks/EvoZone/o/o_wind_kirin.png


+ 1 - 1
tasks/GameUi/assets.py

@@ -44,7 +44,7 @@ class GameUiAssets:
 	# description 
 	I_MAIN_GOTO_EXPLORATION = RuleImage(roi_front=(493,116,45,75), roi_back=(243,100,933,211), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_exploration.png")
 	# description 
-	I_CHECK_EXPLORATION = RuleImage(roi_front=(1103,675,23,20), roi_back=(1063,643,91,76), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_exploration.png")
+	I_CHECK_EXPLORATION = RuleImage(roi_front=(681,12,27,36), roi_back=(661,0,70,61), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_exploration.png")
 	# 探索前往觉醒 
 	I_EXPLORATION_GOTO_AWAKE_ZONE = RuleImage(roi_front=(65,632,50,41), roi_back=(33,619,1125,98), threshold=0.65, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_awake_zone.png")
 	# 探索前往御魂 

BIN
tasks/GameUi/page/page_check_exploration.png


+ 2 - 2
tasks/GameUi/page/page_img.json

@@ -29,8 +29,8 @@
   {
     "itemName": "check_exploration",
     "imageName": "page_check_exploration.png",
-    "roiFront": "1103,675,23,20",
-    "roiBack": "1063,643,91,76",
+    "roiFront": "681,12,27,36",
+    "roiBack": "661,0,70,61",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

+ 9 - 41
tasks/GoryouRealm/script_task.py

@@ -1,19 +1,16 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
-from time import sleep
-from datetime import time, datetime, timedelta
-from random import randint
-
-from module.logger import logger
+from datetime import datetime, timedelta
 from module.exception import TaskEnd
-
+from module.logger import logger
+from random import choice
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_main, page_shikigami_records, page_goryou_realm
-from tasks.GoryouRealm.config import GoryouClass
+from tasks.GameUi.page import page_shikigami_records, page_goryou_realm
 from tasks.GoryouRealm.assets import GoryouRealmAssets
+from tasks.GoryouRealm.config import GoryouClass
 
 
 class ScriptTask(GeneralBattle, GameUi, SwitchSoul, GoryouRealmAssets):
@@ -36,12 +33,15 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, GoryouRealmAssets):
             GoryouClass.Dark_Black_Panther: self.C_GR_C_3,
             GoryouClass.Dark_Peacock: self.C_GR_C_4,
         }
+        goryou_class = con.goryou_config.goryou_class
+        if goryou_class == GoryouClass.RANDOM:
+            goryou_class = choice(list(match_click.keys()))
         while 1:
             self.screenshot()
             if self.appear(self.I_GR_FIRE):
                 logger.info('Enter GoryouRealm')
                 break
-            if self.click(match_click[self.check_date(con.goryou_config.goryou_class)], interval=1):
+            if self.click(match_click[goryou_class], interval=1):
                 continue
         self.check_lock(con.general_battle_config.lock_team_enable, self.I_GR_LOCK, self.I_GR_UNLOCK)
 
@@ -77,38 +77,6 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, GoryouRealmAssets):
         raise TaskEnd
 
 
-    def check_date(self, goryou_class: GoryouClass = GoryouClass.RANDOM) -> GoryouClass:
-        day_of_week = self.start_time.weekday()
-        if day_of_week == 0:
-            # 周一不开放,退出
-            logger.warning('Today is Monday and GoryouRealm is not open')
-            self.set_next_run(task='GoryouRealm', success=False, finish=True)
-            raise TaskEnd('GoryouRealm')
-
-        match_day = {
-            GoryouClass.RANDOM: [1, 2, 3, 4, 5, 6],
-            GoryouClass.Dark_Divine_Dragon: [1, 5, 6],
-            GoryouClass.Dark_Hakuzousu: [2, 5, 6],
-            GoryouClass.Dark_Black_Panther: [3, 5, 6],
-            GoryouClass.Dark_Peacock: [4, 5, 6],
-        }
-        match_class = {
-            1: GoryouClass.Dark_Divine_Dragon,
-            2: GoryouClass.Dark_Hakuzousu,
-            3: GoryouClass.Dark_Black_Panther,
-            4: GoryouClass.Dark_Peacock,
-        }
-        if goryou_class == GoryouClass.RANDOM:
-            random_num = randint(1, 4)
-            goryou_class = match_class[random_num]
-        if day_of_week not in match_day[goryou_class]:
-            logger.warning(f'Today is {day_of_week} that do not support {goryou_class.name}')
-            logger.info(f'OAS will run {match_class[day_of_week].name} instead')
-            goryou_class = match_class[day_of_week]
-
-
-        return goryou_class
-
 
 
 if __name__ == '__main__':

+ 10 - 7
tasks/WantedQuests/assets.py

@@ -23,7 +23,7 @@ class WantedQuestsAssets:
 	# 挑战券的数量 
 	O_WQ_NUMBER = RuleOcr(roi=(569,13,50,32), area=(569,13,50,32), mode="Digit", method="Default", keyword="", name="wq_number")
 	# 悬赏封印 
-	O_WQ_WANTED = RuleOcr(roi=(9,145,123,381), area=(9,145,123,381), mode="Full", method="Default", keyword="", name="wq_wanted")
+	O_WQ_WANTED = RuleOcr(roi=(15,116,85,401), area=(15,116,85,401), mode="Full", method="Default", keyword="", name="wq_wanted")
 	# Ocr-description 
 	O_WQ_TEXT_1 = RuleOcr(roi=(67,233,52,32), area=(67,233,52,32), mode="Single", method="Default", keyword="封印", name="wq_text_1")
 	# Ocr-description 
@@ -55,16 +55,16 @@ class WantedQuestsAssets:
 	# 怪物名称,如酒吞,阎魔等 
 	O_WQ_MONSTER_TYPE = RuleOcr(roi=(165,215,45,175), area=(165,215,45,175), mode="Full", method="Default", keyword="", name="wq_monster_type")
 	#  
-	O_WQ_TEXT_ALL = RuleOcr(roi=(20,140,110,390), area=(20,140,110,390), mode="Full", method="Default", keyword="", name="wq_text_all")
+	O_WQ_TEXT_ALL = RuleOcr(roi=(12,119,88,393), area=(12,119,88,393), mode="Full", method="Default", keyword="", name="wq_text_all")
 
 
 	# Image Rule Assets
 	# description 
-	I_WQC_LOCK = RuleImage(roi_front=(620,528,27,31), roi_back=(620,528,27,31), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png")
+	I_WQC_LOCK = RuleImage(roi_front=(1083,509,27,31), roi_back=(1083,509,27,31), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png")
 	# description 
-	I_WQC_UNLOCK = RuleImage(roi_front=(621,527,26,28), roi_back=(621,527,26,28), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png")
+	I_WQC_UNLOCK = RuleImage(roi_front=(1083,510,26,28), roi_back=(1083,510,26,28), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png")
 	# 挑战 
-	I_WQC_FIRE = RuleImage(roi_front=(893,503,123,64), roi_back=(871,485,164,91), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png")
+	I_WQC_FIRE = RuleImage(roi_front=(1082,587,97,44), roi_back=(1049,551,169,139), threshold=0.7, method="Template matching", file="./tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png")
 
 
 	# Image Rule Assets
@@ -170,8 +170,11 @@ class WantedQuestsAssets:
 	I_WQ_TRACE_ONE_CHECK_OPENED = RuleImage(roi_front=(510,175,210,60), roi_back=(510,175,210,60), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_check_opened.png")
 	# 庭院悬赏任务界面 单个任务点开后的界面 是否为现世任务标志 
 	I_WQ_TRACE_ONE_REALWORLD = RuleImage(roi_front=(850,470,180,180), roi_back=(850,470,180,180), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_trace_one_realworld.png")
-	# 探索界面,左侧任务列表右上角右下角标志 
-	I_WQ_LIST_TOP_BOTTOM_CHECK = RuleImage(roi_front=(120,125,25,425), roi_back=(120,125,25,425), threshold=0.8, method="Template matching", file="./tasks/WantedQuests/wq/wq_list_top_bottom_check.png")
+
+
+	# Ocr Rule Assets
+	# 检测是否有悬赏封印 
+	O_WQ_LIST_CHECK = RuleOcr(roi=(15,116,85,397), area=(15,116,85,397), mode="Full", method="Default", keyword="封印", name="wq_list_check")
 
 
 	# Image Rule Assets

BIN
tasks/WantedQuests/chanllenge/chanllenge_wqc_fire.png


BIN
tasks/WantedQuests/chanllenge/chanllenge_wqc_lock.png


BIN
tasks/WantedQuests/chanllenge/chanllenge_wqc_unlock.png


+ 6 - 6
tasks/WantedQuests/chanllenge/image.json

@@ -2,8 +2,8 @@
   {
     "itemName": "wqc_lock",
     "imageName": "chanllenge_wqc_lock.png",
-    "roiFront": "620,528,27,31",
-    "roiBack": "620,528,27,31",
+    "roiFront": "1083,509,27,31",
+    "roiBack": "1083,509,27,31",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -11,8 +11,8 @@
   {
     "itemName": "wqc_unlock",
     "imageName": "chanllenge_wqc_unlock.png",
-    "roiFront": "621,527,26,28",
-    "roiBack": "621,527,26,28",
+    "roiFront": "1083,510,26,28",
+    "roiBack": "1083,510,26,28",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -20,8 +20,8 @@
   {
     "itemName": "wqc_fire",
     "imageName": "chanllenge_wqc_fire.png",
-    "roiFront": "893,503,123,64",
-    "roiBack": "871,485,164,91",
+    "roiFront": "1082,587,97,44",
+    "roiBack": "1049,551,169,139",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "挑战"

+ 2 - 2
tasks/WantedQuests/explore.py

@@ -28,7 +28,7 @@ class WQExplore(BaseExploration, HighLight):
         search_fail_cnt = 0
         while 1:
             self.screenshot()
-            if self.appear(self.I_UI_BACK_RED) and self.appear(self.I_E_EXPLORATION_CLICK):
+            if self.appear(self.I_UI_BACK_YELLOW) and self.appear(self.I_E_EXPLORATION_CLICK):
                 break
             if self.appear_then_click(goto, interval=2):
                 continue
@@ -39,7 +39,7 @@ class WQExplore(BaseExploration, HighLight):
             if scene == Scene.ENTRANCE:
                 if _cnt_exploration >= num:
                     logger.info('Execution exploration end')
-                    self.ui_click_until_disappear(self.I_UI_BACK_RED)
+                    self.ui_click_until_disappear(self.I_UI_BACK_YELLOW)
                     if explore_only_boss:
                         raise ExploreWantedBoss
                     break

+ 4 - 4
tasks/WantedQuests/ocr.json

@@ -10,8 +10,8 @@
   },
   {
     "itemName": "wq_wanted",
-    "roiFront": "9,145,123,381",
-    "roiBack": "9,145,123,381",
+    "roiFront": "15,116,85,401",
+    "roiBack": "15,116,85,401",
     "mode": "Full",
     "method": "Default",
     "keyword": "",
@@ -154,8 +154,8 @@
   },
   {
     "itemName": "wq_text_all",
-    "roiFront": "20,140,110,390",
-    "roiBack": "20,140,110,390",
+    "roiFront": "12,119,88,393",
+    "roiBack": "12,119,88,393",
     "mode": "Full",
     "method": "Default",
     "keyword": "",

+ 13 - 6
tasks/WantedQuests/script_task.py

@@ -311,7 +311,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         OCR_WQ_INFO = [self.O_WQ_INFO_1, self.O_WQ_INFO_2, self.O_WQ_INFO_3, self.O_WQ_INFO_4]
         GOTO_BUTTON = [self.I_GOTO_1, self.I_GOTO_2, self.I_GOTO_3, self.I_GOTO_4]
         name_funcs: dict = {
-            '挑战': self.challenge,
+            '式神': self.challenge,
             '探索': self.explore,
             '秘闻': self.secret
         }
@@ -357,7 +357,9 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             order_list = self.config.model.wanted_quests.wanted_quests_config.battle_priority
             order_list = order_list.replace(' ', '').replace('\n', '')
             order_list: list = re.split(r'>', order_list)
-            result[0] = order_list.index(type_wq) if type_wq in order_list else -1
+            # OCR识别"式神"但用户配置用"挑战",做映射
+            type_wq_for_order = '挑战' if type_wq == '式神' else type_wq
+            result[0] = order_list.index(type_wq_for_order) if type_wq_for_order in order_list else -1
             result[4] = name_funcs.get(type_wq, lambda: logger.warning('No task can be challenged'))
             result[5] = type_wq
             logger.info(f'[Wanted Quests] type: {type_wq} destination: {wq_destination} number: {wq_number} ')
@@ -395,7 +397,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
             return False
         # sort
         info_wq_list.sort(key=lambda x: x[0])
-        filtered = list(filter(lambda x: (x[5] == '秘闻' or x[5] == '挑战') and x[2] >= 3, info_wq_list))
+        filtered = list(filter(lambda x: (x[5] == '秘闻' or x[5] == '式神') and x[2] >= 3, info_wq_list))
         if not filtered and len(filtered) != 0:
             info_wq_list = filtered
         best_type, destination, once_number, goto_button, func, _ = info_wq_list[0]
@@ -414,8 +416,13 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
         wq_config = GeneralBattleConfig(lock_team_enable=True)
         self.run_general_battle(config=wq_config)
         self.wait_until_appear(self.I_WQC_FIRE, wait_time=4)
-        self.ui_click_until_disappear(self.I_UI_BACK_RED)
-        # 我忘记了打完后是否需要关闭 挑战界面
+        # 关闭 挑战界面
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_CHECK_EXPLORATION):
+                break
+            if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=1.5):
+                continue
 
     def secret(self, goto, num=1):
         self.ui_click(goto, self.I_WQSE_FIRE)
@@ -750,7 +757,7 @@ class ScriptTask(WQExplore, SecretScriptTask, WantedQuestsAssets):
 
     def is_wq_remained(self):
         # 检测是否还存在任务
-        return self.appear(self.I_WQ_LIST_TOP_BOTTOM_CHECK)
+        return self.appear(self.O_WQ_WANTED)
 
 
 

+ 0 - 9
tasks/WantedQuests/wq/image.json

@@ -142,14 +142,5 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "庭院悬赏任务界面 单个任务点开后的界面 是否为现世任务标志"
-  },
-  {
-    "itemName": "wq_list_top_bottom_check",
-    "imageName": "wq_list_top_bottom_check.png",
-    "roiFront": "120,125,25,425",
-    "roiBack": "120,125,25,425",
-    "method": "Template matching",
-    "threshold": 0.8,
-    "description": "探索界面,左侧任务列表右上角右下角标志"
   }
 ]

BIN
tasks/WantedQuests/wq/wq_list_top_bottom_check.png