Procházet zdrojové kódy

Merge branch 'feat1' of https://github.com/ohspecial/OnmyojiAutoScript into fix

jack před 2 roky
rodič
revize
7242909106

+ 7 - 0
module/device/env.py

@@ -0,0 +1,7 @@
+# This Python file uses the following encoding: utf-8
+# https://github.com/LmeSzinc/StarRailCopilot/blob/master/module/device/env.py
+import sys
+
+IS_WINDOWS = sys.platform == 'win32'
+IS_MACINTOSH = sys.platform == 'darwin'
+IS_LINUX = sys.platform == 'linux'

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

@@ -75,14 +75,6 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
             if self.timer_wait.reached():
                 logger.warning('Wait timeout')
                 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):
                 logger.warning('Timeout, now is no room')
                 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_2)
 
-
             fire = False  # 是否开启挑战
             # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
             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()
                 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:
         """
         确认是否进入了组队界面

+ 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:
                 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.swipe(self.S_SWIPE_LEVEL_UP)
             swipeCount += 1
@@ -144,11 +148,17 @@ class BaseExploration(GeneralBattle, GeneralRoom, GeneralInvite, ReplaceShikigam
         # 选中对应章节
         while 1:
             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
             if self.ocr_appear_click(self.O_E_EXPLORATION_LEVEL_NUMBER):
                 self.wait_until_appear(self.I_E_EXPLORATION_CLICK, wait_time=3)
             if self.appear(self.I_E_EXPLORATION_CLICK):
                 break
+            if self.is_in_room():
+                break
 
         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):
                 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__":
     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):
                     self.ui_click_until_disappear(self.I_FIRE, interval=1)
                     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:
                     logger.warning('Invite failed, quit')
                     while 1:
@@ -451,7 +452,6 @@ class ScriptTask(SoloExploration):
             case UserStatus.MEMBER: self.run_member()
             case _: self.run_solo()
 
-
         self.post_process()
 
 

+ 1 - 1
tasks/GameUi/assets.py

@@ -63,7 +63,7 @@ class GameUiAssets:
 	# description 
 	I_CHECK_SOUL_ZONES = RuleImage(roi_front=(49,105,298,405), roi_back=(49,105,298,405), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_soul_zones.png")
 	# description 
-	I_CHECK_REALM_RAID = RuleImage(roi_front=(507,72,261,46), roi_back=(507,72,261,46), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_realm_raid.png")
+	I_CHECK_REALM_RAID = RuleImage(roi_front=(113,625,86,77), roi_back=(113,625,86,77), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_realm_raid.png")
 	# description 
 	I_CHECK_GORYOU = RuleImage(roi_front=(881,17,30,39), roi_back=(881,17,30,39), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_goryou.png")
 	# description 

binární
tasks/GameUi/page/page_check_realm_raid.png


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

@@ -146,8 +146,8 @@
   {
     "itemName": "check_realm_raid",
     "imageName": "page_check_realm_raid.png",
-    "roiFront": "507,72,261,46",
-    "roiBack": "507,72,261,46",
+    "roiFront": "113,625,86,77",
+    "roiBack": "113,625,86,77",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"

binární
tasks/GameUi/page/page_ryoutoppa_goto_realmraid.png


+ 3 - 1
tasks/KekkaiUtilize/assets.py

@@ -115,8 +115,10 @@ class KekkaiUtilizeAssets:
 	# Ocr Rule Assets
 	# 这个寄养的剩余时间 
 	O_UTILIZE_RES_TIME = RuleOcr(roi=(1140,117,100,30), area=(1140,117,100,30), mode="Duration", method="Default", keyword="", name="utilize_res_time")
-	# 今日以领取经验 
+	# 今日已领取经验 
 	O_BOX_EXP = RuleOcr(roi=(654,538,179,39), area=(654,538,179,39), mode="DigitCounter", method="Default", keyword="", name="box_exp")
+	# 今日已领取经验(招财上宾) 
+	O_BOX_EXP_ZCSB = RuleOcr(roi=(584,542,181,35), area=(584,542,181,35), mode="DigitCounter", method="Default", keyword="", name="box_exp_zcsb")
 
 
 	# Swipe Rule Assets

+ 6 - 3
tasks/KekkaiUtilize/script_task.py

@@ -202,9 +202,12 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
                 if self.appear(self.I_EXP_EXTRACT):
                     # 如果达到今日领取的最大,就不领取了
                     cur, res, totol = self.O_BOX_EXP.ocr(self.device.image)
-                    if cur == res == totol == 0:
-                        continue
-                    if cur == totol and cur + res == totol:
+                    if cur != 0 and totol != 0 and cur == totol and cur + res == totol:
+                        logger.info('Exp box reach max do not collect')
+                        break
+                    # 开启招财上宾后,上限增加20%,数值位置有偏移
+                    cur, res, totol = self.O_BOX_EXP_ZCSB.ocr(self.device.image)
+                    if cur != 0 and totol != 0 and cur == totol * 1.2 and cur + res == totol:
                         logger.info('Exp box reach max do not collect')
                         break
                 if self.appear_then_click(self.I_BOX_EXP, threshold=0.6, interval=1):

+ 10 - 1
tasks/KekkaiUtilize/utilize/ocr.json

@@ -15,6 +15,15 @@
     "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",
-    "description": "今日以领取经验"
+    "description": "今日已领取经验"
+  },
+  {
+    "itemName": "box_exp_zcsb",
+    "roiFront": "584,542,181,35",
+    "roiBack": "584,542,181,35",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "今日已领取经验(招财上宾)"
   }
 ]

+ 3 - 1
tasks/RyouToppa/script_task.py

@@ -101,6 +101,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
         self.ui_goto(page_kekkai_toppa)
         ryou_toppa_start_flag = True
         ryou_toppa_success_penetration = False
+        ryou_toppa_admin_flag = False
         # 点击突破
         while 1:
             self.screenshot()
@@ -117,6 +118,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
             # 出现选择寮突说明寮突未开
             elif self.appear(self.I_SELECT_RYOU_BUTTON, threshold=0.8):
                 ryou_toppa_start_flag = False
+                ryou_toppa_admin_flag = True
                 break
             # 出现晴明说明寮突未开
             elif self.appear(self.I_NO_SELECT_RYOU, threshold=0.8):
@@ -131,7 +133,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RyouToppaAssets):
         logger.attr('ryou_toppa_success_penetration', ryou_toppa_success_penetration)
         # 寮突未开 并且有权限, 开开寮突,没有权限则标记失败
         if not ryou_toppa_start_flag:
-            if ryou_config.raid_config.ryou_access:
+            if ryou_config.raid_config.ryou_access and ryou_toppa_admin_flag:
                 # 作为寮管理,开启今天的寮突
                 logger.info("As the manager of the ryou, try to start ryou toppa.")
                 self.start_ryou_toppa()

+ 2 - 0
tasks/SoulsTidy/assets.py

@@ -64,5 +64,7 @@ class SoulsTidyAssets:
 	O_ST_SORT_TYPE = RuleOcr(roi=(414,118,64,43), area=(414,118,64,43), mode="Single", method="Default", keyword="类型", name="st_sort_type")
 	# 位置 
 	O_ST_SORT_LOCATION = RuleOcr(roi=(415,119,61,39), area=(415,119,61,39), mode="Single", method="Default", keyword="位置", name="st_sort_location")
+	# Ocr-description 
+	O_ST_OVERFLOW = RuleOcr(roi=(686,397,109,48), area=(686,397,109,48), mode="Single", method="Default", keyword="知道了", name="st_overflow")
 
 

+ 2 - 0
tasks/SoulsTidy/script_task.py

@@ -43,6 +43,8 @@ class ScriptTask(GameUi, SoulsTidyAssets):
                 continue
             if self.click(self.C_ST_DETAIL, interval=1.5):
                 continue
+        # 御魂超过上限的提示
+        self.ocr_appear_click(self.O_ST_OVERFLOW)
         logger.info('Enter souls page')
 
     def back_records(self):

+ 9 - 0
tasks/SoulsTidy/simple/ocr.json

@@ -61,5 +61,14 @@
     "method": "Default",
     "keyword": "位置",
     "description": "位置"
+  },
+  {
+    "itemName": "st_overflow",
+    "roiFront": "686,397,109,48",
+    "roiBack": "686,397,109,48",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "知道了",
+    "description": "Ocr-description"
   }
 ]

+ 3 - 3
tasks/WeeklyTrifles/assets.py

@@ -30,7 +30,7 @@ class WeeklyTriflesAssets:
 
 	# 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")
 	# 再次召唤 
@@ -39,9 +39,9 @@ class WeeklyTriflesAssets:
 
 	# 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

binární
tasks/WeeklyTrifles/broken_amulet/broken_amulet_bm_enter.png


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

@@ -2,8 +2,8 @@
   {
     "itemName": "bm_enter",
     "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",
     "threshold": 0.8,
     "description": "进入普通召唤"

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

@@ -1,8 +1,8 @@
 [
   {
     "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",
     "method": "Default",
     "keyword": "",
@@ -10,8 +10,8 @@
   },
   {
     "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",
     "method": "Default",
     "keyword": "",

+ 2 - 1
tasks/WeeklyTrifles/script_task.py

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

+ 3 - 0
tasks/base_task.py

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