mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-26 18:20:42 +00:00
Fix: Re-check all timeout timer
- Fix tactical class get stuck when skill level reach to max.
This commit is contained in:
parent
9353ae1707
commit
30e11c6caf
@ -96,6 +96,9 @@ class Timer:
|
||||
def start(self):
|
||||
if not self.started():
|
||||
self._current = time.time()
|
||||
self._reach_count = 0
|
||||
|
||||
return self
|
||||
|
||||
def started(self):
|
||||
return bool(self._current)
|
||||
|
@ -27,11 +27,6 @@ class Equipment(InfoHandler):
|
||||
|
||||
self.device.screenshot()
|
||||
if SWIPE_CHECK.match(self.device.image):
|
||||
if swipe_timer.reached():
|
||||
import time
|
||||
from PIL import Image
|
||||
self.device.image.save(f'{int(time.time() * 1000)}.png')
|
||||
Image.fromarray(SWIPE_CHECK.image).save(f'{int(time.time() * 1000)}.png')
|
||||
continue
|
||||
|
||||
if self.appear(check_button, offset=(30, 30)) and not SWIPE_CHECK.match(self.device.image):
|
||||
|
@ -32,8 +32,7 @@ class ExerciseCombat(HpDaemon, OpponentChoose, ExerciseEquipment):
|
||||
bool: True if wins. False if quit.
|
||||
"""
|
||||
logger.info('Combat execute')
|
||||
self.low_hp_confirm_timer = Timer(self.config.LOW_HP_CONFIRM_WAIT, count=2)
|
||||
self.low_hp_confirm_timer.start()
|
||||
self.low_hp_confirm_timer = Timer(self.config.LOW_HP_CONFIRM_WAIT, count=2).start()
|
||||
show_hp_timer = Timer(5)
|
||||
success = True
|
||||
end = False
|
||||
|
@ -110,8 +110,7 @@ class InfoHandler(ModuleBase):
|
||||
|
||||
def ensure_no_story(self, skip_first_screenshot=True):
|
||||
logger.info('Ensure no story')
|
||||
story_timer = Timer(5, count=4)
|
||||
story_timer.start()
|
||||
story_timer = Timer(5, count=10).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
|
@ -9,7 +9,7 @@ class LoginHandler(Combat):
|
||||
def handle_app_login(self):
|
||||
logger.hr('App login')
|
||||
|
||||
confirm_timer = Timer(1.5, count=4)
|
||||
confirm_timer = Timer(1.5, count=4).start()
|
||||
while 1:
|
||||
self.device.screenshot()
|
||||
|
||||
|
@ -52,9 +52,8 @@ class Reward(RewardCommission, RewardTacticalClass):
|
||||
logger.hr('Reward receive')
|
||||
|
||||
reward = False
|
||||
exit_timer = Timer(1, count=3)
|
||||
exit_timer = Timer(1, count=3).start()
|
||||
click_timer = Timer(1)
|
||||
exit_timer.start()
|
||||
btn = []
|
||||
if self.config.ENABLE_REWARD:
|
||||
btn.append(REWARD_3)
|
||||
|
@ -148,8 +148,6 @@ class BookGroup:
|
||||
|
||||
|
||||
class RewardTacticalClass(UI, InfoHandler):
|
||||
tactical_animation_timer = Timer(2, count=3)
|
||||
|
||||
def _tactical_animation_running(self):
|
||||
"""
|
||||
Returns:
|
||||
@ -208,6 +206,8 @@ class RewardTacticalClass(UI, InfoHandler):
|
||||
return False
|
||||
|
||||
logger.hr('Tactical class receive')
|
||||
tactical_class_timout = Timer(10, count=10).start()
|
||||
tactical_animation_timer = Timer(2, count=3).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
@ -215,11 +215,14 @@ class RewardTacticalClass(UI, InfoHandler):
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear_then_click(REWARD_2, interval=1):
|
||||
tactical_class_timout.reset()
|
||||
continue
|
||||
if self.handle_popup_confirm():
|
||||
tactical_class_timout.reset()
|
||||
continue
|
||||
if self.handle_urgent_commission(save_get_items=False):
|
||||
# Only one button in the middle, when skill reach max level.
|
||||
tactical_class_timout.reset()
|
||||
continue
|
||||
if self.appear(TACTICAL_CLASS_CANCEL, offset=(30, 30), interval=2) \
|
||||
and self.appear(TACTICAL_CLASS_START, offset=(30, 30)):
|
||||
@ -228,17 +231,21 @@ class RewardTacticalClass(UI, InfoHandler):
|
||||
self._tactical_books_choose()
|
||||
self.device.click(TACTICAL_CLASS_START)
|
||||
self.interval_reset(TACTICAL_CLASS_CANCEL)
|
||||
tactical_class_timout.reset()
|
||||
continue
|
||||
|
||||
# End
|
||||
if self.appear(TACTICAL_CHECK, offset=(20, 20)):
|
||||
self.ui_current = page_tactical
|
||||
if not self._tactical_animation_running():
|
||||
if self.tactical_animation_timer.reached():
|
||||
if tactical_animation_timer.reached():
|
||||
logger.info('Tactical reward end.')
|
||||
break
|
||||
else:
|
||||
self.tactical_animation_timer.reset()
|
||||
tactical_animation_timer.reset()
|
||||
if tactical_class_timout.reached():
|
||||
logger.info('Tactical reward timeout.')
|
||||
break
|
||||
|
||||
self.ui_goto(page_reward, skip_first_screenshot=True)
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user