Просмотр исходного кода

doc[(your part)]: Add Task.DevRyouToppa(2023.11.23)
feat[(module name)]: Task.DevRyouToppa
perf[(module name)]: None
fix[(module name)]: None

zhaiyujia 3 лет назад
Родитель
Сommit
26420f7f6f

+ 1 - 1
module/config/config_manual.py

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

+ 1 - 1
module/config/config_menu.py

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

+ 2 - 0
module/config/config_model.py

@@ -13,6 +13,7 @@ from module.logger import logger
 from tasks.Component.config_base import ConfigBase
 from tasks.Exploration.config import Exploration
 from tasks.RyouToppa.config import RyouToppa
+from tasks.DevRyouToppa.config import DevRyouToppa
 from tasks.Script.config import Script
 from tasks.Restart.config import Restart
 from tasks.GlobalGame.config import GlobalGame
@@ -73,6 +74,7 @@ class ConfigModel(ConfigBase):
     nian: Nian = Field(default_factory=Nian)
     realm_raid: RealmRaid = Field(default_factory=RealmRaid)
     ryou_toppa: RyouToppa = Field(default_factory=RyouToppa)
+    dev_ryou_toppa: DevRyouToppa = Field(default_factory=DevRyouToppa)
     kekkai_utilize: KekkaiUtilize = Field(default_factory=KekkaiUtilize)
     kekkai_activation: KekkaiActivation = Field(default_factory=KekkaiActivation)
     demon_encounter: DemonEncounter = Field(default_factory=DemonEncounter)

+ 47 - 0
tasks/DevRyouToppa/assets.py

