|
|
@@ -9,7 +9,7 @@ from module.base.timer import Timer
|
|
|
|
|
|
from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
|
|
|
from tasks.Exploration.base import BaseExploration, UpType, Scene
|
|
|
-from tasks.Exploration.config import ChooseRarity, AutoRotate, UserStatus, ExplorationLevel
|
|
|
+from tasks.Exploration.config import ChooseRarity, AutoRotate, UserStatus
|
|
|
|
|
|
|
|
|
class SoloExploration(BaseExploration):
|
|
|
@@ -30,18 +30,12 @@ class SoloExploration(BaseExploration):
|
|
|
default_invite=False
|
|
|
)
|
|
|
|
|
|
- def _handle_treasure_box(self, roi_back=None) -> bool:
|
|
|
- original_roi_back = self.I_TREASURE_BOX_CLICK.roi_back
|
|
|
- if roi_back is not None:
|
|
|
- self.I_TREASURE_BOX_CLICK.roi_back = roi_back
|
|
|
- try:
|
|
|
- if self.appear(self.I_TREASURE_BOX_CLICK):
|
|
|
- logger.info('Treasure box appear, get it.')
|
|
|
- self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
|
|
|
- return True
|
|
|
- return False
|
|
|
- finally:
|
|
|
- self.I_TREASURE_BOX_CLICK.roi_back = original_roi_back
|
|
|
+ def _handle_treasure_box(self) -> bool:
|
|
|
+ if self.appear(self.I_TREASURE_BOX_CLICK):
|
|
|
+ logger.info('Treasure box appear, get it.')
|
|
|
+ self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
|
|
|
+ return True
|
|
|
+ return False
|
|
|
|
|
|
def _check_mate_leave(self, friend_leave_timer: Timer):
|
|
|
if not self.appear(self.I_TEAM_EMOJI) and not self.appear(self.I_TEAM_EMOJI_FIGHT):
|
|
|
@@ -62,26 +56,9 @@ class SoloExploration(BaseExploration):
|
|
|
friend_leave_timer = Timer(self.FRIEND_LEAVE_TIMEOUT)
|
|
|
return friend_leave_timer, False
|
|
|
|
|
|
- # TODO: BaseTask.swipe() 无返回值,避免扩大影响面新起临时函数
|
|
|
- # 后续 swipe 加返回值后弃用
|
|
|
- def _swipe_background_right(self, interval: float) -> bool:
|
|
|
- swipe = self.S_SWIPE_BACKGROUND_RIGHT
|
|
|
- if swipe.name in self.interval_timer:
|
|
|
- if self.interval_timer[swipe.name].limit != interval:
|
|
|
- self.interval_timer[swipe.name] = Timer(interval)
|
|
|
- else:
|
|
|
- self.interval_timer[swipe.name] = Timer(interval)
|
|
|
- if not self.interval_timer[swipe.name].reached():
|
|
|
- return False
|
|
|
-
|
|
|
- self.swipe(swipe)
|
|
|
- self.interval_timer[swipe.name].reset()
|
|
|
- return True
|
|
|
-
|
|
|
def run_solo(self):
|
|
|
logger.hr('solo')
|
|
|
- search_fail_cnt = 0
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
+ search_fail_timer = Timer(3.2) # 这里设置的时间一定要大于S_SWIPE_BACKGROUND_RIGHT滑动的时间
|
|
|
|
|
|
while 1:
|
|
|
self.screenshot()
|
|
|
@@ -89,21 +66,15 @@ class SoloExploration(BaseExploration):
|
|
|
logger.info(f'[run_solo] Current scene: {scene.name}') # TODO 2026.06.22 之后删掉这个刷屏的
|
|
|
#
|
|
|
if scene == Scene.WORLD:
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
# 打开右边箭头
|
|
|
if not self.wait_world_stable():
|
|
|
continue
|
|
|
- # if self.appear(self.I_TREASURE_BOX_CLICK):
|
|
|
- # # 宝箱
|
|
|
- # logger.info('Treasure box appear, get it.')
|
|
|
- # self.ui_click_until_disappear(self.I_TREASURE_BOX_CLICK)
|
|
|
if self.check_exit():
|
|
|
break
|
|
|
self.open_expect_level()
|
|
|
continue
|
|
|
#
|
|
|
elif scene == Scene.ENTRANCE:
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
if self.check_exit():
|
|
|
break
|
|
|
self.ui_click(self.I_E_EXPLORATION_CLICK, stop=self.I_E_SETTINGS_BUTTON)
|
|
|
@@ -125,40 +96,24 @@ class SoloExploration(BaseExploration):
|
|
|
# boss
|
|
|
if self.appear(self.I_BOSS_BATTLE_BUTTON):
|
|
|
if self.fire(self.I_BOSS_BATTLE_BUTTON):
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
logger.info(f'Boss battle, minions cnt {self.minions_cnt}')
|
|
|
continue
|
|
|
# 小怪
|
|
|
fight_button = self.search_up_fight()
|
|
|
if fight_button is not None:
|
|
|
if self.fire(fight_button):
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
logger.info(f'Fight, minions cnt {self.minions_cnt}')
|
|
|
continue
|
|
|
# 向后拉,寻找怪
|
|
|
- if search_fail_cnt >= 4:
|
|
|
- search_fail_cnt = 0
|
|
|
- # I_SWIPE_END 是第 28 章的末尾标识,其他章节不要用它判断退出。
|
|
|
- if (
|
|
|
- self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28
|
|
|
- and self.appear(self.I_SWIPE_END)
|
|
|
- ):
|
|
|
+ if search_fail_timer.reached():
|
|
|
+ search_fail_timer.reset()
|
|
|
+ if self._match_end.stable(self.device.image, refresh_after_stable=True):
|
|
|
self.quit_explore()
|
|
|
continue
|
|
|
- before_image = self.device.image.copy()
|
|
|
- if self._swipe_background_right(interval=3):
|
|
|
- self.screenshot()
|
|
|
- # 单次画面没变化可能是偶发,连续两次滑不动才认为到尽头。
|
|
|
- if self.is_swipe_unchanged(before_image, self.device.image):
|
|
|
- swipe_unchanged_cnt += 1
|
|
|
- else:
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
- if swipe_unchanged_cnt >= 2:
|
|
|
- logger.info('Swipe unchanged twice, quit exploration')
|
|
|
- self.quit_explore()
|
|
|
- continue
|
|
|
- else:
|
|
|
- search_fail_cnt += 1
|
|
|
+ self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3)
|
|
|
+ continue
|
|
|
+ if not search_fail_timer.started():
|
|
|
+ search_fail_timer.start()
|
|
|
#
|
|
|
elif scene == Scene.BATTLE_PREPARE or scene == Scene.BATTLE_FIGHTING:
|
|
|
self.check_take_over_battle(is_screenshot=False, config=self._config.general_battle_config)
|
|
|
@@ -167,8 +122,7 @@ class SoloExploration(BaseExploration):
|
|
|
|
|
|
def run_leader(self):
|
|
|
logger.hr('leader')
|
|
|
- search_fail_cnt = 0
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
+ search_fail_timer = Timer(3.2) # 这里设置的时间一定要大于S_SWIPE_BACKGROUND_RIGHT滑动的时间
|
|
|
friend_leave_timer = Timer(self.FRIEND_LEAVE_TIMEOUT)
|
|
|
|
|
|
while 1:
|
|
|
@@ -177,7 +131,6 @@ class SoloExploration(BaseExploration):
|
|
|
logger.info(f'[run_leader] Current scene: {scene.name}') # TODO 2026.06.22 之后删掉这个刷屏的
|
|
|
# 探索大世界
|
|
|
if scene == Scene.WORLD:
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
# 打开右边箭头
|
|
|
if not self.wait_world_stable():
|
|
|
continue
|
|
|
@@ -196,7 +149,6 @@ class SoloExploration(BaseExploration):
|
|
|
|
|
|
# 邀请好友, 非常有可能是后面邀请好友,然后直接跳到组队了
|
|
|
elif scene == Scene.ENTRANCE:
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
while 1:
|
|
|
self.screenshot()
|
|
|
if self.is_in_room():
|
|
|
@@ -256,40 +208,24 @@ class SoloExploration(BaseExploration):
|
|
|
# boss
|
|
|
if self.appear(self.I_BOSS_BATTLE_BUTTON):
|
|
|
if self.fire(self.I_BOSS_BATTLE_BUTTON):
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
logger.info(f'Boss battle, minions cnt {self.minions_cnt}')
|
|
|
continue
|
|
|
# 小怪
|
|
|
fight_button = self.search_up_fight()
|
|
|
if fight_button is not None:
|
|
|
if self.fire(fight_button):
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
logger.info(f'Fight, minions cnt {self.minions_cnt}')
|
|
|
continue
|
|
|
# 向后拉,寻找怪
|
|
|
- if search_fail_cnt >= 4:
|
|
|
- search_fail_cnt = 0
|
|
|
- # I_SWIPE_END 是第 28 章的末尾标识,其他章节不要用它判断退出。
|
|
|
- if (
|
|
|
- self._config.exploration_config.exploration_level == ExplorationLevel.EXPLORATION_28
|
|
|
- and self.appear(self.I_SWIPE_END)
|
|
|
- ):
|
|
|
+ if search_fail_timer.reached():
|
|
|
+ search_fail_timer.reset()
|
|
|
+ if self._match_end.stable(self.device.image, refresh_after_stable=True):
|
|
|
self.quit_explore()
|
|
|
continue
|
|
|
- before_image = self.device.image.copy()
|
|
|
- if self._swipe_background_right(interval=3):
|
|
|
- self.screenshot()
|
|
|
- # 单次画面没变化可能是偶发,连续两次滑不动才认为到尽头。
|
|
|
- if self.is_swipe_unchanged(before_image, self.device.image):
|
|
|
- swipe_unchanged_cnt += 1
|
|
|
- else:
|
|
|
- swipe_unchanged_cnt = 0
|
|
|
- if swipe_unchanged_cnt >= 2:
|
|
|
- logger.info('Swipe unchanged twice, quit exploration')
|
|
|
- self.quit_explore()
|
|
|
- continue
|
|
|
- else:
|
|
|
- search_fail_cnt += 1
|
|
|
+ self.swipe(self.S_SWIPE_BACKGROUND_RIGHT, interval=3)
|
|
|
+ continue
|
|
|
+ if not search_fail_timer.started():
|
|
|
+ search_fail_timer.start()
|
|
|
#
|
|
|
elif scene == Scene.BATTLE_PREPARE or scene == Scene.BATTLE_FIGHTING:
|
|
|
self.check_take_over_battle(is_screenshot=False, config=self._config.general_battle_config)
|
|
|
@@ -314,7 +250,7 @@ class SoloExploration(BaseExploration):
|
|
|
break
|
|
|
if self.check_then_accept():
|
|
|
# 接受邀请后清掉计时器
|
|
|
- wait_timer = Timer(50)
|
|
|
+ wait_timer.reset()
|
|
|
continue
|
|
|
if wait_timer.started() and wait_timer.reached():
|
|
|
logger.warning('Wait timer reached')
|