2023-07-10 15:36:35 +00:00
|
|
|
from module.logger import logger
|
|
|
|
from module.ocr.ocr import DigitCounter
|
|
|
|
from tasks.base.ui import UI
|
2023-08-20 16:51:10 +00:00
|
|
|
from tasks.dungeon.assets.assets_dungeon_event import (
|
|
|
|
DOUBLE_CALYX_EVENT_TAG,
|
|
|
|
DOUBLE_RELIC_EVENT_TAG,
|
|
|
|
OCR_DOUBLE_EVENT_REMAIN
|
|
|
|
)
|
2023-07-10 15:36:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DungeonEvent(UI):
|
|
|
|
def has_double_calyx_event(self) -> bool:
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: page_guide, Survival_Index, nav at top
|
|
|
|
"""
|
|
|
|
has = self.image_color_count(DOUBLE_CALYX_EVENT_TAG, color=(252, 209, 123), threshold=221, count=50)
|
2023-08-20 16:51:10 +00:00
|
|
|
has |= self.image_color_count(DOUBLE_CALYX_EVENT_TAG, color=(252, 251, 140), threshold=221, count=50)
|
2023-07-10 15:36:35 +00:00
|
|
|
logger.attr('Double calyx', has)
|
|
|
|
return has
|
|
|
|
|
2023-08-20 16:51:10 +00:00
|
|
|
def has_double_relic_event(self) -> bool:
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: page_guide, Survival_Index, nav at top
|
|
|
|
"""
|
|
|
|
has = self.image_color_count(DOUBLE_RELIC_EVENT_TAG, color=(252, 209, 123), threshold=221, count=50)
|
|
|
|
has |= self.image_color_count(DOUBLE_RELIC_EVENT_TAG, color=(252, 251, 140), threshold=221, count=50)
|
|
|
|
logger.attr('Double relic', has)
|
|
|
|
return has
|
|
|
|
|
2023-07-10 15:36:35 +00:00
|
|
|
def get_double_event_remain(self) -> int:
|
|
|
|
"""
|
|
|
|
Pages:
|
|
|
|
in: page_guide, Survival_Index, selected at the nav with double event
|
|
|
|
"""
|
|
|
|
ocr = DigitCounter(OCR_DOUBLE_EVENT_REMAIN)
|
|
|
|
remain, _, total = ocr.ocr_single_line(self.device.image)
|
2023-08-20 16:51:10 +00:00
|
|
|
if total not in [3, 12]:
|
2023-07-10 15:36:35 +00:00
|
|
|
logger.warning(f'Invalid double event remain')
|
|
|
|
remain = 0
|
|
|
|
logger.attr('Double event remain', remain)
|
|
|
|
return remain
|