runhey 3 лет назад
Родитель
Сommit
6de2d5200d

+ 1 - 0
module/config/config_manual.py

@@ -11,6 +11,7 @@ class ConfigManual:
         Restart
         >KekkaiUtilize > KekkaiActivation > DemonEncounter
         > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid > RyouToppa > DailyTrifles
+        > Hunt
         > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea 
         > ActivityShikigami
         > BondlingFairyland > EvoZone > GoryouRealm

+ 2 - 1
module/config/config_menu.py

@@ -25,7 +25,8 @@ class ConfigMenu:
         # 很肝的任务
         self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm']
         # 阴阳寮
-        self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'CollectiveMissions']
+        self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa', 'CollectiveMissions',
+                              'Hunt']
         # 每周任务
         self.menu["Weekly Task"] = ['TrueOrochi', 'RichMan', 'Secret', 'WeeklyTrifles', 'MysteryShop']
         # 活动的任务

+ 2 - 0
module/config/config_model.py

@@ -36,6 +36,7 @@ from tasks.FallenSun.config import FallenSun
 from tasks.EternitySea.config import EternitySea
 from tasks.RealmRaid.config import RealmRaid
 from tasks.CollectiveMissions.config import CollectiveMissions
+from tasks.Hunt.config import Hunt
 
 # 这一部分是活动的配置-----------------------------------------------------------------------------------------------------
 from tasks.ActivityShikigami.config import ActivityShikigami
@@ -102,6 +103,7 @@ class ConfigModel(ConfigBase):
 
     # 阴阳寮
     collective_missions: CollectiveMissions = Field(default_factory=CollectiveMissions)
+    hunt: Hunt = Field(default_factory=Hunt)
 
     # @validator('script')
     # def script_validator(cls, v):

+ 12 - 0
tasks/Delegation/assets.py

@@ -0,0 +1,12 @@
+from module.atom.image import RuleImage
+from module.atom.click import RuleClick
+from module.atom.long_click import RuleLongClick
+from module.atom.swipe import RuleSwipe
+from module.atom.ocr import RuleOcr
+from module.atom.list import RuleList
+
+# This file was automatically generated by ./dev_tools/assets_extract.py.
+# Don't modify it manually.
+class DelegationAssets: 
+	pass
+

+ 29 - 1
tasks/Hunt/assets.py

@@ -8,5 +8,33 @@ from module.atom.list import RuleList
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 class HuntAssets: 
-	pass
+
+
+	# Click Rule Assets
+	# description 
+	C_HUNT_ENTER = RuleClick(roi_front=(1059,600,193,100), roi_back=(1059,600,193,100), name="hunt_enter")
+
+
+	# Image Rule Assets
+	# 神社 
+	I_HUNT_SHRINE = RuleImage(roi_front=(870,624,65,61), roi_back=(870,624,65,61), threshold=0.8, method="Template matching", file="./tasks/Hunt/hunt/hunt_hunt_shrine.png")
+	# 狩猎战 
+	I_HUNT_HUNT = RuleImage(roi_front=(157,414,215,166), roi_back=(157,414,215,166), threshold=0.8, method="Template matching", file="./tasks/Hunt/hunt/hunt_hunt_hunt.png")
+
+
+	# Image Rule Assets
+	# 麒麟的挑战 
+	I_KIRIN_CHALLAGE = RuleImage(roi_front=(1064,559,117,108), roi_back=(1064,559,117,108), threshold=0.8, method="Template matching", file="./tasks/Hunt/kirin/kirin_kirin_challage.png")
+	# 集合 
+	I_KIRIN_GATHER = RuleImage(roi_front=(28,480,75,64), roi_back=(28,480,75,64), threshold=0.8, method="Template matching", file="./tasks/Hunt/kirin/kirin_kirin_gather.png")
+	# 已结束 
+	I_KIRIN_END = RuleImage(roi_front=(1049,579,143,59), roi_back=(1049,579,143,59), threshold=0.8, method="Template matching", file="./tasks/Hunt/kirin/kirin_kirin_end.png")
+
+
+	# Image Rule Assets
+	# 点击阴界之门 
+	I_NW = RuleImage(roi_front=(1060,602,100,100), roi_back=(1060,602,100,100), threshold=0.8, method="Template matching", file="./tasks/Hunt/netherworld/netherworld_nw.png")
+	# 点击挑战 
+	I_NW_CHALLAGE = RuleImage(roi_front=(306,590,171,63), roi_back=(306,590,171,63), threshold=0.8, method="Template matching", file="./tasks/Hunt/netherworld/netherworld_nw_challage.png")
+
 

+ 10 - 0
tasks/Hunt/config.py

@@ -1,7 +1,17 @@
 # This Python file uses the following encoding: utf-8
 # @author runhey
 # github https://github.com/runhey
+from datetime import timedelta
 from pydantic import BaseModel, Field
 
 from tasks.Component.config_scheduler import Scheduler
 from tasks.Component.config_base import ConfigBase
