diff --git a/assets/share/daily/synthesize_material/GLIMMERING_CORE.SEARCH.png b/assets/share/daily/synthesize_material/GLIMMERING_CORE.SEARCH.png new file mode 100644 index 000000000..3825942bc Binary files /dev/null and b/assets/share/daily/synthesize_material/GLIMMERING_CORE.SEARCH.png differ diff --git a/assets/share/daily/synthesize_material/GLIMMERING_CORE.png b/assets/share/daily/synthesize_material/GLIMMERING_CORE.png new file mode 100644 index 000000000..765306d4b Binary files /dev/null and b/assets/share/daily/synthesize_material/GLIMMERING_CORE.png differ diff --git a/assets/share/daily/synthesize_material/GLIMMERING_CORE_CHECK.png b/assets/share/daily/synthesize_material/GLIMMERING_CORE_CHECK.png new file mode 100644 index 000000000..52798b7de Binary files /dev/null and b/assets/share/daily/synthesize_material/GLIMMERING_CORE_CHECK.png differ diff --git a/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.SEARCH.png b/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.SEARCH.png new file mode 100644 index 000000000..3825942bc Binary files /dev/null and b/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.SEARCH.png differ diff --git a/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.png b/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.png new file mode 100644 index 000000000..5b0d07a9d Binary files /dev/null and b/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.png differ diff --git a/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA_CHECK.png b/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA_CHECK.png new file mode 100644 index 000000000..b42cfb19f Binary files /dev/null and b/assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA_CHECK.png differ diff --git a/assets/share/daily/synthesize_material/SYNTHESIZE_GOTO_MATERIAL.png b/assets/share/daily/synthesize_material/SYNTHESIZE_GOTO_MATERIAL.png new file mode 100644 index 000000000..7eb88624f Binary files /dev/null and b/assets/share/daily/synthesize_material/SYNTHESIZE_GOTO_MATERIAL.png differ diff --git a/assets/share/daily/synthesize_material/SYNTHESIZE_MATERIAL_CHECK.png b/assets/share/daily/synthesize_material/SYNTHESIZE_MATERIAL_CHECK.png new file mode 100644 index 000000000..f279ed2c4 Binary files /dev/null and b/assets/share/daily/synthesize_material/SYNTHESIZE_MATERIAL_CHECK.png differ diff --git a/assets/share/daily/synthesize_material/USURPERS_SCHEME.SEARCH.png b/assets/share/daily/synthesize_material/USURPERS_SCHEME.SEARCH.png new file mode 100644 index 000000000..3825942bc Binary files /dev/null and b/assets/share/daily/synthesize_material/USURPERS_SCHEME.SEARCH.png differ diff --git a/assets/share/daily/synthesize_material/USURPERS_SCHEME.png b/assets/share/daily/synthesize_material/USURPERS_SCHEME.png new file mode 100644 index 000000000..5d78a22f2 Binary files /dev/null and b/assets/share/daily/synthesize_material/USURPERS_SCHEME.png differ diff --git a/assets/share/daily/synthesize_material/USURPERS_SCHEME_CHECK.png b/assets/share/daily/synthesize_material/USURPERS_SCHEME_CHECK.png new file mode 100644 index 000000000..81b2ad72a Binary files /dev/null and b/assets/share/daily/synthesize_material/USURPERS_SCHEME_CHECK.png differ diff --git a/tasks/daily/assets/assets_daily_synthesize_material.py b/tasks/daily/assets/assets_daily_synthesize_material.py new file mode 100644 index 000000000..16edc7e6a --- /dev/null +++ b/tasks/daily/assets/assets_daily_synthesize_material.py @@ -0,0 +1,85 @@ +from module.base.button import Button, ButtonWrapper + +# This file was auto-generated, do not modify it manually. To generate: +# ``` python -m dev_tools.button_extract ``` + +GLIMMERING_CORE = ButtonWrapper( + name='GLIMMERING_CORE', + share=Button( + file='./assets/share/daily/synthesize_material/GLIMMERING_CORE.png', + area=(352, 198, 416, 254), + search=(119, 84, 437, 573), + color=(81, 112, 165), + button=(352, 198, 416, 254), + ), +) +GLIMMERING_CORE_CHECK = ButtonWrapper( + name='GLIMMERING_CORE_CHECK', + share=Button( + file='./assets/share/daily/synthesize_material/GLIMMERING_CORE_CHECK.png', + area=(812, 209, 917, 281), + search=(792, 189, 937, 301), + color=(88, 112, 158), + button=(812, 209, 917, 281), + ), +) +SILVERMANE_INSIGNIA = ButtonWrapper( + name='SILVERMANE_INSIGNIA', + share=Button( + file='./assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA.png', + area=(145, 437, 207, 492), + search=(119, 84, 437, 573), + color=(98, 104, 129), + button=(145, 437, 207, 492), + ), +) +SILVERMANE_INSIGNIA_CHECK = ButtonWrapper( + name='SILVERMANE_INSIGNIA_CHECK', + share=Button( + file='./assets/share/daily/synthesize_material/SILVERMANE_INSIGNIA_CHECK.png', + area=(812, 203, 916, 281), + search=(792, 183, 936, 301), + color=(143, 119, 96), + button=(812, 203, 916, 281), + ), +) +SYNTHESIZE_GOTO_MATERIAL = ButtonWrapper( + name='SYNTHESIZE_GOTO_MATERIAL', + share=Button( + file='./assets/share/daily/synthesize_material/SYNTHESIZE_GOTO_MATERIAL.png', + area=(42, 190, 74, 230), + search=(22, 170, 94, 250), + color=(94, 95, 109), + button=(42, 190, 74, 230), + ), +) +SYNTHESIZE_MATERIAL_CHECK = ButtonWrapper( + name='SYNTHESIZE_MATERIAL_CHECK', + share=Button( + file='./assets/share/daily/synthesize_material/SYNTHESIZE_MATERIAL_CHECK.png', + area=(43, 189, 74, 229), + search=(23, 169, 94, 249), + color=(157, 159, 160), + button=(43, 189, 74, 229), + ), +) +USURPERS_SCHEME = ButtonWrapper( + name='USURPERS_SCHEME', + share=Button( + file='./assets/share/daily/synthesize_material/USURPERS_SCHEME.png', + area=(253, 318, 309, 373), + search=(119, 84, 437, 573), + color=(110, 120, 166), + button=(253, 318, 309, 373), + ), +) +USURPERS_SCHEME_CHECK = ButtonWrapper( + name='USURPERS_SCHEME_CHECK', + share=Button( + file='./assets/share/daily/synthesize_material/USURPERS_SCHEME_CHECK.png', + area=(819, 196, 912, 286), + search=(799, 176, 932, 306), + color=(141, 130, 149), + button=(819, 196, 912, 286), + ), +) diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index cabe29d82..d1ab63415 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -8,7 +8,7 @@ from tasks.daily.assets.assets_daily_reward import * from tasks.daily.camera import CameraUI from tasks.daily.consumable_usage import ConsumableUsageUI from tasks.daily.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST, KEYWORDS_DAILY_QUEST_STATE -from tasks.daily.synthesize import SynthesizeConsumablesUI +from tasks.daily.synthesize import SynthesizeConsumablesUI, SynthesizeMaterialUI from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB from tasks.dungeon.ui import DungeonUI @@ -178,8 +178,11 @@ class DailyQuestUI(DungeonUI): CameraUI(self.config, self.device).take_picture() done += 1 if KEYWORDS_DAILY_QUEST.Synthesize_Consumable_1_time in quests: - SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables() - done += 1 + if SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables(): + done += 1 + if KEYWORDS_DAILY_QUEST.Synthesize_material_1_time in quests: + if SynthesizeMaterialUI(self.config, self.device).synthesize_material(): + done += 1 if KEYWORDS_DAILY_QUEST.Use_Consumables_1_time in quests: if ConsumableUsageUI(self.config, self.device).use_consumable(): done += 1 diff --git a/tasks/daily/synthesize.py b/tasks/daily/synthesize.py index 1d7629c8c..62c55f8d1 100644 --- a/tasks/daily/synthesize.py +++ b/tasks/daily/synthesize.py @@ -7,9 +7,13 @@ from tasks.base.ui import UI from tasks.base.assets.assets_base_page import MENU_SCROLL from tasks.base.assets.assets_base_popup import CONFIRM_POPUP from tasks.daily.assets.assets_daily_synthesize_consumable import * +from tasks.daily.assets.assets_daily_synthesize_material import * class SynthesizeUI(UI): + # Default list of candidate items + default_candidate_items = {} + def ensure_scroll_top(self, page: str | Page, skip_first_screenshot=False) -> None: """ Args: @@ -57,54 +61,28 @@ class SynthesizeUI(UI): scroll.set_top(main=self) continue - -class SynthesizeConsumablesUI(SynthesizeUI): - def synthesize_consumables(self, target_button: ButtonWrapper = None, - target_button_check: ButtonWrapper = None) -> bool: - """ - Args: - target_button(ButtonWrapper): - target_button_check(ButtonWrapper): - - Returns: - bool: - - Examples: - self = SynthesizeConsumablesUI('alas') - self.device.screenshot() - result = self.synthesize_consumables() - """ - - logger.hr('Synthesize consumables', level=2) + def _ensure_synthesize_page(self): # If the current page is not the menu page, # the menu scroll bar must be at the top when opening the menu page from other page, # so first step is determine whether the scroll bar is at the top self.ensure_scroll_top(page=page_menu) - self.ui_ensure(page_synthesize) - self._switch_tag_to_consumables() - self.ensure_scroll_top(page=page_synthesize) - if self._search_and_select_items(target_button, target_button_check): - self._open_synthesize_popup() - self._synthesize_confirm() - self._back_to_synthesize_page() - return True - else: - return False - def _switch_tag_to_consumables(self, skip_first_screenshot=True): + # Default subpage is consumables + def _switch_subpage(self, skip_first_screenshot=True, subpage: ButtonWrapper = SYNTHESIZE_GOTO_CONSUMABLES, + subpage_check: ButtonWrapper = SYNTHESIZE_CONSUMABLES_CHECK): while 1: if skip_first_screenshot: skip_first_screenshot = False else: self.device.screenshot() - if self.appear(SYNTHESIZE_CONSUMABLES_CHECK): - logger.info('Synthesize consumables page appear') + if self.appear(subpage_check): + logger.info(f'Synthesize {subpage.name} subpage appear') break - # Switch to consumables subpage - if self.appear_then_click(SYNTHESIZE_GOTO_CONSUMABLES): - logger.info('Switch to consumables subpage') + # Switch to subpage + if self.appear_then_click(subpage): + logger.info(f'Switch to {subpage.name} subpage') continue def _select_items(self, candidate_items: dict[ButtonWrapper, ButtonWrapper]) -> bool: @@ -120,7 +98,7 @@ class SynthesizeConsumablesUI(SynthesizeUI): else: self.device.screenshot() if self.appear(item_check): - logger.info('Consumables that can be synthesized have been selected') + logger.info('Item that can be synthesized has been selected') return True if self.appear_then_click(item, similarity=0.7): continue @@ -129,11 +107,8 @@ class SynthesizeConsumablesUI(SynthesizeUI): def _search_and_select_items(self, target_button: ButtonWrapper = None, target_button_check: ButtonWrapper = None) -> bool: - candidate_items = {target_button: target_button_check} if target_button and target_button_check else { - CONSUMABLES_TRICK_SNACK: CONSUMABLES_TRICK_SNACK_CHECK, - CONSUMABLES_COMFORT_FOOD: CONSUMABLES_COMFORT_FOOD_CHECK, - CONSUMABLES_SIMPLE_AED: CONSUMABLES_SIMPLE_AED_CHECK - } + candidate_items = {target_button: target_button_check} if target_button and target_button_check \ + else self.__class__.default_candidate_items # Search target button from top to bottom scroll = Scroll(SYNTHESIZE_SCROLL.button, color=(210, 210, 210), name=SYNTHESIZE_SCROLL.name) @@ -197,10 +172,81 @@ class SynthesizeConsumablesUI(SynthesizeUI): else: self.device.screenshot() - if self.appear(SYNTHESIZE_CONSUMABLES_CHECK): + if self.appear(SYNTHESIZE_CHECK): logger.info('Synthesize consumables page appear') break # Go back to the previous page if self.appear_then_click(GET_REWARD): - logger.info('Click on the blank space to back to the synthesize consumables page') + logger.info('Click on the blank space to back to synthesize page') continue + + def _synthesize(self, target_button: ButtonWrapper = None, + target_button_check: ButtonWrapper = None) -> bool: + self.ensure_scroll_top(page=page_synthesize) + if self._search_and_select_items(target_button, target_button_check): + self._open_synthesize_popup() + self._synthesize_confirm() + self._back_to_synthesize_page() + return True + else: + return False + + +class SynthesizeConsumablesUI(SynthesizeUI): + # Selected three items that are easiest to obtain their synthetic materials + default_candidate_items = { + CONSUMABLES_TRICK_SNACK: CONSUMABLES_TRICK_SNACK_CHECK, + CONSUMABLES_COMFORT_FOOD: CONSUMABLES_COMFORT_FOOD_CHECK, + CONSUMABLES_SIMPLE_AED: CONSUMABLES_SIMPLE_AED_CHECK + } + + def synthesize_consumables(self, target_button: ButtonWrapper = None, + target_button_check: ButtonWrapper = None) -> bool: + """ + Args: + target_button(ButtonWrapper): + target_button_check(ButtonWrapper): + + Returns: + bool: + + Examples: + self = SynthesizeConsumablesUI('alas') + self.device.screenshot() + result = self.synthesize_consumables() + """ + + logger.hr('Synthesize consumables', level=2) + self._ensure_synthesize_page() + self._switch_subpage(subpage=SYNTHESIZE_GOTO_CONSUMABLES, subpage_check=SYNTHESIZE_CONSUMABLES_CHECK) + return self._synthesize(target_button, target_button_check) + + +class SynthesizeMaterialUI(SynthesizeUI): + # Selected three items that are easiest to obtain their synthetic materials + default_candidate_items = { + GLIMMERING_CORE: GLIMMERING_CORE_CHECK, + USURPERS_SCHEME: USURPERS_SCHEME_CHECK, + SILVERMANE_INSIGNIA: SILVERMANE_INSIGNIA_CHECK + } + + def synthesize_material(self, target_button: ButtonWrapper = None, + target_button_check: ButtonWrapper = None) -> bool: + """ + Args: + target_button(ButtonWrapper): + target_button_check(ButtonWrapper): + + Returns: + bool: + + Examples: + self = SynthesizeMaterialUI('alas') + self.device.screenshot() + result = self.synthesize_material() + """ + + logger.hr('Synthesize material', level=2) + self._ensure_synthesize_page() + self._switch_subpage(subpage=SYNTHESIZE_GOTO_MATERIAL, subpage_check=SYNTHESIZE_MATERIAL_CHECK) + return self._synthesize(target_button, target_button_check)