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

+ 31 - 0
tasks/Component/Costume/config.py

@@ -4,6 +4,7 @@
 from pydantic import BaseModel, Field
 from enum import Enum
 
+# 庭院皮肤
 class MainType(str, Enum):
     COSTUME_MAIN = 'costume_main'  # 初语谧景
     COSTUME_MAIN_1 = 'costume_main_1'  # 织梦莲庭
@@ -15,10 +16,40 @@ class MainType(str, Enum):
     COSTUME_MAIN_7 = 'costume_main_7'  # 盛夏幽庭
     COSTUME_MAIN_8 = 'costume_main_8'  # 远海航船
 
+# 结界皮肤
+class RealmType(str, Enum):
+    COSTUME_REALM_DEFAULT = 'costume_realm_default'  # 妖扇结界
+    COSTUME_REALM_1 = 'costume_realm_1'  # 鬼灵咒符
+    COSTUME_REALM_2 = 'costume_realm_2'  # 狐梦之乡
+    COSTUME_REALM_3 = 'costume_realm_3'  # 编心织忆
+    COSTUME_REALM_4 = 'costume_realm_4'  # 花海繁生
+
+# 主题,就是庭院最右下角的展开按钮
+class ThemeType(str, Enum):
+    COSTUME_THEME_DEFAULT = 'costume_theme_default'  # 伊始之卷
+
+# 幕间,就是式神录这里
+class ShikigamiType(str, Enum):
+    COSTUME_SHIKIGAMI_DEFAULT = 'costume_shikigami_default'  # 静栖走廊
+
+# 签到主题
+class SignType(str, Enum):
+    COSTUME_SIGN_DEFAULT = 'costume_sign_default'  # 默认
+
+# 战斗主题
+class BattleType(str, Enum):
+    COSTUME_BATTLE_DEFAULT = 'costume_battle_default'  # 默认
+
+
 
 class CostumeConfig(BaseModel):
     # 皮肤配置
     costume_main_type: MainType = Field(default=MainType.COSTUME_MAIN, description='costume_main_type_help')
+    costume_realm_type: RealmType = Field(default=RealmType.COSTUME_REALM_DEFAULT, description='costume_realm_type_help')
+    costume_theme_type: ThemeType = Field(default=ThemeType.COSTUME_THEME_DEFAULT, description='costume_theme_type_help')
+    costume_shikigami_type: ShikigamiType = Field(default=ShikigamiType.COSTUME_SHIKIGAMI_DEFAULT, description='costume_shikigami_type_help')
+    costume_sign_type: SignType = Field(default=SignType.COSTUME_SIGN_DEFAULT, description='costume_sign_type_help')
+    costume_battle_type: BattleType = Field(default=BattleType.COSTUME_BATTLE_DEFAULT, description='costume_battle_type_help')
 
 
 

+ 26 - 9
tasks/Component/Costume/costume_base.py

@@ -4,9 +4,12 @@
 
 from module.atom.image import RuleImage
 
-from tasks.Component.Costume.config import MainType, CostumeConfig
+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
 
+# 庭院皮肤
 main_costume_model = {
     MainType.COSTUME_MAIN_1: {'I_CHECK_MAIN': 'I_CHECK_MAIN_1',
                               'I_MAIN_GOTO_EXPLORATION': 'I_MAIN_GOTO_EXPLORATION_1',
@@ -50,19 +53,17 @@ main_costume_model = {
                               'I_PET_HOUSE': 'I_PET_HOUSE_8', },
 }
 
+# 结界皮肤
+realm_costume_model = {
+    RealmType.COSTUME_REALM_1: {'I_SHI_CARD': 'I_SHI_CARD_1',
+                                'I_SHI_DEFENSE': 'I_SHI_DEFENSE_1',},
+}
 
 class CostumeBase:
 
     def check_costume(self, config: CostumeConfig):
         self.check_costume_main(config.costume_main_type)
-
-    def check_costume_main(self, main_type: MainType):
-        if main_type == MainType.COSTUME_MAIN:
-            return
-        costume_assets = CostumeAssets()
-        for key, value in main_costume_model[main_type].items():
-            assert_value: RuleImage = getattr(costume_assets, value)
-            self.replace_img(key, assert_value)
+        self.check_costume_realm(config.costume_realm_type)
 
     def replace_img(self, asset_before: str, asset_after: RuleImage):
         if not hasattr(self, asset_before):
@@ -74,6 +75,22 @@ class CostumeBase:
         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
+        costume_assets = CostumeAssets()
+        for key, value in main_costume_model[main_type].items():
+            assert_value: RuleImage = getattr(costume_assets, value)
+            self.replace_img(key, assert_value)
+
+    def check_costume_realm(self, realm_type: RealmType):
+        if realm_type == RealmType.COSTUME_REALM_DEFAULT:
+            return
+        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)
+
 
 
 if __name__ == '__main__':