+
+class HuntConfig(BaseModel):
+    kirin_group_team: str = Field(default='-1,-1', description='switch_group_team_help')
+    netherworld_group_team: str = Field(default='-1,-1')
+
+
+class Hunt(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    hunt_config: HuntConfig = Field(default_factory=HuntConfig)

+ 8 - 0
tasks/Hunt/hunt/click.json

@@ -0,0 +1,8 @@
+[
+  {
+    "itemName": "hunt_enter",
+    "roiFront": "1059,600,193,100",
+    "roiBack": "1059,600,193,100",
+    "description": "description"
+  }
+]

BIN
tasks/Hunt/hunt/hunt_hunt_hunt.png


BIN
tasks/Hunt/hunt/hunt_hunt_shrine.png


+ 20 - 0
tasks/Hunt/hunt/image.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "hunt_shrine",
+    "imageName": "hunt_hunt_shrine.png",
+    "roiFront": "870,624,65,61",
+    "roiBack": "870,624,65,61",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "神社"
+  },
+  {
+    "itemName": "hunt_hunt",
+    "imageName": "hunt_hunt_hunt.png",
+    "roiFront": "157,414,215,166",
+    "roiBack": "157,414,215,166",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "狩猎战"
+  }
+]

+ 29 - 0
tasks/Hunt/kirin/image.json

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "kirin_challage",
+    "imageName": "kirin_kirin_challage.png",
+    "roiFront": "1064,559,117,108",
+    "roiBack": "1064,559,117,108",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "麒麟的挑战"
+  },
+  {
+    "itemName": "kirin_gather",
+    "imageName": "kirin_kirin_gather.png",
+    "roiFront": "28,480,75,64",
+    "roiBack": "28,480,75,64",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "集合"
+  },
+  {
+    "itemName": "kirin_end",
+    "imageName": "kirin_kirin_end.png",
+    "roiFront": "1049,579,143,59",
+    "roiBack": "1049,579,143,59",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "已结束"
+  }
+]

BIN
tasks/Hunt/kirin/kirin_kirin_challage.png


BIN
tasks/Hunt/kirin/kirin_kirin_end.png


BIN
tasks/Hunt/kirin/kirin_kirin_gather.png


+ 20 - 0
tasks/Hunt/netherworld/image.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "nw",
+    "imageName": "netherworld_nw.png",
+    "roiFront": "1060,602,100,100",
+    "roiBack": "1060,602,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击阴界之门"
+  },
+  {
+    "itemName": "nw_challage",
+    "imageName": "netherworld_nw_challage.png",
+    "roiFront": "306,590,171,63",
+    "roiBack": "306,590,171,63",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击挑战"
+  }
+]

BIN
tasks/Hunt/netherworld/netherworld_nw.png


BIN
tasks/Hunt/netherworld/netherworld_nw_challage.png


+ 79 - 0
tasks/Hunt/script_task.py

@@ -0,0 +1,79 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from time import sleep
+from datetime import timedelta, datetime, time
+from cached_property import cached_property
+
+from module.exception import TaskEnd
+from module.logger import logger
+from module.base.timer import Timer
+
+from tasks.GameUi.game_ui import GameUi
+from tasks.GameUi.page import page_main, page_hunt, page_shikigami_records
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.GeneralRoom.general_room import GeneralRoom
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.Hunt.assets import HuntAssets
+
+class ScriptTask(GameUi, GeneralBattle, GeneralRoom, SwitchSoul, HuntAssets):
+    kirin_day = True  # 不是麒麟就是阴界之门
+
+    def run(self):
+        if not self.check_datetime():
+            # 设置下次运行时间 为今天的晚上七点钟
+            now = datetime.now()
+            next_run_time = datetime.combine(now.date(), time(19, 0, 0))
+            self.set_next_run(task='Hunt', success=False, finish=True, target=next_run_time)
+            raise TaskEnd('Hunt')
+        con = self.config.hunt.hunt_config
+        if con.kirin_group_team != '-1,-1' or con.netherworld_group_team != '-1,-1':
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            if con.kirin_group_team != '-1,-1':
+                self.run_switch_soul(con.kirin_group_team)
+            if con.netherworld_group_team != '-1,-1':
+                self.run_switch_soul(con.netherworld_group_team)
+        self.ui_get_current_page()
+        self.ui_goto(page_hunt)
+
+        self.set_next_run(task='Hunt', success=True, finish=True)
+        raise TaskEnd('Hunt')
+
+    def check_datetime(self) -> bool:
+        """
+        检查日期和时间, 会设置是麒麟还是阴界之门
+        :return: 符合19:00-21:00的时间返回True, 否则返回False
+        """
+        now = datetime.now()
+        day_of_week = now.weekday()
+        if 0 <= day_of_week <= 3:
+            self.kirin_day = True
+        elif 4 <= day_of_week <= 6:
+            self.kirin_day = False
+
+
+        if time(18, 59) < now.time() < time(21, 1):
+            return True
+        else:
+            logger.warning('Not in the time period')
+            return False
+
+    def kirin(self):
+        pass
+
+    def netherworld(self):
+        pass
+
+
+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.screenshot()
+
+    t.run()
+