Explorar el Código

1. 当道馆时间相关bug
2. 缩小绿标图片,提高检测成功率
3. 修正道馆开启相关检测逻辑
4. 增加开启道馆时,人数及赏金限制

ChengRanORZ hace 1 año
padre
commit
59b8d2a555

+ 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


+ 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')
 
 

+ 20 - 24
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_map()
 
 
         # 是否已击败馆主第一阵容
         # 是否已击败馆主第一阵容
         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
             # 场景状态:馆主第一阵容 且战斗未开始
             # 场景状态:馆主第一阵容 且战斗未开始
@@ -512,29 +518,12 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
                 continue
                 continue
 
 
     def goto_dokan_map(self):
     def goto_dokan_map(self):
-        """
-            任意场景进入道馆地图
-            # 有权限开启道馆 - 通过神社进入道馆地图
-            # 没有权限开启道馆 - 判断阴阳寮界面左侧的已开启活动列表是否存在道馆
-        """
-        try_start_dokan = self.config.dokan.dokan_config.try_start_dokan
         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
                 return True
             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:
@@ -671,6 +660,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
@@ -895,7 +890,8 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
                 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:
+            now_time = now.time()
+            if now_time - 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分钟后执行