Explorar o código

Merge branch 'dev'

qiyonghan %!s(int64=2) %!d(string=hai) anos
pai
achega
db7db8d1cf

+ 3 - 3
dev_tools/assets_test.py

@@ -34,10 +34,10 @@ def detect_ocr(file: str, target: RuleOcr):
 
 
 
 
 # 图片文件路径 可以是相对路径
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = r"C:\Users\萌萌哒\Desktop\2024-08-15_23-01-04-220349.png"
+IMAGE_FILE = r"C:\Users\Ryland\Desktop\363385164-41fa341c-3efc-43f8-91b5-0cdd065ed8cf.png"
 if __name__ == '__main__':
 if __name__ == '__main__':
-    from tasks.GlobalGame.assets import GlobalGameAssets
-    targe = GlobalGameAssets.I_G_ACCEPT
+    from tasks.KekkaiUtilize.assets import KekkaiUtilizeAssets
+    targe = KekkaiUtilizeAssets.I_SHI_CARD
     print(detect_image(IMAGE_FILE, targe))
     print(detect_image(IMAGE_FILE, targe))
 
 
     # ocr demo
     # ocr demo

+ 1 - 0
module/ocr/base_ocr.py

@@ -147,6 +147,7 @@ class BaseCor:
         start_time = time.time()
         start_time = time.time()
         image = self.crop(image, self.roi)
         image = self.crop(image, self.roi)
         image = self.pre_process(image)
         image = self.pre_process(image)
+        image = enlarge_canvas(image)
         # ocr
         # ocr
         result, score = self.model.ocr_single_line(image)
         result, score = self.model.ocr_single_line(image)
         if score < self.score:
         if score < self.score:

+ 5 - 1
module/ocr/sub_ocr.py

@@ -97,6 +97,7 @@ class Digit(Single):
         result = super().after_process(result)
         result = super().after_process(result)
         result = result.replace('I', '1').replace('D', '0').replace('S', '5')
         result = result.replace('I', '1').replace('D', '0').replace('S', '5')
         result = result.replace('B', '8').replace('?', '2').replace('?', '2')
         result = result.replace('B', '8').replace('?', '2').replace('?', '2')
+        result = result.replace('d', '6')
         result = [char for char in result if char.isdigit()]
         result = [char for char in result if char.isdigit()]
         result = ''.join(result)
         result = ''.join(result)
 
 
@@ -124,7 +125,10 @@ class DigitCounter(Single):
     def after_process(self, result):
     def after_process(self, result):
         result = super().after_process(result)
         result = super().after_process(result)
         result = result.replace('I', '1').replace('D', '0').replace('S', '5')
         result = result.replace('I', '1').replace('D', '0').replace('S', '5')
-        result = result.replace('B', '8')
+        result = result.replace('B', '8').replace('?', '2').replace('?', '2')
+        result = result.replace('d', '6')
+        result = [char for char in result if char.isdigit() or char == '/']
+        result = ''.join(result)
         return result
         return result
 
 
     @classmethod
     @classmethod

+ 9 - 9
tasks/Component/GeneralInvite/general_invite.py

@@ -75,14 +75,6 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
             if self.timer_wait.reached():
             if self.timer_wait.reached():
                 logger.warning('Wait timeout')
                 logger.warning('Wait timeout')
                 return False
                 return False
-            if self.timer_invite and self.timer_invite.reached():
-                if is_first:
-                    logger.info('Invitation is triggered every 20s')
-                    self.timer_invite.reset()
-                else:
-                    logger.info('Wait for 30s and invite again')
-                    self.timer_invite = None
-                self.invite_friends(config)
             if self.appear(self.I_MATCHING):
             if self.appear(self.I_MATCHING):
                 logger.warning('Timeout, now is no room')
                 logger.warning('Timeout, now is no room')
                 return False
                 return False
