Fix: Handle missing EFFECT_NOTIFICATION when entering forgotten hall

This commit is contained in:
LmeSzinc 2023-07-24 23:37:22 +08:00
parent 3e5a9d4625
commit 3f0bdb6aa3
3 changed files with 21 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -27,10 +27,10 @@ ENTER_FORGOTTEN_HALL_DUNGEON = ButtonWrapper(
name='ENTER_FORGOTTEN_HALL_DUNGEON', name='ENTER_FORGOTTEN_HALL_DUNGEON',
share=Button( share=Button(
file='./assets/share/forgotten_hall/ENTER_FORGOTTEN_HALL_DUNGEON.png', file='./assets/share/forgotten_hall/ENTER_FORGOTTEN_HALL_DUNGEON.png',
area=(1233, 653, 1241, 680), area=(989, 649, 1231, 684),
search=(1213, 633, 1261, 700), search=(969, 629, 1251, 704),
color=(219, 221, 221), color=(214, 214, 217),
button=(1233, 653, 1241, 680), button=(989, 649, 1231, 684),
), ),
) )
ENTRANCE_CHECKED = ButtonWrapper( ENTRANCE_CHECKED = ButtonWrapper(

View File

@ -151,19 +151,24 @@ class ForgottenHallUI(DungeonUI):
else: else:
self.device.screenshot() self.device.screenshot()
if np.mean(get_color(self.device.image, ENTER_FORGOTTEN_HALL_DUNGEON.area)) > 128: if self._forgotten_hall_enter_appear():
logger.info("First character is chosen") logger.info("First character is chosen")
break break
if interval.reached(): if interval.reached():
self.device.click(FIRST_CHARACTER) self.device.click(FIRST_CHARACTER)
interval.reset() interval.reset()
def _forgotten_hall_enter_appear(self):
# White button, with a color of (214, 214, 214)
color = get_color(self.device.image, ENTER_FORGOTTEN_HALL_DUNGEON.area)
return np.mean(color) > 180
def _enter_forgotten_hall_dungeon(self, skip_first_screenshot=True): def _enter_forgotten_hall_dungeon(self, skip_first_screenshot=True):
""" """
called after team is set called after team is set
""" """
interval = Timer(1) interval = Timer(3)
joystick = MapControlJoystick(self.config, self.device) timeout = Timer(3)
while 1: # enter ui -> popup while 1: # enter ui -> popup
if skip_first_screenshot: if skip_first_screenshot:
skip_first_screenshot = False skip_first_screenshot = False
@ -172,11 +177,19 @@ class ForgottenHallUI(DungeonUI):
if self.appear(EFFECT_NOTIFICATION): if self.appear(EFFECT_NOTIFICATION):
break break
if self.match_template_color(DUNGEON_ENTER_CHECKED):
if timeout.reached():
logger.info('Wait dungeon EFFECT_NOTIFICATION timeout')
break
else:
timeout.reset()
if interval.reached() and np.mean(get_color(self.device.image, ENTER_FORGOTTEN_HALL_DUNGEON.area)) > 128: if interval.reached() and self._forgotten_hall_enter_appear():
self.device.image_save()
self.device.click(ENTER_FORGOTTEN_HALL_DUNGEON) self.device.click(ENTER_FORGOTTEN_HALL_DUNGEON)
interval.reset() interval.reset()
joystick = MapControlJoystick(self.config, self.device)
skip_first_screenshot = True skip_first_screenshot = True
while 1: # pop up -> dungeon inside while 1: # pop up -> dungeon inside
if skip_first_screenshot: if skip_first_screenshot: