Browse Source

feat(ActivityShikigami):卑弥呼爬塔活动

GanSer 1 year ago
parent
commit
d353f2c462

BIN
tasks/ActivityShikigami/as/as_ap.png


BIN
tasks/ActivityShikigami/as/as_ap_activity.png


BIN
tasks/ActivityShikigami/as/as_battle.png


BIN
tasks/ActivityShikigami/as/as_fire.png


BIN
tasks/ActivityShikigami/as/as_shi.png


BIN
tasks/ActivityShikigami/as/as_switch.png


+ 8 - 8
tasks/ActivityShikigami/as/image.json

@@ -2,7 +2,7 @@
   {
   {
     "itemName": "shi",
     "itemName": "shi",
     "imageName": "as_shi.png",
     "imageName": "as_shi.png",
-    "roiFront": "520,265,33,34",
+    "roiFront": "186,255,33,34",
     "roiBack": "64,115,1110,427",
     "roiBack": "64,115,1110,427",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.7,
     "threshold": 0.7,
@@ -20,8 +20,8 @@
   {
   {
     "itemName": "battle",
     "itemName": "battle",
     "imageName": "as_battle.png",
     "imageName": "as_battle.png",
-    "roiFront": "199,292,35,135",
-    "roiBack": "144,205,153,315",
+    "roiFront": "285,282,35,135",
+    "roiBack": "223,196,153,315",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.7,
     "threshold": 0.7,
     "description": "进入爬塔"
     "description": "进入爬塔"
@@ -57,7 +57,7 @@
     "itemName": "fire",
     "itemName": "fire",
     "imageName": "as_fire.png",
     "imageName": "as_fire.png",
     "roiFront": "1140,583,84,78",
     "roiFront": "1140,583,84,78",
-    "roiBack": "1099,522,150,174",
+    "roiBack": "1099,536,150,160",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.7,
     "threshold": 0.7,
     "description": "点击战斗"
     "description": "点击战斗"
@@ -65,7 +65,7 @@
   {
   {
     "itemName": "ap",
     "itemName": "ap",
     "imageName": "as_ap.png",
     "imageName": "as_ap.png",
-    "roiFront": "1138,668,23,24",
+    "roiFront": "1093,667,23,24",
     "roiBack": "1088,638,103,71",
     "roiBack": "1088,638,103,71",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
@@ -74,7 +74,7 @@
   {
   {
     "itemName": "ap_activity",
     "itemName": "ap_activity",
     "imageName": "as_ap_activity.png",
     "imageName": "as_ap_activity.png",
-    "roiFront": "1141,673,21,21",
+    "roiFront": "1147,667,21,27",
     "roiBack": "1095,654,84,54",
     "roiBack": "1095,654,84,54",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
@@ -83,8 +83,8 @@
   {
   {
     "itemName": "switch",
     "itemName": "switch",
     "imageName": "as_switch.png",
     "imageName": "as_switch.png",
-    "roiFront": "1220,671,23,23",
-    "roiBack": "1191,653,69,56",
+    "roiFront": "1241,669,23,23",
+    "roiBack": "1207,652,69,56",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "切换按键"
     "description": "切换按键"

+ 6 - 6
tasks/ActivityShikigami/as/ocr.json

@@ -1,8 +1,8 @@
 [
 [
   {
   {
     "itemName": "remain_ap",
     "itemName": "remain_ap",
-    "roiFront": "1162,549,97,25",
-    "roiBack": "1162,549,97,25",
+    "roiFront": "131,572,42,25",
+    "roiBack": "131,572,42,25",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -10,8 +10,8 @@
   },
   },
   {
   {
     "itemName": "remain_ap_activity",
     "itemName": "remain_ap_activity",
-    "roiFront": "713,25,95,30",
-    "roiBack": "713,25,95,30",
+    "roiFront": "715,18,95,28",
+    "roiBack": "715,18,95,28",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -28,8 +28,8 @@
   },
   },
   {
   {
     "itemName": "remain_ap_activity2",
     "itemName": "remain_ap_activity2",
-    "roiFront": "775,26,35,29",
-    "roiBack": "775,26,35,29",
+    "roiFront": "756,17,52,29",
+    "roiBack": "756,17,52,29",
     "mode": "Digit",
     "mode": "Digit",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",

+ 9 - 9
tasks/ActivityShikigami/assets.py

@@ -45,11 +45,11 @@ class ActivityShikigamiAssets:
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# 进入活动 
 	# 进入活动 
-	I_SHI = RuleImage(roi_front=(520,265,33,34), roi_back=(64,115,1110,427), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
+	I_SHI = RuleImage(roi_front=(186,255,33,34), roi_back=(64,115,1110,427), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_shi.png")
 	# 左上角返回 
 	# 左上角返回 
 	I_BACK_GREEN = RuleImage(roi_front=(23,27,44,44), roi_back=(23,27,44,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	I_BACK_GREEN = RuleImage(roi_front=(23,27,44,44), roi_back=(23,27,44,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	# 进入爬塔 
 	# 进入爬塔 
-	I_BATTLE = RuleImage(roi_front=(199,292,35,135), roi_back=(144,205,153,315), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
+	I_BATTLE = RuleImage(roi_front=(285,282,35,135), roi_back=(223,196,153,315), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
 	# 归鹿之途 
 	# 归鹿之途 
 	I_DRUM = RuleImage(roi_front=(327,627,145,28), roi_back=(256,462,301,232), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	I_DRUM = RuleImage(roi_front=(327,627,145,28), roi_back=(256,462,301,232), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	# 上锁图标 
 	# 上锁图标 
@@ -57,13 +57,13 @@ class ActivityShikigamiAssets:
 	# 还未上锁图片 
 	# 还未上锁图片 
 	I_UNLOCK = RuleImage(roi_front=(823,654,28,28), roi_back=(776,610,112,87), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	I_UNLOCK = RuleImage(roi_front=(823,654,28,28), roi_back=(776,610,112,87), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	# 点击战斗 
 	# 点击战斗 
-	I_FIRE = RuleImage(roi_front=(1140,583,84,78), roi_back=(1099,522,150,174), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
+	I_FIRE = RuleImage(roi_front=(1140,583,84,78), roi_back=(1099,536,150,160), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
 	# 体力按钮 
 	# 体力按钮 
-	I_AP = RuleImage(roi_front=(1138,668,23,24), roi_back=(1088,638,103,71), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
+	I_AP = RuleImage(roi_front=(1093,667,23,24), roi_back=(1088,638,103,71), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
 	# 活动体力 
 	# 活动体力 
-	I_AP_ACTIVITY = RuleImage(roi_front=(1141,673,21,21), roi_back=(1095,654,84,54), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
+	I_AP_ACTIVITY = RuleImage(roi_front=(1147,667,21,27), roi_back=(1095,654,84,54), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap_activity.png")
 	# 切换按键 
 	# 切换按键 
-	I_SWITCH = RuleImage(roi_front=(1220,671,23,23), roi_back=(1191,653,69,56), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
+	I_SWITCH = RuleImage(roi_front=(1241,669,23,23), roi_back=(1207,652,69,56), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_switch.png")
 	# 购买活动的体力 
 	# 购买活动的体力 
 	I_BUY_JADE = RuleImage(roi_front=(1004,192,38,42), roi_back=(836,619,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_buy_jade.png")
 	I_BUY_JADE = RuleImage(roi_front=(1004,192,38,42), roi_back=(836,619,38,42), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_buy_jade.png")
 	# 增加到最大 
 	# 增加到最大 
@@ -74,12 +74,12 @@ class ActivityShikigamiAssets:
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
 	# 体力的数量检测 
 	# 体力的数量检测 
-	O_REMAIN_AP = RuleOcr(roi=(1162,549,97,25), area=(1162,549,97,25), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
+	O_REMAIN_AP = RuleOcr(roi=(131,572,42,25), area=(131,572,42,25), mode="DigitCounter", method="Default", keyword="", name="remain_ap")
 	# 活动体力的剩余检测 
 	# 活动体力的剩余检测 
-	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(713,25,95,30), area=(713,25,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
+	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(715,18,95,28), area=(715,18,95,28), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	# 还有多少次购买体力的机会 
 	# 还有多少次购买体力的机会 
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 	# 活动票数(没有百分比) 
 	# 活动票数(没有百分比) 
-	O_REMAIN_AP_ACTIVITY2 = RuleOcr(roi=(775,26,35,29), area=(775,26,35,29), mode="Digit", method="Default", keyword="", name="remain_ap_activity2")
+	O_REMAIN_AP_ACTIVITY2 = RuleOcr(roi=(756,17,52,29), area=(756,17,52,29), mode="Digit", method="Default", keyword="", name="remain_ap_activity2")
 
 
 
 

+ 16 - 8
tasks/ActivityShikigami/script_task.py

@@ -56,6 +56,7 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
         self.switch(current_ap)
         self.switch(current_ap)
 
 
         # 设定是否锁定阵容
         # 设定是否锁定阵容
+
         if config.general_battle.lock_team_enable:
         if config.general_battle.lock_team_enable:
             logger.info("Lock team")
             logger.info("Lock team")
             while 1:
             while 1:
@@ -188,15 +189,22 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
             # return True
             # return True
 
 
         elif current_ap == ApMode.AP_GAME:
         elif current_ap == ApMode.AP_GAME:
-            cu, res, total = self.O_REMAIN_AP.ocr(image=self.device.image)
-            if cu == total and cu + res == total:
-                if cu > total:
-                    logger.warning(f'Game ap {cu} more than total {total}')
-                    return True
-                logger.warning(f'Game ap not enough: {cu}')
-                return False
+            cu: int = self.O_REMAIN_AP.ocr_digit(self.device.image)
+            if cu > 0:
+                logger.warning(f'Game ap {cu} more than 0')
+                return True
+            logger.warning(f'Game ap not enough: {cu}')
+            return False
 
 
-            return True
+            # cu, res, total = self.O_REMAIN_AP.ocr(image=self.device.image)
+            # if cu == total and cu + res == total:
+            #     if cu > total:
+            #         logger.warning(f'Game ap {cu} more than total {total}')
+            #         return True
+            #     logger.warning(f'Game ap not enough: {cu}')
+            #     return False
+            #
+            # return True
 
 
     def switch(self, current_ap: ApMode) -> None:
     def switch(self, current_ap: ApMode) -> None:
         """
         """