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

feat(Costume): Support time-variant courtyard skin 玉岚狐庭 #1824

neptine 2 месяцев назад
Родитель
Сommit
36e1a822a5

+ 1 - 0
assets/i18n/zh-CN.json

@@ -43,6 +43,7 @@
   "exit_four_help": "支持打九退四,保证稳定57级,要求设置好战斗主题,即 脚本->全局配置->游戏装饰自定义->战斗主题",
   "costume_main_15": "茨心乐园",
   "costume_main_16": "狐栖归处",
+  "costume_main_17": "玉岚狐庭",
   "check_true_orochi_enable": "是否在结束后检测真蛇",
   "check_true_orochi_enable_help": "开启后会在任务结束后检测是否出现真蛇, 若出现则自动拉起真蛇",
   "enable_book_auto": "自动选择",

+ 8 - 3
module/atom/gif.py

@@ -12,11 +12,13 @@ class RuleGif:
 
     @property
     def name(self) -> str:
-        return self.appear_target.name
+        return self.targets[0].name
 
     def __init__(self, targets: list[RuleImage]):
         self.targets = targets
         self.roi_front: list = [0, 0, 0, 0]
+        self.roi_back: list = targets[0].roi_back
+        self._match_init = False
         self.appear_target = targets[0]
 
     def pre_process(self, image):
@@ -44,18 +46,21 @@ class RuleGif:
                 return True, target
         return False, None
 
-    def search_with_multi_scale(self, image, roi=None, threshold=None, scale_range=(0.8, 1.1, 0.05)):
+    def search_with_multi_scale(self, image, roi=None, threshold=None, scales=None, scale_range=(0.8, 1.1, 0.05)):
         image = self.pre_process(image)
         threshold = self.targets[0].threshold if threshold is None else threshold
         roi = self.targets[0].roi_back if roi is None else roi
         for target in self.targets:
             target.roi_back = roi
-            if target.match_multi_scale(image, threshold=threshold, scale_range=scale_range):
+            if target.match_multi_scale(image, threshold=threshold, scales=scales, scale_range=scale_range):
                 self.roi_front = target.roi_front
                 self.appear_target = target
                 return True, target
         return False, None
 
+    def match_multi_scale(self, image, threshold: float = None, scales: list = None, scale_range: tuple = None) -> bool:
+        return self.search_with_multi_scale(image, threshold=threshold, scales=scales, scale_range=scale_range)[0]
+
     def match(self, image, threshold: float = None) -> bool:
         return self.search(image, threshold=threshold)[0]
 

+ 39 - 5
tasks/Component/Costume/assets.py

@@ -102,18 +102,51 @@ class CostumeAssets:
 
 
 	# Image Rule Assets
