diff --git a/assets/share/item/relics/ORDER_ASCENDING.png b/assets/share/item/relics/ORDER_ASCENDING.png new file mode 100644 index 000000000..5f3495c42 Binary files /dev/null and b/assets/share/item/relics/ORDER_ASCENDING.png differ diff --git a/assets/share/item/relics/REVERSE_ORDER.png b/assets/share/item/relics/ORDER_DESCENDING.png similarity index 100% rename from assets/share/item/relics/REVERSE_ORDER.png rename to assets/share/item/relics/ORDER_DESCENDING.png diff --git a/assets/share/item/relics/SALVAGE.SEARCH.png b/assets/share/item/relics/SALVAGE.SEARCH.png new file mode 100644 index 000000000..7ec63f074 Binary files /dev/null and b/assets/share/item/relics/SALVAGE.SEARCH.png differ diff --git a/tasks/item/assets/assets_item_relics.py b/tasks/item/assets/assets_item_relics.py index ec21d95ac..4a74732bc 100644 --- a/tasks/item/assets/assets_item_relics.py +++ b/tasks/item/assets/assets_item_relics.py @@ -23,10 +23,20 @@ GOTO_SALVAGE = ButtonWrapper( button=(668, 652, 690, 674), ), ) -REVERSE_ORDER = ButtonWrapper( - name='REVERSE_ORDER', +ORDER_ASCENDING = ButtonWrapper( + name='ORDER_ASCENDING', share=Button( - file='./assets/share/item/relics/REVERSE_ORDER.png', + file='./assets/share/item/relics/ORDER_ASCENDING.png', + area=(720, 649, 737, 667), + search=(700, 629, 757, 687), + color=(176, 176, 178), + button=(720, 649, 737, 667), + ), +) +ORDER_DESCENDING = ButtonWrapper( + name='ORDER_DESCENDING', + share=Button( + file='./assets/share/item/relics/ORDER_DESCENDING.png', area=(720, 649, 738, 667), search=(700, 629, 758, 687), color=(179, 180, 180), @@ -38,7 +48,7 @@ SALVAGE = ButtonWrapper( share=Button( file='./assets/share/item/relics/SALVAGE.png', area=(1038, 646, 1062, 670), - search=(1018, 626, 1082, 690), + search=(936, 642, 1213, 675), color=(122, 115, 98), button=(1038, 646, 1062, 670), ), diff --git a/tasks/item/relics.py b/tasks/item/relics.py index 9ea73e688..0f10852a2 100644 --- a/tasks/item/relics.py +++ b/tasks/item/relics.py @@ -1,39 +1,42 @@ from module.base.timer import Timer from module.logger import logger from tasks.base.assets.assets_base_page import CLOSE -from tasks.base.assets.assets_base_popup import CONFIRM_POPUP +from tasks.base.assets.assets_base_popup import CONFIRM_POPUP, GET_REWARD from tasks.item.assets.assets_item_relics import * from tasks.item.keywords import KEYWORD_ITEM_TAB from tasks.item.ui import ItemUI class RelicsUI(ItemUI): + def _is_in_salvage(self) -> bool: + return self.appear(ORDER_ASCENDING) or self.appear(ORDER_DESCENDING) + def salvage_relic(self, skip_first_screenshot=True) -> bool: logger.hr('Salvage Relic', level=2) self.item_goto(KEYWORD_ITEM_TAB.Relics, wait_until_stable=False) - interval = Timer(1) while 1: # relic tab -> salvage if skip_first_screenshot: skip_first_screenshot = False else: self.device.screenshot() - if self.appear(REVERSE_ORDER): + if self._is_in_salvage(): break - if self.appear_then_click(GOTO_SALVAGE): + if self.appear_then_click(GOTO_SALVAGE, interval=2): continue skip_first_screenshot = True + interval = Timer(1) while 1: # salvage -> first relic selected if skip_first_screenshot: skip_first_screenshot = False else: self.device.screenshot() - if self.appear_then_click(REVERSE_ORDER): # this should judge before break condition - continue - if self.appear(SALVAGE): + if SALVAGE.match_template_color(self.device.image): break + if self.appear_then_click(ORDER_DESCENDING, interval=2): + continue if interval.reached() and self.image_color_count(FIRST_RELIC, (233, 192, 108)): self.device.click(FIRST_RELIC) interval.reset() @@ -46,15 +49,16 @@ class RelicsUI(ItemUI): else: self.device.screenshot() - if self.handle_reward(): + if self.appear(GET_REWARD): logger.info("Relic salvaged") break - if self.appear_then_click(SALVAGE): + if self.appear_then_click(SALVAGE, interval=2): continue - if self.appear_then_click(CONFIRM_POPUP): + if self.appear_then_click(CONFIRM_POPUP, interval=2): continue skip_first_screenshot = True + interval = Timer(1) while 1: # rewards claimed -> relic tab page if skip_first_screenshot: skip_first_screenshot = False @@ -64,6 +68,11 @@ class RelicsUI(ItemUI): if self.appear(GOTO_SALVAGE): logger.info("Salvage page exited") break - if self.appear_then_click(CLOSE, interval=1): + if self.handle_reward(interval=2): + continue + if interval.reached() and self._is_in_salvage(): + logger.info(f'_is_in_salvage -> {CLOSE}') + self.device.click(CLOSE) + interval.reset() continue return True