Fix: Wait until dungeon list loaded

This commit is contained in:
LmeSzinc 2024-02-07 05:52:57 +08:00
parent e27332c609
commit 3f38deedd7
3 changed files with 37 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -63,6 +63,16 @@ DAILY_TRAINING_LOADED = ButtonWrapper(
button=(1143, 546, 1158, 561), button=(1143, 546, 1158, 561),
), ),
) )
LIST_LOADED_CHECK = ButtonWrapper(
name='LIST_LOADED_CHECK',
share=Button(
file='./assets/share/dungeon/ui/LIST_LOADED_CHECK.png',
area=(576, 606, 951, 664),
search=(556, 586, 971, 684),
color=(180, 188, 195),
button=(576, 606, 951, 664),
),
)
OCR_DUNGEON_LIST = ButtonWrapper( OCR_DUNGEON_LIST = ButtonWrapper(
name='OCR_DUNGEON_LIST', name='OCR_DUNGEON_LIST',
share=Button( share=Button(

View File

@ -1,5 +1,6 @@
import re import re
import cv2
import numpy as np import numpy as np
from module.base.base import ModuleBase from module.base.base import ModuleBase
@ -27,6 +28,7 @@ from tasks.dungeon.keywords import (
) )
from tasks.dungeon.keywords.classes import DungeonEntrance from tasks.dungeon.keywords.classes import DungeonEntrance
from tasks.dungeon.state import DungeonState from tasks.dungeon.state import DungeonState
from tasks.map.interact.aim import inrange
from tasks.map.keywords import KEYWORDS_MAP_WORLD from tasks.map.keywords import KEYWORDS_MAP_WORLD
@ -266,6 +268,28 @@ class DungeonUI(DungeonState):
logger.info('Treasures lightward loaded (event locked)') logger.info('Treasures lightward loaded (event locked)')
return True return True
def _dungeon_wait_until_dungeon_list_loaded(self, skip_first_screenshot=True):
timeout = Timer(1, count=3).start()
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
if timeout.reached():
logger.warning('Wait until dungeon list loaded timeout')
return False
# Check if having any content
# List background: 254, guild border: 225
r, g, b = cv2.split(self.image_crop(LIST_LOADED_CHECK))
minimum = cv2.min(cv2.min(r, g), b)
minimum = inrange(minimum, lower=0, upper=180)
if minimum.size > 100:
logger.info('Dungeon list loaded')
break
def _dungeon_wait_until_echo_or_war_stabled(self, skip_first_screenshot=True): def _dungeon_wait_until_echo_or_war_stabled(self, skip_first_screenshot=True):
""" """
Returns: Returns:
@ -581,12 +605,15 @@ class DungeonUI(DungeonState):
or dungeon.is_Cavern_of_Corrosion \ or dungeon.is_Cavern_of_Corrosion \
or dungeon.is_Echo_of_War: or dungeon.is_Echo_of_War:
self._dungeon_nav_goto(dungeon) self._dungeon_nav_goto(dungeon)
self._dungeon_wait_until_dungeon_list_loaded()
self._dungeon_insight(dungeon) self._dungeon_insight(dungeon)
self._dungeon_enter(dungeon) self._dungeon_enter(dungeon)
return True return True
if dungeon.is_Calyx_Golden: if dungeon.is_Calyx_Golden:
self._dungeon_nav_goto(dungeon) self._dungeon_nav_goto(dungeon)
self._dungeon_wait_until_dungeon_list_loaded()
self._dungeon_world_set(dungeon) self._dungeon_world_set(dungeon)
self._dungeon_wait_until_dungeon_list_loaded()
self._dungeon_insight(dungeon) self._dungeon_insight(dungeon)
self._dungeon_enter(dungeon) self._dungeon_enter(dungeon)
return True return True