Fix: Handle repeated words in OCR_WEEKLY_LIMIT (#554)

This commit is contained in:
LmeSzinc 2024-06-29 20:16:07 +08:00
parent bc4081a697
commit dc6bcf4a56
2 changed files with 19 additions and 2 deletions

View File

@ -355,7 +355,7 @@ class DigitCounter(Ocr):
Do OCR on a counter, such as `14/15`, and returns 14, 1, 15
Returns:
int:
int, int, int: current, remain, total
"""
result = super().after_process(result)
logger.attr(name=self.name, text=str(result))

View File

@ -8,6 +8,23 @@ from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_NAV, KEYWORDS_D
from tasks.dungeon.ui import DUNGEON_LIST
class OcrWeeklyLimit(DigitCounter):
def format_result(self, result) -> tuple[int, int, int]:
current, remain, total = super().format_result(result)
# [OCR_WEEKLY_LIMIT format] 3/3 -> (33, -30, 3)
if current == 11:
current = 1
remain = total - current
if current == 22:
current = 2
remain = total - current
if current == 33:
current = 3
remain = total - current
return current, remain, total
class WeeklyDungeon(Dungeon):
def require_compulsory_support(self) -> bool:
return False
@ -31,7 +48,7 @@ class WeeklyDungeon(Dungeon):
Pages:
in: page_guide, Survival_Index, KEYWORDS_DUNGEON_NAV.Echo_of_War
"""
ocr = DigitCounter(OCR_WEEKLY_LIMIT)
ocr = OcrWeeklyLimit(OCR_WEEKLY_LIMIT)
current, _, _ = ocr.ocr_single_line(self.device.image)
total = self.config.stored.EchoOfWar.FIXED_TOTAL
if current <= total: