diff --git a/assets/cn/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png b/assets/cn/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png deleted file mode 100644 index 5bac51466..000000000 Binary files a/assets/cn/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png and /dev/null differ diff --git a/assets/en/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png b/assets/en/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png deleted file mode 100644 index 22ddc015d..000000000 Binary files a/assets/en/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png and /dev/null differ diff --git a/assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png b/assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png new file mode 100644 index 000000000..84abdea5c Binary files /dev/null and b/assets/share/dungeon/event/OCR_DOUBLE_EVENT_REMAIN_AT_COMBAT.png differ diff --git a/tasks/dungeon/assets/assets_dungeon_event.py b/tasks/dungeon/assets/assets_dungeon_event.py index 90e6f030f..f3e6af6a0 100644 --- a/tasks/dungeon/assets/assets_dungeon_event.py +++ b/tasks/dungeon/assets/assets_dungeon_event.py @@ -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), ), ) diff --git a/tasks/dungeon/dungeon.py b/tasks/dungeon/dungeon.py index c57c7ef89..9abb08353 100644 --- a/tasks/dungeon/dungeon.py +++ b/tasks/dungeon/dungeon.py @@ -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: diff --git a/tasks/dungeon/event.py b/tasks/dungeon/event.py index b6bf3560c..2afef0e49 100644 --- a/tasks/dungeon/event.py +++ b/tasks/dungeon/event.py @@ -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