From 514d81b34fb3cf54c0f8dda355dd354650ef0ea7 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 20 Jun 2023 00:44:53 +0800 Subject: [PATCH] Add: Use consumables in daily quests --- tasks/daily/consumable_usage.py | 4 +++- tasks/daily/daily_quest.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks/daily/consumable_usage.py b/tasks/daily/consumable_usage.py index 87740976c..09b96d14c 100644 --- a/tasks/daily/consumable_usage.py +++ b/tasks/daily/consumable_usage.py @@ -10,13 +10,14 @@ class ConsumableUsageUI(UI): def use_consumable(self) -> bool: """ Returns: - bool: + bool: If success Examples: self = ConsumableUsageUI('alas') self.device.screenshot() result = self.use_consumable() """ + logger.hr('Use consumable', level=2) self.ui_ensure(page_item) self._switch_tag_to_consumables() if self._search_and_select_consumable(): @@ -43,6 +44,7 @@ class ConsumableUsageUI(UI): continue def _search_and_select_consumable(self, skip_first_screenshot=True) -> bool: + logger.info('Search consumable') # If the default subpage is the consumables page, it is necessary to screenshot and check subpage again, # because in this scenario, scroll bar delay appears and the previous screenshot was # taken after clicking on the "item" to determine whether to enter the "item", which may be inaccurate diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index 3aadd3d29..cabe29d82 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -6,6 +6,7 @@ from module.ocr.ocr import Ocr, OcrResultButton from module.ocr.utils import split_and_pair_buttons 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.dungeon.keywords import KEYWORDS_DUNGEON_TAB @@ -179,6 +180,9 @@ class DailyQuestUI(DungeonUI): if KEYWORDS_DAILY_QUEST.Synthesize_Consumable_1_time in quests: SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables() done += 1 + if KEYWORDS_DAILY_QUEST.Use_Consumables_1_time in quests: + if ConsumableUsageUI(self.config, self.device).use_consumable(): + done += 1 return done