Fix: Handle BLESSING_ENHANCED and BLESSING_OBTAINED popups

This commit is contained in:
LmeSzinc 2023-10-06 17:07:24 +08:00
parent b2b540698f
commit 357c3096c1
6 changed files with 36 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -13,6 +13,26 @@ BLESSING_CONFIRM = ButtonWrapper(
button=(960, 629, 1233, 677), button=(960, 629, 1233, 677),
), ),
) )
BLESSING_ENHANCED = ButtonWrapper(
name='BLESSING_ENHANCED',
share=Button(
file='./assets/share/rogue/ui/BLESSING_ENHANCED.png',
area=(630, 351, 651, 370),
search=(610, 331, 671, 390),
color=(124, 125, 128),
button=(630, 351, 651, 370),
),
)
BLESSING_OBTAINED = ButtonWrapper(
name='BLESSING_OBTAINED',
share=Button(
file='./assets/share/rogue/ui/BLESSING_OBTAINED.png',
area=(733, 561, 765, 583),
search=(710, 551, 777, 593),
color=(248, 248, 248),
button=(733, 561, 765, 583),
),
)
CHECK_BLESSING = ButtonWrapper( CHECK_BLESSING = ButtonWrapper(
name='CHECK_BLESSING', name='CHECK_BLESSING',
share=Button( share=Button(

View File

@ -1,6 +1,7 @@
import re import re
from module.base.utils import area_offset from module.base.utils import area_offset
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_ui import * from tasks.rogue.assets.assets_rogue_ui import *
@ -56,3 +57,16 @@ class RogueUI(UI):
""" """
FLAG_UNRECORD.matched_button.search = area_offset(relative_area, target.area[:2]) FLAG_UNRECORD.matched_button.search = area_offset(relative_area, target.area[:2])
return self.appear(FLAG_UNRECORD) return self.appear(FLAG_UNRECORD)
def handle_blessing_popup(self):
# Obtained a free blessing from curio
if self.appear(BLESSING_OBTAINED, interval=2):
logger.info(f'{BLESSING_OBTAINED} -> {BLESSING_CONFIRM}')
self.device.click(BLESSING_CONFIRM)
return True
# Enhanced a blessing from occurrence
if self.appear(BLESSING_ENHANCED, interval=2):
logger.info(f'{BLESSING_ENHANCED} -> {BLESSING_CONFIRM}')
self.device.click(BLESSING_CONFIRM)
return True
return False

View File

@ -50,6 +50,8 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent):
selector = RogueBonusSelector(self) selector = RogueBonusSelector(self)
selector.recognize_and_select() selector.recognize_and_select()
return True return True
if self.handle_blessing_popup():
return True
return False return False