Fix: Search for double remains

This commit is contained in:
LmeSzinc 2023-11-03 14:02:54 +08:00
parent 9d282b23b7
commit 145a2862b8
6 changed files with 26 additions and 25 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@ -35,18 +35,11 @@ OCR_DOUBLE_EVENT_REMAIN = ButtonWrapper(
) )
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT = ButtonWrapper( OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT = ButtonWrapper(
name='OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT', name='OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT',
cn=Button( share=Button(
file='./assets/cn/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png', file='./assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png',
area=(872, 515, 1192, 538), area=(799, 460, 1268, 626),
search=(852, 495, 1212, 558), search=(779, 440, 1280, 646),
color=(171, 139, 76), color=(59, 53, 48),
button=(872, 515, 1192, 538), button=(799, 460, 1268, 626),
),
en=Button(
file='./assets/en/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png',
area=(814, 510, 1246, 530),
search=(794, 490, 1266, 550),
color=(194, 158, 86),
button=(814, 510, 1246, 530),
), ),
) )

View File

@ -63,7 +63,7 @@ class Dungeon(DungeonUI, DungeonEvent, Combat):
if (dungeon.is_Calyx_Golden or dungeon.is_Calyx_Crimson) and \ if (dungeon.is_Calyx_Golden or dungeon.is_Calyx_Crimson) and \
self.running_double and self.config.stored.DungeonDouble.calyx > 0: self.running_double and self.config.stored.DungeonDouble.calyx > 0:
calyx = self.get_double_event_remain_at_combat() calyx = self.get_double_event_remain_at_combat()
if calyx < self.config.stored.DungeonDouble.calyx: if calyx is not None and calyx < self.config.stored.DungeonDouble.calyx:
self.config.stored.DungeonDouble.calyx = calyx self.config.stored.DungeonDouble.calyx = calyx
wave_limit = calyx wave_limit = calyx
if calyx == 0: if calyx == 0:
@ -71,7 +71,7 @@ class Dungeon(DungeonUI, DungeonEvent, Combat):
if dungeon.is_Cavern_of_Corrosion and self.running_double and \ if dungeon.is_Cavern_of_Corrosion and self.running_double and \
self.config.stored.DungeonDouble.relic > 0: self.config.stored.DungeonDouble.relic > 0:
relic = self.get_double_event_remain_at_combat() relic = self.get_double_event_remain_at_combat()
if relic < self.config.stored.DungeonDouble.relic: if relic is not None and relic < self.config.stored.DungeonDouble.relic:
self.config.stored.DungeonDouble.relic = relic self.config.stored.DungeonDouble.relic = relic
wave_limit = relic wave_limit = relic
if relic == 0: if relic == 0:

View File

@ -45,14 +45,13 @@ class DungeonEvent(UI):
def has_double_event_at_combat(self) -> bool: def has_double_event_at_combat(self) -> bool:
""" """
TODO: OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT of relic may be different from that of calyx
Pages: Pages:
in: COMBAT_PREPARE in: COMBAT_PREPARE
""" """
has = self.image_color_count( has = self.image_color_count(
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT, OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT,
color=(252, 209, 123), color=(231, 188, 103),
threshold=195, count=1000 threshold=240, count=1000
) )
logger.attr('Double event at combat', has) logger.attr('Double event at combat', has)
return has return has
@ -74,14 +73,23 @@ class DungeonEvent(UI):
logger.attr('Double event remain', remain) logger.attr('Double event remain', remain)
return remain return remain
def get_double_event_remain_at_combat(self) -> int: def get_double_event_remain_at_combat(self) -> int | None:
""" """
Pages: Pages:
in: COMBAT_PREPARE in: COMBAT_PREPARE
""" """
remain = 0 if not self.has_double_event_at_combat():
if self.has_double_event_at_combat(): logger.attr('Double event remain at combat', 0)
remain = self._get_double_event_remain( return 0
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT)
ocr = DoubleEventOcr(OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT)
for row in ocr.detect_and_ocr(self.device.image):
if '/' not in row.ocr_text:
continue
remain, _, total = ocr.format_result(row.ocr_text)
if total in [3, 12]:
logger.attr('Double event remain at combat', remain) logger.attr('Double event remain at combat', remain)
return remain return remain
logger.warning('Double event appears but failed to get remain')
logger.attr('Double event remain at combat', None)
return None