2023-08-10 09:12:17 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
2023-08-10 18:43:06 +00:00
|
|
|
from module.base.filter import MultiLangFilter
|
2023-08-10 09:12:17 +00:00
|
|
|
from module.base.timer import Timer
|
2023-08-14 07:12:02 +00:00
|
|
|
from module.base.utils import get_color
|
2023-08-10 09:12:17 +00:00
|
|
|
from module.logger import logger
|
2023-10-05 10:52:55 +00:00
|
|
|
from module.ocr.ocr import Digit, DigitCounter, Ocr, OcrResultButton
|
2023-08-18 12:22:46 +00:00
|
|
|
from module.ocr.utils import split_and_pair_buttons
|
2023-08-10 09:12:17 +00:00
|
|
|
from tasks.rogue.assets.assets_rogue_blessing import *
|
2023-08-20 15:53:25 +00:00
|
|
|
from tasks.rogue.assets.assets_rogue_ui import BLESSING_CONFIRM
|
2023-12-20 16:19:10 +00:00
|
|
|
from tasks.rogue.blessing.preset import BLESSING_PRESET, RESONANCE_PRESET
|
2023-12-18 16:53:33 +00:00
|
|
|
from tasks.rogue.blessing.selector import RogueSelector
|
|
|
|
from tasks.rogue.blessing.utils import get_regex_from_keyword_name, is_card_selected, parse_name
|
2023-10-05 10:52:55 +00:00
|
|
|
from tasks.rogue.keywords import *
|
2023-08-10 09:12:17 +00:00
|
|
|
|
2023-08-18 12:22:46 +00:00
|
|
|
# normal blessing filter
|
|
|
|
# path name
|
2023-08-10 09:12:17 +00:00
|
|
|
pattern = ""
|
|
|
|
BLESSING_FILTER_ATTR = tuple()
|
2023-08-10 18:43:06 +00:00
|
|
|
PATH_ATTR_NAME = 'path_name'
|
|
|
|
path_regex = get_regex_from_keyword_name(RoguePath, PATH_ATTR_NAME)
|
2023-08-10 09:12:17 +00:00
|
|
|
pattern += path_regex
|
2023-08-20 14:43:07 +00:00
|
|
|
# remove 'the' in path 'the hunt'
|
|
|
|
pattern = pattern.lower().replace('the', '')
|
2023-08-10 18:43:06 +00:00
|
|
|
BLESSING_FILTER_ATTR += (PATH_ATTR_NAME,)
|
2023-08-10 09:12:17 +00:00
|
|
|
|
2023-08-18 12:22:46 +00:00
|
|
|
# rarity
|
2023-08-10 09:12:17 +00:00
|
|
|
pattern += "([123])?-?"
|
|
|
|
BLESSING_FILTER_ATTR += ("rarity",)
|
2023-08-18 12:22:46 +00:00
|
|
|
|
|
|
|
# blessing name
|
2023-08-10 18:43:06 +00:00
|
|
|
BLESSING_ATTR_NAME = 'blessing_name'
|
|
|
|
blessing_regex = get_regex_from_keyword_name(RogueBlessing, BLESSING_ATTR_NAME)
|
2023-08-10 09:12:17 +00:00
|
|
|
pattern += blessing_regex
|
2023-08-10 18:43:06 +00:00
|
|
|
BLESSING_FILTER_ATTR += (BLESSING_ATTR_NAME,)
|
2023-08-10 09:12:17 +00:00
|
|
|
|
2023-08-18 12:22:46 +00:00
|
|
|
# enhanced
|
|
|
|
ENHANCEMENT_ATTR_NAME = "enhancement"
|
|
|
|
enhancement_regex = get_regex_from_keyword_name(RogueEnhancement, "enhancement_keyword")
|
|
|
|
pattern += enhancement_regex
|
|
|
|
BLESSING_FILTER_ATTR += (ENHANCEMENT_ATTR_NAME,)
|
|
|
|
|
2023-08-10 09:12:17 +00:00
|
|
|
FILETER_REGEX = re.compile(pattern)
|
2023-08-22 19:00:45 +00:00
|
|
|
BLESSING_FILTER_PRESET = ("reset", "random", "unrecorded")
|
2023-08-10 18:43:06 +00:00
|
|
|
BLESSING_FILTER = MultiLangFilter(FILETER_REGEX, BLESSING_FILTER_ATTR, BLESSING_FILTER_PRESET)
|
2023-08-10 09:12:17 +00:00
|
|
|
|
2023-08-18 12:22:46 +00:00
|
|
|
# resonance filter
|
2023-08-10 18:43:06 +00:00
|
|
|
RESONANCE_ATTR_NAME = 'resonance_name'
|
2023-08-11 09:35:57 +00:00
|
|
|
pattern = get_regex_from_keyword_name(RogueResonance, RESONANCE_ATTR_NAME)
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
FILETER_REGEX = re.compile(pattern)
|
2023-08-22 19:00:45 +00:00
|
|
|
RESONANCE_FILTER_PRESET = ("random", "unrecorded")
|
2023-08-10 18:43:06 +00:00
|
|
|
RESONANCE_FILTER = MultiLangFilter(FILETER_REGEX, (RESONANCE_ATTR_NAME,), RESONANCE_FILTER_PRESET)
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RogueBuffOcr(Ocr):
|
2023-08-22 19:00:45 +00:00
|
|
|
merge_thres_x = 40
|
|
|
|
merge_thres_y = 20
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
def after_process(self, result):
|
|
|
|
result = super().after_process(result)
|
2023-09-10 16:38:32 +00:00
|
|
|
if self.lang == 'cn':
|
2023-08-10 09:12:17 +00:00
|
|
|
replace_pattern_dict = {
|
|
|
|
"蓬失": "蓬矢",
|
|
|
|
"柘弓危失": "柘弓危矢",
|
2023-08-22 19:00:45 +00:00
|
|
|
"飞虹珠?凿?齿": "飞虹诛凿齿",
|
2023-09-10 16:38:32 +00:00
|
|
|
"天[培梧]步危": "天棓步危",
|
2023-08-22 19:00:45 +00:00
|
|
|
"云[摘销锅]?逐步离": "云镝逐步离",
|
2023-08-10 09:12:17 +00:00
|
|
|
"制桑": "制穹桑",
|
2023-10-23 16:22:28 +00:00
|
|
|
"乌号[綦基纂]*箭?": "乌号綦箭",
|
2023-10-07 13:52:41 +00:00
|
|
|
"流岚追摩?物": "流岚追孽物",
|
2023-08-10 09:12:17 +00:00
|
|
|
"特月": "狩月",
|
2023-09-10 16:38:32 +00:00
|
|
|
"彤弓素.*": "彤弓素矰",
|
2023-08-11 09:35:57 +00:00
|
|
|
"白决射御": "白矢决射御",
|
2023-08-10 09:12:17 +00:00
|
|
|
"苦表": "苦衷",
|
2023-10-07 13:52:41 +00:00
|
|
|
"[沦沧][決]?肌髓": "沦浃肌髓",
|
2023-08-10 09:12:17 +00:00
|
|
|
"进发": "迸发",
|
|
|
|
"永缩体": "永坍缩体",
|
2023-10-20 18:06:23 +00:00
|
|
|
"完美体验:[绒]?默": "完美体验:缄默",
|
2023-10-07 13:52:41 +00:00
|
|
|
"[涯]?灭回归不等式": "湮灭回归不等式",
|
2023-08-12 17:04:54 +00:00
|
|
|
r".*灾$": "禳灾",
|
|
|
|
"虚安供品": "虚妄供品",
|
|
|
|
"原初的苦$": "原初的苦衷",
|
2023-10-07 13:52:41 +00:00
|
|
|
"厌离邪[移]?苦": "厌离邪秽苦",
|
2023-08-22 19:00:45 +00:00
|
|
|
r".*繁.*": "葳蕤繁祉,延彼遐龄",
|
2023-10-20 18:06:23 +00:00
|
|
|
"回馈底护": "回馈庇护",
|
2023-10-23 16:22:28 +00:00
|
|
|
"[范茫]+白夜": "茫茫白夜",
|
2024-01-06 19:49:01 +00:00
|
|
|
"阅下": "阈下",
|
2024-06-04 08:13:52 +00:00
|
|
|
'未日': '末日',
|
|
|
|
'尚末': '尚未',
|
2024-07-05 18:04:45 +00:00
|
|
|
'进裂晶格': '迸裂晶格',
|
2023-08-10 09:12:17 +00:00
|
|
|
}
|
2023-10-04 21:09:50 +00:00
|
|
|
elif self.lang == 'en':
|
|
|
|
replace_pattern_dict = {
|
|
|
|
"RestIin": "Restin",
|
|
|
|
}
|
2023-10-20 18:06:23 +00:00
|
|
|
else:
|
|
|
|
replace_pattern_dict = {}
|
2023-10-07 13:52:41 +00:00
|
|
|
for pat, replace in replace_pattern_dict.items():
|
2023-10-07 15:21:26 +00:00
|
|
|
result = re.sub(pat, replace, result)
|
|
|
|
return result
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
|
2023-08-14 19:35:15 +00:00
|
|
|
class RogueBlessingSelector(RogueSelector):
|
2023-08-12 17:04:54 +00:00
|
|
|
"""
|
|
|
|
Usage:
|
|
|
|
self = RogueBlessingSelector('alas')
|
|
|
|
self.device.screenshot()
|
|
|
|
self.recognize_and_select()
|
|
|
|
"""
|
|
|
|
|
2023-08-10 17:16:25 +00:00
|
|
|
def get_blessing_count(self) -> int:
|
|
|
|
"""
|
|
|
|
Returns: The number of blessing
|
|
|
|
"""
|
2023-08-14 19:35:15 +00:00
|
|
|
if not self.main.image_color_count(BOTTOM_WHITE_BAR.area, color=(255, 255, 255), count=5000):
|
2023-08-12 17:04:54 +00:00
|
|
|
return 0
|
2023-08-14 19:35:15 +00:00
|
|
|
color = get_color(self.main.device.image, BOTTOM_WHITE_BAR.area)
|
2023-08-10 17:16:25 +00:00
|
|
|
mean = np.mean(color)
|
|
|
|
return int(mean // 60) # the magic number that maps blessing num with mean_color
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
def recognition(self):
|
2023-08-18 12:22:46 +00:00
|
|
|
def not_enhancement_keyword(keyword):
|
|
|
|
return keyword != KEYWORDS_ROGUE_ENHANCEMENT.Already_Enhanced
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
self.ocr_results = []
|
2023-08-20 14:43:07 +00:00
|
|
|
self._wait_until_blessing_loaded()
|
2023-08-10 09:12:17 +00:00
|
|
|
ocr = RogueBuffOcr(OCR_ROGUE_BUFF)
|
2023-08-18 12:22:46 +00:00
|
|
|
results = ocr.matched_ocr(self.main.device.image,
|
|
|
|
[RogueBlessing, RogueResonance, RogueEnhancement])
|
|
|
|
|
|
|
|
enhanced_blessing = [result for result, _ in
|
|
|
|
split_and_pair_buttons(results, split_func=not_enhancement_keyword,
|
|
|
|
relative_area=(-300, -720, 0, 0))]
|
|
|
|
results = [result for result in results if not_enhancement_keyword(result)]
|
2023-08-10 17:16:25 +00:00
|
|
|
blessing_count = self.get_blessing_count()
|
|
|
|
if blessing_count != len(results):
|
|
|
|
logger.warning(f"The OCR result does not match the blessing count. "
|
|
|
|
f"Expect {blessing_count}, but recognized {len(results)} only.")
|
2023-08-18 12:22:46 +00:00
|
|
|
for result in results:
|
|
|
|
if result in enhanced_blessing:
|
|
|
|
result.matched_keyword.enhancement = KEYWORDS_ROGUE_ENHANCEMENT.Already_Enhanced.enhancement_keyword
|
2023-08-12 17:04:54 +00:00
|
|
|
self.ocr_results = results
|
2023-08-10 09:12:17 +00:00
|
|
|
return results
|
|
|
|
|
2023-11-16 13:50:56 +00:00
|
|
|
def _blessing_confirm_appear(self) -> bool:
|
|
|
|
return self.main.image_color_count(BLESSING_CONFIRM, color=(223, 223, 223), threshold=221, count=500)
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
def ui_select(self, target: OcrResultButton | None, skip_first_screenshot=True):
|
2023-08-10 09:12:17 +00:00
|
|
|
"""
|
|
|
|
Select buff once. Multiple calls needed if there's more than one time to choose
|
|
|
|
It might occur that all listed blessings are not recognized
|
|
|
|
So this method provides a hard code way to choose one, which fit in case when blessing num is 1-3
|
|
|
|
"""
|
|
|
|
|
|
|
|
def is_select_blessing_complete():
|
|
|
|
"""
|
|
|
|
Case 1: back to main page
|
|
|
|
Case 2: choose curio
|
|
|
|
Case 3: another choose blessings, but no blessing is selected when the new selection page loaded
|
2023-08-14 20:16:31 +00:00
|
|
|
Case 4: event ui
|
2023-08-10 09:12:17 +00:00
|
|
|
"""
|
2023-08-20 16:03:08 +00:00
|
|
|
if self.main.is_in_main():
|
|
|
|
logger.info("Main page checked")
|
|
|
|
return True
|
|
|
|
if self.main.is_page_choose_curio():
|
|
|
|
logger.info("Choose curio page checked")
|
|
|
|
return True
|
2023-11-17 13:51:12 +00:00
|
|
|
if self.main.is_page_choose_blessing() and not self._blessing_confirm_appear():
|
2023-08-20 16:03:08 +00:00
|
|
|
logger.info("A new choose blessing page checked")
|
|
|
|
return True
|
|
|
|
if self.main.is_page_event():
|
|
|
|
logger.info("Event page checked")
|
|
|
|
return True
|
|
|
|
return False
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
interval = Timer(1)
|
2023-08-12 17:04:54 +00:00
|
|
|
enforce = False
|
|
|
|
|
|
|
|
if not target:
|
2023-08-10 09:12:17 +00:00
|
|
|
enforce = True
|
|
|
|
|
|
|
|
# start -> selected
|
2023-11-16 13:50:56 +00:00
|
|
|
clicked = 0
|
2023-08-10 09:12:17 +00:00
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.screenshot()
|
2023-08-10 09:12:17 +00:00
|
|
|
|
2024-05-06 13:36:29 +00:00
|
|
|
if self.main.handle_blessing_popup():
|
|
|
|
logger.warning('Mistakenly recognized current page as blessing choosing page, quit')
|
|
|
|
return
|
2023-08-20 15:53:25 +00:00
|
|
|
if is_card_selected(self.main, target, confirm_button=BLESSING_CONFIRM):
|
2023-08-10 09:12:17 +00:00
|
|
|
if enforce:
|
|
|
|
logger.info("Buff selected (enforce)")
|
|
|
|
else:
|
2023-08-12 17:04:54 +00:00
|
|
|
logger.info(f"Buff {target} selected")
|
2023-08-10 09:12:17 +00:00
|
|
|
break
|
2023-11-16 13:50:56 +00:00
|
|
|
# A game bug, blessing card does not appear to be selected but actually being selected
|
|
|
|
if clicked >= 3 and self._blessing_confirm_appear():
|
|
|
|
logger.warning('blessing card does not appear to be selected but actually being selected')
|
|
|
|
if enforce:
|
|
|
|
logger.info("Buff selected (enforce)")
|
|
|
|
else:
|
|
|
|
logger.info(f"Buff {target} selected")
|
|
|
|
break
|
2023-08-10 09:12:17 +00:00
|
|
|
if interval.reached():
|
|
|
|
if enforce:
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.click(BLESSING_ENFORCE)
|
2023-08-10 09:12:17 +00:00
|
|
|
else:
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.click(target)
|
2023-08-10 09:12:17 +00:00
|
|
|
interval.reset()
|
2023-11-16 13:50:56 +00:00
|
|
|
clicked += 1
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
skip_first_screenshot = True
|
2023-09-10 16:37:46 +00:00
|
|
|
# Avoid double-clicking
|
|
|
|
interval = Timer(3, count=6)
|
2023-08-10 09:12:17 +00:00
|
|
|
# selected -> confirm
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.screenshot()
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
if is_select_blessing_complete():
|
2023-08-20 16:03:08 +00:00
|
|
|
logger.info("Select blessing complete")
|
2023-08-10 09:12:17 +00:00
|
|
|
break
|
2023-10-19 02:06:31 +00:00
|
|
|
if self.main.handle_popup_confirm():
|
|
|
|
continue
|
2023-08-10 09:12:17 +00:00
|
|
|
if interval.reached():
|
2023-08-20 15:53:25 +00:00
|
|
|
self.main.device.click(BLESSING_CONFIRM)
|
2023-08-10 09:12:17 +00:00
|
|
|
interval.reset()
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
def _get_reset_count(self):
|
2023-08-14 19:35:15 +00:00
|
|
|
current, _, _ = DigitCounter(OCR_RESET_COUNT).ocr_single_line(self.main.device.image)
|
2023-08-10 09:12:17 +00:00
|
|
|
return current
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
def _wait_until_blessing_loaded(self, timer=Timer(0.3, count=1), timeout=Timer(5, count=10)):
|
2023-08-11 09:35:57 +00:00
|
|
|
timer.reset()
|
|
|
|
timeout.reset()
|
|
|
|
previous_count = self.get_blessing_count()
|
2023-08-10 09:12:17 +00:00
|
|
|
while 1:
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.screenshot()
|
2023-08-11 09:35:57 +00:00
|
|
|
blessing_count = self.get_blessing_count()
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
if timeout.reached():
|
|
|
|
logger.warning('Wait blessing page loaded timeout')
|
2023-08-11 09:35:57 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
if previous_count and previous_count == blessing_count:
|
|
|
|
if timer.reached():
|
|
|
|
logger.info('Blessing page stabled')
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
previous_count = blessing_count
|
|
|
|
timer.reset()
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
def reset_blessing_list(self, skip_first_screenshot=True):
|
2023-08-14 19:35:15 +00:00
|
|
|
if not self.main.is_page_choose_blessing():
|
2023-08-10 09:12:17 +00:00
|
|
|
return False
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
reset_count = self._get_reset_count()
|
2023-08-10 09:12:17 +00:00
|
|
|
if not reset_count:
|
2023-08-12 17:04:54 +00:00
|
|
|
logger.info("Does not have enough reset count")
|
|
|
|
return False
|
|
|
|
|
2023-08-14 19:35:15 +00:00
|
|
|
reset_cost = Digit(OCR_RESET_COST).ocr_single_line(self.main.device.image)
|
|
|
|
if reset_cost > self.main.cosmic_fragment:
|
2023-08-12 17:04:54 +00:00
|
|
|
logger.info("Does not have enough cosmic fragment")
|
2023-08-10 09:12:17 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
interval = Timer(1)
|
|
|
|
while 1:
|
|
|
|
if skip_first_screenshot:
|
|
|
|
skip_first_screenshot = False
|
|
|
|
else:
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.screenshot()
|
2023-08-10 09:12:17 +00:00
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
new_count = self._get_reset_count()
|
2023-08-10 09:12:17 +00:00
|
|
|
|
|
|
|
if reset_count - new_count == 1:
|
|
|
|
logger.info("Reset once")
|
|
|
|
break
|
|
|
|
if interval.reached():
|
2023-08-14 19:35:15 +00:00
|
|
|
self.main.device.click(BLESSING_RESET)
|
2023-08-10 09:12:17 +00:00
|
|
|
interval.reset()
|
|
|
|
return True
|
|
|
|
|
2023-08-12 17:04:54 +00:00
|
|
|
def load_filter(self):
|
2023-09-10 16:38:32 +00:00
|
|
|
try:
|
|
|
|
keyword = self.ocr_results[0].matched_keyword
|
|
|
|
except IndexError:
|
|
|
|
return
|
2023-08-22 19:00:45 +00:00
|
|
|
if not isinstance(keyword, (RogueBlessing, RogueResonance)):
|
|
|
|
return
|
|
|
|
filter_configs = {
|
|
|
|
RogueBlessing: {
|
|
|
|
"filter_": BLESSING_FILTER,
|
2023-09-10 15:48:24 +00:00
|
|
|
"preset_config": self.main.config.RogueBlessing_PresetBlessingFilter,
|
2023-12-18 15:30:48 +00:00
|
|
|
"strategy_config": self.main.config.RogueBlessing_SelectionStrategy,
|
2023-08-22 19:00:45 +00:00
|
|
|
"preset_values": {
|
2023-12-20 16:19:10 +00:00
|
|
|
'preset': BLESSING_PRESET[self.main.config.RogueWorld_Path],
|
2023-09-10 15:48:24 +00:00
|
|
|
'custom': self.main.config.RogueBlessing_CustomBlessingFilter
|
2023-08-22 19:00:45 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
RogueResonance: {
|
|
|
|
"filter_": RESONANCE_FILTER,
|
2023-12-18 15:30:48 +00:00
|
|
|
"preset_config": self.main.config.RogueBlessing_PresetResonanceFilter,
|
|
|
|
"strategy_config": self.main.config.RogueBlessing_SelectionStrategy,
|
2023-08-22 19:00:45 +00:00
|
|
|
"preset_values": {
|
2023-12-20 16:19:10 +00:00
|
|
|
'preset': RESONANCE_PRESET[self.main.config.RogueWorld_Path],
|
2024-04-22 15:17:55 +00:00
|
|
|
'custom': self.main.config.RogueBlessing_CustomResonanceFilter,
|
2023-08-22 19:00:45 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# preset
|
|
|
|
config = filter_configs[type(keyword)]
|
|
|
|
filter_ = config['filter_']
|
|
|
|
preset_config = config['preset_config']
|
|
|
|
preset_values = config['preset_values']
|
|
|
|
string = preset_values[preset_config]
|
|
|
|
string = parse_name(string)
|
|
|
|
|
|
|
|
# strategy
|
2023-10-20 15:19:37 +00:00
|
|
|
if not string.endswith('random'):
|
|
|
|
string += '> random'
|
2023-08-22 19:00:45 +00:00
|
|
|
strategy_config = config['strategy_config']
|
|
|
|
if strategy_config == 'unrecorded-first':
|
|
|
|
string = "unrecorded > " + string
|
|
|
|
if strategy_config == 'before-random':
|
|
|
|
string = string.replace('random', 'unrecorded > random')
|
|
|
|
|
|
|
|
filter_.load(string)
|
2023-08-12 17:04:54 +00:00
|
|
|
self.filter_ = filter_
|
|
|
|
|
|
|
|
def try_select(self, option: OcrResultButton | str):
|
|
|
|
if isinstance(option, str):
|
|
|
|
if option.lower() == 'reset':
|
|
|
|
if self.reset_blessing_list():
|
|
|
|
self.recognize_and_select()
|
|
|
|
return True
|
|
|
|
if option.lower() == 'random':
|
|
|
|
choose = np.random.choice(self.ocr_results)
|
|
|
|
self.ui_select(choose)
|
|
|
|
return True
|
2023-08-22 19:00:45 +00:00
|
|
|
if option.lower() == 'unrecorded':
|
|
|
|
for result in self.ocr_results:
|
|
|
|
if self.main.is_unrecorded(result, (0, -720, 300, 0)):
|
|
|
|
self.ui_select(result)
|
|
|
|
return True
|
|
|
|
return False
|
2023-08-12 17:04:54 +00:00
|
|
|
|
|
|
|
if isinstance(option, OcrResultButton):
|
|
|
|
self.ui_select(option)
|
|
|
|
return True
|
|
|
|
return False
|