Skip to content

Commit 00f2307

Browse files
authored
Merge pull request #2495 from LmeSzinc/dev
Bug fix
2 parents 9a64583 + d86e890 commit 00f2307

4 files changed

Lines changed: 29 additions & 16 deletions

File tree

alas.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ class AzurLaneAutoScript:
2121
def __init__(self, config_name='alas'):
2222
logger.hr('Start', level=0)
2323
self.config_name = config_name
24+
# Skip first restart
25+
self.is_first_task = True
26+
# Failure count of tasks
27+
# Key: str, task name, value: int, failure count
28+
self.failure_record = {}
2429

2530
@cached_property
2631
def config(self):
@@ -427,14 +432,15 @@ def get_next_task(self):
427432

428433
if task.next_run > datetime.now():
429434
logger.info(f'Wait until {task.next_run} for task `{task.command}`')
435+
self.is_first_task = False
430436
method = self.config.Optimization_WhenTaskQueueEmpty
431437
if method == 'close_game':
432438
logger.info('Close game during wait')
433439
self.device.app_stop()
434440
release_resources()
435441
self.device.release_during_wait()
436442
if not self.wait_until(task.next_run):
437-
del self.__dict__['config']
443+
del_cached_property(self, 'config')
438444
continue
439445
self.run('start')
440446
elif method == 'goto_main':
@@ -443,21 +449,21 @@ def get_next_task(self):
443449
release_resources()
444450
self.device.release_during_wait()
445451
if not self.wait_until(task.next_run):
446-
del self.__dict__['config']
452+
del_cached_property(self, 'config')
447453
continue
448454
elif method == 'stay_there':
449455
logger.info('Stay there during wait')
450456
release_resources()
451457
self.device.release_during_wait()
452458
if not self.wait_until(task.next_run):
453-
del self.__dict__['config']
459+
del_cached_property(self, 'config')
454460
continue
455461
else:
456462
logger.warning(f'Invalid Optimization_WhenTaskQueueEmpty: {method}, fallback to stay_there')
457463
release_resources()
458464
self.device.release_during_wait()
459465
if not self.wait_until(task.next_run):
460-
del self.__dict__['config']
466+
del_cached_property(self, 'config')
461467
continue
462468
break
463469

@@ -467,8 +473,6 @@ def get_next_task(self):
467473
def loop(self):
468474
logger.set_file_logger(self.config_name)
469475
logger.info(f'Start scheduler loop: {self.config_name}')
470-
is_first = True
471-
failure_record = {}
472476

473477
while 1:
474478
# Check update event from GUI
@@ -492,10 +496,10 @@ def loop(self):
492496
# Init device and change server
493497
_ = self.device
494498
# Skip first restart
495-
if is_first and task == 'Restart':
499+
if self.is_first_task and task == 'Restart':
496500
logger.info('Skip task `Restart` at scheduler start')
497501
self.config.task_delay(server_update=True)
498-
del self.__dict__['config']
502+
del_cached_property(self, 'config')
499503
continue
500504

501505
# Run
@@ -505,12 +509,12 @@ def loop(self):
505509
logger.hr(task, level=0)
506510
success = self.run(inflection.underscore(task))
507511
logger.info(f'Scheduler: End task `{task}`')
508-
is_first = False
512+
self.is_first_task = False
509513

510514
# Check failures
511-
failed = deep_get(failure_record, keys=task, default=0)
515+
failed = deep_get(self.failure_record, keys=task, default=0)
512516
failed = 0 if success else failed + 1
513-
deep_set(failure_record, keys=task, value=failed)
517+
deep_set(self.failure_record, keys=task, value=failed)
514518
if failed >= 3:
515519
logger.critical(f"Task `{task}` failed 3 or more times.")
516520
logger.critical("Possible reason #1: You haven't used it correctly. "
@@ -526,11 +530,11 @@ def loop(self):
526530
exit(1)
527531

528532
if success:
529-
del self.__dict__['config']
533+
del_cached_property(self, 'config')
530534
continue
531535
elif self.config.Error_HandleError:
532536
# self.config.task_delay(success=False)
533-
del self.__dict__['config']
537+
del_cached_property(self, 'config')
534538
self.checker.check_now()
535539
continue
536540
else:
-24.6 KB
Loading

module/os_handler/action_point.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,19 @@ def action_point_safe_get(self, skip_first_screenshot=True):
160160
# Having too many current AP, probably an OCR error
161161
if self._action_point_current > 600:
162162
continue
163+
164+
oil, boxes = self._action_point_box[0], self._action_point_box[1:]
163165
# Having boxes
164-
if sum(self._action_point_box[1:]) > 0:
165-
break
166+
if sum(boxes) > 0:
167+
if oil > 100:
168+
break
169+
else:
170+
# [11, 0, 1, 0]
171+
continue
166172
# Or having oil
167173
# Might be 0 or 1 when page is not fully loaded
168-
if self._action_point_box[0] > 100:
174+
# [1, 0, 0, 0]
175+
if oil > 100:
169176
break
170177

171178
@staticmethod

module/ui/ui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ def ui_additional(self):
558558
# Login
559559
if self.appear_then_click(LOGIN_CHECK, offset=(30, 30), interval=3):
560560
return True
561+
if self.appear_then_click(LOGIN_ANNOUNCE, offset=(30, 30), interval=3):
562+
return True
561563

562564
# Mistaken click
563565
if self.appear(EXERCISE_PREPARATION, interval=3):

0 commit comments

Comments
 (0)