@@ -95,7 +87,6 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
                 self.appear_then_click(self.I_GI_EMOJI_1)
                 self.appear_then_click(self.I_GI_EMOJI_1)
                 self.appear_then_click(self.I_GI_EMOJI_2)
                 self.appear_then_click(self.I_GI_EMOJI_2)
 
 
-
             fire = False  # 是否开启挑战
             fire = False  # 是否开启挑战
             # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
             # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
             if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_2):
             if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_2):
@@ -130,6 +121,15 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
                 self.click_fire()
                 self.click_fire()
                 return True
                 return True
 
 
+            if self.timer_invite and self.timer_invite.reached():
+                if is_first:
+                    logger.info('Invitation is triggered every 20s')
+                    self.timer_invite.reset()
+                else:
+                    logger.info('Wait for 30s and invite again')
+                    self.timer_invite = None
+                self.invite_friends(config)
+
     def ensure_enter(self) -> bool:
     def ensure_enter(self) -> bool:
         """
         """
         确认是否进入了组队界面
         确认是否进入了组队界面

+ 22 - 0
tasks/Exploration/base.py

@@ -135,6 +135,10 @@ class BaseExploration(GeneralBattle, GeneralRoom, GeneralInvite, ReplaceShikigam
             # 有则跳出检测
             # 有则跳出检测
             if self.appear(self.I_E_EXPLORATION_CLICK) or result and len(result) > 0:
             if self.appear(self.I_E_EXPLORATION_CLICK) or result and len(result) > 0:
                 break
                 break
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            if self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                continue
             self.device.click_record_clear()
             self.device.click_record_clear()
             self.swipe(self.S_SWIPE_LEVEL_UP)
             self.swipe(self.S_SWIPE_LEVEL_UP)
             swipeCount += 1
             swipeCount += 1
@@ -144,11 +148,17 @@ class BaseExploration(GeneralBattle, GeneralRoom, GeneralInvite, ReplaceShikigam
         # 选中对应章节
         # 选中对应章节
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                continue
+            if self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                continue
             self.O_E_EXPLORATION_LEVEL_NUMBER.keyword = explorationConfig.exploration_config.exploration_level
             self.O_E_EXPLORATION_LEVEL_NUMBER.keyword = explorationConfig.exploration_config.exploration_level
             if self.ocr_appear_click(self.O_E_EXPLORATION_LEVEL_NUMBER):
             if self.ocr_appear_click(self.O_E_EXPLORATION_LEVEL_NUMBER):
                 self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=3)
                 self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=3)
             if self.appear(self.I_E_EXPLORATION_CLICK):
             if self.appear(self.I_E_EXPLORATION_CLICK):
                 break
                 break
+            if self.is_in_room():
+                break
 
 
         return True
         return True
 
 
@@ -330,6 +340,18 @@ class BaseExploration(GeneralBattle, GeneralRoom, GeneralInvite, ReplaceShikigam
             if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1.5):
             if self.appear_then_click(self.I_UI_BACK_BLUE, interval=1.5):
                 continue
                 continue
 
 
+    def fire(self, button) -> bool:
+        self.ui_click_until_disappear(button, interval=3)
+        if (self.appear(self.I_E_SETTINGS_BUTTON) or
+                self.appear(self.I_E_AUTO_ROTATE_ON) or
+                self.appear(self.I_E_AUTO_ROTATE_OFF)):
+            # 如果还在探索说明,这个是显示滑动导致挑战按钮不在范围内
+            logger.warning('Fire button disappear, but still in exploration')
+            return False
+        self.run_general_battle(self._config.general_battle_config)
+        self.minions_cnt += 1
+        return True
+
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     from module.config.config import Config
     from module.config.config import Config

+ 3 - 3
tasks/Exploration/solo.py

