diff --git a/alas.py b/alas.py index 5fa8fd6c5..a4daf7088 100644 --- a/alas.py +++ b/alas.py @@ -23,6 +23,11 @@ class AzurLaneAutoScript: def __init__(self, config_name='alas'): logger.hr('Start', level=0) self.config_name = config_name + # Skip first restart + self.is_first_task = True + # Failure count of tasks + # Key: str, task name, value: int, failure count + self.failure_record = {} @cached_property def config(self): @@ -450,6 +455,7 @@ class AzurLaneAutoScript: if task.next_run > datetime.now(): logger.info(f'Wait until {task.next_run} for task `{task.command}`') + self.is_first_task = False method = self.config.Optimization_WhenTaskQueueEmpty if method == 'close_game': logger.info('Close game during wait') @@ -457,7 +463,7 @@ class AzurLaneAutoScript: release_resources() self.device.release_during_wait() if not self.wait_until(task.next_run): - del self.__dict__['config'] + del_cached_property(self, 'config') continue self.run('start') elif method == 'goto_main': @@ -466,21 +472,21 @@ class AzurLaneAutoScript: release_resources() self.device.release_during_wait() if not self.wait_until(task.next_run): - del self.__dict__['config'] + del_cached_property(self, 'config') continue elif method == 'stay_there': logger.info('Stay there during wait') release_resources() self.device.release_during_wait() if not self.wait_until(task.next_run): - del self.__dict__['config'] + del_cached_property(self, 'config') continue else: logger.warning(f'Invalid Optimization_WhenTaskQueueEmpty: {method}, fallback to stay_there') release_resources() self.device.release_during_wait() if not self.wait_until(task.next_run): - del self.__dict__['config'] + del_cached_property(self, 'config') continue break @@ -490,8 +496,6 @@ class AzurLaneAutoScript: def loop(self): logger.set_file_logger(self.config_name) logger.info(f'Start scheduler loop: {self.config_name}') - is_first = True - failure_record = {} while 1: # Check update event from GUI @@ -515,10 +519,10 @@ class AzurLaneAutoScript: # Init device and change server _ = self.device # Skip first restart - if is_first and task == 'Restart': + if self.is_first_task and task == 'Restart': logger.info('Skip task `Restart` at scheduler start') self.config.task_delay(server_update=True) - del self.__dict__['config'] + del_cached_property(self, 'config') continue # Run @@ -528,12 +532,12 @@ class AzurLaneAutoScript: logger.hr(task, level=0) success = self.run(inflection.underscore(task)) logger.info(f'Scheduler: End task `{task}`') - is_first = False + self.is_first_task = False # Check failures - failed = deep_get(failure_record, keys=task, default=0) + failed = deep_get(self.failure_record, keys=task, default=0) failed = 0 if success else failed + 1 - deep_set(failure_record, keys=task, value=failed) + deep_set(self.failure_record, keys=task, value=failed) if failed >= 3: if not self.GAME_HAS_RESTARTED: failed = 0 @@ -558,11 +562,11 @@ class AzurLaneAutoScript: exit(1) if success: - del self.__dict__['config'] + del_cached_property(self, 'config') continue elif self.config.Error_HandleError: # self.config.task_delay(success=False) - del self.__dict__['config'] + del_cached_property(self, 'config') self.checker.check_now() continue else: diff --git a/assets/cn/war_archives/TEMPLATE_ENCIRCLING_GRAF_SPEE.png b/assets/cn/war_archives/TEMPLATE_ENCIRCLING_GRAF_SPEE.png index cf1bd8acb..5c04432ee 100644 Binary files a/assets/cn/war_archives/TEMPLATE_ENCIRCLING_GRAF_SPEE.png and b/assets/cn/war_archives/TEMPLATE_ENCIRCLING_GRAF_SPEE.png differ diff --git a/module/os_handler/action_point.py b/module/os_handler/action_point.py index aa3e9e047..dcc2cbddd 100644 --- a/module/os_handler/action_point.py +++ b/module/os_handler/action_point.py @@ -160,12 +160,19 @@ class ActionPointHandler(UI, MapEventHandler): # Having too many current AP, probably an OCR error if self._action_point_current > 600: continue + + oil, boxes = self._action_point_box[0], self._action_point_box[1:] # Having boxes - if sum(self._action_point_box[1:]) > 0: - break + if sum(boxes) > 0: + if oil > 100: + break + else: + # [11, 0, 1, 0] + continue # Or having oil # Might be 0 or 1 when page is not fully loaded - if self._action_point_box[0] > 100: + # [1, 0, 0, 0] + if oil > 100: break @staticmethod diff --git a/module/ui/ui.py b/module/ui/ui.py index 2a722fcce..4c2f65728 100644 --- a/module/ui/ui.py +++ b/module/ui/ui.py @@ -558,6 +558,8 @@ class UI(InfoHandler): # Login if self.appear_then_click(LOGIN_CHECK, offset=(30, 30), interval=3): return True + if self.appear_then_click(LOGIN_ANNOUNCE, offset=(30, 30), interval=3): + return True # Mistaken click if self.appear(EXERCISE_PREPARATION, interval=3):