Răsfoiți Sursa

Merge pull request #813 from runhey/dev

Automated PR 2025.04.03
huangrunheng 1 an în urmă
părinte
comite
0fa89df343

+ 1 - 1
module/atom/image.py

@@ -74,7 +74,7 @@ class RuleImage:
         if height != self.roi_front[3] or width != self.roi_front[2]:
         if height != self.roi_front[3] or width != self.roi_front[2]:
             self.roi_front[2] = width
             self.roi_front[2] = width
             self.roi_front[3] = height
             self.roi_front[3] = height
-            logger.info(f"{self.name} roi_front size changed to {width}x{height}")
+            logger.debug(f"{self.name} roi_front size changed to {width}x{height}")
 
 
     def load_kp_des(self) -> None:
     def load_kp_des(self) -> None:
         if self._kp is not None and self._des is not None:
         if self._kp is not None and self._des is not None:

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


+ 1 - 1
tasks/DailyTrifles/assets.py

@@ -33,7 +33,7 @@ class DailyTriflesAssets:
 	# 礼包屋 
 	# 礼包屋 
 	I_ROOM_GIFT = RuleImage(roi_front=(1152,644,52,53), roi_back=(1127,611,103,94), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_room_gift.png")
 	I_ROOM_GIFT = RuleImage(roi_front=(1152,644,52,53), roi_back=(1127,611,103,94), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_room_gift.png")
 	# description 
 	# description 
-	I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
+	I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.7, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
 	# 免费一抽 
 	# 免费一抽 
 	I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
 	I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
 	# 体力 
 	# 体力 

+ 1 - 1
tasks/DailyTrifles/store/image.json

@@ -14,7 +14,7 @@
     "roiFront": "1186,98,53,64",
     "roiFront": "1186,98,53,64",
     "roiBack": "1172,83,83,306",
     "roiBack": "1172,83,83,306",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "description"
     "description": "description"
   },
   },
   {
   {

+ 6 - 0
tasks/Dokan/config.py

@@ -144,6 +144,12 @@ class DokanConfig(BaseModel):
     # 道馆系数,赏金/人数 根据喜好配置
     # 道馆系数,赏金/人数 根据喜好配置
     find_dokan_score: float = Field(default=4.6, description='dokan_score_help')
     find_dokan_score: float = Field(default=4.6, description='dokan_score_help')
 
 
+    # 道馆最小人数限制
+    min_people_num: int = Field(default=-1, description='min_people_num_help')
+
+    # 最少赏金设置
+    min_bounty: int = Field(default=0, description='min_bounty_help')
+
     # 单次查找道馆时,最大刷新次数.超过此次数后,若还未找到符合要求的,会随机选择一个道馆
     # 单次查找道馆时,最大刷新次数.超过此次数后,若还未找到符合要求的,会随机选择一个道馆
     find_dokan_refresh_count: int = Field(default=7, description='find_dokan_refresh_count_help')
     find_dokan_refresh_count: int = Field(default=7, description='find_dokan_refresh_count_help')
 
 

+ 27 - 27
tasks/Dokan/script_task.py

@@ -90,9 +90,7 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
         out_dokan_timer = Timer(60)
         out_dokan_timer = Timer(60)
         if not in_dokan:
         if not in_dokan:
             out_dokan_timer.start()
             out_dokan_timer.start()
-            if not self.goto_dokan_map():
-                logger.warning("dokan didn`t started")
-                is_dokan_activated = False
+            self.goto_dokan_scene()
 
 
         # 是否已击败馆主第一阵容
         # 是否已击败馆主第一阵容
         first_master_killed = False
         first_master_killed = False
@@ -130,15 +128,22 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
 
 
             # 场景状态:寻找合适道馆中
             # 场景状态:寻找合适道馆中
             if current_scene == DokanScene.RYOU_DOKAN_SCENE_FINDING_DOKAN:
             if current_scene == DokanScene.RYOU_DOKAN_SCENE_FINDING_DOKAN:
-                # NOTE 只在周一尝试建立道馆
-                if datetime.now().weekday() == 0:
-                    self.creat_dokan()
 
 
                 # 更新可挑战次数 可挑战次数为<=0,当作道馆成功完成
                 # 更新可挑战次数 可挑战次数为<=0,当作道馆成功完成
                 count = self.update_remain_attack_count()
                 count = self.update_remain_attack_count()
                 if count <= 0:
                 if count <= 0:
                     is_dokan_activated = True
                     is_dokan_activated = True
                     break
                     break
+
+                # 如果没有权限,道馆还未开启
+                try_start_dokan = self.config.dokan.dokan_config.try_start_dokan
+                if not try_start_dokan:
+                    is_dokan_activated = False
+                    break
+                # NOTE 只在周一尝试建立道馆
+                if datetime.now().weekday() == 0:
+                    self.creat_dokan()
+
                 # 寻找合适道馆,找不到直接退出
                 # 寻找合适道馆,找不到直接退出
                 if not self.find_dokan(self.config.dokan.dokan_config.find_dokan_score):
                 if not self.find_dokan(self.config.dokan.dokan_config.find_dokan_score):
                     is_dokan_activated = False
                     is_dokan_activated = False
@@ -191,6 +196,7 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
                 continue
                 continue
             # 场景状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
             # 场景状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
             if current_scene == DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE:
             if current_scene == DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE:
+                self.switch_soul_in_dokan()
                 self.click(self.I_RYOU_DOKAN_START_CHALLENGE, interval=1)
                 self.click(self.I_RYOU_DOKAN_START_CHALLENGE, interval=1)
                 continue
                 continue
             # 场景状态:馆主第一阵容 且战斗未开始
             # 场景状态:馆主第一阵容 且战斗未开始
@@ -511,30 +517,15 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
                 self.click(self.I_BACK_Y, interval=3)
                 self.click(self.I_BACK_Y, interval=3)
                 continue
                 continue
 
 
-    def goto_dokan_map(self):
-        """
-            任意场景进入道馆地图
-            # 有权限开启道馆 - 通过神社进入道馆地图
-            # 没有权限开启道馆 - 判断阴阳寮界面左侧的已开启活动列表是否存在道馆
-        """
-        try_start_dokan = self.config.dokan.dokan_config.try_start_dokan
+    def goto_dokan_scene(self):
+        # 截图速度太快会导致在道馆-神社之间一直循环无法退出,故设置截图间隔
+        self.device.screenshot_interval_set(0.3)
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             in_dokan, cur_scene = self.get_current_scene()
             in_dokan, cur_scene = self.get_current_scene()
             if in_dokan:
             if in_dokan:
-                return True
+                break
             if cur_scene == DokanScene.RYOU_DOKAN_RYOU:
             if cur_scene == DokanScene.RYOU_DOKAN_RYOU:
-                if not try_start_dokan:
-                    # 等待左侧活动列表弹出
-                    self.wait_until_stable(self.I_RYOU_DOKAN_ACTIVATED, Timer(0.5, 2), Timer(5, 10))
-
-                    # 尝试通过已开启活动列表中查找道馆
-                    if self.appear(self.I_RYOU_DOKAN_ACTIVATED):
-                        self.ui_click_until_disappear(self.I_RYOU_DOKAN_ACTIVATED)
-                        return True
-                    # 在已开启活动列表中 没有找到道馆
-                    logger.error(f"can not find dokan in activated list,FAILED")
-                    return False
                 self.ui_click_until_disappear(self.I_RYOU_SHENSHE)
                 self.ui_click_until_disappear(self.I_RYOU_SHENSHE)
                 continue
                 continue
             if cur_scene == DokanScene.RYOU_DOKAN_SHENSHE:
             if cur_scene == DokanScene.RYOU_DOKAN_SHENSHE:
@@ -544,6 +535,8 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
                 self.ui_get_current_page()
                 self.ui_get_current_page()
                 self.ui_goto(page_guild)
                 self.ui_goto(page_guild)
                 continue
                 continue
+        self.device.screenshot_interval_set()
+        return True
 
 
     def enter_dokan(self):
     def enter_dokan(self):
         """
         """
@@ -671,6 +664,12 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
                 if item_score > score or item_score < 1.5:
                 if item_score > score or item_score < 1.5:
                     logger.info("click to making challenge disappear")
                     logger.info("click to making challenge disappear")
                     continue
                     continue
+                if p_num < self.config.dokan.dokan_config.min_people_num:
+                    logger.info("people num too small")
+                    continue
+                if bounty < self.config.dokan.dokan_config.min_bounty:
+                    logger.info("bounty too small")
+                    continue
                 # 馆主不是修习等级的
                 # 馆主不是修习等级的
                 if not self.appear(self.I_CENTER_GUANZHU_XIUXI):
                 if not self.appear(self.I_CENTER_GUANZHU_XIUXI):
                     continue
                     continue
@@ -889,13 +888,14 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
         # 道馆没有开启
         # 道馆没有开启
         now = datetime.now()
         now = datetime.now()
         ser_time: Time = self.config.dokan.scheduler.server_update
         ser_time: Time = self.config.dokan.scheduler.server_update
+        ser_time = datetime.combine(now.date(), ser_time)
         if not is_dokan_activated:
         if not is_dokan_activated:
             # 在服务器时间之前,设置为服务器时间
             # 在服务器时间之前,设置为服务器时间
-            if now.hour < ser_time.hour or (now.hour == ser_time.hour and now.minute < ser_time.minute):
+            if now < ser_time:
                 self.set_next_run(task="Dokan", target=now.replace(hour=ser_time.hour, minute=ser_time.minute))
                 self.set_next_run(task="Dokan", target=now.replace(hour=ser_time.hour, minute=ser_time.minute))
                 return
                 return
             # 在服务器时间之后,如超过两小时,则直接当作成功;未超过则当作失败
             # 在服务器时间之后,如超过两小时,则直接当作成功;未超过则当作失败
-            if now.hour - ser_time.hour > 2:
+            if now - ser_time > timedelta(hours=2):
                 self.set_next_run(task="Dokan", finish=False, success=True, server=True)
                 self.set_next_run(task="Dokan", finish=False, success=True, server=True)
                 return
                 return
             # 时间在道馆开启时间附近,3分钟后执行
             # 时间在道馆开启时间附近,3分钟后执行

+ 1 - 1
tasks/RichMan/assets.py

@@ -267,7 +267,7 @@ class RichManAssets:
 
 
 	# Ocr Rule Assets
 	# Ocr Rule Assets
 	# 蛇皮剩余可买的 
 	# 蛇皮剩余可买的 
-	O_SCA_NUMBER_OROCHI = RuleOcr(roi=(46,318,27,25), area=(46,318,27,25), mode="Quantity", method="Default", keyword="", name="sca_number_orochi")
+	O_SCA_NUMBER_OROCHI = RuleOcr(roi=(46,318,30,25), area=(46,318,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_orochi")
 	# 首领御魂剩余可买的 
 	# 首领御魂剩余可买的 
 	O_SCA_NUMBER_DEMON = RuleOcr(roi=(627,319,30,25), area=(627,319,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_demon")
 	O_SCA_NUMBER_DEMON = RuleOcr(roi=(627,319,30,25), area=(627,319,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_demon")
 	# 永生之海 
 	# 永生之海 

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

@@ -1,8 +1,8 @@
 [
 [
   {
   {
     "itemName": "sca_number_orochi",
     "itemName": "sca_number_orochi",
-    "roiFront": "46,318,27,25",
-    "roiBack": "46,318,27,25",
+    "roiFront": "46,318,30,25",
+    "roiBack": "46,318,30,25",
     "mode": "Quantity",
     "mode": "Quantity",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",

+ 8 - 3
tasks/Secret/script_task.py

@@ -20,6 +20,7 @@ from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.Component.GeneralBuff.config_buff import BuffClass
 from tasks.Component.GeneralBuff.config_buff import BuffClass
 from tasks.WeeklyTrifles.assets import WeeklyTriflesAssets
 from tasks.WeeklyTrifles.assets import WeeklyTriflesAssets
 
 
+
 class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
 class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
     lay_list = ['壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾']
     lay_list = ['壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾']
 
 
@@ -35,7 +36,9 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
 
 
     @cached_property
     @cached_property
     def battle_config(self) -> GeneralBattleConfig:
     def battle_config(self) -> GeneralBattleConfig:
-        return GeneralBattleConfig()
+        conf = self.config.model.secret.general_battle
+        conf.lock_team_enable = False
+        return conf
 
 
     def run(self):
     def run(self):
         self.check_time()
         self.check_time()
@@ -134,14 +137,16 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
         self.set_next_run(task='Secret', success=True, finish=True)
         self.set_next_run(task='Secret', success=True, finish=True)
         raise TaskEnd('Secret')
         raise TaskEnd('Secret')
 
 
-    def find_battle(self, screenshot: bool=False) -> int or None:
+    def find_battle(self, screenshot: bool = False) -> int or None:
         """
         """
         自动寻找挑战的层数并且选定 , 找不到会向下划一点
         自动寻找挑战的层数并且选定 , 找不到会向下划一点
         :return: 如果找得到返回层数,找不到返回None
         :return: 如果找得到返回层数,找不到返回None
         """
         """
+
         def set_layer_roi(ocr_target: RuleOcr, roi: tuple):
         def set_layer_roi(ocr_target: RuleOcr, roi: tuple):
             ocr_target.roi[0] = int(roi[0]) - 225
             ocr_target.roi[0] = int(roi[0]) - 225
             ocr_target.roi[1] = int(roi[1]) - 40
             ocr_target.roi[1] = int(roi[1]) - 40
+
         def check_layer(ocr_target: RuleOcr, roi=None) -> int or None:
         def check_layer(ocr_target: RuleOcr, roi=None) -> int or None:
             #
             #
             # 手动留了一个bug: 即使匹配到了未通关 但是在判断层数的时候还是会先判断第一个是什么的
             # 手动留了一个bug: 即使匹配到了未通关 但是在判断层数的时候还是会先判断第一个是什么的
@@ -199,7 +204,6 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
                 logger.warning(f'OCR failed, try again {jade_num}')
                 logger.warning(f'OCR failed, try again {jade_num}')
                 return None
                 return None
 
 
-
         if screenshot:
         if screenshot:
             self.screenshot()
             self.screenshot()
         if self.appear(self.I_CHAT_CLOSE_BUTTON):
         if self.appear(self.I_CHAT_CLOSE_BUTTON):
@@ -286,6 +290,7 @@ class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
 if __name__ == '__main__':
 if __name__ == '__main__':
     from module.config.config import Config
     from module.config.config import Config
     from module.device.device import Device
     from module.device.device import Device
+
     c = Config('oas1')
     c = Config('oas1')
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)

+ 2 - 2
tasks/SoulsTidy/assets.py

@@ -12,7 +12,7 @@ class SoulsTidyAssets:
 
 
 	# Click Rule Assets
 	# Click Rule Assets
 	# 御魂详细 
 	# 御魂详细 
-	C_ST_DETAIL = RuleClick(roi_front=(1189,321,87,74), roi_back=(1189,321,87,74), name="st_detail")
+	C_ST_DETAIL = RuleClick(roi_front=(1188,318,87,74), roi_back=(1190,317,87,74), name="st_detail")
 	# 出现神赐 
 	# 出现神赐 
 	C_ST_GOD_PRSENT = RuleClick(roi_front=(717,165,100,48), roi_back=(926,165,100,54), name="st_god_prsent")
 	C_ST_GOD_PRSENT = RuleClick(roi_front=(717,165,100,48), roi_back=(926,165,100,54), name="st_god_prsent")
 
 
@@ -43,7 +43,7 @@ class SoulsTidyAssets:
 	# 神赐 
 	# 神赐 
 	I_ST_GOD_PRESENT = RuleImage(roi_front=(578,234,131,73), roi_back=(542,117,204,219), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_god_present.png")
 	I_ST_GOD_PRESENT = RuleImage(roi_front=(578,234,131,73), roi_back=(542,117,204,219), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_god_present.png")
 	# 已弃置被选中 
 	# 已弃置被选中 
-	I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(20,110,140,50), roi_back=(20,110,140,50), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
+	I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(47,118,84,33), roi_back=(45,119,85,34), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
 	# 第一个御魂是+0的 
 	# 第一个御魂是+0的 
 	I_ST_LEVEL_0 = RuleImage(roi_front=(85,235,45,30), roi_back=(85,235,45,30), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_level_0.png")
 	I_ST_LEVEL_0 = RuleImage(roi_front=(85,235,45,30), roi_back=(85,235,45,30), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_level_0.png")
 	# 御魂奉纳后获得的金币 
 	# 御魂奉纳后获得的金币 

+ 5 - 7
tasks/SoulsTidy/script_task.py

@@ -99,11 +99,9 @@ class ScriptTask(GameUi, SoulsTidyAssets):
                 continue
                 continue
         logger.hr('Enter bongna')
         logger.hr('Enter bongna')
         # 进入已弃置界面
         # 进入已弃置界面
-        while True:
-            if not self.appear(self.I_ST_ABANDONED_SELECTED):
-                self.click(self.I_ST_ABANDONED_SELECTED, interval=2)
-                continue
-            break
+        """
+        现在默认进入就是已弃置界面,所以不需要点击
+        """
         # 确保是按照等级来排序的
         # 确保是按照等级来排序的
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
@@ -181,5 +179,5 @@ if __name__ == '__main__':
     d = Device(c)
     d = Device(c)
     t = ScriptTask(c, d)
     t = ScriptTask(c, d)
 
 
-    t.greed_maneki()
-    # t.run()
+    #t.greed_maneki()
+    t.run()

+ 2 - 2
tasks/SoulsTidy/simple/click.json

@@ -1,8 +1,8 @@
 [
 [
   {
   {
     "itemName": "st_detail",
     "itemName": "st_detail",
-    "roiFront": "1189,321,87,74",
-    "roiBack": "1189,321,87,74",
+    "roiFront": "1188,318,87,74",
+    "roiBack": "1190,317,87,74",
     "description": "御魂详细"
     "description": "御魂详细"
   },
   },
   {
   {

+ 2 - 2
tasks/SoulsTidy/simple/image.json

@@ -110,8 +110,8 @@
   {
   {
     "itemName": "st_abandoned_selected",
     "itemName": "st_abandoned_selected",
     "imageName": "simple_st_abandoned_selected.png",
     "imageName": "simple_st_abandoned_selected.png",
-    "roiFront": "20,110,140,50",
-    "roiBack": "20,110,140,50",
+    "roiFront": "47,118,84,33",
+    "roiBack": "45,119,85,34",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "已弃置被选中"
     "description": "已弃置被选中"

BIN
tasks/SoulsTidy/simple/simple_st_abandoned_selected.png


BIN
tasks/SoulsTidy/simple/simple_st_souls.png