فهرست منبع

Merge pull request #735 from yEs1do/feat(MetaDemon)

超鬼王更新 @Gan1Ser
huangrunheng 1 سال پیش
والد
کامیت
dcbb324bbb

+ 14 - 0
tasks/MetaDemon/assets.py

@@ -31,6 +31,20 @@ class MetaDemonAssets:
 	I_MD_FIRE_POWER = RuleImage(roi_front=(1159,498,100,37), roi_back=(1159,498,100,37), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_md_fire_power.png")
 	# 失败 
 	I_MD_BATTLE_FAILURE = RuleImage(roi_front=(412,105,100,100), roi_back=(412,105,100,100), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_md_battle_failure.png")
+	# 进入鬼王界面 
+	I_A2 = RuleImage(roi_front=(751,137,41,149), roi_back=(751,137,41,149), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/Screenshots_a2.png")
+	# 召唤鬼王 
+	I_A3 = RuleImage(roi_front=(1137,581,100,100), roi_back=(1137,581,100,100), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/Screenshots_a3.png")
+	# 挑战 
+	I_A4 = RuleImage(roi_front=(1137,581,100,100), roi_back=(1137,581,100,100), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/Screenshots_a4.png")
+	# 准备 
+	I_A5 = RuleImage(roi_front=(1129,536,100,100), roi_back=(1129,536,100,100), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/Screenshots_a5.png")
+	# description 
+	I_A6 = RuleImage(roi_front=(435,147,100,100), roi_back=(435,147,100,100), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/Screenshots_a6.png")
+	# 超鬼王打完了 
+	I_BACK_CHECK = RuleImage(roi_front=(378,257,68,32), roi_back=(378,257,68,32), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_back_check.png")
+	# 红色的叉叉 
+	I_RED_BACK = RuleImage(roi_front=(925,181,47,48), roi_back=(925,181,47,48), threshold=0.8, method="Template matching", file="./tasks/MetaDemon/md/md_red_back.png")
 
 
 	# Ocr Rule Assets

+ 3 - 5
tasks/MetaDemon/config.py

@@ -4,14 +4,11 @@
 from tasks.Component.config_base import ConfigBase, TimeDelta, DateTime, Time
 from pydantic import BaseModel, ValidationError, validator, Field
 from enum import Enum
+from tasks.Component.config_scheduler import Scheduler
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
 
 # 鬼王的难度为: 易、中、高、难、极 五个 对应英文:easy、medium、hard、difficult、extreme
 
-class Scheduler(ConfigBase):
-    enable: bool = Field(default=False, description='enable_help')
-    next_run: DateTime = Field(default="2023-01-01 00:00:00", description='next_run_help')
-    priority: int = Field(default=5, description='priority_help')
-    interval: TimeDelta = Field(default=TimeDelta(hours=3), description='interval_help')
 
 class MetaDemonConfig(ConfigBase):
     auto_tea: bool = Field(default=False, description='auto_tea_help')
@@ -21,6 +18,7 @@ class MetaDemonConfig(ConfigBase):
 class MetaDemon(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
     meta_demon_config: MetaDemonConfig = Field(default_factory=MetaDemonConfig)
+    switch_soul: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
 
 
 

BIN
tasks/MetaDemon/md/Screenshots_a2.png


BIN
tasks/MetaDemon/md/Screenshots_a3.png


BIN
tasks/MetaDemon/md/Screenshots_a4.png


BIN
tasks/MetaDemon/md/Screenshots_a5.png


BIN
tasks/MetaDemon/md/Screenshots_a6.png


+ 63 - 0
tasks/MetaDemon/md/image.json

@@ -88,5 +88,68 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "失败"
+  },
+  {
+    "itemName": "a2",
+    "imageName": "Screenshots_a2.png",
+    "roiFront": "751,137,41,149",
+    "roiBack": "751,137,41,149",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入鬼王界面"
+  },
+  {
+    "itemName": "a3",
+    "imageName": "Screenshots_a3.png",
+    "roiFront": "1137,581,100,100",
+    "roiBack": "1137,581,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "召唤鬼王"
+  },
+  {
+    "itemName": "a4",
+    "imageName": "Screenshots_a4.png",
+    "roiFront": "1137,581,100,100",
+    "roiBack": "1137,581,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "挑战"
+  },
+  {
+    "itemName": "a5",
+    "imageName": "Screenshots_a5.png",
+    "roiFront": "1129,536,100,100",
+    "roiBack": "1129,536,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "准备"
+  },
+  {
+    "itemName": "a6",
+    "imageName": "Screenshots_a6.png",
+    "roiFront": "435,147,100,100",
+    "roiBack": "435,147,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "back_check",
+    "imageName": "md_back_check.png",
+    "roiFront": "378,257,68,32",
+    "roiBack": "378,257,68,32",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "超鬼王打完了"
+  },
+  {
+    "itemName": "red_back",
+    "imageName": "md_red_back.png",
+    "roiFront": "925,181,47,48",
+    "roiBack": "925,181,47,48",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "红色的叉叉"
   }
 ]

BIN
tasks/MetaDemon/md/md_back_check.png


BIN
tasks/MetaDemon/md/md_red_back.png


+ 51 - 63
tasks/MetaDemon/script_task.py

@@ -10,84 +10,74 @@ from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_main
+from tasks.GameUi.page import page_main, page_shikigami_records
 from tasks.MetaDemon.config import MetaDemon
 from tasks.MetaDemon.assets import MetaDemonAssets
 
 from module.logger import logger
 from module.exception import TaskEnd
+from tasks.Restart.assets import RestartAssets
+from tasks.ActivityShikigami.assets import ActivityShikigamiAssets
+from module.base.timer import Timer
+
+"""超鬼王"""
+
 
 class ScriptTask(GeneralBattle, SwitchSoul, GameUi, MetaDemonAssets):
 
     def run(self):
+
+
+        if self.config.meta_demon.switch_soul.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(self.config.meta_demon.switch_soul.switch_group_team)
+
+        if self.config.meta_demon.switch_soul.enable_switch_by_name:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul_by_name(self.config.meta_demon.switch_soul.group_name,
+                                         self.config.meta_demon.switch_soul.team_name)
         self.ui_get_current_page()
         self.ui_goto(page_main)
+
+        boss_timer = Timer(200)
+        boss_timer.start()
         while 1:
             self.screenshot()
-            if self.appear(self.I_MD_FIND):
+            sleep(0.1)
+            if boss_timer.reached():
+                self.config.notifier.push(title='超鬼王', message='识别超时退出')
                 break
-            if self.appear(self.I_MD_FIRE):
+            if self.appear(self.I_BACK_CHECK):
+                self.click(self.I_RED_BACK, interval=1.5)
                 break
-            if self.appear_then_click(self.I_MD_ENTER, interval=1.5):
+            if self.appear_then_click(RestartAssets.I_HARVEST_CHAT_CLOSE):
+                boss_timer.reset()
                 continue
-            if self.appear_then_click(self.I_MD_MAIN, interval=1.5):
+            if self.appear_then_click(ActivityShikigamiAssets.I_SHI, interval=1):
+                boss_timer.reset()
+                continue
+            if self.appear_then_click(self.I_A2):
+                boss_timer.reset()
+                continue
+            if self.appear_then_click(self.I_A3, interval=1):
+                boss_timer.reset()
+                continue
+            if self.appear_then_click(self.I_A4, interval=1):
+                boss_timer.reset()
+                continue
+            if self.appear_then_click(self.I_A5, interval=1):
+                self.device.stuck_record_clear()
+                self.device.stuck_record_add('BATTLE_STATUS_S')
+                boss_timer.reset()
+                continue
+            if self.appear_then_click(self.I_A6, interval=1):
+                boss_timer.reset()
                 continue
 
         config: MetaDemon = self.config.model.meta_demon
         # 主循环
-        while 1:
-            self.screenshot()
-            if not self.appear(self.I_MD_GIFT_BOX):
-                continue
-            # 检查是否有票
-            if not self.ensure_ticket():
-                logger.info('There is no common ticket')
-                self.set_next_run('MetaDemon', finish=True,
-                                  target=config.scheduler.interval + datetime.now().replace(second=0, microsecond=0))
-                break
-            # 检查疲劳°
-            if not self.check_exhaustion():
-                logger.info('Exhaustion is more than 100')
-                if config.meta_demon_config.auto_tea:
-                    logger.info('Try to buy tea')
-                    self.buy_tea()
-                    continue
-                else:
-                    logger.info('Stop because of exhaustion is more than 100')
-                    interval_delta = TimeDelta(minutes=self.current_exhaustion())
-                    self.set_next_run('MetaDemon', finish=True,
-                                      target=interval_delta + datetime.now().replace(second=0, microsecond=0))
-                    break
-            # 寻找鬼王
-            if self.appear_then_click(self.I_MD_FIND, interval=1.5):
-                continue
-            #
-            if self.appear(self.I_MD_FIRE) and self.appear(self.I_MD_FIRE_COMMON):
-                if self.ocr_appear(self.O_MD_COUNT_INFO):
-                    # 结算中
-                    logger.info('Waiting for settlement')
-                    sleep(1)
-                    continue
-                # 是否为极
-                if self.appear(self.I_MD_EXTREME):
-                    logger.info('Find extreme Demon')
-                    if config.meta_demon_config.extreme_notify:
-                        self.config.notifier.push(title='超鬼王', content=f"发现极鬼王")
-                        self.set_next_run('MetaDemon', finish=True,
-                                          target=config.scheduler.interval + datetime.now().replace(second=0, microsecond=0))
-                        break
-                    else:
-                        pass
-                while 1:
-                    self.screenshot()
-                    if self.appear(self.I_MD_FIRE) and self.appear(self.I_MD_FIRE_COMMON):
-                        pass
-                    else:
-                        break
-                    if self.appear_then_click(self.I_MD_FIRE, interval=2):
-                        continue
-                self.run_general_battle(config=self.battle_config)
-        # exit
         while 1:
             self.screenshot()
             if self.appear(self.I_CHECK_MAIN):
@@ -95,12 +85,9 @@ class ScriptTask(GeneralBattle, SwitchSoul, GameUi, MetaDemonAssets):
                 break
             if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=1):
                 continue
+        self.set_next_run(task="MetaDemon", success=True)
         raise TaskEnd
 
-
-
-
-
     @cached_property
     def battle_config(self):
         config = GeneralBattleConfig()
@@ -161,12 +148,13 @@ class ScriptTask(GeneralBattle, SwitchSoul, GameUi, MetaDemonAssets):
                 self.ui_click_until_disappear(self.I_MD_BATTLE_FAILURE)
                 return False
 
+
 if __name__ == '__main__':
     from module.config.config import Config
     from module.device.device import Device
+
     c = Config('oas1')
     d = Device(c)
     t = ScriptTask(c, d)
 
     t.run()
-