Kaynağa Gözat

feat(task): Add goryou-realm

runhey 3 yıl önce
ebeveyn
işleme
1ea9578d93

+ 2 - 2
module/config/config_manual.py

@@ -11,9 +11,9 @@ class ConfigManual:
         Restart
         >KekkaiUtilize > KekkaiActivation > DemonEncounter
         > AreaBoss > GoldYoukai > ExperienceYoukai > Nian > RealmRaid > RyouToppa > DailyTrifles
-        > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea
+        > Orochi > OrochiMoans > OrochiJudgement > Sougenbi > FallenSun > EternitySea 
         > ActivityShikigami
-        > BondlingFairyland > EvoZone
+        > BondlingFairyland > EvoZone > GoryouRealm
         > TrueOrochi > RichMan
         > Pets > TalismanPass > SoulsTidy
         > Secret > WeeklyTrifles > MysteryShop

+ 1 - 1
module/config/config_menu.py

@@ -23,7 +23,7 @@ class ConfigMenu:
         self.menu["Daily Task"] = ['DailyTrifles', 'AreaBoss', 'GoldYoukai', 'ExperienceYoukai', 'Nian',
                                    'TalismanPass', 'DemonEncounter', 'Pets', 'SoulsTidy']
         # 很肝的任务
-        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone']
+        self.menu["Liver Emperor Exclusive"] = ['BondlingFairyland', 'EvoZone', 'GoryouRealm']
         # 阴阳寮
         self.menu["Guild"] = ['KekkaiUtilize', 'KekkaiActivation', 'RealmRaid', 'RyouToppa']
         # 每周任务

+ 2 - 0
module/config/config_model.py

@@ -42,6 +42,7 @@ from tasks.ActivityShikigami.config import ActivityShikigami
 # 肝帝专属---------------------------------------------------------------------------------------------------------------
 from tasks.BondlingFairyland.config import BondlingFairyland
 from tasks.EvoZone.config import EvoZone
+from tasks.GoryouRealm.config import GoryouRealm
 # ----------------------------------------------------------------------------------------------------------------------
 
 # 每周任务---------------------------------------------------------------------------------------------------------------
@@ -86,6 +87,7 @@ class ConfigModel(ConfigBase):
     # 这些是肝帝专属
     bondling_fairyland: BondlingFairyland = Field(default_factory=BondlingFairyland)
     evo_zone: EvoZone = Field(default_factory=EvoZone)
+    goryou_realm: GoryouRealm = Field(default_factory=GoryouRealm)
 
 
     # 这些是每周任务

BIN
module/config/i18n/zh_CN.qm


+ 3 - 0
module/config/i18n/zh_CN.ts

@@ -670,5 +670,8 @@ Refresh:直接刷新,如果刷新操作进入CD,将标记为失败并退
 	<message><source>Share Friend 3</source><translation>第三个好友名字</translation></message>
 	<message><source>Share Friend 4</source><translation>第四个好友名字</translation></message>
 	<message><source>Share Friend 5</source><translation>第五个好友名字</translation></message>
+	<message><source>GoryouConfig</source><translation>御灵</translation></message>
+	<message><source>GoryouClass</source><translation>御灵类型</translation></message>
+	<message><source>goryou_class_help</source><translation>闭着眼睛选,自动支持到当天的类型。不支持选择层数是因为正常人都会打第三层</translation></message>
 </context>
 </TS>

+ 1 - 1
tasks/GameUi/assets.py