+ 61 - 0
tasks/Component/Costume/costume_test_realm.py

@@ -0,0 +1,61 @@
+# 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.KekkaiActivation.script_task import ScriptTask as KekkaiActivationScriptTask
+
+class ScriptTask(KekkaiActivationScriptTask):
+
+    def run(self):
+
+        images_count = [[self.I_SHI_GROWN,     0],  # 式神育成
+                        [self.I_SHI_CARD,      0],  # 结界卡
+                        [self.I_SHI_DEFENSE,   0],  # 结界防守
+                        [self.I_REALM_SHIN,    0],  # 结界皮肤
+                        # 下面是测试的时候不一定有的, 但是这三个运行一段时间后应该会有
+                        [self.I_CARD_EXP,      0],  # 收取经验(没有满的图)
+                        [self.I_BOX_AP,        0],  # 收取体力(没有满的图)
+                        [self.I_BOX_EXP,       0],  # 收取盒子经验(没有满)
+                        # 下面两个才是很难有
+                        [self.I_BOX_EXP_MAX,   0],  # 收取盒子经验(经验满)
+                        [self.I_UTILIZE_EXP,   0],  # 收取寄养别人的经验
+                        ]
+
+        logger.hr('Costume Test Start')
+        timer = Timer(5)
+        timer.start()
+        while 1:
+            self.screenshot()
+            logger.info('Detecting images...')
+
+            for i in images_count:
+                if self.appear(i[0]):
+                    i[1] += 1
+                    # logger.info('Find image %s %d times' % (i[0], i[1]))
+
+            if timer.reached():
+                # 五秒测试结束
+                logger.info('Five seconds test over')
+                break
+
+        logger.info('--------------------------------------------------------')
+        logger.info('%-20s   %s' % ('Image', 'Count'))
+        for i in images_count:
+            logger.info('%-20s %3d times' % (i[0], i[1]))
+        logger.info('Test Done')
+
+
+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.run()
+
+

+ 19 - 0
tasks/Component/CostumeRealm/assets.py

