Răsfoiți Sursa

feat(task): add sougenbi

runhey 3 ani în urmă
părinte
comite
064f7c93af

BIN
module/config/i18n/zh_CN.qm


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

@@ -537,4 +537,9 @@ Refresh:直接刷新,如果刷新操作进入CD,将标记为失败并退
 	<message><source>three_refresh_help</source><translation>挑战进度到三,领取奖励后就刷新,如果刷新操作进入CD,将标记为失败并退出</translation></message>
 	<message><source>number_base_help</source><translation>旨在检查突破卷数量,如果当前的数量没有大于等于这个值,将标记为成功并退出</translation></message>
 </context>	
+<context>
+    <name>Args</name>
+	<message><source>SougenbiConfig</source><translation>业原火</translation></message>	
+	<message><source>SougenbiClass</source><translation>挑战类型</translation></message>	
+</context>	
 </TS>

+ 24 - 3
tasks/Component/GeneralBattle/general_battle.py

@@ -401,9 +401,30 @@ class GeneralBattle(BaseTask, GeneralBattleAssets):
 
         return self.battle_wait(config.random_click_swipt_enable)
 
-
-
-
+    def check_lock(self, enable: bool, lock_image, unlock_image):
+        """
+        检测是否锁定队伍,
+        :param enable:
+        :param lock_image:
+        :param unlock_image:
+        :return:
+        """
+        if enable:
+            logger.info("Lock team")
+            while 1:
+                self.screenshot()
+                if self.appear(lock_image):
+                    break
+                if self.appear_then_click(unlock_image, interval=1):
+                    continue
+        else:
+            logger.info("Unlock team")
+            while 1:
+                self.screenshot()
+                if self.appear(unlock_image):
+                    break
+                if self.appear_then_click(lock_image, interval=1):
+                    continue
 
 
 

+ 6 - 0
tasks/Component/SwitchSoul/switch_soul.py

