Fix: Trying to handle books empty (#3753)

This commit is contained in:
LmeSzinc 2024-06-11 23:38:43 +08:00
parent 4c98442422
commit 863458a23a
6 changed files with 19 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -5,6 +5,7 @@ from module.base.template import Template
# Don't modify it manually.
ADD_NEW_STUDENT = Button(area={'cn': (417, 375, 438, 398), 'en': (417, 375, 438, 398), 'jp': (410, 371, 440, 402), 'tw': (417, 375, 438, 398)}, color={'cn': (81, 91, 106), 'en': (81, 91, 106), 'jp': (75, 84, 100), 'tw': (81, 91, 106)}, button={'cn': (417, 375, 438, 398), 'en': (417, 375, 438, 398), 'jp': (410, 371, 440, 402), 'tw': (417, 375, 438, 398)}, file={'cn': './assets/cn/tactical/ADD_NEW_STUDENT.png', 'en': './assets/en/tactical/ADD_NEW_STUDENT.png', 'jp': './assets/jp/tactical/ADD_NEW_STUDENT.png', 'tw': './assets/cn/tactical/ADD_NEW_STUDENT.png'})
BOOK_EMPTY_POPUP = Button(area={'cn': (880, 180, 908, 209), 'en': (880, 180, 908, 209), 'jp': (880, 180, 908, 209), 'tw': (880, 180, 908, 209)}, color={'cn': (211, 109, 105), 'en': (211, 109, 105), 'jp': (211, 109, 105), 'tw': (211, 109, 105)}, button={'cn': (880, 180, 908, 209), 'en': (880, 180, 908, 209), 'jp': (880, 180, 908, 209), 'tw': (880, 180, 908, 209)}, file={'cn': './assets/cn/tactical/BOOK_EMPTY_POPUP.png', 'en': './assets/en/tactical/BOOK_EMPTY_POPUP.png', 'jp': './assets/jp/tactical/BOOK_EMPTY_POPUP.png', 'tw': './assets/tw/tactical/BOOK_EMPTY_POPUP.png'})
OCR_SKILL_EXP = Button(area={'cn': (771, 191, 951, 209), 'en': (771, 191, 951, 209), 'jp': (771, 191, 951, 209), 'tw': (771, 191, 951, 209)}, color={'cn': (72, 82, 83), 'en': (72, 82, 83), 'jp': (72, 82, 83), 'tw': (72, 82, 83)}, button={'cn': (771, 191, 951, 209), 'en': (771, 191, 951, 209), 'jp': (771, 191, 951, 209), 'tw': (771, 191, 951, 209)}, file={'cn': './assets/cn/tactical/OCR_SKILL_EXP.png', 'en': './assets/en/tactical/OCR_SKILL_EXP.png', 'jp': './assets/jp/tactical/OCR_SKILL_EXP.png', 'tw': './assets/tw/tactical/OCR_SKILL_EXP.png'})
RAPID_TRAINING = Button(area={'cn': (518, 566, 583, 582), 'en': (518, 568, 585, 580), 'jp': (518, 566, 584, 583), 'tw': (518, 566, 583, 582)}, color={'cn': (233, 212, 171), 'en': (229, 205, 156), 'jp': (232, 209, 165), 'tw': (233, 212, 171)}, button={'cn': (518, 566, 583, 582), 'en': (518, 568, 585, 580), 'jp': (518, 566, 584, 583), 'tw': (518, 566, 583, 582)}, file={'cn': './assets/cn/tactical/RAPID_TRAINING.png', 'en': './assets/en/tactical/RAPID_TRAINING.png', 'jp': './assets/jp/tactical/RAPID_TRAINING.png', 'tw': './assets/cn/tactical/RAPID_TRAINING.png'})
REWARD_2 = Button(area={'cn': (418, 413, 468, 434), 'en': (403, 416, 504, 432), 'jp': (432, 415, 476, 436), 'tw': (418, 413, 468, 434)}, color={'cn': (240, 191, 120), 'en': (240, 201, 145), 'jp': (240, 191, 121), 'tw': (240, 191, 120)}, button={'cn': (383, 404, 503, 444), 'en': (392, 404, 515, 445), 'jp': (383, 404, 503, 444), 'tw': (383, 404, 503, 444)}, file={'cn': './assets/cn/tactical/REWARD_2.png', 'en': './assets/en/tactical/REWARD_2.png', 'jp': './assets/jp/tactical/REWARD_2.png', 'tw': './assets/tw/tactical/REWARD_2.png'})

View File

@ -6,6 +6,7 @@ from module.base.filter import Filter
from module.base.timer import Timer
from module.base.utils import *
from module.combat.level import LevelOcr
from module.config.utils import get_server_next_update
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
@ -389,6 +390,7 @@ class RewardTacticalClass(Dock):
logger.hr('Tactical class receive', level=1)
received = False
study_finished = not self.config.AddNewStudent_Enable
book_empty = False
# tactical cards can't be loaded that fast, confirm if it's empty.
empty_confirm = Timer(0.6, count=2).start()
while 1:
@ -416,6 +418,10 @@ class RewardTacticalClass(Dock):
# Get finish time
if self.appear(TACTICAL_CHECK, offset=(20, 20), interval=2):
self.interval_clear([POPUP_CONFIRM, POPUP_CANCEL, GET_MISSION])
if book_empty:
self.device.click(BACK_ARROW)
self.interval_reset(TACTICAL_CHECK)
continue
if self._tactical_get_finish():
self.device.click(BACK_ARROW)
self.interval_reset(TACTICAL_CHECK)
@ -450,6 +456,13 @@ class RewardTacticalClass(Dock):
continue
if self.ui_page_main_popups():
continue
# No books
if self.appear(BOOK_EMPTY_POPUP, offset=(20, 20), interval=3):
self.device.click(BOOK_EMPTY_POPUP)
study_finished = True
received = True
book_empty = True
continue
# Similar to handle_mission_popup_ack, but battle pass item expire popup has a different ACK button
if self.appear(MISSION_POPUP_GO, offset=self._popup_offset, interval=2):
self.device.click(MISSION_POPUP_ACK)
@ -506,6 +519,11 @@ class RewardTacticalClass(Dock):
self.interval_reset(TACTICAL_CHECK)
self.interval_clear(ADD_NEW_STUDENT)
continue
if book_empty:
logger.warning('Tactical books empty, delay to tomorrow')
self.tactical_finish = get_server_next_update(self.config.Scheduler_ServerUpdate)
logger.info(f'Tactical finish: {[str(f) for f in self.tactical_finish]}')
return True
def _tactical_skill_select(self, selected_skill, skip_first_screenshot=True):