Merge remote-tracking branch 'origin/bug_fix' into dev

This commit is contained in:
LmeSzinc 2023-11-20 02:09:17 +08:00
commit 80274ae4c9
5 changed files with 28 additions and 4 deletions

View File

@ -25,6 +25,7 @@ class Route(RouteBase, ForgottenHallUI):
logger.hr('Forgotten hall stage 1')
self.stage_goto(KEYWORDS_DUNGEON_LIST.The_Last_Vestiges_of_Towering_Citadel,
KEYWORDS_FORGOTTEN_HALL_STAGE.Stage_1)
if not self.team_is_prepared():
self.team_choose_first_4()
self.enter_forgotten_hall_dungeon()

View File

@ -27,7 +27,7 @@ class SupportCharacter:
_image_cache = {}
_crop_area = COMBAT_SUPPORT_LIST_GRID.matched_button.area
def __init__(self, name, screenshot, similarity=0.85):
def __init__(self, name, screenshot, similarity=0.75):
self.name = name
self.image = self._scale_character()
self.screenshot = crop(screenshot, SupportCharacter._crop_area)

View File

@ -56,7 +56,8 @@ class UseTechniqueUI(MapControlJoystick, ForgottenHallUI):
logger.hr('Use techniques', level=2)
self.stage_goto(KEYWORDS_DUNGEON_LIST.The_Last_Vestiges_of_Towering_Citadel,
KEYWORDS_FORGOTTEN_HALL_STAGE.Stage_1)
self.team_choose_first()
if not self.team_is_prepared():
self.team_choose_first_4()
self.enter_forgotten_hall_dungeon()
self._use_technique(count, skip_first_screenshot=skip_first_screenshot)
self.exit_dungeon()

View File

@ -1,6 +1,7 @@
import cv2
import numpy as np
from module.base.timer import Timer
from module.base.utils import color_similarity_2d, get_color
from module.logger import logger
from tasks.base.ui import UI
@ -72,3 +73,24 @@ class ForgottenHallTeam(UI):
self.device.click(character)
# Casual sleep, game may not respond that fast
self.device.sleep((0.1, 0.2))
def team_is_prepared(self, skip_first_screenshot=True) -> bool:
"""
Pages:
in: ENTRANCE_CHECKED, ENTER_FORGOTTEN_HALL_DUNGEON
"""
characters = [CHARACTER_1, CHARACTER_2, CHARACTER_3, CHARACTER_4]
timeout = Timer(1, count=5).start()
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if timeout.reached():
logger.info('Team not prepared')
return False
chosen_list = [self.is_character_chosen(c) for c in characters]
if all(chosen_list):
logger.info("Team already prepared")
return True

View File

@ -233,7 +233,7 @@ class Aim:
self.draw_item = cv2.multiply(draw, 4)
# Find peaks
points = inrange(draw, lower=12)
points = inrange(draw, lower=10)
points = Points(points).group(threshold=10)
if points.shape[0] > 3:
logger.warning(f'AimDetector.predict_item() too many peaks: {points.shape}')