Procházet zdrojové kódy

Merge pull request #356 from runhey/dev

Dev
huangrunheng před 2 roky
rodič
revize
2927a79d98
33 změnil soubory, kde provedl 489 přidání a 156 odebrání
  1. 1 2
      README.md
  2. 3 2
      dev_tools/assets_test.py
  3. 92 139
      module/logger.py
  4. 7 1
      tasks/Component/Costume/config.py
  5. 58 2
      tasks/Component/Costume/costume_base.py
  6. 66 0
      tasks/Component/CostumeBattle/assets.py
  7. binární
      tasks/Component/CostumeBattle/battle1/battle1_exit_1.png
  8. binární
      tasks/Component/CostumeBattle/battle1/battle1_friends_1.png
  9. binární
      tasks/Component/CostumeBattle/battle1/battle1_local_1.png
  10. 29 0
      tasks/Component/CostumeBattle/battle1/image.json
  11. binární
      tasks/Component/CostumeBattle/battle2/battle2_exit_2.png
  12. binární
      tasks/Component/CostumeBattle/battle2/battle2_friends_2.png
  13. binární
      tasks/Component/CostumeBattle/battle2/battle2_local_2.png
  14. 29 0
      tasks/Component/CostumeBattle/battle2/image.json
  15. binární
      tasks/Component/CostumeBattle/battle3/battle3_exit_3.png
  16. binární
      tasks/Component/CostumeBattle/battle3/battle3_friends_3.png
  17. binární
      tasks/Component/CostumeBattle/battle3/battle3_local_3.png
  18. 29 0
      tasks/Component/CostumeBattle/battle3/image.json
  19. binární
      tasks/Component/CostumeBattle/battle4/battle1_friends_4.png
  20. binární
      tasks/Component/CostumeBattle/battle4/battle4_exit_4.png
  21. binární
      tasks/Component/CostumeBattle/battle4/battle4_local_4.png
  22. 29 0
      tasks/Component/CostumeBattle/battle4/image.json
  23. binární
      tasks/Component/CostumeBattle/battle5/battle5_exit_5.png
  24. binární
      tasks/Component/CostumeBattle/battle5/battle5_friends_5.png
  25. binární
      tasks/Component/CostumeBattle/battle5/battle5_local_5.png
  26. 29 0
      tasks/Component/CostumeBattle/battle5/image.json
  27. binární
      tasks/Component/CostumeBattle/battle6/battle1_friends_6.png
  28. binární
      tasks/Component/CostumeBattle/battle6/battle6_exit_6.png
  29. binární
      tasks/Component/CostumeBattle/battle6/battle6_local_6.png
  30. 29 0
      tasks/Component/CostumeBattle/battle6/image.json
  31. 78 0
      tasks/Component/CostumeBattle/costume_test_battle.py
  32. 5 5
      tasks/GameUi/assets.py
  33. 5 5
      tasks/GameUi/page/page_img_3.json

+ 1 - 2
README.md

@@ -33,7 +33,6 @@
 
 ## 功能 Features
 