@@ -0,0 +1,47 @@
+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 DevRyouToppaAssets: 
+
+
+	# Image Rule Assets
+	# 区域1攻略失败 
+	I_AREA_1_IS_FAILURE = RuleImage(roi_front=(673,146,63,32), roi_back=(421,138,325,123), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域2攻略失败 
+	I_AREA_2_IS_FAILURE = RuleImage(roi_front=(1011,146,63,30), roi_back=(757,137,327,128), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域3攻略失败 
+	I_AREA_3_IS_FAILURE = RuleImage(roi_front=(665,283,73,40), roi_back=(419,271,327,127), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域4攻略失败 
+	I_AREA_4_IS_FAILURE = RuleImage(roi_front=(1000,283,72,38), roi_back=(756,271,325,128), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域5攻略失败 
+	I_AREA_5_IS_FAILURE = RuleImage(roi_front=(669,419,65,29), roi_back=(418,406,328,128), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域6攻略失败 
+	I_AREA_6_IS_FAILURE = RuleImage(roi_front=(988,416,84,37), roi_back=(755,405,328,131), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域7攻略失败 
+	I_AREA_7_IS_FAILURE = RuleImage(roi_front=(672,556,61,37), roi_back=(420,543,326,114), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域8攻略失败 
+	I_AREA_8_IS_FAILURE = RuleImage(roi_front=(1004,556,64,29), roi_back=(756,541,327,113), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_2.png")
+	# 区域1攻略失败(最近一次) 
+	I_AREA_1_IS_FAILURE_NEW = RuleImage(roi_front=(673,146,63,32), roi_back=(421,138,325,123), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域2攻略失败(最近一次) 
+	I_AREA_2_IS_FAILURE_NEW = RuleImage(roi_front=(1011,146,63,30), roi_back=(757,137,327,128), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域3攻略失败(最近一次) 
+	I_AREA_3_IS_FAILURE_NEW = RuleImage(roi_front=(665,283,73,40), roi_back=(419,271,327,127), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区4攻略失败(最近一次) 
+	I_AREA_4_IS_FAILURE_NEW = RuleImage(roi_front=(1000,283,72,38), roi_back=(756,271,325,128), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域5攻略失败(最近一次) 
+	I_AREA_5_IS_FAILURE_NEW = RuleImage(roi_front=(669,419,65,29), roi_back=(418,406,328,128), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域6攻略失败(最近一次) 
+	I_AREA_6_IS_FAILURE_NEW = RuleImage(roi_front=(988,416,84,37), roi_back=(755,405,328,131), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域7攻略失败(最近一次) 
+	I_AREA_7_IS_FAILURE_NEW = RuleImage(roi_front=(672,556,61,37), roi_back=(420,543,326,114), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+	# 区域8攻略失败(最近一次) 
+	I_AREA_8_IS_FAILURE_NEW = RuleImage(roi_front=(1004,556,64,29), roi_back=(756,541,327,113), threshold=0.8, method="Template matching", file="./tasks/DevRyouToppa/res/loser_sign_1.png")
+
+

+ 14 - 0
tasks/DevRyouToppa/config.py

@@ -0,0 +1,14 @@
+from pydantic import BaseModel, Field
+from tasks.Component.GeneralBattle.config_general_battle import GeneralBattleConfig
+from tasks.Component.config_base import ConfigBase
+from tasks.Component.config_scheduler import Scheduler
+
+
+class RaidConfig(BaseModel):
+    is_skip_difficult: bool = Field(default=True, description='是否跳过难度较高的结界,失败后不再攻打该结界')
+
+
+class DevRyouToppa(ConfigBase):
+    scheduler: Scheduler = Field(default_factory=Scheduler)
+    raid_config: RaidConfig = Field(default_factory=RaidConfig)
+    general_battle_config: GeneralBattleConfig = Field(default_factory=GeneralBattleConfig)

+ 146 - 0
tasks/DevRyouToppa/res/image.json

@@ -0,0 +1,146 @@
+[
+  {
+    "itemName": "area_1_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "673,146,63,32",
+    "roiBack": "421,138,325,123",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域1攻略失败"
+  },
+  {
+    "itemName": "area_2_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "1011,146,63,30",
+    "roiBack": "757,137,327,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域2攻略失败"
+  },
+  {
+    "itemName": "area_3_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "665,283,73,40",
+    "roiBack": "419,271,327,127",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域3攻略失败"
+  },
+  {
+    "itemName": "area_4_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "1000,283,72,38",
+    "roiBack": "756,271,325,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域4攻略失败"
+  },
+  {
+    "itemName": "area_5_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "669,419,65,29",
+    "roiBack": "418,406,328,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域5攻略失败"
+  },
+  {
+    "itemName": "area_6_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "988,416,84,37",
+    "roiBack": "755,405,328,131",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域6攻略失败"
+  },
+  {
+    "itemName": "area_7_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "672,556,61,37",
+    "roiBack": "420,543,326,114",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域7攻略失败"
+  },
+  {
+    "itemName": "area_8_is_failure",
+    "imageName": "loser_sign_2.png",
+    "roiFront": "1004,556,64,29",
+    "roiBack": "756,541,327,113",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域8攻略失败"
+  },
+  {
+    "itemName": "area_1_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "673,146,63,32",
+    "roiBack": "421,138,325,123",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域1攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_2_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "1011,146,63,30",
+    "roiBack": "757,137,327,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域2攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_3_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "665,283,73,40",
+    "roiBack": "419,271,327,127",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域3攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_4_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "1000,283,72,38",
+    "roiBack": "756,271,325,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区4攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_5_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "669,419,65,29",
+    "roiBack": "418,406,328,128",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域5攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_6_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "988,416,84,37",
+    "roiBack": "755,405,328,131",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域6攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_7_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "672,556,61,37",
+    "roiBack": "420,543,326,114",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域7攻略失败(最近一次)"
+  },
+  {
+    "itemName": "area_8_is_failure_new",
+    "imageName": "loser_sign_1.png",
+    "roiFront": "1004,556,64,29",
+    "roiBack": "756,541,327,113",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "区域8攻略失败(最近一次)"
+  }
+]

BIN
tasks/DevRyouToppa/res/loser_sign_1.png


BIN
tasks/DevRyouToppa/res/loser_sign_2.png


+ 68 - 0
tasks/DevRyouToppa/script_task.py

@@ -0,0 +1,68 @@
+# This Python file uses the following encoding: utf-8
+
+import time
+
+from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
+from tasks.Component.GeneralBattle.general_battle import GeneralBattle
+from tasks.GameUi.game_ui import GameUi
+from tasks.RealmRaid.assets import RealmRaidAssets
+from tasks.DevRyouToppa.assets import DevRyouToppaAssets
+from module.atom.image_grid import ImageGrid
+from module.logger import logger
+
+area_tuple = (
+    (DevRyouToppaAssets.I_AREA_1_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_1_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_2_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_2_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_3_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_3_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_4_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_4_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_5_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_5_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_6_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_6_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_7_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_7_IS_FAILURE),
+    (DevRyouToppaAssets.I_AREA_8_IS_FAILURE_NEW, DevRyouToppaAssets.I_AREA_8_IS_FAILURE)
+)
+
+
+def validate_area_num(num: int):
+    if num < 1 or num > 8:
+        logger.error("Invalid area, [1-8]")
+        raise Exception("Invalid area")
+
+
+class ScriptTask(GeneralBattle, GameUi, SwitchSoul, DevRyouToppaAssets):
+    medal_grid: ImageGrid = None
+
+    def run(self):
+        """
+        执行
+        :return:
+        """
+        logger.info("Test Message")
+        print(self.check_area(2))
+
+    def check_area(self, area_num: int):
+        """
+        检查该区域是否攻略失败
+        :return:
+        """
+        validate_area_num(area_num)
+        index = area_num - 1
+        f1, f2 = area_tuple[index]
+        self.screenshot()
+        if self.appear(f1, threshold=0.8) or self.appear(f2, threshold=0.8):
+            return True
+        return False
+
+    def attack_area(self, area_num: int):
+        validate_area_num(area_num)
+        index = area_num - 1
+        self.screenshot()
+
+
+if __name__ == "__main__":
+    from module.config.config import Config
+    from module.device.device import Device
+
+    config = Config('oas1')
+    device = Device(config)
+    t = ScriptTask(config, device)
+    t.run()