Sfoglia il codice sorgente

Merge pull request #123 from runhey/dev

Dev
huangrunheng 3 anni fa
parent
commit
0679e26938

+ 1 - 1
tasks/Component/GeneralBuff/general_buff.py

@@ -25,7 +25,7 @@ class GeneralBuff(BaseTask, GeneralBuffAssets):
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_CLOUD):
             if self.appear(self.I_CLOUD):
                 break
                 break
-            if self.appear_then_click(self.I_BUFF_1, interval=2) or self.ocr_appear_click(self.O_GB_BUFF_2, interval=2):
+            if self.appear_then_click(self.I_BUFF_1, interval=2):
                 continue
                 continue
 
 
         check_image = self.I_AWAKE
         check_image = self.I_AWAKE

+ 2 - 2
tasks/GoryouRealm/assets.py

@@ -31,7 +31,7 @@ class GoryouRealmAssets:
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
-	# 多少张票 
-	O_GR_TICKET = RuleOcr(roi=(934,21,84,41), area=(934,21,84,41), mode="Digit", method="Default", keyword="", name="gr_ticket")
+	# 多少张票
+	O_GR_TICKET = RuleOcr(roi=(920,21,100,41), area=(920,21,100,41), mode="Digit", method="Default", keyword="", name="gr_ticket")
 
 
 
 

+ 3 - 3
tasks/GoryouRealm/gr/ocr.json

@@ -1,11 +1,11 @@
 [
 [
   {
   {
     "itemName": "gr_ticket",
     "itemName": "gr_ticket",
-    "roiFront": "934,21,84,41",
-    "roiBack": "934,21,84,41",
+    "roiFront": "920,21,100,41",
+    "roiBack": "920,21,100,41",
     "mode": "Digit",
     "mode": "Digit",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
     "description": "多少张票"
     "description": "多少张票"
   }
   }
-]
+]

+ 4 - 2
tasks/RealmRaid/assets.py