-- OAS 还在开发中,[查看已实现](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - **日常任务**: 悬赏封印、小猫咪、小杂签到、金币妖怪、年兽、花合战、地鬼、封魔、御魂整理
 - **每周相关**: 真蛇、秘闻竞速、神秘商店、搜刮商店、斗技、每周小杂事
 - **阴阳寮**: 结界上卡、结界蹭卡、结界突破、寮突破、狩猎战、集体任务、道馆
@@ -92,7 +91,7 @@ OAS 在其基础上进行了如下优化:
 
 #### QQ开发群: 207613181 (有意开发本项目请加此群, 请不要胡乱加群)
 
-- 发展规划:[#54](https://github.com/runhey/OnmyojiAutoScript/issues/54)
+- 开发规划:[#354](https://github.com/runhey/OnmyojiAutoScript/issues/354)
 - OAS 继承了 Alas 的设计思路,极大简便了开发,欢迎提交 PR,挑选你感兴趣的部分进行开发即可。
 - OAS 仍在活跃中, 我们会不定期发布未来的工作在 Issues 上并标记为 `help wanted`,欢迎向 OAS 提交 PR,我们会认真阅读你的每一行代码的。
 

+ 3 - 2
dev_tools/assets_test.py

@@ -34,10 +34,11 @@ def detect_ocr(file: str, target: RuleOcr):
 
 
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = r"C:\Users\萌萌哒\Desktop\341978692-fdceb33c-eec1-4965-a2b9-8f75cd54d5e2.png"
+IMAGE_FILE = r"C:\Users\萌萌哒\Desktop\349772746-36423909-af3d-4d9c-bae4-9d2597e2ecda.png"
 if __name__ == '__main__':
     from tasks.RyouToppa.assets import RyouToppaAssets
-    targe = RyouToppaAssets.I_RYOU_TOPPA
+    from tasks.GameUi.assets import GameUiAssets
+    targe = GameUiAssets.I_MAIN_GOTO_GUILD
     print(detect_image(IMAGE_FILE, targe))
 
     # ocr demo

+ 92 - 139
module/logger.py

@@ -24,172 +24,76 @@ def empty_function(*args, **kwargs):
     pass
 
 
+# Ensure running in Alas root folder
+os.chdir(os.path.join(os.path.dirname(__file__), '../'))
 # cnocr will set root logger in cnocr.utils
 # Delete logging.basicConfig to avoid logging the same message twice.
 logging.basicConfig = empty_function
 logging.raiseExceptions = True  # Set True if wanna see encode errors on console
 
 # Remove HTTP keywords (GET, POST etc.)
-RichHandler.KEYWORDS = []
-
-
-class RichFileHandler(RichHandler):
-    # Rename
-    pass
+# RichHandler.KEYWORDS = []
 
 
-
-#
-# class FlutterHandler(RichHandler):
-#     """
-#     Pass renderable into a function
-#     主要是传入一个回调函数
-#     """
-#
-#     def __init__(self, *args, func: Callable[[ConsoleRenderable], None] = None, **kwargs):
-#         super().__init__(*args, **kwargs)
-#         self._func = func
-#
-#     def emit(self, record: logging.LogRecord) -> None:
-#         message = self.format(record)
-#         tb = None
-#         if (
-#             self.rich_tracebacks
-#             and record.exc_info
-#             and record.exc_info != (None, None, None)
-#         ):
-#             exc_type, exc_value, exc_traceback = record.exc_info
-#             traceback.print_tb(exc_traceback)
-#             self._func(exc_traceback)
-#             assert exc_type is not None
-#             assert exc_value is not None
-#             tb = Traceback.from_exception(
-#                 exc_type,
-#                 exc_value,
-#                 exc_traceback,
-#                 width=self.tracebacks_width,
-#                 extra_lines=self.tracebacks_extra_lines,
-#                 theme=self.tracebacks_theme,
-#                 word_wrap=self.tracebacks_word_wrap,
-#                 show_locals=self.tracebacks_show_locals,
-#                 locals_max_length=self.locals_max_length,
-#                 locals_max_string=self.locals_max_string,
-#             )
-#             # 这个好理解转化为特定格式, getMessage()返回寸str
-#             message = record.getMessage()
-#             if self.formatter:
-#                 record.message = record.getMessage()
-#                 formatter = self.formatter
-#                 if hasattr(formatter, "usesTime") and formatter.usesTime():
-#                     record.asctime = formatter.formatTime(
-#                         record, formatter.datefmt)
-#                 message = formatter.formatMessage(record)
+# def show_handlers(handlers):
+#     # 获取并打印日志记录器中处理器的信息
+#     for handler in logger.handlers:
+#         # 获取处理器的类名
+#         handler_class = handler.__class__.__name__
+#         print(f"Handler class: {handler_class}")
 #
-#         # 这个message_renderable是一个Text对象
-#         message_renderable = self.render_message(record, message)
-#         log_renderable: ConsoleRenderable = self.render(
-#             record=record, traceback=tb, message_renderable=message_renderable
-#         )
+#         # 获取处理器的级别
+#         handler_level = logging.getLevelName(handler.level)
+#         print(f"Handler level: {handler_level}")
 #
-#         # msg2 = Text.from_markup(message).markup
+#         # 获取处理器的格式化器
+#         formatter = handler.formatter
+#         if formatter is not None:
+#             formatter_class = formatter.__class__.__name__
+#             print(f"Formatter class: {formatter_class}")
 #
-#         # 这个message_renderable是一个Text对象
-#         # traceback是表示异常的对象
-#         # Directly put renderable into function
-#         if log_renderable:
-#             if log_renderable is not str:
-#                 print(f'-------------------------------------------------------log is not str{log_renderable}')
-#                 log_renderable = str(log_renderable)
-#             self._func(log_renderable)
-#
-#     def handle(self, record: logging.LogRecord) -> bool:
-#         if not self._func:
-#             return True
-#         super().handle(record)
-
-class FlutterHandler(RichHandler):
-    # Rename
-    pass
-
-class FlutterConsole(Console):
-    """
-    Force full feature console
-    but not working lol :(
-    """
-    @property
-    def options(self) -> ConsoleOptions:
-        return ConsoleOptions(
-            max_height=self.size.height,
-            size=self.size,
-            legacy_windows=False,
-            min_width=1,
-            max_width=self.width,
-            encoding='utf-8',
-            is_terminal=False,
-        )
-
-class FlutterLogStream(TextIOBase):
-    def __init__(self, *args, func: Callable[[ConsoleRenderable], None] = None, **kwargs):
-        super().__init__(*args, **kwargs)
-        self._func = func
-
-    def write(self, msg: str) -> int:
-        if isinstance(msg, bytes):
-            msg = msg.decode("utf-8")
-        self._func(msg)
-        return len(msg)
-
-
-def show_handlers(handlers):
-    # 获取并打印日志记录器中处理器的信息
-    for handler in logger.handlers:
-        # 获取处理器的类名
-        handler_class = handler.__class__.__name__
-        print(f"Handler class: {handler_class}")
-
-        # 获取处理器的级别
-        handler_level = logging.getLevelName(handler.level)
-        print(f"Handler level: {handler_level}")
-
-        # 获取处理器的格式化器
-        formatter = handler.formatter
-        if formatter is not None:
-            formatter_class = formatter.__class__.__name__
-            print(f"Formatter class: {formatter_class}")
-
-        # 其他处理器的属性和方法,根据需要进行获取和打印
+#         # 其他处理器的属性和方法,根据需要进行获取和打印
+#         print()  # 打印空行,用于分隔处理器的信息
 
-        print()  # 打印空行,用于分隔处理器的信息
 
 # Logger init
 logger_debug = False
 logger = logging.getLogger('oas')
 logger.setLevel(logging.DEBUG if logger_debug else logging.INFO)
 file_formatter = logging.Formatter(
-    fmt='%(asctime)s.%(msecs)03d | %(filename)s:%(lineno)d | %(levelname)8s | %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+    fmt='%(asctime)s.%(msecs)03d | %(filename)20s:%(lineno)04d | %(levelname)8s | %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
 console_formatter = logging.Formatter(
-    fmt='%(asctime)s.%(msecs)03d | %(filename)s:%(lineno)d│ %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+    fmt='%(asctime)s.%(msecs)03d │ %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
 flutter_formatter = logging.Formatter(
     fmt='| %(asctime)s.%(msecs)03d | %(message)08s', datefmt='%H:%M:%S')
 
 
-# Add rich console logger
 # ======================================================================================================================
-#            设置控制台的
+#            Set console logger
 # ======================================================================================================================
-stdout_console = console = Console()
 console_hdlr = RichHandler(
+    console=Console(
+        width=120
+    ),
     show_path=False,
     show_time=False,
     rich_tracebacks=True,
     tracebacks_show_locals=True,
     tracebacks_extra_lines=3,
+    tracebacks_width=160
 )
 console_hdlr.setFormatter(console_formatter)
 logger.addHandler(console_hdlr)
 
-# Ensure running in Alas root folder
-os.chdir(os.path.join(os.path.dirname(__file__), '../'))
+
+# ======================================================================================================================
+#            Set file
+# ======================================================================================================================
+class RichFileHandler(RichHandler):
+    # Rename
+    pass
+
+
 # Add file logger
 pyw_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
 
@@ -208,8 +112,8 @@ def set_file_logger(name=pyw_name):
         file=file,
         no_color=True,
         highlight=False,
-        width=80,
-    )
+        width=160,
+    ) 
 
     hdlr = RichFileHandler(
         console=file_console,
@@ -219,7 +123,7 @@ def set_file_logger(name=pyw_name):
         rich_tracebacks=True,
         tracebacks_show_locals=True,
         tracebacks_extra_lines=3,
-        tracebacks_width=80,
+        tracebacks_width=160,
         highlighter=NullHighlighter(),
     )
     hdlr.setFormatter(file_formatter)
@@ -229,7 +133,46 @@ def set_file_logger(name=pyw_name):
     logger.addHandler(hdlr)
     logger.log_file = log_file
 
-# 给flutter设置
+
+# ======================================================================================================================
+#            Set flutter
+# ======================================================================================================================
+class FlutterHandler(RichHandler):
+    # Rename
+    pass
+
+
+class FlutterConsole(Console):
+    """
+    Force full feature console
+    but not working lol :(
+    """
+
+    @property
+    def options(self) -> ConsoleOptions:
+        return ConsoleOptions(
+            max_height=self.size.height,
+            size=self.size,
+            legacy_windows=False,
+            min_width=1,
+            max_width=self.width,
+            encoding='utf-8',
+            is_terminal=False,
+        )
+
+
+class FlutterLogStream(TextIOBase):
+    def __init__(self, *args, func: Callable[[ConsoleRenderable], None] = None, **kwargs):
+        super().__init__(*args, **kwargs)
+        self._func = func
+
+    def write(self, msg: str) -> int:
+        if isinstance(msg, bytes):
+            msg = msg.decode("utf-8")
+        self._func(msg)
+        return len(msg)
+
+
 def set_func_logger(func):
     stream = FlutterLogStream(func=func)
     stream_console = Console(
@@ -253,9 +196,13 @@ def set_func_logger(func):
     hdlr.setFormatter(flutter_formatter)
     logger.addHandler(hdlr)
 
+# ======================================================================================================================
+#            Set print format
+# ======================================================================================================================
+
 
 def _get_renderables(
-    self: Console, *objects, sep=" ", end="\n", justify=None, emoji=None, markup=None, highlight=None,
+        self: Console, *objects, sep=" ", end="\n", justify=None, emoji=None, markup=None, highlight=None,
 ) -> List[ConsoleRenderable]:
     """
     Refer to rich.console.Console.print()
@@ -287,6 +234,7 @@ def print(*objects: ConsoleRenderable, **kwargs):
         elif isinstance(hdlr, RichHandler):
             hdlr.console.print(*objects)
 
+
 class GuiRule(Rule):
     def __rich_console__(
             self, console: Console, options: ConsoleOptions
@@ -309,11 +257,13 @@ class GuiRule(Rule):
     def __repr__(self):
         return self.__str__()
 
+
 def rule(title="", *, characters="─", style="rule.line", end="\n", align="center"):
     rule = GuiRule(title=title, characters=characters,
-                style=style, end=end)
+                   style=style, end=end)
     print(rule)
 
+
 def hr(title, level=3):
     title = str(title).upper()
     if level == 1:
@@ -329,15 +279,18 @@ def hr(title, level=3):
         logger.rule(title, characters='─')
         logger.rule(characters='═')
 
+
 def attr(name, text):
     logger.info('[%s] %s' % (str(name), str(text)))
 
+
 def attr_align(name, text, front='', align=22):
     name = str(name).rjust(align)
     if front:
         name = front + name[len(front):]
     logger.info('%s: %s' % (name, str(text)))
 
+
 def show():
     logger.info('INFO')
     logger.warning('WARNING')
@@ -351,11 +304,13 @@ def show():
     logger.info(r'Brace { [ ( ) ] }')
     logger.info(r'True, False, None')
     logger.info(r'E:/path\\to/alas/alas.exe, /root/alas/, ./relative/path/log.txt')
+    logger.info('Tests very long strings. Tests very long strings. Tests very long strings. Tests very long strings. Tests very long strings.')
     local_var1 = 'This is local variable'
     # Line before exception
     raise Exception("Exception")
     # Line below exception
 
+
 def error_convert(func):
     def error_wrapper(msg, *args, **kwargs):
         if isinstance(msg, Exception):
@@ -377,5 +332,3 @@ logger.log_file: str
 
 logger.set_file_logger()
 logger.hr('Start', level=0)
-
-

+ 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'  # 桂馥金秋
 
 
 

+ 58 - 2
tasks/Component/Costume/costume_base.py

@@ -3,11 +3,13 @@
 # github https://github.com/runhey
 
 from module.atom.image import RuleImage
+from module.logger import logger
 
 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 +71,41 @@ 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',
+    },
+    BattleType.COSTUME_BATTLE_2: {
+        'I_LOCAL': 'I_LOCAL_2',
+        'I_EXIT': 'I_EXIT_2',
+        'I_FRIENDS': 'I_FRIENDS_2',
+    },
+    BattleType.COSTUME_BATTLE_3: {
+        'I_LOCAL': 'I_LOCAL_3',
+        'I_EXIT': 'I_EXIT_3',
+        'I_FRIENDS': 'I_FRIENDS_3',
+    },
+    BattleType.COSTUME_BATTLE_4: {
+        'I_LOCAL': 'I_LOCAL_4',
+        'I_EXIT': 'I_EXIT_4',
+        'I_FRIENDS': 'I_FRIENDS_4',
+    },
+    BattleType.COSTUME_BATTLE_5: {
+        'I_LOCAL': 'I_LOCAL_5',
+        'I_EXIT': 'I_EXIT_5',
+        'I_FRIENDS': 'I_FRIENDS_5',
+    },
+    BattleType.COSTUME_BATTLE_6: {
+        'I_LOCAL': 'I_LOCAL_6',
+        'I_EXIT': 'I_EXIT_6',
+        'I_FRIENDS': 'I_FRIENDS_6',
+    },
+}
+
+
 class CostumeBase:
 
     def check_costume(self, config: CostumeConfig=None):
@@ -76,20 +113,26 @@ 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):
+    def replace_img(self,
+                    asset_before: str,
+                    asset_after: RuleImage,
+                    rp_roi_back: bool = True):
         if not hasattr(self, asset_before):
             return
         # setattr(self, asset_before, asset_after)
         asset_before_object: RuleImage = getattr(self, asset_before)
         asset_before_object.roi_front = asset_after.roi_front
-        asset_before_object.roi_back = asset_after.roi_back
+        if rp_roi_back:
+            asset_before_object.roi_back = asset_after.roi_back
         asset_before_object.threshold = asset_after.threshold
         asset_before_object.file = asset_after.file
 
     def check_costume_main(self, main_type: MainType):
         if main_type == MainType.COSTUME_MAIN:
             return
+        logger.info(f'Switch main costume to {main_type}')
         costume_assets = CostumeAssets()
         for key, value in main_costume_model[main_type].items():
             assert_value: RuleImage = getattr(costume_assets, value)
@@ -98,11 +141,24 @@ class CostumeBase:
     def check_costume_realm(self, realm_type: RealmType):
         if realm_type == RealmType.COSTUME_REALM_DEFAULT:
             return
+        logger.info(f'Switch realm theme {realm_type}')
         costume_realm_assets = CostumeRealmAssets()
         for key, value in realm_costume_model[realm_type].items():
             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
+        logger.info(f'Switch battle theme {battle_type}')
+        costume_battle_assets = CostumeBattleAssets()
+        for key, value in battle_theme_model[battle_type].items():
+            assert_value: RuleImage = getattr(costume_battle_assets, value)
+            # 绿标的坐标点范围不变
+            if key == 'I_LOCAL':
+                self.replace_img(key, assert_value, rp_roi_back=False)
+            else:
+                self.replace_img(key, assert_value)
 
 
 if __name__ == '__main__':

+ 66 - 0
tasks/Component/CostumeBattle/assets.py

@@ -0,0 +1,66 @@
+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 CostumeBattleAssets: 
+
+
+	# Image Rule Assets
+	# 指针 
+	I_LOCAL_1 = RuleImage(roi_front=(119,493,23,25), roi_back=(119,493,23,25), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle1/battle1_local_1.png")
+	# 左上角退出 
+	I_EXIT_1 = RuleImage(roi_front=(21,20,27,31), roi_back=(21,20,27,31), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle1/battle1_exit_1.png")
+	# 左上角好友 
+	I_FRIENDS_1 = RuleImage(roi_front=(88,18,35,34), roi_back=(88,18,35,34), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle1/battle1_friends_1.png")
+
+
+	# Image Rule Assets
+	# description 
+	I_LOCAL_2 = RuleImage(roi_front=(30,569,21,22), roi_back=(30,569,21,22), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle2/battle2_local_2.png")
+	# description 
+	I_EXIT_2 = RuleImage(roi_front=(17,16,35,34), roi_back=(17,16,35,34), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle2/battle2_exit_2.png")
+	# description 
+	I_FRIENDS_2 = RuleImage(roi_front=(88,15,34,39), roi_back=(88,15,34,39), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle2/battle2_friends_2.png")
+
+
+	# Image Rule Assets
+	# 指针 
+	I_LOCAL_3 = RuleImage(roi_front=(29,567,23,25), roi_back=(29,567,23,25), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle3/battle3_local_3.png")
+	# 左上角退出 
+	I_EXIT_3 = RuleImage(roi_front=(23,18,27,31), roi_back=(23,18,27,31), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle3/battle3_exit_3.png")
+	# 左上角好友 
+	I_FRIENDS_3 = RuleImage(roi_front=(89,17,35,34), roi_back=(89,17,35,34), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle3/battle3_friends_3.png")
+
+
+	# Image Rule Assets
+	# 指针 
+	I_LOCAL_4 = RuleImage(roi_front=(29,567,23,25), roi_back=(29,567,23,25), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle4/battle4_local_4.png")
+	# 左上角退出 
+	I_EXIT_4 = RuleImage(roi_front=(22,17,27,31), roi_back=(22,17,27,31), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle4/battle4_exit_4.png")
+	# 左上角好友 
+	I_FRIENDS_4 = RuleImage(roi_front=(88,16,35,34), roi_back=(88,16,35,34), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle4/battle4_friends_4.png")
+
+
+	# Image Rule Assets
+	# 指针 
+	I_LOCAL_5 = RuleImage(roi_front=(30,567,23,25), roi_back=(30,567,23,25), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle5/battle5_local_5.png")
+	# 左上角退出 
+	I_EXIT_5 = RuleImage(roi_front=(22,17,27,31), roi_back=(22,17,27,31), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle5/battle5_exit_5.png")
+	# 左上角好友 
+	I_FRIENDS_5 = RuleImage(roi_front=(90,17,35,34), roi_back=(90,17,35,34), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle5/battle5_friends_5.png")
+
+
+	# Image Rule Assets
+	# 指针 
+	I_LOCAL_6 = RuleImage(roi_front=(30,566,23,25), roi_back=(30,566,23,25), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle6/battle6_local_6.png")
+	# 左上角退出 
+	I_EXIT_6 = RuleImage(roi_front=(22,17,27,31), roi_back=(22,17,27,31), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle6/battle6_exit_6.png")
+	# 左上角好友 
+	I_FRIENDS_6 = RuleImage(roi_front=(89,18,35,34), roi_back=(89,18,35,34), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeBattle/battle6/battle6_friends_6.png")
+
+

binární
tasks/Component/CostumeBattle/battle1/battle1_exit_1.png


binární
tasks/Component/CostumeBattle/battle1/battle1_friends_1.png


binární
tasks/Component/CostumeBattle/battle1/battle1_local_1.png


+ 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": "左上角好友"
+  }
+]

binární
tasks/Component/CostumeBattle/battle2/battle2_exit_2.png


binární
tasks/Component/CostumeBattle/battle2/battle2_friends_2.png


binární
tasks/Component/CostumeBattle/battle2/battle2_local_2.png


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

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "local_2",
+    "imageName": "battle2_local_2.png",
+    "roiFront": "30,569,21,22",
+    "roiBack": "30,569,21,22",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "exit_2",
+    "imageName": "battle2_exit_2.png",
+    "roiFront": "17,16,35,34",
+    "roiBack": "17,16,35,34",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "friends_2",
+    "imageName": "battle2_friends_2.png",
+    "roiFront": "88,15,34,39",
+    "roiBack": "88,15,34,39",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

binární
tasks/Component/CostumeBattle/battle3/battle3_exit_3.png


binární
tasks/Component/CostumeBattle/battle3/battle3_friends_3.png


binární
tasks/Component/CostumeBattle/battle3/battle3_local_3.png


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

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "local_3",
+    "imageName": "battle3_local_3.png",
+    "roiFront": "29,567,23,25",
+    "roiBack": "29,567,23,25",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "指针"
+  },
+  {
+    "itemName": "exit_3",
+    "imageName": "battle3_exit_3.png",
+    "roiFront": "23,18,27,31",
+    "roiBack": "23,18,27,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角退出"
+  },
+  {
+    "itemName": "friends_3",
+    "imageName": "battle3_friends_3.png",
+    "roiFront": "89,17,35,34",
+    "roiBack": "89,17,35,34",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角好友"
+  }
+]

binární
tasks/Component/CostumeBattle/battle4/battle1_friends_4.png


binární
tasks/Component/CostumeBattle/battle4/battle4_exit_4.png


binární
tasks/Component/CostumeBattle/battle4/battle4_local_4.png


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

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "local_4",
+    "imageName": "battle4_local_4.png",
+    "roiFront": "29,567,23,25",
+    "roiBack": "29,567,23,25",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "指针"
+  },
+  {
+    "itemName": "exit_4",
+    "imageName": "battle4_exit_4.png",
+    "roiFront": "22,17,27,31",
+    "roiBack": "22,17,27,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角退出"
+  },
+  {
+    "itemName": "friends_4",
+    "imageName": "battle4_friends_4.png",
+    "roiFront": "88,16,35,34",
+    "roiBack": "88,16,35,34",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角好友"
+  }
+]

binární
tasks/Component/CostumeBattle/battle5/battle5_exit_5.png


binární
tasks/Component/CostumeBattle/battle5/battle5_friends_5.png


binární
tasks/Component/CostumeBattle/battle5/battle5_local_5.png


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

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "local_5",
+    "imageName": "battle5_local_5.png",
+    "roiFront": "30,567,23,25",
+    "roiBack": "30,567,23,25",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "指针"
+  },
+  {
+    "itemName": "exit_5",
+    "imageName": "battle5_exit_5.png",
+    "roiFront": "22,17,27,31",
+    "roiBack": "22,17,27,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角退出"
+  },
+  {
+    "itemName": "friends_5",
+    "imageName": "battle5_friends_5.png",
+    "roiFront": "90,17,35,34",
+    "roiBack": "90,17,35,34",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角好友"
+  }
+]

binární
tasks/Component/CostumeBattle/battle6/battle1_friends_6.png


binární
tasks/Component/CostumeBattle/battle6/battle6_exit_6.png


binární
tasks/Component/CostumeBattle/battle6/battle6_local_6.png


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

@@ -0,0 +1,29 @@
+[
+  {
+    "itemName": "local_6",
+    "imageName": "battle6_local_6.png",
+    "roiFront": "30,566,23,25",
+    "roiBack": "30,566,23,25",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "指针"
+  },
+  {
+    "itemName": "exit_6",
+    "imageName": "battle6_exit_6.png",
+    "roiFront": "22,17,27,31",
+    "roiBack": "22,17,27,31",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "左上角退出"
+  },
+  {
+    "itemName": "friends_6",
+    "imageName": "battle6_friends_6.png",
+    "roiFront": "89,18,35,34",
+    "roiBack": "89,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()

+ 5 - 5
tasks/GameUi/assets.py

@@ -127,21 +127,21 @@ class GameUiAssets:
 
 	# Image Rule Assets
 	# 式神录 
-	I_MAIN_GOTO_SHIKIGAMI_RECORDS = RuleImage(roi_front=(1098,611,56,64), roi_back=(1084,589,93,106), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_shikigami_records.png")
+	I_MAIN_GOTO_SHIKIGAMI_RECORDS = RuleImage(roi_front=(1098,611,56,64), roi_back=(1084,589,93,106), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_shikigami_records.png")
 	# description 
 	I_MAIN_GOTO_ONMYODO = RuleImage(roi_front=(992,614,51,60), roi_back=(992,614,51,60), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_onmyodo.png")
 	# description 
-	I_MAIN_GOTO_FRIENDS = RuleImage(roi_front=(879,623,55,55), roi_back=(867,606,79,77), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_friends.png")
+	I_MAIN_GOTO_FRIENDS = RuleImage(roi_front=(879,623,55,55), roi_back=(867,606,79,77), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_friends.png")
 	# 进入花合战 
 	I_MAIN_GOTO_DAILY = RuleImage(roi_front=(779,612,51,67), roi_back=(754,595,89,97), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_daily.png")
 	# description 
 	I_MAIN_GOTO_MALL = RuleImage(roi_front=(663,661,41,22), roi_back=(644,613,81,78), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_mall.png")
 	# description 
-	I_MAIN_GOTO_GUILD = RuleImage(roi_front=(540,611,50,54), roi_back=(540,611,50,54), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_guild.png")
+	I_MAIN_GOTO_GUILD = RuleImage(roi_front=(540,611,50,54), roi_back=(540,611,50,54), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_guild.png")
 	# description 
-	I_MAIN_GOTO_TEAM = RuleImage(roi_front=(437,625,38,48), roi_back=(366,606,192,83), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_team.png")
+	I_MAIN_GOTO_TEAM = RuleImage(roi_front=(437,625,38,48), roi_back=(366,606,192,83), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_team.png")
 	# description 
-	I_MAIN_GOTO_COLLECTION = RuleImage(roi_front=(92,621,36,41), roi_back=(51,596,159,85), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_goto_collection.png")
+	I_MAIN_GOTO_COLLECTION = RuleImage(roi_front=(92,621,36,41), roi_back=(51,596,159,85), threshold=0.7, method="Template matching", file="./tasks/GameUi/page/page_main_goto_collection.png")
 	# description 
 	I_CHECK_RECORDS = RuleImage(roi_front=(269,71,55,50), roi_back=(269,71,55,50), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_records.png")
 	# description 

+ 5 - 5
tasks/GameUi/page/page_img_3.json

@@ -5,7 +5,7 @@
     "roiFront": "1098,611,56,64",
     "roiBack": "1084,589,93,106",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "式神录"
   },
   {
@@ -23,7 +23,7 @@
     "roiFront": "879,623,55,55",
     "roiBack": "867,606,79,77",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   },
   {
@@ -50,7 +50,7 @@
     "roiFront": "540,611,50,54",
     "roiBack": "540,611,50,54",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   },
   {
@@ -59,7 +59,7 @@
     "roiFront": "437,625,38,48",
     "roiBack": "366,606,192,83",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   },
   {
@@ -68,7 +68,7 @@
     "roiFront": "92,621,36,41",
     "roiBack": "51,596,159,85",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
   },
   {