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

feat(Costume): Add Battle costume '雅乐之邦'

huangrunheng 2 лет назад
Родитель
Сommit
28a696c0fc

+ 7 - 1
tasks/Component/Costume/config.py

@@ -39,7 +39,13 @@ class SignType(str, Enum):
 
 # 战斗主题
 class BattleType(str, Enum):
-    COSTUME_BATTLE_DEFAULT = 'costume_battle_default'  # 默认
+    COSTUME_BATTLE_DEFAULT = 'costume_battle_default'  # 简约主题 / 不支持怀旧
+    COSTUME_BATTLE_1 = 'costume_battle_1'  # 雅乐之邦
+    COSTUME_BATTLE_2 = 'costume_battle_2'  # 蝶寻花踪
+    COSTUME_BATTLE_3 = 'costume_battle_3'  # 凛霜寒雪
+    COSTUME_BATTLE_4 = 'costume_battle_4'  # 春缕含青
+    COSTUME_BATTLE_5 = 'costume_battle_5'  # 祥夜幽芳
+    COSTUME_BATTLE_6 = 'costume_battle_6'  # 桂馥金秋
 
 
 

+ 17 - 0
tasks/Component/Costume/costume_base.py

@@ -8,6 +8,7 @@ from tasks.Component.Costume.config import (MainType, CostumeConfig, RealmType,
                                             ThemeType, ShikigamiType, SignType, BattleType)
 from tasks.Component.Costume.assets import CostumeAssets
 from tasks.Component.CostumeRealm.assets import CostumeRealmAssets
+from tasks.Component.CostumeBattle.assets import CostumeBattleAssets
 
 # 庭院皮肤
 main_costume_model = {
@@ -69,6 +70,14 @@ realm_costume_model = {
                                 'I_BOX_EXP': 'I_BOX_EXP_2'},
 }
 
+# 战斗主题
+battle_theme_model = {
+    BattleType.COSTUME_BATTLE_1: {
+        'I_LOCAL': 'I_LOCAL_1',
+        'I_EXIT': 'I_EXIT_1',
+        'I_FRIENDS': 'I_FRIENDS_1',
+    },
+}
 class CostumeBase:
 
     def check_costume(self, config: CostumeConfig=None):
@@ -76,6 +85,7 @@ class CostumeBase:
             config: CostumeConfig = self.config.model.global_game.costume_config
         self.check_costume_main(config.costume_main_type)
         self.check_costume_realm(config.costume_realm_type)
+        self.check_costume_battle(config.costume_battle_type)
 
     def replace_img(self, asset_before: str, asset_after: RuleImage):
         if not hasattr(self, asset_before):
@@ -103,6 +113,13 @@ class CostumeBase:
             assert_value: RuleImage = getattr(costume_realm_assets, value)
             self.replace_img(key, assert_value)
 
+    def check_costume_battle(self, battle_type: BattleType):
+        if battle_type == BattleType.COSTUME_BATTLE_DEFAULT:
+            return
+        costume_battle_assets = CostumeBattleAssets()
+        for key, value in battle_theme_model[battle_type].items():
+            assert_value: RuleImage = getattr(costume_battle_assets, value)
+            self.replace_img(key, assert_value)
 
 
 if __name__ == '__main__':

+ 29 - 0
tasks/Component/CostumeBattle/battle1/image.json

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "local_1",
+    "imageName": "battle1_local_1.png",
+    "roiFront": "119,493,23,25",
+    "roiBack": "119,493,23,25",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "指针"
+  },
+  {
+    "itemName": "exit_1",
+    "imageName": "battle1_exit_1.png",
+    "roiFront": "21,20,27,31",
+    "roiBack": "21,20,27,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角退出"
+  },
+  {
+    "itemName": "friends_1",
+    "imageName": "battle1_friends_1.png",
+    "roiFront": "88,18,35,34",
+    "roiBack": "88,18,35,34",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角好友"
+  }
+]

+ 78 - 0
tasks/Component/CostumeBattle/costume_test_battle.py

@@ -0,0 +1,78 @@
+# This Python file uses the following encoding: utf-8
+# @author runhey
+# github https://github.com/runhey
+from module.logger import logger
+from module.base.timer import Timer
+
+from tasks.GameUi.page import page_kekkai_toppa
+from tasks.Component.GeneralBattle.config_general_battle import GreenMarkType, GeneralBattleConfig
+from tasks.RyouToppa.script_task import ScriptTask as ScriptTaskBase
+from tasks.Component.Costume.config import BattleType
+
+# 突破/前提是有突破券
+class ScriptTask(ScriptTaskBase):
+
+    def run(self):
+        self.ui_get_current_page()
+        self.ui_goto(page_kekkai_toppa)
+
+        self.attack()
+
+        # self.fire(1)
+        # self.run_general_battle_back(con.general_battle_config)
+        # self.fire(1)
+        # self.run_general_battle_back(con.general_battle_config)
+
+    @property
+    def battle_config(self) -> GeneralBattleConfig:
+        _con = GeneralBattleConfig()
+        # 绿标测试
+        _con.green_enable = True
+        _con.green_mark = GreenMarkType.GREEN_LEFT4
+        return _con
+
+    def attack(self):
+        import time
+        from tasks.RyouToppa.script_task import area_map
+        from tasks.RealmRaid.assets import RealmRaidAssets
+
+        index = 1
+        if not self.check_area(index):
+            return False
+
+        rcl = area_map[index].get("rule_click")
+        click_failure_count = 0
+        while True:
+            self.screenshot()
+            if click_failure_count >= 3:
+                logger.warning("Click failure, check your click position")
+                return False
+            if not self.appear(self.I_TOPPA_RECORD, threshold=0.85):
+                time.sleep(1)
+                self.screenshot()
+                if self.appear(self.I_TOPPA_RECORD, threshold=0.85):
+                    continue
+                logger.info("Start attach area [%s]" % str(index + 1))
+                return self.run_general_battle_back(config=self.battle_config)
+
+            if self.appear_then_click(RealmRaidAssets.I_FIRE, interval=2, threshold=0.8):
+                click_failure_count += 1
+                continue
+            if self.click(rcl, interval=5):
+                continue
+
+    def set_costume(self, costume: BattleType=BattleType.COSTUME_BATTLE_DEFAULT):
+        self.config.model.global_game.costume_config.costume_battle_type = costume
+        self.check_costume()
+        logger.info('Set costume to %s' % self.config.model.global_game.costume_config.costume_battle_type)
+
+
+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.set_costume(BattleType.COSTUME_BATTLE_1)
+    t.run()