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

Merge pull request #1445 from LGG686/dev-switch_soul

fix(CostumeShikigami): 缩小分组点击范围#1423
huangrunheng 8 месяцев назад
Родитель
Сommit
74a7c3470d

+ 4 - 11
tasks/AbyssShadows/script_task.py

@@ -545,18 +545,11 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AbyssShadowsAssets):
         # 点击返回
         while 1:
             self.screenshot()
-            if self.appear_then_click(self.I_EXIT, interval=1.5):
+            if self.appear_then_click(self.I_EXIT, interval=2):
                 continue
-            if self.appear(self.I_EXIT_ENSURE):
-                break
-        logger.info(f"Click {self.I_EXIT.name}")
-
-        # 点击返回确认
-        while 1:
-            self.screenshot()
-            if self.appear_then_click(self.I_EXIT_ENSURE, interval=1.5):
+            if self.appear_then_click(self.I_EXIT_ENSURE, interval=2):
                 continue
-            if self.appear_then_click(self.I_WIN, interval=1.5):
+            if self.appear_then_click(self.I_WIN, interval=2):
                 continue
             if self.appear(self.I_ABYSS_NAVIGATION):
                 break
@@ -573,4 +566,4 @@ if __name__ == "__main__":
     config = Config('zhu')
     device = Device(config)
     t = ScriptTask(config, device)
-    t.run()
+    t.run()

+ 5 - 3
tasks/Component/Costume/config.py

@@ -79,10 +79,12 @@ class CostumeConfig(BaseModel):
     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')
 
-    @field_validator('costume_realm_type', mode='after')
+    @field_validator('costume_realm_type', mode='before')
     @classmethod
-    def validator_realm(cls, v: RealmType) -> RealmType:
-        return RealmType.COSTUME_REALM_DEFAULT
+    def validate_realm(cls, v):
+        if v and v not in RealmType._value2member_map_:
+            return RealmType.COSTUME_REALM_DEFAULT
+        return v
 
 
 

+ 7 - 7
tasks/Component/CostumeShikigami/assets.py