@@ -0,0 +1,19 @@
+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 CostumeRealmAssets: 
+
+
+	# Image Rule Assets
+	# description 
+	I_SHI_CARD_1 = RuleImage(roi_front=(919,295,36,66), roi_back=(868,238,141,150), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeRealm/realm1/realm1_shi_card_1.png")
+	# description 
+	I_SHI_DEFENSE_1 = RuleImage(roi_front=(308,294,35,100), roi_back=(197,241,247,207), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeRealm/realm1/realm1_shi_defense_1.png")
+
+

+ 20 - 0
tasks/Component/CostumeRealm/realm1/image.json

@@ -0,0 +1,20 @@
+[
+  {
+    "itemName": "shi_card_1",
+    "imageName": "realm1_shi_card_1.png",
+    "roiFront": "919,295,36,66",
+    "roiBack": "868,238,141,150",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "shi_defense_1",
+    "imageName": "realm1_shi_defense_1.png",
+    "roiFront": "308,294,35,100",
+    "roiBack": "197,241,247,207",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  }
+]

BIN
tasks/Component/CostumeRealm/realm1/realm1_shi_card_1.png


BIN
tasks/Component/CostumeRealm/realm1/realm1_shi_defense_1.png


+ 8 - 8
tasks/KekkaiUtilize/assets.py

@@ -29,19 +29,19 @@ class KekkaiUtilizeAssets:
 
 	# Image Rule Assets
 	# 育成 
-	I_SHI_GROWN = RuleImage(roi_front=(595,291,35,38), roi_back=(540,264,155,167), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_grown.png")
+	I_SHI_GROWN = RuleImage(roi_front=(595,291,35,38), roi_back=(530,254,181,198), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_grown.png")
 	# 结界卡 
-	I_SHI_CARD = RuleImage(roi_front=(886,290,44,56), roi_back=(806,271,183,128), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_card.png")
+	I_SHI_CARD = RuleImage(roi_front=(886,290,44,56), roi_back=(801,259,215,175), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_card.png")
 	# description 
-	I_SHI_DEFENSE = RuleImage(roi_front=(294,298,49,56), roi_back=(255,262,131,146), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_defense.png")
+	I_SHI_DEFENSE = RuleImage(roi_front=(294,298,49,56), roi_back=(215,207,208,221), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_defense.png")
 	# 收取经验(没有满的图) 
-	I_CARD_EXP = RuleImage(roi_front=(889,151,57,54), roi_back=(863,118,124,121), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_card_exp.png")
+	I_CARD_EXP = RuleImage(roi_front=(889,151,57,54), roi_back=(829,107,199,185), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_card_exp.png")
 	# 收取体力(没有满) 
-	I_BOX_AP = RuleImage(roi_front=(815,435,57,51), roi_back=(778,411,130,100), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_ap.png")
+	I_BOX_AP = RuleImage(roi_front=(815,435,57,51), roi_back=(744,336,202,204), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_ap.png")
 	# 收取盒子的经验(没有满) 
-	I_BOX_EXP = RuleImage(roi_front=(893,440,42,45), roi_back=(866,407,100,100), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_exp.png")
+	I_BOX_EXP = RuleImage(roi_front=(893,440,42,45), roi_back=(862,396,147,127), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_exp.png")
 	# 结界皮肤 
-	I_REALM_SHIN = RuleImage(roi_front=(175,460,54,58), roi_back=(147,443,100,100), threshold=0.9, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_realm_shin.png")
+	I_REALM_SHIN = RuleImage(roi_front=(175,460,54,58), roi_back=(22,380,393,308), threshold=0.9, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_realm_shin.png")
 	# 寄养别人的经验 
 	I_UTILIZE_EXP = RuleImage(roi_front=(583,144,58,43), roi_back=(531,112,156,123), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_utilize_exp.png")
 	# 取出 
@@ -49,7 +49,7 @@ class KekkaiUtilizeAssets:
 	# 提取 
 	I_EXP_EXTRACT = RuleImage(roi_front=(592,448,100,73), roi_back=(592,448,100,73), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_exp_extract.png")
 	# 盒子经验满 
-	I_BOX_EXP_MAX = RuleImage(roi_front=(886,425,61,64), roi_back=(886,425,61,64), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_exp_max.png")
+	I_BOX_EXP_MAX = RuleImage(roi_front=(889,430,61,64), roi_back=(829,372,228,186), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_box_exp_max.png")
 
 
 	# Image Rule Assets

+ 9 - 9
tasks/KekkaiUtilize/realm/image.json

@@ -3,7 +3,7 @@
     "itemName": "shi_grown",
     "imageName": "realm_shi_grown.png",
     "roiFront": "595,291,35,38",
-    "roiBack": "540,264,155,167",
+    "roiBack": "530,254,181,198",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "育成"
@@ -12,7 +12,7 @@
     "itemName": "shi_card",
     "imageName": "realm_shi_card.png",
     "roiFront": "886,290,44,56",
-    "roiBack": "806,271,183,128",
+    "roiBack": "801,259,215,175",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "结界卡"
@@ -21,7 +21,7 @@
     "itemName": "shi_defense",
     "imageName": "realm_shi_defense.png",
     "roiFront": "294,298,49,56",
-    "roiBack": "255,262,131,146",
+    "roiBack": "215,207,208,221",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -30,7 +30,7 @@
     "itemName": "card_exp",
     "imageName": "realm_card_exp.png",
     "roiFront": "889,151,57,54",
-    "roiBack": "863,118,124,121",
+    "roiBack": "829,107,199,185",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "收取经验(没有满的图)"
@@ -39,7 +39,7 @@
     "itemName": "box_ap",
     "imageName": "realm_box_ap.png",
     "roiFront": "815,435,57,51",
-    "roiBack": "778,411,130,100",
+    "roiBack": "744,336,202,204",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "收取体力(没有满)"
@@ -48,7 +48,7 @@
     "itemName": "box_exp",
     "imageName": "realm_box_exp.png",
     "roiFront": "893,440,42,45",
-    "roiBack": "866,407,100,100",
+    "roiBack": "862,396,147,127",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "收取盒子的经验(没有满)"
@@ -57,7 +57,7 @@
     "itemName": "realm_shin",
     "imageName": "realm_realm_shin.png",
     "roiFront": "175,460,54,58",
-    "roiBack": "147,443,100,100",
+    "roiBack": "22,380,393,308",
     "method": "Template matching",
     "threshold": 0.9,
     "description": "结界皮肤"
@@ -92,8 +92,8 @@
   {
     "itemName": "box_exp_max",
     "imageName": "realm_box_exp_max.png",
-    "roiFront": "886,425,61,64",
-    "roiBack": "886,425,61,64",
+    "roiFront": "889,430,61,64",
+    "roiBack": "829,372,228,186",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "盒子经验满"