1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2025-12-16 22:05:12 +00:00

refactor(sweep): use regex for index match

This commit is contained in:
YoursFunny 2023-11-29 13:10:47 +08:00
parent 32cee3f6b5
commit 257e092936
Signed by: YoursFunny
GPG Key ID: 207EDC3CD5B40F9C

View File

@ -1,3 +1,5 @@
import re
import numpy as np
from module.base.base import ModuleBase
@ -50,7 +52,8 @@ class StageList:
def load_stage_indexes(self, main: ModuleBase):
self.current_indexes = list(
filter(lambda x: x.ocr_text.isdigit(), self.index_ocr.detect_and_ocr(main.device.image))
filter(lambda x: re.match(r'^\d{1,2}-?\d?$', x.ocr_text),
self.index_ocr.detect_and_ocr(main.device.image))
)
if not self.current_indexes:
logger.warning(f'No valid index in {self.index_ocr.name}')