diff --git a/config/template.json b/config/template.json index dece83037..10552c881 100644 --- a/config/template.json +++ b/config/template.json @@ -1441,7 +1441,8 @@ "AddNewStudent": { "Enable": false, "Favorite": false, - "MinLevel": 50 + "MinLevel": 50, + "EnableNotify": false }, "Storage": { "Storage": {} diff --git a/module/config/argument/args.json b/module/config/argument/args.json index c2ed8173c..f864467a1 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -7554,6 +7554,10 @@ "MinLevel": { "type": "input", "value": 50 + }, + "EnableNotify": { + "type": "checkbox", + "value": false } }, "Storage": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index e25c1b3a2..cf722385a 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -412,6 +412,7 @@ AddNewStudent: Enable: false Favorite: false MinLevel: 50 + EnableNotify: false Research: UseCube: value: only_05_hour diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 9fcc7358c..8537b711f 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -227,6 +227,7 @@ class GeneratedConfig: AddNewStudent_Enable = False AddNewStudent_Favorite = False AddNewStudent_MinLevel = 50 + AddNewStudent_EnableNotify = False # Group `Research` Research_UseCube = 'only_05_hour' # always_use, only_05_hour, only_no_project, do_not_use diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 43f201e92..6333cf1c3 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -1561,6 +1561,10 @@ "MinLevel": { "name": "Add Students with Level >= X Only", "help": "" + }, + "EnableNotify": { + "name": "Notify on Empty Slot", + "help": "Send a notification when there is an empty slot in the Tactical Academy: a ship girl has finished studying and 'Level Skills' is disabled, or enabled but failed to assign a new student" } }, "Research": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 1ac15b7ca..dd7ed0ea3 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -1561,6 +1561,10 @@ "MinLevel": { "name": "レベルがX以上のキャラクターのみを追加してください。", "help": "" + }, + "EnableNotify": { + "name": "空席通知を送信", + "help": "戦術学院に空席がある時に通知を送信:艦娘が学習を完了し、かつ'新しいスキルを学ぶ'が無効、または有効だが新規生徒の割り当てに失敗した時" } }, "Research": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 802d0ca7c..9e689e391 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -1561,6 +1561,10 @@ "MinLevel": { "name": "仅添加等级 >= X 的角色", "help": "" + }, + "EnableNotify": { + "name": "推送空位提醒", + "help": "在战术学院有空位时推送通知:舰娘完成学习且未启用'学习新技能',或启用了但指派失败时" } }, "Research": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 68a507fe0..093c3212f 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -1561,6 +1561,10 @@ "MinLevel": { "name": "僅新增等級 >= X 的角色", "help": "" + }, + "EnableNotify": { + "name": "推送空位提醒", + "help": "在戰術學院有空位時推送通知:艦娘完成學習且未啟用'學習新技能',或啟用了但指派失敗時" } }, "Research": { diff --git a/module/tactical/tactical_class.py b/module/tactical/tactical_class.py index 0e518a49a..e430e0d44 100644 --- a/module/tactical/tactical_class.py +++ b/module/tactical/tactical_class.py @@ -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: