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

Merge pull request #128 from runhey/dev

Dev
huangrunheng 3 лет назад
Родитель
Сommit
2237f9588e

+ 1 - 1
README.md

@@ -64,7 +64,7 @@ This project is licensed under the GNU General Public License v3.0.
 - 你必须拥有一个 Github 账户来点一个 **Star** (这并不影响你入群后取消Star),同样的要求注册时间过半年。
 - 你必须拥有一个 Github 账户来点一个 **Star** (这并不影响你入群后取消Star),同样的要求注册时间过半年。
 - 入群验证填入你的 Github 账号名,无需在意问题是什么。
 - 入群验证填入你的 Github 账号名,无需在意问题是什么。
 
 
-#### 技术/开发群: 207613181
+#### 开发群: 207613181
 
 
 - 发展规划:[#54](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - 发展规划:[#54](https://github.com/runhey/OnmyojiAutoScript/issues/54)
 - OAS 继承了 Alas 的设计思路,这使得极大简便了开发,欢迎提交 Pull Requests,挑选你感兴趣的部分进行开发即可。
 - OAS 继承了 Alas 的设计思路,这使得极大简便了开发,欢迎提交 Pull Requests,挑选你感兴趣的部分进行开发即可。

+ 1 - 1
tasks/BondlingFairyland/script_task.py

@@ -481,7 +481,7 @@ class ScriptTask(GameUi, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
         """
         """
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if not self.appear(self.I_BALL_FIRE):
+            if not self.appear(self.I_CLICK_CAPTION, threshold=0.7):
                 break
                 break
             if self.appear_then_click(self.I_BALL_FIRE, interval=1):
             if self.appear_then_click(self.I_BALL_FIRE, interval=1):
                 continue
                 continue

+ 1 - 1
tasks/Component/GeneralBattle/assets.py

@@ -78,7 +78,7 @@ class GeneralBattleAssets:
 	# 失败 
 	# 失败 
 	I_FALSE = RuleImage(roi_front=(413,124,100,100), roi_back=(413,124,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_false.png")
 	I_FALSE = RuleImage(roi_front=(413,124,100,100), roi_back=(413,124,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_false.png")
 	# 确认预设的队伍 
 	# 确认预设的队伍 
-	I_PRESET_ENSURE = RuleImage(roi_front=(354,641,141,50), roi_back=(354,641,141,50), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_preset_ensure.png")
+	I_PRESET_ENSURE = RuleImage(roi_front=(352,643,141,50), roi_back=(305,625,236,83), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_preset_ensure.png")
 	# 选择buff 
 	# 选择buff 
 	I_BUFF = RuleImage(roi_front=(115,657,42,50), roi_back=(106,641,67,77), threshold=0.7, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_buff.png")
 	I_BUFF = RuleImage(roi_front=(115,657,42,50), roi_back=(106,641,67,77), threshold=0.7, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_buff.png")
 	# 觉醒加成 
 	# 觉醒加成 

BIN
tasks/Component/GeneralBattle/gb/gb_preset_ensure.png


+ 2 - 2
tasks/Component/GeneralBattle/gb/image.json

@@ -56,8 +56,8 @@
   {
   {
     "itemName": "preset_ensure",
     "itemName": "preset_ensure",
     "imageName": "gb_preset_ensure.png",
     "imageName": "gb_preset_ensure.png",
-    "roiFront": "354,641,141,50",
-    "roiBack": "354,641,141,50",
+    "roiFront": "352,643,141,50",
+    "roiBack": "305,625,236,83",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "确认预设的队伍"
     "description": "确认预设的队伍"

+ 8 - 2
tasks/Exploration/script_task.py

@@ -35,7 +35,8 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
         if explorationConfig.switch_soul_config.enable_switch_by_name:
         if explorationConfig.switch_soul_config.enable_switch_by_name:
             self.ui_get_current_page()
             self.ui_get_current_page()
             self.ui_goto(page_shikigami_records)
             self.ui_goto(page_shikigami_records)
-            self.run_switch_soul_by_name(explorationConfig.switch_soul_config.group_name, explorationConfig.switch_soul_config.team_name)
+            self.run_switch_soul_by_name(explorationConfig.switch_soul_config.group_name,
+                                         explorationConfig.switch_soul_config.team_name)
 
 
         # 开启加成
         # 开启加成
         con = self.config.exploration.exploration_config
         con = self.config.exploration.exploration_config
@@ -66,6 +67,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
             count = 0
             count = 0
             while count < 7:
             while count < 7:
                 self.screenshot()
                 self.screenshot()
+                time.sleep(0.5)
                 if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
                 if self.appear_then_click(self.I_E_EXPLORATION_CLICK):
                     count += 1
                     count += 1
                     # 进入战斗环节
                     # 进入战斗环节
@@ -199,7 +201,11 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, ExplorationAssets):
                     break
                     break
             # 小怪 战
             # 小怪 战
             if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
             if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
-                self.run_general_battle(self.config.exploration.general_battle_config)
+                self.screenshot()
+                if self.appear_then_click(self.I_NORMAL_BATTLE_BUTTON):
+                    self.run_general_battle(self.config.exploration.general_battle_config)
+                else:
+                    self.run_general_battle(self.config.exploration.general_battle_config)
                 self.screenshot()
                 self.screenshot()
                 while self.appear(self.I_BATTLE_REWARD):
                 while self.appear(self.I_BATTLE_REWARD):
                     self.screenshot()
                     self.screenshot()

+ 1 - 1
tasks/GoryouRealm/assets.py

@@ -31,7 +31,7 @@ class GoryouRealmAssets:
 
 
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
-	# 多少张票
+	# 多少张票 
 	O_GR_TICKET = RuleOcr(roi=(920,21,100,41), area=(920,21,100,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")
 
 
 
 

+ 4 - 4
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,8 +69,6 @@ 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 
@@ -89,6 +87,8 @@ class RealmRaidAssets:
 	O_FROG_8 = RuleOcr(roi=(494,441,31,31), area=(494,441,31,31), mode="Digit", method="Default", keyword="", name="frog_8")
 	O_FROG_8 = RuleOcr(roi=(494,441,31,31), area=(494,441,31,31), mode="Digit", method="Default", keyword="", name="frog_8")
 	# Ocr-description 
 	# Ocr-description 
 	O_FROG_9 = RuleOcr(roi=(825,440,33,33), area=(825,440,33,33), mode="Digit", method="Default", keyword="", name="frog_9")
 	O_FROG_9 = RuleOcr(roi=(825,440,33,33), area=(825,440,33,33), mode="Digit", method="Default", keyword="", name="frog_9")
+	# text 
+	O_TEXT = RuleOcr(roi=(1143,13,80,39), area=(0,0,100,100), mode="Single", method="Default", keyword="", name="text")
 
 
 
 
 	# Click Rule Assets
 	# Click Rule Assets

+ 10 - 1
tasks/RealmRaid/res/ocr.json

@@ -97,5 +97,14 @@
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
     "description": "Ocr-description"
     "description": "Ocr-description"
-  }
+  },
+  {
+    "itemName": "text",
+    "roiFront": "1143,13,80,39",
+    "roiBack": "0,0,100,100",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "text"
+    }
 ]
 ]

+ 1 - 1
tasks/Restart/assets.py

@@ -68,6 +68,6 @@ class RestartAssets:
 	# 点击屏幕跳过 
 	# 点击屏幕跳过 
 	O_LOGIN_SKIP_1 = RuleOcr(roi=(1046,35,130,37), area=(1046,35,130,37), mode="Single", method="Default", keyword="点击屏幕跳过", name="login_skip_1")
 	O_LOGIN_SKIP_1 = RuleOcr(roi=(1046,35,130,37), area=(1046,35,130,37), mode="Single", method="Default", keyword="点击屏幕跳过", name="login_skip_1")
 	# 登录指定角色,默认第一个 
 	# 登录指定角色,默认第一个 
-	O_LOGIN_SPECIFIC_SERVE = RuleOcr(roi=(524,600,242,53), area=(516,75,662,585), mode="Single", method="Default", keyword="点击屏幕进入游戏", name="login_specific_serve")
+	O_LOGIN_SPECIFIC_SERVE = RuleOcr(roi=(524,600,242,53), area=(516,75,662,585), mode="Single", method="Default", keyword="游戏", name="login_specific_serve")
 
 
 
 

+ 1 - 1
tasks/Restart/login/ocr.json

@@ -32,7 +32,7 @@
     "roiBack": "516,75,662,585",
     "roiBack": "516,75,662,585",
     "mode": "Single",
     "mode": "Single",
     "method": "Default",
     "method": "Default",
-    "keyword": "点击屏幕进入游戏",
+    "keyword": "游戏",
     "description": "登录指定角色,默认第一个"
     "description": "登录指定角色,默认第一个"
   }
   }
 ]
 ]

+ 5 - 3
tasks/RichMan/assets.py

@@ -18,11 +18,11 @@ class RichManAssets:
 	# description 
 	# description 
 	I_GUILD_CLOSE_RED = RuleImage(roi_front=(1029,120,53,57), roi_back=(1029,120,53,57), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_close_red.png")
 	I_GUILD_CLOSE_RED = RuleImage(roi_front=(1029,120,53,57), roi_back=(1029,120,53,57), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_close_red.png")
 	# 蓝票 
 	# 蓝票 
-	I_GUILD_BLUE = RuleImage(roi_front=(793,179,74,80), roi_back=(793,179,74,80), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_blue.png")
+	I_GUILD_BLUE = RuleImage(roi_front=(344,186,74,73), roi_back=(315,164,584,370), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_blue.png")
 	# 黑蛋碎片 
 	# 黑蛋碎片 
-	I_GUILD_SCRAP = RuleImage(roi_front=(570,442,71,68), roi_back=(570,442,71,68), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_scrap.png")
+	I_GUILD_SCRAP = RuleImage(roi_front=(795,187,71,68), roi_back=(331,160,559,372), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_scrap.png")
 	# 皮肤券 
 	# 皮肤券 
-	I_GUILD_SKIN = RuleImage(roi_front=(795,436,71,74), roi_back=(795,436,71,74), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_skin.png")
+	I_GUILD_SKIN = RuleImage(roi_front=(345,438,71,72), roi_back=(320,162,573,371), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_skin.png")
 	# 购买检查 
 	# 购买检查 
 	I_GUILD_CHECK_SCRAP = RuleImage(roi_front=(590,246,90,88), roi_back=(590,246,90,88), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_check_scrap.png")
 	I_GUILD_CHECK_SCRAP = RuleImage(roi_front=(590,246,90,88), roi_back=(590,246,90,88), threshold=0.8, method="Template matching", file="./tasks/RichMan/guild/guild_guild_check_scrap.png")
 
 
@@ -36,6 +36,8 @@ class RichManAssets:
 	O_GUILD_NUMBER_BLACK = RuleOcr(roi=(663,523,21,27), area=(663,523,21,27), mode="Digit", method="Default", keyword="", name="guild_number_black")
 	O_GUILD_NUMBER_BLACK = RuleOcr(roi=(663,523,21,27), area=(663,523,21,27), mode="Digit", method="Default", keyword="", name="guild_number_black")
 	# Ocr-description 
 	# Ocr-description 
 	O_GUILD_NUMBER_SKIN = RuleOcr(roi=(889,519,21,35), area=(889,519,21,35), mode="Digit", method="Default", keyword="", name="guild_number_skin")
 	O_GUILD_NUMBER_SKIN = RuleOcr(roi=(889,519,21,35), area=(889,519,21,35), mode="Digit", method="Default", keyword="", name="guild_number_skin")
+	# 本周剩余数量x 
+	O_GUILD_REMAIN = RuleOcr(roi=(304,268,154,33), area=(304,268,154,33), mode="Single", method="Default", keyword="", name="guild_remain")
 
 
 
 
 	# Swipe Rule Assets
 	# Swipe Rule Assets

+ 23 - 15
tasks/RichMan/guild.py

@@ -2,8 +2,10 @@
 # @author runhey
 # @author runhey
 # github https://github.com/runhey
 # github https://github.com/runhey
 import time
 import time
+import re
 
 
 from module.logger import logger
 from module.logger import logger
+from module.atom.image import RuleImage
 
 
 from tasks.GameUi.page import page_main, page_guild
 from tasks.GameUi.page import page_main, page_guild
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.game_ui import GameUi
@@ -29,7 +31,7 @@ class Guild(Buy, GameUi, RichManAssets):
         time.sleep(0.5)
         time.sleep(0.5)
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if self.appear(self.I_GUILD_SCRAP):
+            if self.appear(self.I_GUILD_SKIN):
                 break
                 break
             if self.swipe(self.S_GUILD_STORE, interval=1.5):
             if self.swipe(self.S_GUILD_STORE, interval=1.5):
                 time.sleep(2)
                 time.sleep(2)
@@ -58,10 +60,7 @@ class Guild(Buy, GameUi, RichManAssets):
         self.screenshot()
         self.screenshot()
         if not self.buy_check_money(self.O_GUILD_TOTAL, 240):
         if not self.buy_check_money(self.O_GUILD_TOTAL, 240):
             return False
             return False
-        number = self.O_GUILD_NUMBER_BLUE.ocr(self.device.image)
-        if not isinstance(number, int):
-            logger.warning('OCR number failed')
-            return False
+        number = self.check_remain(self.I_GUILD_BLUE)
         if number == 0:
         if number == 0:
             logger.warning('No mystery amulet can buy')
             logger.warning('No mystery amulet can buy')
             return False
             return False
@@ -74,10 +73,7 @@ class Guild(Buy, GameUi, RichManAssets):
         self.screenshot()
         self.screenshot()
         if not self.buy_check_money(self.O_GUILD_TOTAL, 200):
         if not self.buy_check_money(self.O_GUILD_TOTAL, 200):
             return False
             return False
-        number = self.O_GUILD_NUMBER_BLACK.ocr(self.device.image)
-        if not isinstance(number, int):
-            logger.warning('OCR number failed')
-            return False
+        number = self.check_remain(self.I_GUILD_SCRAP)
         if number == 0:
         if number == 0:
             logger.warning('No black daruma can buy')
             logger.warning('No black daruma can buy')
             return False
             return False
@@ -93,10 +89,7 @@ class Guild(Buy, GameUi, RichManAssets):
         self.screenshot()
         self.screenshot()
         if not self.buy_check_money(self.O_GUILD_TOTAL, 50):
         if not self.buy_check_money(self.O_GUILD_TOTAL, 50):
             return False
             return False
-        number = self.O_GUILD_NUMBER_SKIN.ocr(self.device.image)
-        if not isinstance(number, int):
-            logger.warning('OCR number failed')
-            return False
+        number = self.check_remain(self.I_GUILD_SKIN)
         if number == 0:
         if number == 0:
             logger.warning('No skin ticket can buy')
             logger.warning('No skin ticket can buy')
             return False
             return False
@@ -104,6 +97,21 @@ class Guild(Buy, GameUi, RichManAssets):
         time.sleep(0.5)
         time.sleep(0.5)
         return True
         return True
 
 
+    def check_remain(self, image: RuleImage) -> int:
+        self.O_GUILD_REMAIN.roi[0] = image.roi_front[0] - 38
+        self.O_GUILD_REMAIN.roi[1] = image.roi_front[1] + 83
+        logger.info(f'Image roi {image.roi_front}')
+        logger.info(f'Image roi {self.O_GUILD_REMAIN.roi}')
+        self.screenshot()
+        result = self.O_GUILD_REMAIN.ocr(self.device.image)
+        result = result.replace('?', '2').replace('?', '2').replace(':', ';')
+        try:
+            result = re.findall(r'本周剩余数量(\d+)', result)[0]
+            result = int(result)
+        except:
+            result = 0
+        logger.info('Remain: %s' % result)
+        return int(result)
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
@@ -114,7 +122,7 @@ if __name__ == '__main__':
     d = Device(c)
     d = Device(c)
     t = Guild(c, d)
     t = Guild(c, d)
 
 
-    t._guild_skin_ticket(5)
-
+    # t._guild_skin_ticket(5)
+    t.execute_guild(con=c.rich_man.guild_store)
 
 
 
 

BIN
tasks/RichMan/guild/guild_guild_blue.png


BIN
tasks/RichMan/guild/guild_guild_scrap.png


BIN
tasks/RichMan/guild/guild_guild_skin.png


+ 6 - 6
tasks/RichMan/guild/image.json

@@ -29,8 +29,8 @@
   {
   {
     "itemName": "guild_blue",
     "itemName": "guild_blue",
     "imageName": "guild_guild_blue.png",
     "imageName": "guild_guild_blue.png",
-    "roiFront": "793,179,74,80",
-    "roiBack": "793,179,74,80",
+    "roiFront": "344,186,74,73",
+    "roiBack": "315,164,584,370",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "蓝票"
     "description": "蓝票"
@@ -38,8 +38,8 @@
   {
   {
     "itemName": "guild_scrap",
     "itemName": "guild_scrap",
     "imageName": "guild_guild_scrap.png",
     "imageName": "guild_guild_scrap.png",
-    "roiFront": "570,442,71,68",
-    "roiBack": "570,442,71,68",
+    "roiFront": "795,187,71,68",
+    "roiBack": "331,160,559,372",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "黑蛋碎片"
     "description": "黑蛋碎片"
@@ -47,8 +47,8 @@
   {
   {
     "itemName": "guild_skin",
     "itemName": "guild_skin",
     "imageName": "guild_guild_skin.png",
     "imageName": "guild_guild_skin.png",
-    "roiFront": "795,436,71,74",
-    "roiBack": "795,436,71,74",
+    "roiFront": "345,438,71,72",
+    "roiBack": "320,162,573,371",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "皮肤券"
     "description": "皮肤券"

+ 9 - 0
tasks/RichMan/guild/ocr.json

@@ -34,5 +34,14 @@
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
     "description": "Ocr-description"
     "description": "Ocr-description"
+  },
+  {
+    "itemName": "guild_remain",
+    "roiFront": "304,268,154,33",
+    "roiBack": "304,268,154,33",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "本周剩余数量x"
   }
   }
 ]
 ]

+ 8 - 16
tasks/Secret/script_task.py

@@ -72,6 +72,7 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
                 logger.info('Secret zone finished')
                 logger.info('Secret zone finished')
                 break
                 break
             layer = self.find_battle()
             layer = self.find_battle()
+            logger.info(f'Current layer: {layer}')
             if not layer:
             if not layer:
                 continue
                 continue
             if layer >= 6:
             if layer >= 6:
@@ -165,8 +166,8 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
             """
             """
             ocr_target.roi[0] = int(roi[0]) - 118
             ocr_target.roi[0] = int(roi[0]) - 118
             ocr_target.roi[1] = int(roi[1]) + 37
             ocr_target.roi[1] = int(roi[1]) + 37
-            print(f'检测到的未通过ROI: {roi}')
-            print(f'检测到的勾玉数量ROI: {ocr_target.roi}')
+            # print(f'检测到的未通过ROI: {roi}')
+            # print(f'检测到的勾玉数量ROI: {ocr_target.roi}')
             jade_num = ocr_target.ocr(self.device.image)
             jade_num = ocr_target.ocr(self.device.image)
             if isinstance(jade_num, str):
             if isinstance(jade_num, str):
                 logger.warning(f'OCR failed, try again {jade_num}')
                 logger.warning(f'OCR failed, try again {jade_num}')
@@ -199,14 +200,6 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
         if text_pos != (0, 0, 0, 0):
         if text_pos != (0, 0, 0, 0):
             # 如果能找得到 未通关 ,那可以挑战
             # 如果能找得到 未通关 ,那可以挑战
             layer = confirm_layer(self.O_SE_JADE, text_pos)
             layer = confirm_layer(self.O_SE_JADE, text_pos)
-            # layer = check_layer(self.O_SE_LAYER_1, None)
-            # # 如果第一个文字就找得到的,就点击这个
-            # if not layer:
-            #     layer = check_layer(self.O_SE_LAYER_8, None)
-            # if not layer:
-            #     layer = check_layer(self.O_SE_LAYER_1, text_pos)
-
-            print('识别到的层数:', layer)
             if layer:
             if layer:
                 self.C_SE_CLICK_LAYER.roi_front = text_pos
                 self.C_SE_CLICK_LAYER.roi_front = text_pos
                 self.click(self.C_SE_CLICK_LAYER, interval=1)
                 self.click(self.C_SE_CLICK_LAYER, interval=1)
@@ -220,12 +213,11 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
             if last_text_pos != (0, 0, 0, 0):
             if last_text_pos != (0, 0, 0, 0):
                 # 如果是后面找得到
                 # 如果是后面找得到
                 layer = confirm_layer(self.O_SE_JADE, last_text_pos)
                 layer = confirm_layer(self.O_SE_JADE, last_text_pos)
-                # layer = check_layer(self.O_SE_LAYER_10, last_text_pos)
-                # if not layer:
-                #     layer = check_layer(self.O_SE_LAYER_9, None)
-                # if not layer:
-                #     layer = check_layer(self.O_SE_LAYER_10, None)
-                # 如果第一个文字就找得到的,就点击这个
+
+                # 有个bug 十层的发现不了
+                if not layer and last_text_pos[1] > 520:
+                    layer = 10
+
                 if layer:
                 if layer:
                     self.C_SE_CLICK_LAYER.roi_front = last_text_pos
                     self.C_SE_CLICK_LAYER.roi_front = last_text_pos
                     self.click(self.C_SE_CLICK_LAYER, interval=1)
                     self.click(self.C_SE_CLICK_LAYER, interval=1)