@@ -245,19 +245,19 @@ class CostumeShikigamiAssets:
 	# 用于判断是否在式神录里面 
 	I_SOU_CHECK_IN_6 = RuleImage(roi_front=(269,69,50,49), roi_back=(269,69,50,49), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_in_6.png")
 	# 检查是否为第一组 
-	I_SOU_CHECK_GROUP_1_6 = RuleImage(roi_front=(1078,79,22,52), roi_back=(1078,79,22,52), threshold=0.9, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_1_6.png")
+	I_SOU_CHECK_GROUP_1_6 = RuleImage(roi_front=(1087,80,22,52), roi_back=(1087,80,22,52), threshold=0.9, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_1_6.png")
 	# description 
-	I_SOU_CHECK_GROUP_2_6 = RuleImage(roi_front=(1080,149,25,49), roi_back=(1080,149,25,49), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_2_6.png")
+	I_SOU_CHECK_GROUP_2_6 = RuleImage(roi_front=(1088,152,25,49), roi_back=(1088,152,25,49), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_2_6.png")
 	# description 
-	I_SOU_CHECK_GROUP_3_6 = RuleImage(roi_front=(1080,221,22,43), roi_back=(1080,221,22,43), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_3_6.png")
+	I_SOU_CHECK_GROUP_3_6 = RuleImage(roi_front=(1089,225,22,43), roi_back=(1089,225,22,43), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_3_6.png")
 	# description 
-	I_SOU_CHECK_GROUP_4_6 = RuleImage(roi_front=(1081,289,21,50), roi_back=(1081,289,21,50), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_4_6.png")
+	I_SOU_CHECK_GROUP_4_6 = RuleImage(roi_front=(1092,293,21,47), roi_back=(1092,293,21,47), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_4_6.png")
 	# description 
-	I_SOU_CHECK_GROUP_5_6 = RuleImage(roi_front=(1081,360,21,50), roi_back=(1081,360,21,50), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_5_6.png")
+	I_SOU_CHECK_GROUP_5_6 = RuleImage(roi_front=(1090,361,21,50), roi_back=(1090,361,21,50), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_5_6.png")
 	# description 
-	I_SOU_CHECK_GROUP_6_6 = RuleImage(roi_front=(1081,428,23,49), roi_back=(1081,428,23,49), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_6_6.png")
+	I_SOU_CHECK_GROUP_6_6 = RuleImage(roi_front=(1089,429,23,49), roi_back=(1089,429,23,49), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_6_6.png")
 	# description 
-	I_SOU_CHECK_GROUP_7_6 = RuleImage(roi_front=(1079,500,21,48), roi_back=(1079,500,21,48), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_7_6.png")
+	I_SOU_CHECK_GROUP_7_6 = RuleImage(roi_front=(1088,502,21,48), roi_back=(1088,502,21,48), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_7_6.png")
 	# 匹配队伍预设 
 	I_SOU_TEAM_PRESENT_6 = RuleImage(roi_front=(720,76,136,43), roi_back=(706,68,175,63), threshold=0.8, method="Template matching", file="./tasks/Component/CostumeShikigami/sk6/sk6_sou_team_present_6.png")
 	# 需要切换的预设按钮(颜色深一点) 

+ 14 - 14
tasks/Component/CostumeShikigami/sk6/image.json

@@ -83,8 +83,8 @@
   {
     "itemName": "sou_check_group_1_6",
     "imageName": "sk6_sou_check_group_1_6.png",
-    "roiFront": "1078,79,22,52",
-    "roiBack": "1078,79,22,52",
+    "roiFront": "1087,80,22,52",
+    "roiBack": "1087,80,22,52",
     "method": "Template matching",
     "threshold": 0.9,
     "description": "检查是否为第一组"
@@ -92,8 +92,8 @@
   {
     "itemName": "sou_check_group_2_6",
     "imageName": "sk6_sou_check_group_2_6.png",
-    "roiFront": "1080,149,25,49",
-    "roiBack": "1080,149,25,49",
+    "roiFront": "1088,152,25,49",
+    "roiBack": "1088,152,25,49",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -101,8 +101,8 @@
   {
     "itemName": "sou_check_group_3_6",
     "imageName": "sk6_sou_check_group_3_6.png",
-    "roiFront": "1080,221,22,43",
-    "roiBack": "1080,221,22,43",
+    "roiFront": "1089,225,22,43",
+    "roiBack": "1089,225,22,43",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -110,8 +110,8 @@
   {
     "itemName": "sou_check_group_4_6",
     "imageName": "sk6_sou_check_group_4_6.png",
-    "roiFront": "1081,289,21,50",
-    "roiBack": "1081,289,21,50",
+    "roiFront": "1092,293,21,47",
+    "roiBack": "1092,293,21,47",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -119,8 +119,8 @@
   {
     "itemName": "sou_check_group_5_6",
     "imageName": "sk6_sou_check_group_5_6.png",
-    "roiFront": "1081,360,21,50",
-    "roiBack": "1081,360,21,50",
+    "roiFront": "1090,361,21,50",
+    "roiBack": "1090,361,21,50",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -128,8 +128,8 @@
   {
     "itemName": "sou_check_group_6_6",
     "imageName": "sk6_sou_check_group_6_6.png",
-    "roiFront": "1081,428,23,49",
-    "roiBack": "1081,428,23,49",
+    "roiFront": "1089,429,23,49",
+    "roiBack": "1089,429,23,49",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -137,8 +137,8 @@
   {
     "itemName": "sou_check_group_7_6",
     "imageName": "sk6_sou_check_group_7_6.png",
-    "roiFront": "1079,500,21,48",
-    "roiBack": "1079,500,21,48",
+    "roiFront": "1088,502,21,48",
+    "roiBack": "1088,502,21,48",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_1_6.png


BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_2_6.png


BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_3_6.png


BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_4_6.png


BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_5_6.png


BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_6_6.png


BIN
tasks/Component/CostumeShikigami/sk6/sk6_sou_check_group_7_6.png


+ 3 - 1
tasks/Component/GeneralInvite/assets.py

@@ -54,7 +54,7 @@ class GeneralInviteAssets:
 	# description 
 	I_FLAG_1_OFF = RuleImage(roi_front=(353,126,58,22), roi_back=(353,126,58,22), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_flag_1_off.png")
 	# description 
-	I_FLAG_2_ON = RuleImage(roi_front=(465,126,61,24), roi_back=(465,126,61,24), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_flag_2_on.png")
+	I_FLAG_2_ON = RuleImage(roi_front=(471,128,54,18), roi_back=(471,128,54,18), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_flag_2_on.png")
 	# description 
 	I_FLAG_2_OFF = RuleImage(roi_front=(469,127,58,21), roi_back=(469,127,58,21), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_flag_2_off.png")
 	# description 
@@ -127,3 +127,5 @@ class GeneralInviteAssets:
 	O_FRIEND_NAME_2 = RuleOcr(roi=(729,184,196,346), area=(729,184,196,346), mode="Full", method="Default", keyword="", name="friend_name_2")
 	# Ocr-description 
 	O_ONLINE = RuleOcr(roi=(790,102,124,42), area=(0,0,100,100), mode="Single", method="Default", keyword="", name="online")
+
+

BIN
tasks/Component/GeneralInvite/gi/gi_flag_2_on.png


+ 3 - 3
tasks/Component/GeneralInvite/gi/image.json

@@ -191,8 +191,8 @@
   {
     "itemName": "flag_2_on",
     "imageName": "gi_flag_2_on.png",
-    "roiFront": "465,126,61,24",
-    "roiBack": "465,126,61,24",
+    "roiFront": "471,128,54,18",
+    "roiBack": "471,128,54,18",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -377,4 +377,4 @@
     "threshold": 0.8,
     "description": "识别到寄养邀请"
   }
-]
+]

+ 7 - 7
tasks/Component/SwitchSoul/assets.py

@@ -12,19 +12,19 @@ class SwitchSoulAssets:
 
 	# Click Rule Assets
 	# description 
-	C_SOU_GROUP_1 = RuleClick(roi_front=(1086,85,158,67), roi_back=(1086,85,158,67), name="sou_group_1")
+	C_SOU_GROUP_1 = RuleClick(roi_front=(1086,85,158,47), roi_back=(1086,85,158,47), name="sou_group_1")
 	# description 
-	C_SOU_GROUP_2 = RuleClick(roi_front=(1087,155,162,62), roi_back=(1087,155,162,62), name="sou_group_2")
+	C_SOU_GROUP_2 = RuleClick(roi_front=(1087,155,162,48), roi_back=(1087,155,162,48), name="sou_group_2")
 	# description 
-	C_SOU_GROUP_3 = RuleClick(roi_front=(1088,226,154,61), roi_back=(1088,226,154,61), name="sou_group_3")
+	C_SOU_GROUP_3 = RuleClick(roi_front=(1088,226,154,49), roi_back=(1088,226,154,49), name="sou_group_3")
 	# description 
-	C_SOU_GROUP_4 = RuleClick(roi_front=(1087,297,157,59), roi_back=(1087,297,157,59), name="sou_group_4")
+	C_SOU_GROUP_4 = RuleClick(roi_front=(1087,297,157,46), roi_back=(1087,297,157,46), name="sou_group_4")
 	# description 
-	C_SOU_GROUP_5 = RuleClick(roi_front=(1087,365,154,62), roi_back=(1087,365,154,62), name="sou_group_5")
+	C_SOU_GROUP_5 = RuleClick(roi_front=(1087,365,154,47), roi_back=(1087,365,154,47), name="sou_group_5")
 	# description 
-	C_SOU_GROUP_6 = RuleClick(roi_front=(1088,437,156,57), roi_back=(1088,437,156,57), name="sou_group_6")
+	C_SOU_GROUP_6 = RuleClick(roi_front=(1088,437,156,46), roi_back=(1088,437,156,46), name="sou_group_6")
 	# description 
-	C_SOU_GROUP_7 = RuleClick(roi_front=(1090,505,156,62), roi_back=(1090,505,156,62), name="sou_group_7")
+	C_SOU_GROUP_7 = RuleClick(roi_front=(1090,505,156,51), roi_back=(1090,505,156,51), name="sou_group_7")
 	# 阵容选择按钮位置 
 	C_SOU_TEAM_SELECT = RuleClick(roi_front=(977,157,21,21), roi_back=(977,157,21,21), name="sou_team_select")
 

+ 14 - 14
tasks/Component/SwitchSoul/ss/click.json

@@ -1,44 +1,44 @@
 [
   {
     "itemName": "sou_group_1",
-    "roiFront": "1086,85,158,67",
-    "roiBack": "1086,85,158,67",
+    "roiFront": "1086,85,158,47",
+    "roiBack": "1086,85,158,47",
     "description": "description"
   },
   {
     "itemName": "sou_group_2",
-    "roiFront": "1087,155,162,62",
-    "roiBack": "1087,155,162,62",
+    "roiFront": "1087,155,162,48",
+    "roiBack": "1087,155,162,48",
     "description": "description"
   },
   {
     "itemName": "sou_group_3",
-    "roiFront": "1088,226,154,61",
-    "roiBack": "1088,226,154,61",
+    "roiFront": "1088,226,154,49",
+    "roiBack": "1088,226,154,49",
     "description": "description"
   },
   {
     "itemName": "sou_group_4",
-    "roiFront": "1087,297,157,59",
-    "roiBack": "1087,297,157,59",
+    "roiFront": "1087,297,157,46",
+    "roiBack": "1087,297,157,46",
     "description": "description"
   },
   {
     "itemName": "sou_group_5",
-    "roiFront": "1087,365,154,62",
-    "roiBack": "1087,365,154,62",
+    "roiFront": "1087,365,154,47",
+    "roiBack": "1087,365,154,47",
     "description": "description"
   },
   {
     "itemName": "sou_group_6",
-    "roiFront": "1088,437,156,57",
-    "roiBack": "1088,437,156,57",
+    "roiFront": "1088,437,156,46",
+    "roiBack": "1088,437,156,46",
     "description": "description"
   },
   {
     "itemName": "sou_group_7",
-    "roiFront": "1090,505,156,62",
-    "roiBack": "1090,505,156,62",
+    "roiFront": "1090,505,156,51",
+    "roiBack": "1090,505,156,51",
     "description": "description"
   },
   {

+ 1 - 1
tasks/Restart/assets.py

@@ -39,7 +39,7 @@ class RestartAssets:
 	# 999签到福袋 
 	I_HARVEST_SIGN_999 = RuleImage(roi_front=(345,494,23,29), roi_back=(51,459,888,103), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_sign_999.png")
 	# 邮件小图标 
-	I_HARVEST_MAIL = RuleImage(roi_front=(337,505,37,25), roi_back=(38,465,880,89), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail.png")
+	I_HARVEST_MAIL = RuleImage(roi_front=(249,504,37,25), roi_back=(38,389,1006,164), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail.png")
 	# 全部收取 
 	I_HARVEST_MAIL_ALL = RuleImage(roi_front=(69,579,80,67), roi_back=(28,551,142,144), threshold=0.8, method="Template matching", file="./tasks/Restart/harvest/harvest_harvest_mail_all.png")
 	# 有些邮件需要点击一次 

+ 2 - 2
tasks/Restart/harvest/image.json

@@ -38,8 +38,8 @@
   {
     "itemName": "harvest_mail",
     "imageName": "harvest_harvest_mail.png",
-    "roiFront": "337,505,37,25",
-    "roiBack": "38,465,880,89",
+    "roiFront": "249,504,37,25",
+    "roiBack": "38,389,1006,164",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "邮件小图标"

+ 2 - 2
tasks/Restart/login.py

@@ -288,7 +288,7 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets):
         self.O_LOGIN_SPECIFIC_SERVE.keyword = character
 
     def harvest_mail(self) -> bool:
-        if not self.appear(self.I_HARVEST_MAIL) and \
+        if not self.appear_multi_scale(self.I_HARVEST_MAIL,scale_range=(0.8, 1.1)) and \
                 not self.appear(self.I_HARVEST_MAIL_COPY):
             if not self.appear(self.I_READ_ALL_MAIL):
                 return False
@@ -297,7 +297,7 @@ class LoginHandler(BaseTask, RestartAssets, GameUiAssets):
             self.screenshot()
             if self.appear(self.I_READ_ALL_MAIL):
                 break
-            if self.appear_then_click(self.I_HARVEST_MAIL, interval=1.5):
+            if self.appear_then_click_multi_scale(self.I_HARVEST_MAIL, interval=1.5, scale_range=(0.8, 1.1)):
                 continue
             if self.appear_then_click(self.I_HARVEST_MAIL_COPY, interval=1.5):
                 continue

+ 1 - 1
tasks/TalismanPass/assets.py

@@ -34,7 +34,7 @@ class TalismanPassAssets:
 	# 溢出确认 
 	I_OVERFLOW_CONFIRME = RuleImage(roi_front=(585,410,116,44), roi_back=(585,410,116,44), threshold=0.8, method="Template matching", file="./tasks/TalismanPass/tp/tp_overflow_confirme.png")
 	# 点击随机御魂 
-	I_TP_SOUL_1 = RuleImage(roi_front=(248,501,34,37), roi_back=(165,389,929,168), threshold=0.8, method="Template matching", file="./tasks/TalismanPass/tp/tp_tp_soul_1.png")
+	I_TP_SOUL_1 = RuleImage(roi_front=(248,501,34,37), roi_back=(165,389,929,168), threshold=0.7, method="Template matching", file="./tasks/TalismanPass/tp/tp_tp_soul_1.png")
 	# 选择中间第二个御魂 
 	I_TP_SOUL_2 = RuleImage(roi_front=(582,438,115,48), roi_back=(570,427,139,71), threshold=0.8, method="Template matching", file="./tasks/TalismanPass/tp/tp_tp_soul_2.png")
 	# 六星御魂标志 

+ 1 - 1
tasks/TalismanPass/tp/image.json

@@ -104,7 +104,7 @@
     "roiFront": "248,501,34,37",
     "roiBack": "165,389,929,168",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "点击随机御魂"
   },
   {