mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: Search for double remains
This commit is contained in:
parent
b1c3c0caef
commit
4e779f5dda
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
BIN
assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png
Normal file
BIN
assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
@ -35,18 +35,11 @@ OCR_DOUBLE_EVENT_REMAIN = ButtonWrapper(
|
||||
)
|
||||
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT = ButtonWrapper(
|
||||
name='OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT',
|
||||
cn=Button(
|
||||
file='./assets/cn/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png',
|
||||
area=(872, 515, 1192, 538),
|
||||
search=(852, 495, 1212, 558),
|
||||
color=(171, 139, 76),
|
||||
button=(872, 515, 1192, 538),
|
||||
),
|
||||
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),
|
||||
share=Button(
|
||||
file='./assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png',
|
||||
area=(799, 460, 1268, 626),
|
||||
search=(779, 440, 1280, 646),
|
||||
color=(59, 53, 48),
|
||||
button=(799, 460, 1268, 626),
|
||||
),
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ class Dungeon(DungeonUI, DungeonEvent, Combat):
|
||||
if (dungeon.is_Calyx_Golden or dungeon.is_Calyx_Crimson) and \
|
||||
self.running_double and self.config.stored.DungeonDouble.calyx > 0:
|
||||
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
|
||||
wave_limit = calyx
|
||||
if calyx == 0:
|
||||
@ -71,7 +71,7 @@ class Dungeon(DungeonUI, DungeonEvent, Combat):
|
||||
if dungeon.is_Cavern_of_Corrosion and self.running_double and \
|
||||
self.config.stored.DungeonDouble.relic > 0:
|
||||
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
|
||||
wave_limit = relic
|
||||
if relic == 0:
|
||||
|
@ -45,14 +45,13 @@ class DungeonEvent(UI):
|
||||
|
||||
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:
|
||||
in: COMBAT_PREPARE
|
||||
"""
|
||||
has = self.image_color_count(
|
||||
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT,
|
||||
color=(252, 209, 123),
|
||||
threshold=195, count=1000
|
||||
color=(231, 188, 103),
|
||||
threshold=240, count=1000
|
||||
)
|
||||
logger.attr('Double event at combat', has)
|
||||
return has
|
||||
@ -74,14 +73,23 @@ class DungeonEvent(UI):
|
||||
logger.attr('Double event remain', remain)
|
||||
return remain
|
||||
|
||||
def get_double_event_remain_at_combat(self) -> int:
|
||||
def get_double_event_remain_at_combat(self) -> int | None:
|
||||
"""
|
||||
Pages:
|
||||
in: COMBAT_PREPARE
|
||||
"""
|
||||
remain = 0
|
||||
if self.has_double_event_at_combat():
|
||||
remain = self._get_double_event_remain(
|
||||
OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT)
|
||||
logger.attr('Double event remain at combat', remain)
|
||||
return remain
|
||||
if not self.has_double_event_at_combat():
|
||||
logger.attr('Double event remain at combat', 0)
|
||||
return 0
|
||||
|
||||
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)
|
||||
return remain
|
||||
logger.warning('Double event appears but failed to get remain')
|
||||
logger.attr('Double event remain at combat', None)
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user