@@ -23,6 +23,12 @@ class SwitchSoul(BaseTask, SwitchSoulAssets):
         保证在式神录的界面
         :return:
         """
+        if isinstance(target, str):
+            try:
+                target = switch_parser(target)
+            except ValueError:
+                logger.error('Switch soul config error')
+                return
         self.click_preset()
         self.switch_souls(target)
 

+ 0 - 1
tasks/Orochi/script_task.py

@@ -4,7 +4,6 @@
 from time import sleep
 from datetime import time, datetime, timedelta
 
-from tasks.base_task import BaseTask
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralInvite.general_invite import GeneralInvite
 from tasks.Component.GeneralBuff.general_buff import GeneralBuff

+ 38 - 1
tasks/Sougenbi/assets.py

@@ -8,5 +8,42 @@ from module.atom.list import RuleList
 # This file was automatically generated by ./dev_tools/assets_extract.py.
 # Don't modify it manually.
 class SougenbiAssets: 
-	pass
+
+
+	# Click Rule Assets
+	# description 
+	C_C_GREED = RuleClick(roi_front=(172,144,299,100), roi_back=(172,144,299,100), name="c_greed")
+	# description 
+	C_C_ANGER = RuleClick(roi_front=(165,289,307,100), roi_back=(165,289,307,100), name="c_anger")
+	# description 
+	C_C_FOOLERY = RuleClick(roi_front=(166,435,303,100), roi_back=(166,435,303,100), name="c_foolery")
+
+
+	# Image Rule Assets
+	# 进入业原火 
+	I_S_SOUGENBI = RuleImage(roi_front=(405,97,301,414), roi_back=(405,97,301,414), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_sougenbi.png")
+	# 贪 
+	I_S_GREED = RuleImage(roi_front=(167,143,307,100), roi_back=(167,143,307,100), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_greed.png")
+	#  
+	I_S_ANGER = RuleImage(roi_front=(164,291,307,100), roi_back=(164,291,307,100), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_anger.png")
+	# 痴 
+	I_S_FOOLERY = RuleImage(roi_front=(164,436,307,100), roi_back=(164,436,307,100), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_foolery.png")
+	# description 
+	I_S_TEAM_LOCK = RuleImage(roi_front=(559,562,31,36), roi_back=(559,562,31,36), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_team_lock.png")
+	# description 
+	I_S_TEAM_UNLOCK = RuleImage(roi_front=(555,561,33,33), roi_back=(555,561,33,33), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_team_unlock.png")
+	# 挑战 
+	I_S_FIRE = RuleImage(roi_front=(1105,585,100,100), roi_back=(1105,585,100,100), threshold=0.7, method="Template matching", file="./tasks/Sougenbi/s/s_s_fire.png")
+	# 确认进入业原火 
+	I_S_CHECK_SOUGENBI = RuleImage(roi_front=(772,222,307,292), roi_back=(772,222,307,292), threshold=0.8, method="Template matching", file="./tasks/Sougenbi/s/s_s_check_sougenbi.png")
+
+
+	# Ocr Rule Assets
+	# Ocr-description 
+	O_S_GREED = RuleOcr(roi=(388,20,63,42), area=(388,20,63,42), mode="Single", method="Default", keyword="", name="s_greed")
+	# Ocr-description 
+	O_S_ANGER = RuleOcr(roi=(571,18,79,43), area=(571,18,79,43), mode="Digit", method="Default", keyword="", name="s_anger")
+	# Ocr-description 
+	O_S_FOOLERY = RuleOcr(roi=(755,23,68,36), area=(755,23,68,36), mode="Digit", method="Default", keyword="", name="s_foolery")
+
 

+ 21 - 0
tasks/Sougenbi/config.py

@@ -2,10 +2,31 @@
 # @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 SougenbiClass(str, Enum):
+    GREED = '贪'
+    Anger = '嗔'
+    Foolery = '痴'
+
+class SougenbiConfig(ConfigBase):
+    sougenbi_class: SougenbiClass = Field(default=SougenbiClass.Foolery)
+    # 限制时间
+    limit_time: time = Field(default=time(minute=30), description='limit_time_help')
+    # 限制次数
+    limit_count: int = Field(default=30, description='limit_count_help')
+
 
 class Sougenbi(ConfigBase):
     scheduler: Scheduler = Field(default_factory=Scheduler)
+    sougenbi_config: SougenbiConfig = Field(default_factory=SougenbiConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)
+    switch_soul_config: SwitchSoulConfig = Field(default_factory=SwitchSoulConfig)
 

+ 20 - 0
tasks/Sougenbi/s/click.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "c_greed",
+    "roiFront": "172,144,299,100",
+    "roiBack": "172,144,299,100",
+    "description": "description"
+  },
+  {
+    "itemName": "c_anger",
+    "roiFront": "165,289,307,100",
+    "roiBack": "165,289,307,100",
+    "description": "description"
+  },
+  {
+    "itemName": "c_foolery",
+    "roiFront": "166,435,303,100",
+    "roiBack": "166,435,303,100",
+    "description": "description"
+  }
+]

+ 74 - 0
tasks/Sougenbi/s/image.json

@@ -0,0 +1,74 @@
+[
+  {
+    "itemName": "s_sougenbi",
+    "imageName": "s_s_sougenbi.png",
+    "roiFront": "405,97,301,414",
+    "roiBack": "405,97,301,414",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "进入业原火"
+  },
+  {
+    "itemName": "s_greed",
+    "imageName": "s_s_greed.png",
+    "roiFront": "167,143,307,100",
+    "roiBack": "167,143,307,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "贪"
+  },
+  {
+    "itemName": "s_anger",
+    "imageName": "s_s_anger.png",
+    "roiFront": "164,291,307,100",
+    "roiBack": "164,291,307,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": ""
+  },
+  {
+    "itemName": "s_foolery",
+    "imageName": "s_s_foolery.png",
+    "roiFront": "164,436,307,100",
+    "roiBack": "164,436,307,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "痴"
+  },
+  {
+    "itemName": "s_team_lock",
+    "imageName": "s_s_team_lock.png",
+    "roiFront": "559,562,31,36",
+    "roiBack": "559,562,31,36",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "s_team_unlock",
+    "imageName": "s_s_team_unlock.png",
+    "roiFront": "555,561,33,33",
+    "roiBack": "555,561,33,33",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "s_fire",
+    "imageName": "s_s_fire.png",
+    "roiFront": "1105,585,100,100",
+    "roiBack": "1105,585,100,100",
+    "method": "Template matching",
+    "threshold": 0.7,
+    "description": "挑战"
+  },
+  {
+    "itemName": "s_check_sougenbi",
+    "imageName": "s_s_check_sougenbi.png",
+    "roiFront": "772,222,307,292",
+    "roiBack": "772,222,307,292",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "确认进入业原火"
+  }
+]

+ 29 - 0
tasks/Sougenbi/s/ocr.json

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "s_greed",
+    "roiFront": "388,20,63,42",
+    "roiBack": "388,20,63,42",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "s_anger",
+    "roiFront": "571,18,79,43",
+    "roiBack": "571,18,79,43",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  },
+  {
+    "itemName": "s_foolery",
+    "roiFront": "755,23,68,36",
+    "roiBack": "755,23,68,36",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "Ocr-description"
+  }
+]

BIN
tasks/Sougenbi/s/s_s_anger.png


BIN
tasks/Sougenbi/s/s_s_check_sougenbi.png


BIN
tasks/Sougenbi/s/s_s_fire.png


BIN
tasks/Sougenbi/s/s_s_foolery.png


BIN
tasks/Sougenbi/s/s_s_greed.png


BIN
tasks/Sougenbi/s/s_s_sougenbi.png


BIN
tasks/Sougenbi/s/s_s_team_lock.png


BIN
tasks/Sougenbi/s/s_s_team_unlock.png


+ 116 - 0
tasks/Sougenbi/script_task.py

@@ -0,0 +1,116 @@
+# 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 tasks.Sougenbi.assets import SougenbiAssets
+from tasks.Sougenbi.config import SougenbiConfig, SougenbiClass
+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_soul_zones, page_shikigami_records
+from module.logger import logger
+from module.exception import TaskEnd
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, SougenbiAssets):
+
+    def run(self):
+        con = self.config.sougenbi
+        limit_time = con.sougenbi_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_soul_zones)
+
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_S_CHECK_SOUGENBI):
+                break
+            if self.appear_then_click(self.I_S_SOUGENBI, interval=1):
+                continue
+        logger.info('Click sougenbi in soul zones')
+        sleep(0.5)
+        image_target = None
+        click_target = None
+        number_target = None
+        match con.sougenbi_config.sougenbi_class:
+            case SougenbiClass.GREED:
+                image_target = self.I_S_GREED
+                click_target = self.C_C_GREED
+                number_target = self.O_S_GREED
+            case SougenbiClass.Anger:
+                image_target = self.I_S_ANGER
+                click_target = self.C_C_ANGER
+                number_target = self.O_S_ANGER
+            case SougenbiClass.Foolery:
+                image_target = self.I_S_FOOLERY
+                click_target = self.C_C_FOOLERY
+                number_target = self.O_S_FOOLERY
+            case _:
+                raise ValueError('Sougenbi class error')
+        self.check_lock(con.general_battle_config.lock_team_enable, self.I_S_TEAM_LOCK, self.I_S_TEAM_UNLOCK)
+        while 1:
+            self.screenshot()
+            if self.click(click_target, interval=0.5):
+                pass
+            if self.appear(image_target, threshold=0.97):
+                break
+
+        # 开始循环
+        while 1:
+            self.screenshot()
+
+            if not self.appear(self.I_S_CHECK_SOUGENBI):
+                continue
+            if self.current_count >= con.sougenbi_config.limit_count:
+                logger.info('Sougenbi count limit out')
+                break
+            if datetime.now() - self.start_time >= self.limit_time:
+                logger.info('Sougenbi time limit out')
+                break
+            ticket = number_target.ocr(self.device.image)
+            if ticket == 0:
+                break
+
+            # 点击挑战
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_S_FIRE, interval=1):
+                    pass
+                if not self.appear(self.I_S_FIRE):
+                    self.run_general_battle(config=con.general_battle_config)
+                    break
+
+        # 回去到探索大世界
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_CHECK_EXPLORATION):
+                break
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1):
+                continue
+        logger.info('Back to exploration')
+        self.set_next_run("Sougenbi", success=True, finish=True)
+        raise TaskEnd
+
+
+
+
+
+
+
+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()
+    # print(t.appear(t.I_S_FOOLERY, threshold=0.97))
+