@@ -158,8 +158,9 @@ class SoloExploration(BaseExploration):
                 if self.appear(self.I_FIRE, threshold=0.8) and not self.appear(self.I_ADD_2):
                 if self.appear(self.I_FIRE, threshold=0.8) and not self.appear(self.I_ADD_2):
                     self.ui_click_until_disappear(self.I_FIRE, interval=1)
                     self.ui_click_until_disappear(self.I_FIRE, interval=1)
                     continue
                     continue
-                if self.run_invite(config=self._invite_config, is_first=True):
-                    continue
+                if self.appear(self.I_ADD_2):
+                    if self.run_invite(config=self._invite_config, is_first=True):
+                        continue
                 else:
                 else:
                     logger.warning('Invite failed, quit')
                     logger.warning('Invite failed, quit')
                     while 1:
                     while 1:
@@ -451,7 +452,6 @@ class ScriptTask(SoloExploration):
             case UserStatus.MEMBER: self.run_member()
             case UserStatus.MEMBER: self.run_member()
             case _: self.run_solo()
             case _: self.run_solo()
 
 
-
         self.post_process()
         self.post_process()
 
 
 
 

+ 2 - 2
tasks/GameUi/assets.py

@@ -53,9 +53,9 @@ class GameUiAssets:
 	# 平安奇谭 
 	# 平安奇谭 
 	I_EXPLORATION_GOTO_HEIAN_KITAN = RuleImage(roi_front=(739,643,52,44), roi_back=(739,643,52,44), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_heian_kitan.png")
 	I_EXPLORATION_GOTO_HEIAN_KITAN = RuleImage(roi_front=(739,643,52,44), roi_back=(739,643,52,44), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_heian_kitan.png")
 	# 六道之门 
 	# 六道之门 
-	I_EXPLORATION_GOTO_SIX_GATES = RuleImage(roi_front=(838,640,60,49), roi_back=(793,632,143,66), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_six_gates.png")
+	I_EXPLORATION_GOTO_SIX_GATES = RuleImage(roi_front=(838,640,60,49), roi_back=(818,631,200,66), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_six_gates.png")
 	# 器灵 
 	# 器灵 
-	I_EXPLORATION_GOTO_BONDLING_FAIRYLAND = RuleImage(roi_front=(937,639,61,54), roi_back=(937,639,61,54), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_bondling_fairyland.png")
+	I_EXPLORATION_GOTO_BONDLING_FAIRYLAND = RuleImage(roi_front=(937,639,56,49), roi_back=(928,633,203,64), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_exploration_goto_bondling_fairyland.png")
 	# description 
 	# description 
 	I_BACK_BLUE = RuleImage(roi_front=(32,37,54,52), roi_back=(3,2,130,114), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_blue.png")
 	I_BACK_BLUE = RuleImage(roi_front=(32,37,54,52), roi_back=(3,2,130,114), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_blue.png")
 	# description 
 	# description 

+ 3 - 3
tasks/GameUi/page/page_img.json

@@ -102,7 +102,7 @@
     "itemName": "exploration_goto_six_gates",
     "itemName": "exploration_goto_six_gates",
     "imageName": "page_exploration_goto_six_gates.png",
     "imageName": "page_exploration_goto_six_gates.png",
     "roiFront": "838,640,60,49",
     "roiFront": "838,640,60,49",
-    "roiBack": "793,632,143,66",
+    "roiBack": "818,631,200,66",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "六道之门"
     "description": "六道之门"
@@ -110,8 +110,8 @@
   {
   {
     "itemName": "exploration_goto_bondling_fairyland",
     "itemName": "exploration_goto_bondling_fairyland",
     "imageName": "page_exploration_goto_bondling_fairyland.png",
     "imageName": "page_exploration_goto_bondling_fairyland.png",
-    "roiFront": "937,639,61,54",
-    "roiBack": "937,639,61,54",
+    "roiFront": "937,639,56,49",
+    "roiBack": "928,633,203,64",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "器灵"
     "description": "器灵"

+ 2 - 2
tasks/KekkaiActivation/script_task.py

@@ -317,8 +317,8 @@ class ScriptTask(KU, KekkaiActivationAssets):
         if last_best is not None:
         if last_best is not None:
             last_index = self.order_cards.index(last_best)
             last_index = self.order_cards.index(last_best)
             current_index = self.order_cards.index(current_card)
             current_index = self.order_cards.index(current_card)
-            if current_index > last_index:
-                # 不比上一张卡好就退出不执行操作
+            if current_index >= last_index:
+                # 不比上一张卡好就退出不执行操作,相同星级卡亦跳过
                 logger.info('Current card is not better than last best card')
                 logger.info('Current card is not better than last best card')
                 return last_best
                 return last_best
 
 

+ 1 - 1
tasks/KekkaiUtilize/assets.py

@@ -31,7 +31,7 @@ class KekkaiUtilizeAssets:
 	# 育成 
 	# 育成 
 	I_SHI_GROWN = RuleImage(roi_front=(595,291,35,38), roi_back=(530,254,181,198), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_grown.png")
 	I_SHI_GROWN = RuleImage(roi_front=(595,291,35,38), roi_back=(530,254,181,198), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_grown.png")
 	# 结界卡 
 	# 结界卡 
-	I_SHI_CARD = RuleImage(roi_front=(886,290,38,56), roi_back=(870,276,75,86), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_card.png")
+	I_SHI_CARD = RuleImage(roi_front=(886,290,38,56), roi_back=(870,276,75,86), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_card.png")
 	# description 
 	# description 
 	I_SHI_DEFENSE = RuleImage(roi_front=(294,298,49,56), roi_back=(215,207,208,221), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_defense.png")
 	I_SHI_DEFENSE = RuleImage(roi_front=(294,298,49,56), roi_back=(215,207,208,221), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_defense.png")
 	# 收取经验(没有满的图) 
 	# 收取经验(没有满的图) 

+ 1 - 1
tasks/KekkaiUtilize/realm/image.json

@@ -14,7 +14,7 @@
     "roiFront": "886,290,38,56",
     "roiFront": "886,290,38,56",
     "roiBack": "870,276,75,86",
     "roiBack": "870,276,75,86",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "结界卡"
     "description": "结界卡"
   },
   },
   {
   {

+ 2 - 2
tasks/KekkaiUtilize/script_task.py

@@ -365,8 +365,8 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
             if last_best is not None:
             if last_best is not None:
                 last_index = self.order_cards.index(last_best)
                 last_index = self.order_cards.index(last_best)
                 current_index = self.order_cards.index(card_class)
                 current_index = self.order_cards.index(card_class)
-                if current_index > last_index:
-                    # 不比上一张卡好就退出不执行操作
+                if current_index >= last_index:
+                    # 不比上一张卡好就退出不执行操作,相同星级卡亦跳过
                     logger.info('Current card is not better than last best card')
                     logger.info('Current card is not better than last best card')
                     return last_best
                     return last_best
             logger.info('Current select card: %s', card_class)
             logger.info('Current select card: %s', card_class)

+ 3 - 3
tasks/WeeklyTrifles/assets.py

@@ -30,7 +30,7 @@ class WeeklyTriflesAssets:
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# 进入普通召唤 
 	# 进入普通召唤 
-	I_BM_ENTER = RuleImage(roi_front=(399,601,62,68), roi_back=(399,601,62,68), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/broken_amulet/broken_amulet_bm_enter.png")
+	I_BM_ENTER = RuleImage(roi_front=(437,600,62,68), roi_back=(437,600,62,68), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/broken_amulet/broken_amulet_bm_enter.png")
 	# 确定 
 	# 确定 
 	I_BM_CONFIRM = RuleImage(roi_front=(418,620,173,59), roi_back=(418,620,173,59), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/broken_amulet/broken_amulet_bm_confirm.png")
 	I_BM_CONFIRM = RuleImage(roi_front=(418,620,173,59), roi_back=(418,620,173,59), threshold=0.8, method="Template matching", file="./tasks/WeeklyTrifles/broken_amulet/broken_amulet_bm_confirm.png")
 	# 再次召唤 
 	# 再次召唤 
@@ -39,9 +39,9 @@ class WeeklyTriflesAssets:
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
 	# 左上角的数量 
 	# 左上角的数量 
-	O_BA_AMOUNT_1 = RuleOcr(roi=(360,11,86,36), area=(360,11,86,36), mode="Digit", method="Default", keyword="", name="ba_amount_1")
+	O_BA_AMOUNT_1 = RuleOcr(roi=(535,11,124,36), area=(535,11,124,36), mode="Digit", method="Default", keyword="", name="ba_amount_1")
 	# 召唤的时候的数量 
 	# 召唤的时候的数量 
-	O_BA_AMOUNT_2 = RuleOcr(roi=(762,570,118,35), area=(762,570,118,35), mode="DigitCounter", method="Default", keyword="", name="ba_amount_2")
+	O_BA_AMOUNT_2 = RuleOcr(roi=(762,570,125,35), area=(762,570,125,35), mode="DigitCounter", method="Default", keyword="", name="ba_amount_2")
 
 
 
 
 	# Click Rule Assets
 	# Click Rule Assets

BIN=BIN
tasks/WeeklyTrifles/broken_amulet/broken_amulet_bm_enter.png


+ 2 - 2
tasks/WeeklyTrifles/broken_amulet/image.json

@@ -2,8 +2,8 @@
   {
   {
     "itemName": "bm_enter",
     "itemName": "bm_enter",
     "imageName": "broken_amulet_bm_enter.png",
     "imageName": "broken_amulet_bm_enter.png",
-    "roiFront": "399,601,62,68",
-    "roiBack": "399,601,62,68",
+    "roiFront": "437,600,62,68",
+    "roiBack": "437,600,62,68",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "进入普通召唤"
     "description": "进入普通召唤"

+ 4 - 4
tasks/WeeklyTrifles/broken_amulet/ocr.json

@@ -1,8 +1,8 @@
 [
 [
   {
   {
     "itemName": "ba_amount_1",
     "itemName": "ba_amount_1",
-    "roiFront": "360,11,86,36",
-    "roiBack": "360,11,86,36",
+    "roiFront": "535,11,124,36",
+    "roiBack": "535,11,124,36",
     "mode": "Digit",
     "mode": "Digit",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
@@ -10,8 +10,8 @@
   },
   },
   {
   {
     "itemName": "ba_amount_2",
     "itemName": "ba_amount_2",
-    "roiFront": "762,570,118,35",
-    "roiBack": "762,570,118,35",
+    "roiFront": "762,570,125,35",
+    "roiBack": "762,570,125,35",
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",

+ 2 - 1
tasks/WeeklyTrifles/script_task.py

@@ -273,7 +273,8 @@ if __name__ == '__main__':
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
     t.screenshot()
     t.screenshot()
 
 
-    t._share_collect()
+    t.run()
+    # t._share_collect()
     # t.click_share(t.I_WT_SE_WECHAT)
     # t.click_share(t.I_WT_SE_WECHAT)
 
 
 
 

+ 3 - 0
tasks/base_task.py

@@ -114,6 +114,9 @@ class BaseTask(GlobalGameAssets, CostumeBase):
                 continue
                 continue
         # 有的时候长战斗 点击后会取消战斗状态
         # 有的时候长战斗 点击后会取消战斗状态
         self.device.detect_record = detect_record
         self.device.detect_record = detect_record
+        # 如果接受邀请则立即执行悬赏任务
+        if click_button == self.I_G_ACCEPT:
+            self.set_next_run(task='WantedQuests', target=datetime.now())
         return True
         return True
 
 
     def screenshot(self):
     def screenshot(self):