@@ -56,11 +56,11 @@ class RealmRaidAssets:
 	# Image Rule Assets
 	# Image Rule Assets
 	# 出现呱太勋章 
 	# 出现呱太勋章 
 	I_FROG_MEDAL = RuleImage(roi_front=(912,12,32,35), roi_back=(912,12,32,35), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_frog_medal.png")
 	I_FROG_MEDAL = RuleImage(roi_front=(912,12,32,35), roi_back=(912,12,32,35), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_frog_medal.png")
-	# 已经进攻三次了 
+	# 已经进攻三次了
 	I_RR_THREE = RuleImage(roi_front=(346,584,42,44), roi_back=(346,584,42,44), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_rr_three.png")
 	I_RR_THREE = RuleImage(roi_front=(346,584,42,44), roi_back=(346,584,42,44), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_rr_three.png")
 	# 呱太入侵, 第一次进入结界时候出现 
 	# 呱太入侵, 第一次进入结界时候出现 
 	I_FROG_RAID = RuleImage(roi_front=(511,301,282,100), roi_back=(511,301,282,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_frog_raid.png")
 	I_FROG_RAID = RuleImage(roi_front=(511,301,282,100), roi_back=(511,301,282,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_frog_raid.png")
-	# 个人 
+	# 个人
 	I_RR_PERSON = RuleImage(roi_front=(1203,236,56,100), roi_back=(1203,236,56,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_rr_person.png")
 	I_RR_PERSON = RuleImage(roi_front=(1203,236,56,100), roi_back=(1203,236,56,100), threshold=0.8, method="Template matching", file="./tasks/RealmRaid/res/res_rr_person.png")
 
 
 
 
@@ -69,6 +69,8 @@ class RealmRaidAssets:
 	O_FRESH_TIME = RuleOcr(roi=(1042,582,85,36), area=(0,0,100,100), mode="Duration", method="Default", keyword="", name="fresh_time")
 	O_FRESH_TIME = RuleOcr(roi=(1042,582,85,36), area=(0,0,100,100), mode="Duration", method="Default", keyword="", name="fresh_time")
 	# 右上角 突破卷的数量 
 	# 右上角 突破卷的数量 
 	O_NUMBER = RuleOcr(roi=(1143,13,80,39), area=(0,0,100,100), mode="DigitCounter", method="Default", keyword="", name="number")
 	O_NUMBER = RuleOcr(roi=(1143,13,80,39), area=(0,0,100,100), mode="DigitCounter", method="Default", keyword="", name="number")
+	# 右上角 突破卷位置可能出现的文字
+	O_TEXT = RuleOcr(roi=(1143,13,80,39), area=(0,0,100,100), mode="Single", method="Default", keyword="", name="text")
 	# Ocr-description 
 	# Ocr-description 
 	O_FROG_1 = RuleOcr(roi=(158,168,42,33), area=(158,168,42,33), mode="Digit", method="Default", keyword="", name="frog_1")
 	O_FROG_1 = RuleOcr(roi=(158,168,42,33), area=(158,168,42,33), mode="Digit", method="Default", keyword="", name="frog_1")
 	# Ocr-description 
 	# Ocr-description 

+ 53 - 32
tasks/RealmRaid/script_task.py

@@ -152,9 +152,9 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
         # 开始循环
         # 开始循环
         success = True
         success = True
         last_battle = True  # 记录上一次战斗的结果
         last_battle = True  # 记录上一次战斗的结果
+        # 更改循环顺序
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-
             # 检查票数
             # 检查票数
             if not self.check_ticket(con.raid_config.number_base):
             if not self.check_ticket(con.raid_config.number_base):
                 break
                 break
@@ -162,25 +162,6 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
             if self.current_count >= con.raid_config.number_attack:
             if self.current_count >= con.raid_config.number_attack:
                 logger.info(f'Current count {self.current_count}, max count {con.raid_config.number_attack}')
                 logger.info(f'Current count {self.current_count}, max count {con.raid_config.number_attack}')
                 break
                 break
-            # 检查是否每三次领一个奖励
-            if self.reward_detect_click(False):
-                continue
-            # 刷新 >> 如果勾选了三次刷新并且到达了三次,就刷新
-            if con.raid_config.three_refresh and self.appear(self.I_RR_THREE, threshold=0.8):
-                logger.info('Three refresh')
-                if self.check_refresh():
-                    continue
-                else:
-                    success = False
-                    break
-            # 刷新 >> 如果上一轮的失败并且勾选了失败刷新,就刷新
-            if not last_battle and con.raid_config.when_attack_fail == WhenAttackFail.REFRESH:
-                logger.info('Battle lost and then refresh')
-                if self.check_refresh():
-                    continue
-                else:
-                    success = False
-                    break
             # ----------------------------------------开始进攻
             # ----------------------------------------开始进攻
             medal, index = self.find_one(False)
             medal, index = self.find_one(False)
             if not medal and not index:
             if not medal and not index:
@@ -217,6 +198,27 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
             last_battle = self.run_general_battle(con.general_battle_config)
             last_battle = self.run_general_battle(con.general_battle_config)
             if lock_before:
             if lock_before:
                 con.general_battle_config.lock_team_enable = lock_before
                 con.general_battle_config.lock_team_enable = lock_before
+            # 检查是否每三次领一个奖励
+            if self.reward_detect_click(False):
+                logger.info('Rewards of three wins')
+                continue
+            # 刷新 >> 如果勾选了三次刷新并且到达了三次,就刷新
+            if con.raid_config.three_refresh and self.appear(self.I_RR_THREE, threshold=0.8):
+                logger.info('Three refresh')
+                if self.check_refresh():
+                    continue
+                else:
+                    success = False
+                    break
+            # 刷新 >> 如果上一轮的失败并且勾选了失败刷新,就刷新
+            if not last_battle and con.raid_config.when_attack_fail == WhenAttackFail.REFRESH:
+                logger.info('Battle lost and then refresh')
+                if self.check_refresh():
+                    continue
+                else:
+                    success = False
+                    break
+
 
 
         self.ui_click(self.I_BACK_RED, self.I_CHECK_EXPLORATION)
         self.ui_click(self.I_BACK_RED, self.I_CHECK_EXPLORATION)
         self.ui_get_current_page()
         self.ui_get_current_page()
@@ -288,6 +290,11 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
         self.wait_until_appear(self.I_BACK_RED)
         self.wait_until_appear(self.I_BACK_RED)
         self.screenshot()
         self.screenshot()
         cu, res, total = self.O_NUMBER.ocr(self.device.image)
         cu, res, total = self.O_NUMBER.ocr(self.device.image)
+
+        if total == 0:
+            self.reward_detect_click(False)
+            # 增加出现聊天框遮挡,处理奖励之后,重新识别票数
+            cu, res, total = self.O_NUMBER.ocr(self.device.image)
         if cu == 0 and cu + res == total:
         if cu == 0 and cu + res == total:
             logger.warning(f'Execute raid failed, no ticket')
             logger.warning(f'Execute raid failed, no ticket')
             return False
             return False
@@ -388,18 +395,32 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
         """
         """
         if screenshot:
         if screenshot:
             self.screenshot()
             self.screenshot()
-        if self.appear(self.I_SOUL_RAID):
-            self.screenshot()
-            # 稳定一次的截图时间
-            # 再次判断是否出现的
-            if not self.appear(self.I_SOUL_RAID):
-                return False
-            while 1:
-                self.screenshot()
-                if not self.appear(self.I_SOUL_RAID, threshold=0.7):
-                    return True
-                if self.appear_then_click(self.I_SOUL_RAID, interval=1.5):
-                    continue
+        # 由于更改识别顺序,退出战斗之后,需要先等待回到个人突破界面,即识别到红色退出按钮,再进行奖励判断
+        self.wait_until_appear(self.I_BACK_RED)
+        text = self.O_TEXT.ocr(self.device.image)
+        # 识别突破卷区域,如果识别到了且其中含有文字,即有聊天框遮挡则进入循环,等待三胜奖励出现并点击,循环退出条件为识别到票(即*/*的形式)
+        if text != "":
+            if re.search(r'[\u4e00-\u9fff]', text):
+                while 1:
+                    self.screenshot()
+                    result = self.O_TEXT.ocr(self.device.image)
+                    if not re.search(r'[\u4e00-\u9fff]', result) and re.search(r'(\d+)/(\d+)', result):
+                        return True
+                    if self.appear_then_click(self.I_SOUL_RAID, interval=1.5):
+                        continue
+
+        # if self.appear(self.I_SOUL_RAID):
+        #     self.screenshot()
+        #     # 稳定一次的截图时间
+        #     # 再次判断是否出现的
+        #     if not self.appear(self.I_SOUL_RAID):
+        #         return False
+        #     while 1:
+        #         self.screenshot()
+        #         if not self.appear(self.I_SOUL_RAID, threshold=0.7):
+        #             return True
+        #         if self.appear_then_click(self.I_SOUL_RAID, interval=1.5):
+        #             continue
 
 
     def check_refresh(self, screenshot: bool=True) -> bool:
     def check_refresh(self, screenshot: bool=True) -> bool:
         """
         """

+ 4 - 4
tasks/RichMan/assets.py

@@ -148,11 +148,11 @@ class RichManAssets:
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# 寄售屋 
 	# 寄售屋 
-	I_MALL_CONSIGNMENT = RuleImage(roi_front=(192,629,63,72), roi_back=(192,629,63,72), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_consignment.png")
+	I_MALL_CONSIGNMENT = RuleImage(roi_front=(200,626,63,72), roi_back=(175,610,120,103), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_consignment.png")
 	# 寄售屋 
 	# 寄售屋 
 	I_MALL_CONSIGNMENT_CHECK = RuleImage(roi_front=(171,83,100,49), roi_back=(171,83,100,49), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_consignment_check.png")
 	I_MALL_CONSIGNMENT_CHECK = RuleImage(roi_front=(171,83,100,49), roi_back=(171,83,100,49), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_consignment_check.png")
 	# 密卷屋 
 	# 密卷屋 
-	I_MALL_SCCALES = RuleImage(roi_front=(433,635,100,64), roi_back=(433,635,100,64), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sccales.png")
+	I_MALL_SCCALES = RuleImage(roi_front=(447,634,91,64), roi_back=(427,621,147,92), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sccales.png")
 	# 密卷屋 
 	# 密卷屋 
 	I_MALL_SCCALES_CHECK = RuleImage(roi_front=(409,253,100,100), roi_back=(409,253,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sccales_check.png")
 	I_MALL_SCCALES_CHECK = RuleImage(roi_front=(409,253,100,100), roi_back=(409,253,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sccales_check.png")
 	# description 
 	# description 
@@ -162,7 +162,7 @@ class RichManAssets:
 	# 契灵商店 
 	# 契灵商店 
 	I_MALL_BONDLINGS_CHECK = RuleImage(roi_front=(355,186,34,104), roi_back=(355,186,34,104), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_bondlings_check.png")
 	I_MALL_BONDLINGS_CHECK = RuleImage(roi_front=(355,186,34,104), roi_back=(355,186,34,104), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_bondlings_check.png")
 	# 杂货铺 
 	# 杂货铺 
-	I_MALL_SUNDRY = RuleImage(roi_front=(854,623,74,61), roi_back=(854,623,74,61), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sundry.png")
+	I_MALL_SUNDRY = RuleImage(roi_front=(856,639,74,61), roi_back=(834,621,116,90), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sundry.png")
 	# 杂货铺 
 	# 杂货铺 
 	I_MALL_SUNDRY_CHECK = RuleImage(roi_front=(1093,10,31,44), roi_back=(1093,10,31,44), threshold=0.7, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sundry_check.png")
 	I_MALL_SUNDRY_CHECK = RuleImage(roi_front=(1093,10,31,44), roi_back=(1093,10,31,44), threshold=0.7, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_mall_sundry_check.png")
 
 
@@ -250,7 +250,7 @@ class RichManAssets:
 	# description 
 	# description 
 	I_SCA_SELECT_3 = RuleImage(roi_front=(972,517,123,50), roi_back=(972,517,123,50), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_select_3.png")
 	I_SCA_SELECT_3 = RuleImage(roi_front=(972,517,123,50), roi_back=(972,517,123,50), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_select_3.png")
 	# 获得的六星 
 	# 获得的六星 
-	I_SCA_SIX_STAR = RuleImage(roi_front=(119,259,100,22), roi_back=(119,259,100,22), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_six_star.png")
+	I_SCA_SIX_STAR = RuleImage(roi_front=(119,261,100,22), roi_back=(108,246,261,57), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_six_star.png")
 	# 点击屏幕继续 
 	# 点击屏幕继续 
 	I_SCA_REWARD = RuleImage(roi_front=(584,503,100,100), roi_back=(584,503,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_reward.png")
 	I_SCA_REWARD = RuleImage(roi_front=(584,503,100,100), roi_back=(584,503,100,100), threshold=0.8, method="Template matching", file="./tasks/RichMan/mall/scales/scales_sca_reward.png")
 	# 点击兑换 
 	# 点击兑换 

+ 6 - 6
tasks/RichMan/mall/navbar/image_bottom.json

@@ -2,8 +2,8 @@
   {
   {
     "itemName": "mall_consignment",
     "itemName": "mall_consignment",
     "imageName": "navbar_mall_consignment.png",
     "imageName": "navbar_mall_consignment.png",
-    "roiFront": "192,629,63,72",
-    "roiBack": "192,629,63,72",
+    "roiFront": "200,626,63,72",
+    "roiBack": "175,610,120,103",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "寄售屋"
     "description": "寄售屋"
@@ -20,8 +20,8 @@
   {
   {
     "itemName": "mall_sccales",
     "itemName": "mall_sccales",
     "imageName": "navbar_mall_sccales.png",
     "imageName": "navbar_mall_sccales.png",
-    "roiFront": "433,635,100,64",
-    "roiBack": "433,635,100,64",
+    "roiFront": "447,634,91,64",
+    "roiBack": "427,621,147,92",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "密卷屋"
     "description": "密卷屋"
@@ -65,8 +65,8 @@
   {
   {
     "itemName": "mall_sundry",
     "itemName": "mall_sundry",
     "imageName": "navbar_mall_sundry.png",
     "imageName": "navbar_mall_sundry.png",
-    "roiFront": "854,623,74,61",
-    "roiBack": "854,623,74,61",
+    "roiFront": "856,639,74,61",
+    "roiBack": "834,621,116,90",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "杂货铺"
     "description": "杂货铺"

BIN
tasks/RichMan/mall/navbar/navbar_mall_consignment.png


BIN
tasks/RichMan/mall/navbar/navbar_mall_sccales.png


BIN
tasks/RichMan/mall/navbar/navbar_mall_sundry.png


BIN
tasks/RichMan/mall/navbar/navbar_side_suer_honor.png


BIN
tasks/RichMan/mall/navbar/navbar_side_sure_charisma.png


BIN
tasks/RichMan/mall/navbar/navbar_side_sure_friends.png


BIN
tasks/RichMan/mall/navbar/navbar_side_sure_medal.png


BIN
tasks/RichMan/mall/navbar/navbar_side_sure_special.png


+ 2 - 2
tasks/RichMan/mall/scales/image.json

@@ -110,8 +110,8 @@
   {
   {
     "itemName": "sca_six_star",
     "itemName": "sca_six_star",
     "imageName": "scales_sca_six_star.png",
     "imageName": "scales_sca_six_star.png",
-    "roiFront": "119,259,100,22",
-    "roiBack": "119,259,100,22",
+    "roiFront": "119,261,100,22",
+    "roiBack": "108,246,261,57",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "获得的六星"
     "description": "获得的六星"

BIN
tasks/RichMan/mall/scales/scales_sca_six_star.png