@@ -43,7 +43,7 @@ class GameUiAssets:
 	# description 
 	I_EXPLORATION_GOTO_REALM_RAID = RuleImage(roi_front=(245,638,67,48), roi_back=(245,638,67,48), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_realm_raid.png")
 	# 前往御灵 
-	I_EXPLORATION_GOTO_GORYOU_REALM = RuleImage(roi_front=(343,629,60,67), roi_back=(343,629,60,67), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_goryou_realm.png")
+	I_EXPLORATION_GOTO_GORYOU_REALM = RuleImage(roi_front=(353,639,47,45), roi_back=(346,626,60,67), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_goryou_realm.png")
 	# 式神委派 
 	I_EXPLORATION_GOTO_DELEGATION = RuleImage(roi_front=(445,638,60,50), roi_back=(445,638,60,50), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_delegation.png")
 	# 秘闻 

BIN
tasks/GameUi/page/page_exploration_goto_goryou_realm.png


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

@@ -56,10 +56,10 @@
   {
     "itemName": "exploration_goto_goryou_realm",
     "imageName": "page_exploration_goto_goryou_realm.png",
-    "roiFront": "343,629,60,67",
-    "roiBack": "343,629,60,67",
+    "roiFront": "353,639,47,45",
+    "roiBack": "346,626,60,67",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "前往御灵"
   },
   {

+ 37 - 0
tasks/GoryouRealm/assets.py

@@ -0,0 +1,37 @@
+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 GoryouRealmAssets: 
+
+
+	# Click Rule Assets
+	# description 
+	C_GR_C_1 = RuleClick(roi_front=(95,105,224,548), roi_back=(95,105,224,548), name="gr_c_1")
+	# description 
+	C_GR_C_2 = RuleClick(roi_front=(382,109,229,536), roi_back=(382,109,229,536), name="gr_c_2")
+	# description 
+	C_GR_C_3 = RuleClick(roi_front=(669,112,232,539), roi_back=(669,112,232,539), name="gr_c_3")
+	# description 
+	C_GR_C_4 = RuleClick(roi_front=(961,108,225,538), roi_back=(961,108,225,538), name="gr_c_4")
+
+
+	# Image Rule Assets
+	# 点击挑战 
+	I_GR_FIRE = RuleImage(roi_front=(1097,582,100,100), roi_back=(1097,582,100,100), threshold=0.8, method="Template matching", file="./tasks/GoryouRealm/gr/gr_gr_fire.png")
+	# description 
+	I_GR_LOCK = RuleImage(roi_front=(559,564,27,32), roi_back=(559,564,27,32), threshold=0.8, method="Template matching", file="./tasks/GoryouRealm/gr/gr_gr_lock.png")
+	# description 
+	I_GR_UNLOCK = RuleImage(roi_front=(556,562,26,33), roi_back=(556,562,26,33), threshold=0.8, method="Template matching", file="./tasks/GoryouRealm/gr/gr_gr_unlock.png")
+
+
+	# Ocr Rule Assets
+	# 多少张票 
+	O_GR_TICKET = RuleOcr(roi=(934,21,84,41), area=(934,21,84,41), mode="Digit", method="Default", keyword="", name="gr_ticket")
+
+

+ 34 - 0
tasks/GoryouRealm/config.py

@@ -0,0 +1,34 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from pydantic import BaseModel, Field
+from enum import Enum
+from datetime import datetime, time
+
+from tasks.Component.config_scheduler import Scheduler
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.SwitchSoul.switch_soul_config import SwitchSoulConfig
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+
+class GoryouClass(str, Enum):
+    RANDOM = '随机',
+    Dark_Divine_Dragon = '暗神龙',
+    Dark_Hakuzousu = '暗白蔵主',
+    Dark_Black_Panther = '暗黑豹',
+    Dark_Peacock = '暗孔雀'
+
+class GoryouConfig(ConfigBase):
+    # 限制时间
+    limit_time: time = Field(default=time(minute=30), description='limit_time_help')
+    # 限制次数
+    limit_count: int = Field(default=30, description='limit_count_help')
+    # 类型
+    goryou_class: GoryouClass = Field(default=GoryouClass.RANDOM, description='goryou_class_help')
+
+
+class GoryouRealm(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    goryou_config: GoryouConfig = Field(default_factory=GoryouConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
+

+ 26 - 0
tasks/GoryouRealm/gr/click.json

@@ -0,0 +1,26 @@
+[
+  {
+    "itemName": "gr_c_1",
+    "roiFront": "95,105,224,548",
+    "roiBack": "95,105,224,548",
+    "description": "description"
+  },
+  {
+    "itemName": "gr_c_2",
+    "roiFront": "382,109,229,536",
+    "roiBack": "382,109,229,536",
+    "description": "description"
+  },
+  {
+    "itemName": "gr_c_3",
+    "roiFront": "669,112,232,539",
+    "roiBack": "669,112,232,539",
+    "description": "description"
+  },
+  {
+    "itemName": "gr_c_4",
+    "roiFront": "961,108,225,538",
+    "roiBack": "961,108,225,538",
+    "description": "description"
+  }
+]

BIN
tasks/GoryouRealm/gr/gr_gr_fire.png


BIN
tasks/GoryouRealm/gr/gr_gr_lock.png


BIN
tasks/GoryouRealm/gr/gr_gr_unlock.png


+ 29 - 0
tasks/GoryouRealm/gr/image.json

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "gr_fire",
+    "imageName": "gr_gr_fire.png",
+    "roiFront": "1097,582,100,100",
+    "roiBack": "1097,582,100,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "点击挑战"
+  },
+  {
+    "itemName": "gr_lock",
+    "imageName": "gr_gr_lock.png",
+    "roiFront": "559,564,27,32",
+    "roiBack": "559,564,27,32",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "gr_unlock",
+    "imageName": "gr_gr_unlock.png",
+    "roiFront": "556,562,26,33",
+    "roiBack": "556,562,26,33",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

+ 11 - 0
tasks/GoryouRealm/gr/ocr.json

@@ -0,0 +1,11 @@
+[
+  {
+    "itemName": "gr_ticket",
+    "roiFront": "934,21,84,41",
+    "roiBack": "934,21,84,41",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "多少张票"
+  }
+]

+ 122 - 0
tasks/GoryouRealm/script_task.py

@@ -0,0 +1,122 @@
+# 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 module.exception import TaskEnd
+
+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.GoryouRealm.assets import GoryouRealmAssets
+
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, GoryouRealmAssets):
+
+    def run(self):
+        con = self.config.goryou_realm
+        limit_time = con.goryou_config.limit_time
+        self.limit_time: timedelta = timedelta(hours=limit_time.hour, minutes=limit_time.minute,
+                                               seconds=limit_time.second)
+        if con.switch_soul_config.enable:
+            self.ui_get_current_page()
+            self.ui_goto(page_shikigami_records)
+            self.run_switch_soul(con.switch_soul_config.switch_group_team)
+        self.ui_get_current_page()
+        self.ui_goto(page_goryou_realm)
+
+        match_click = {
+            GoryouClass.Dark_Divine_Dragon: self.C_GR_C_1,
+            GoryouClass.Dark_Hakuzousu: self.C_GR_C_2,
+            GoryouClass.Dark_Black_Panther: self.C_GR_C_3,
+            GoryouClass.Dark_Peacock: self.C_GR_C_4,
+        }
+        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):
+                continue
+        self.check_lock(con.general_battle_config.lock_team_enable, self.I_GR_LOCK, self.I_GR_UNLOCK)
+
+        # 开始循环
+        while 1:
+            self.screenshot()
+            if not self.appear(self.I_GR_FIRE):
+                continue
+
+            if self.current_count >= con.goryou_config.limit_count:
+                logger.info('GoryouRealm count limit out')
+                break
+            if datetime.now() - self.start_time >= self.limit_time:
+                logger.info('GoryouRealm time limit out')
+                break
+            ticket = self.O_GR_TICKET.ocr(self.device.image)
+            if ticket == 0:
+                break
+
+            # 点击挑战
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_GR_FIRE, interval=1):
+                    pass
+                if not self.appear(self.I_GR_FIRE):
+                    self.run_general_battle(config=con.general_battle_config)
+                    break
+
+
+        self.ui_click(self.I_UI_BACK_BLUE, self.I_CHECK_EXPLORATION)
+        logger.info('Back to exploration')
+        self.set_next_run(task='GoryouRealm', success=True, finish=True)
+        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__':
+    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()