-	# 狐栖归处庭院判定
+	# 狐栖归处庭院判定 
 	I_CHECK_MAIN_16 = RuleImage(roi_front=(260,168,80,54), roi_back=(180,100,240,180), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main16/main16_check_main_16.png")
-	# 探索
+	# 探索 
 	I_MAIN_GOTO_EXPLORATION_16 = RuleImage(roi_front=(729,231,28,52), roi_back=(680,180,130,150), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main16/main16_main_goto_exploration_16.png")
-	# 召唤屋
+	# 召唤屋 
 	I_MAIN_GOTO_SUMMON_16 = RuleImage(roi_front=(981,218,28,24), roi_back=(930,170,130,150), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main16/main16_main_goto_summon_16.png")
-	# 町中
+	# 町中 
 	I_MAIN_GOTO_TOWN_16 = RuleImage(roi_front=(1014,346,14,34), roi_back=(960,300,100,120), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main16/main16_main_goto_town_16.png")
-	# 宠物屋
+	# 宠物屋 
 	I_PET_HOUSE_16 = RuleImage(roi_front=(1256,402,20,58), roi_back=(1210,340,70,140), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main16/main16_pet_house_16.png")
 
 
+	# Image Rule Assets
+	# 庭院判定 a 
+	I_CHECK_MAIN_17_A = RuleImage(roi_front=(260,168,80,54), roi_back=(180,100,240,180), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_check_main_17_a.png")
+	# 庭院判定 b 
+	I_CHECK_MAIN_17_B = RuleImage(roi_front=(260,168,80,54), roi_back=(180,100,240,180), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_check_main_17_b.png")
+	# 庭院判定 c 
+	I_CHECK_MAIN_17_C = RuleImage(roi_front=(260,168,80,54), roi_back=(180,100,240,180), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_check_main_17_c.png")
+	# 探索 a 
+	I_MAIN_GOTO_EXPLORATION_17_A = RuleImage(roi_front=(714,224,43,40), roi_back=(680,180,130,150), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_exploration_17_a.png")
+	# 探索 b 
+	I_MAIN_GOTO_EXPLORATION_17_B = RuleImage(roi_front=(719,216,41,42), roi_back=(667,180,143,106), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_exploration_17_b.png")
+	# 探索 c 
+	I_MAIN_GOTO_EXPLORATION_17_C = RuleImage(roi_front=(717,222,43,42), roi_back=(680,180,125,110), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_exploration_17_c.png")
+	# 召唤屋 a 
+	I_MAIN_GOTO_SUMMON_17_A = RuleImage(roi_front=(981,218,40,41), roi_back=(930,170,130,150), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_summon_17_a.png")
+	# 召唤屋 b 
+	I_MAIN_GOTO_SUMMON_17_B = RuleImage(roi_front=(981,218,39,38), roi_back=(930,170,130,150), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_summon_17_b.png")
+	# 召唤屋 c 
+	I_MAIN_GOTO_SUMMON_17_C = RuleImage(roi_front=(981,218,39,37), roi_back=(930,170,130,150), threshold=0.55, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_summon_17_c.png")
+	# 町中 a 
+	I_MAIN_GOTO_TOWN_17_A = RuleImage(roi_front=(1004,336,35,49), roi_back=(960,300,100,120), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_town_17_a.png")
+	# 町中 b 
+	I_MAIN_GOTO_TOWN_17_B = RuleImage(roi_front=(1007,346,26,31), roi_back=(960,300,100,120), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_town_17_b.png")
+	# 町中 c 
+	I_MAIN_GOTO_TOWN_17_C = RuleImage(roi_front=(1008,343,29,43), roi_back=(960,300,100,120), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_main_goto_town_17_c.png")
+	# 宠物屋 a 
+	I_PET_HOUSE_17_A = RuleImage(roi_front=(1226,423,34,37), roi_back=(1191,340,89,152), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_pet_house_17_a.png")
+	# 宠物屋 b 
+	I_PET_HOUSE_17_B = RuleImage(roi_front=(1221,422,33,39), roi_back=(1191,366,89,116), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_pet_house_17_b.png")
+	# 宠物屋 c 
+	I_PET_HOUSE_17_C = RuleImage(roi_front=(1226,417,42,45), roi_back=(1210,340,70,140), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main17/main17_pet_house_17_c.png")
+
+
 	# Image Rule Assets
 	# description 
 	I_CHECK_MAIN_2 = RuleImage(roi_front=(1090,146,48,55), roi_back=(880,108,271,100), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main2/main2_check_main_2.png")
@@ -217,3 +250,4 @@ class CostumeAssets:
 	# description 
 	I_PET_HOUSE_9 = RuleImage(roi_front=(888,327,40,35), roi_back=(730,316,440,57), threshold=0.8, method="Template matching", file="./tasks/Component/Costume/main9/main9_pet_house_9.png")
 
+

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

@@ -23,6 +23,7 @@ class MainType(str, Enum):
     COSTUME_MAIN_14 = 'costume_main_14'  # 雪月华庭
     COSTUME_MAIN_15 = 'costume_main_15'  # 茨心乐园
     COSTUME_MAIN_16 = 'costume_main_16'  # 狐栖归处
+    COSTUME_MAIN_17 = 'costume_main_17'  # 玉岚狐庭
 
 # 结界皮肤
 class RealmType(str, Enum):

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

@@ -3,6 +3,7 @@
 # github https://github.com/runhey
 
 from module.atom.image import RuleImage
+from module.atom.gif import RuleGif
 from module.logger import logger
 
 from tasks.Component.Costume.config import (MainType, CostumeConfig, RealmType,
@@ -23,6 +24,14 @@ main_costume_model = {
         'I_PET_HOUSE': f'I_PET_HOUSE_{i}'
     } for i in range(1, 17)
 }
+# 玉岚狐庭(issue #1824)
+main_costume_model[getattr(MainType, "COSTUME_MAIN_17")] = {
+    'I_CHECK_MAIN': ['I_CHECK_MAIN_17_A', 'I_CHECK_MAIN_17_B', 'I_CHECK_MAIN_17_C'],
+    'I_MAIN_GOTO_EXPLORATION': ['I_MAIN_GOTO_EXPLORATION_17_A', 'I_MAIN_GOTO_EXPLORATION_17_B', 'I_MAIN_GOTO_EXPLORATION_17_C'],
+    'I_MAIN_GOTO_SUMMON': ['I_MAIN_GOTO_SUMMON_17_A', 'I_MAIN_GOTO_SUMMON_17_B', 'I_MAIN_GOTO_SUMMON_17_C'],
+    'I_MAIN_GOTO_TOWN': ['I_MAIN_GOTO_TOWN_17_A', 'I_MAIN_GOTO_TOWN_17_B', 'I_MAIN_GOTO_TOWN_17_C'],
+    'I_PET_HOUSE': ['I_PET_HOUSE_17_A', 'I_PET_HOUSE_17_B', 'I_PET_HOUSE_17_C'],
+}
 
 
 # 鲤鱼旗皮肤
@@ -95,14 +104,21 @@ class CostumeBase:
         asset_before_object.threshold = asset_after.threshold
         asset_before_object.file = asset_after.file
 
+    def set_asset(self, asset_before: str, rule: RuleImage | RuleGif) -> None:
+        setattr(self, asset_before, rule)
+
     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)
-            self.replace_img(key, assert_value)
+            if isinstance(value, list):
+                rules: list[RuleImage] = [getattr(costume_assets, item) for item in value]
+                self.set_asset(key, RuleGif(rules))
+            else:
+                assert_value: RuleImage = getattr(costume_assets, value)
+                self.replace_img(key, assert_value)
 
     def check_costume_carpbanner(self, carpbanner_type: CarpBannerType):
         if carpbanner_type == CarpBannerType.COSTUME_CARPBANNER_DEFAULT:

+ 137 - 0
tasks/Component/Costume/main17/image.json

@@ -0,0 +1,137 @@
+[
+  {
+    "itemName": "check_main_17_a",
+    "imageName": "main17_check_main_17_a.png",
+    "roiFront": "260,168,80,54",
+    "roiBack": "180,100,240,180",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院判定 a"
+  },
+  {
+    "itemName": "check_main_17_b",
+    "imageName": "main17_check_main_17_b.png",
+    "roiFront": "260,168,80,54",
+    "roiBack": "180,100,240,180",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院判定 b"
+  },
+  {
+    "itemName": "check_main_17_c",
+    "imageName": "main17_check_main_17_c.png",
+    "roiFront": "260,168,80,54",
+    "roiBack": "180,100,240,180",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "庭院判定 c"
+  },
+  {
+    "itemName": "main_goto_exploration_17_a",
+    "imageName": "main17_main_goto_exploration_17_a.png",
+    "roiFront": "714,224,43,40",
+    "roiBack": "680,180,130,150",
+    "method": "Template matching",
+    "threshold": 0.55,
+    "description": "探索 a"
+  },
+  {
+    "itemName": "main_goto_exploration_17_b",
+    "imageName": "main17_main_goto_exploration_17_b.png",
+    "roiFront": "719,216,41,42",
+    "roiBack": "667,180,143,106",
+    "method": "Template matching",
+    "threshold": 0.55,
+    "description": "探索 b"
+  },
+  {
+    "itemName": "main_goto_exploration_17_c",
+    "imageName": "main17_main_goto_exploration_17_c.png",
+    "roiFront": "717,222,43,42",
+    "roiBack": "680,180,125,110",
+    "method": "Template matching",
+    "threshold": 0.55,
+    "description": "探索 c"
+  },
+  {
+    "itemName": "main_goto_summon_17_a",
+    "imageName": "main17_main_goto_summon_17_a.png",
+    "roiFront": "981,218,40,41",
+    "roiBack": "930,170,130,150",
+    "method": "Template matching",
+    "threshold": 0.55,
+    "description": "召唤屋 a"
+  },
+  {
+    "itemName": "main_goto_summon_17_b",
+    "imageName": "main17_main_goto_summon_17_b.png",
+    "roiFront": "981,218,39,38",
+    "roiBack": "930,170,130,150",
+    "method": "Template matching",
+    "threshold": 0.55,
+    "description": "召唤屋 b"
+  },
+  {
+    "itemName": "main_goto_summon_17_c",
+    "imageName": "main17_main_goto_summon_17_c.png",
+    "roiFront": "981,218,39,37",
+    "roiBack": "930,170,130,150",
+    "method": "Template matching",
+    "threshold": 0.55,
+    "description": "召唤屋 c"
+  },
+  {
+    "itemName": "main_goto_town_17_a",
+    "imageName": "main17_main_goto_town_17_a.png",
+    "roiFront": "1004,336,35,49",
+    "roiBack": "960,300,100,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "町中 a"
+  },
+  {
+    "itemName": "main_goto_town_17_b",
+    "imageName": "main17_main_goto_town_17_b.png",
+    "roiFront": "1007,346,26,31",
+    "roiBack": "960,300,100,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "町中 b"
+  },
+  {
+    "itemName": "main_goto_town_17_c",
+    "imageName": "main17_main_goto_town_17_c.png",
+    "roiFront": "1008,343,29,43",
+    "roiBack": "960,300,100,120",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "町中 c"
+  },
+  {
+    "itemName": "pet_house_17_a",
+    "imageName": "main17_pet_house_17_a.png",
+    "roiFront": "1226,423,34,37",
+    "roiBack": "1191,340,89,152",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "宠物屋 a"
+  },
+  {
+    "itemName": "pet_house_17_b",
+    "imageName": "main17_pet_house_17_b.png",
+    "roiFront": "1221,422,33,39",
+    "roiBack": "1191,366,89,116",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "宠物屋 b"
+  },
+  {
+    "itemName": "pet_house_17_c",
+    "imageName": "main17_pet_house_17_c.png",
+    "roiFront": "1226,417,42,45",
+    "roiBack": "1210,340,70,140",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "宠物屋 c"
+  }
+]

BIN
tasks/Component/Costume/main17/main17_check_main_17_a.png


BIN
tasks/Component/Costume/main17/main17_check_main_17_b.png


BIN
tasks/Component/Costume/main17/main17_check_main_17_c.png


BIN
tasks/Component/Costume/main17/main17_main_goto_exploration_17_a.png


BIN
tasks/Component/Costume/main17/main17_main_goto_exploration_17_b.png


BIN
tasks/Component/Costume/main17/main17_main_goto_exploration_17_c.png


BIN
tasks/Component/Costume/main17/main17_main_goto_summon_17_a.png


BIN
tasks/Component/Costume/main17/main17_main_goto_summon_17_b.png


BIN
tasks/Component/Costume/main17/main17_main_goto_summon_17_c.png


BIN
tasks/Component/Costume/main17/main17_main_goto_town_17_a.png


BIN
tasks/Component/Costume/main17/main17_main_goto_town_17_b.png


BIN
tasks/Component/Costume/main17/main17_main_goto_town_17_c.png


BIN
tasks/Component/Costume/main17/main17_pet_house_17_a.png


BIN
tasks/Component/Costume/main17/main17_pet_house_17_b.png


BIN
tasks/Component/Costume/main17/main17_pet_house_17_c.png


+ 3 - 3
tasks/base_task.py

@@ -283,7 +283,7 @@ class BaseTask(GlobalGameAssets, CostumeBase):
         return appear
 
     def wait_until_appear(self,
-                          target: RuleImage | RuleOcr,
+                          target: RuleImage | RuleGif | RuleOcr,
                           skip_first_screenshot=False,
                           wait_time: int = None) -> bool:
         """
@@ -305,13 +305,13 @@ class BaseTask(GlobalGameAssets, CostumeBase):
             if wait_timer and wait_timer.reached():
                 logger.warning(f"Wait until appear {target.name} timeout")
                 return False
-            if isinstance(target, RuleImage) and self.appear(target):
+            if isinstance(target, (RuleImage, RuleGif)) and self.appear(target):
                 return True
             if isinstance(target, RuleOcr) and self.ocr_appear(target):
                 return True
 
     def wait_until_appear_then_click(self,
-                                     target: RuleImage,
+                                     target: RuleImage | RuleGif,
                                      action: Union[RuleClick, RuleLongClick] = None,
                                      wait_time: int = None) -> bool:
         """