Opt: Wait rogue buttons loaded before clicking to prevent retries

This commit is contained in:
LmeSzinc 2024-05-08 00:47:42 +08:00
parent 3679f00c13
commit 4d086d1753
5 changed files with 26 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -238,3 +238,13 @@ PAGE_ROGUE_PATH = ButtonWrapper(
button=(606, 89, 656, 108), button=(606, 89, 656, 108),
), ),
) )
PATH_LOADED_CHECK = ButtonWrapper(
name='PATH_LOADED_CHECK',
share=Button(
file='./assets/share/rogue/path/PATH_LOADED_CHECK.png',
area=(989, 18, 1175, 59),
search=(969, 0, 1195, 79),
color=(45, 45, 47),
button=(989, 18, 1175, 59),
),
)

View File

@ -4,8 +4,8 @@ from module.base.utils import area_offset
from module.logger import logger from module.logger import logger
from module.ocr.ocr import Digit, Ocr, OcrResultButton from module.ocr.ocr import Digit, Ocr, OcrResultButton
from tasks.base.ui import UI from tasks.base.ui import UI
from tasks.rogue.assets.assets_rogue_weekly import REWARD_ENTER
from tasks.rogue.assets.assets_rogue_ui import * from tasks.rogue.assets.assets_rogue_ui import *
from tasks.rogue.assets.assets_rogue_weekly import REWARD_ENTER
from tasks.rogue.keywords import RoguePath from tasks.rogue.keywords import RoguePath

View File

@ -250,6 +250,9 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonUI):
self.interval_reset(REWARD_ENTER, interval=2) self.interval_reset(REWARD_ENTER, interval=2)
continue continue
if self.match_template_color(LEVEL_CONFIRM, interval=2): if self.match_template_color(LEVEL_CONFIRM, interval=2):
if not self.image_color_count(LEVEL_CONFIRM, color=(223, 223, 225), threshold=240, count=50):
self.interval_clear(LEVEL_CONFIRM)
continue
self.dungeon_update_stamina() self.dungeon_update_stamina()
self.check_stop_condition() self.check_stop_condition()
self.device.click(LEVEL_CONFIRM) self.device.click(LEVEL_CONFIRM)

View File

@ -206,6 +206,9 @@ class RoguePathHandler(RogueUI):
break break
if self.match_template_color(ROGUE_LAUNCH, interval=2): if self.match_template_color(ROGUE_LAUNCH, interval=2):
if not self.image_color_count(ROGUE_LAUNCH, color=(223, 223, 225), threshold=240, count=50):
self.interval_clear(ROGUE_LAUNCH)
continue
if not self._is_team_prepared(): if not self._is_team_prepared():
raise RogueTeamNotPrepared raise RogueTeamNotPrepared
self.device.click(ROGUE_LAUNCH) self.device.click(ROGUE_LAUNCH)
@ -216,11 +219,19 @@ class RoguePathHandler(RogueUI):
continue continue
# Select path # Select path
if self.interval_is_reached(entry, interval=2) and self._is_page_rogue_path(): if self.interval_is_reached(entry, interval=2) and self._is_page_rogue_path():
if self.appear_then_click(entry, interval=2): if not self.image_color_count(PATH_LOADED_CHECK, color=(246, 246, 246), threshold=240, count=50):
self.interval_clear(entry)
continue
if self.appear(entry):
self.device.click(entry)
self.interval_reset(entry, interval=2) self.interval_reset(entry, interval=2)
continue continue
# Confirm path # Confirm path
if self.appear(CONFIRM_PATH, interval=2): if self.appear(CONFIRM_PATH, interval=2):
if not self.image_color_count(CONFIRM_PATH, color=(223, 223, 225), threshold=240, count=50):
self.interval_clear(CONFIRM_PATH)
continue
if self._change_confirm_path(path): if self._change_confirm_path(path):
self.device.click(CONFIRM_PATH) self.device.click(CONFIRM_PATH)
self.interval_reset(CONFIRM_PATH)
continue continue