1
0
mirror of https://github.com/sui-feng-cb/AzurLaneAutoScript1.git synced 2026-07-13 10:58:02 +08:00

Feat: notify on empty tactical class slot

This commit is contained in:
positnuec
2026-07-10 03:18:06 +08:00
parent 9920c89fea
commit 47a433d2fc
9 changed files with 51 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ from module.exception import ScriptError
from module.handler.assets import GET_MISSION, MISSION_POPUP_ACK, MISSION_POPUP_GO, POPUP_CANCEL, POPUP_CONFIRM
from module.logger import logger
from module.map.map_grids import SelectedGrids
from module.notify import handle_notify
from module.ocr.ocr import DigitCounter, Duration, Ocr
from module.retire.assets import DOCK_CHECK, DOCK_EMPTY, SHIP_CONFIRM
from module.retire.dock import CARD_GRIDS, CARD_LEVEL_GRIDS, Dock
@@ -378,6 +379,23 @@ class RewardTacticalClass(Dock):
return False
def _notify_tactical_empty_slot(self, reason: str):
"""
Push notification when tactical class has empty slots.
Only the first call in a single run will actually send, later calls are skipped.
Args:
reason (str):
"""
if getattr(self, '_tactical_notified', False):
return
handle_notify(
self.config.Error_OnePushConfig,
title=f"Alas <{self.config.config_name}> tactical slot empty",
content=f"{reason}",
)
self._tactical_notified = True
def _tactical_get_finish(self):
"""
Get the future finish time.
@@ -389,6 +407,10 @@ class RewardTacticalClass(Dock):
is_running = [self.image_color_count(button, color=(148, 255, 99), count=50) for button in grids.buttons]
logger.info(f'Tactical status: {["running" if s else "empty" for s in is_running]}')
if (self.config.AddNewStudent_EnableNotify
and not self.config.AddNewStudent_Enable and self.appear(ADD_NEW_STUDENT, offset=(800, 20))):
self._notify_tactical_empty_slot("Slot unfilled or lesson just completed, with 'Add New Student' disabled")
buttons = [b for b, s in zip(grids.buttons, is_running) if s]
ocr = Duration(buttons, letter=(148, 255, 99), name='TACTICAL_REMAIN')
remains = ocr.ocr(self.device.image)
@@ -415,6 +437,7 @@ class RewardTacticalClass(Dock):
"""
logger.hr('Tactical class receive', level=1)
received = False
self._tactical_notified = False
study_finished = not self.config.AddNewStudent_Enable
book_empty = False
# tactical cards can't be loaded that fast, confirm if it's empty.
@@ -520,6 +543,8 @@ class RewardTacticalClass(Dock):
if self.select_suitable_ship():
pass
else:
if self.config.AddNewStudent_EnableNotify:
self._notify_tactical_empty_slot('No available student to add')
study_finished = True
self.device.click(BACK_ARROW)
else:
@@ -536,6 +561,8 @@ class RewardTacticalClass(Dock):
if self._tactical_skill_choose():
pass
else:
if self.config.AddNewStudent_EnableNotify:
self._notify_tactical_empty_slot('No available skill to learn')
study_finished = True
self.device.click(BACK_ARROW)
else: