Add: Use consumables in daily quests

This commit is contained in:
LmeSzinc 2023-06-20 00:44:53 +08:00
parent 9edd120538
commit 514d81b34f
2 changed files with 7 additions and 1 deletions

View File

@ -10,13 +10,14 @@ class ConsumableUsageUI(UI):
def use_consumable(self) -> bool: def use_consumable(self) -> bool:
""" """
Returns: Returns:
bool: bool: If success
Examples: Examples:
self = ConsumableUsageUI('alas') self = ConsumableUsageUI('alas')
self.device.screenshot() self.device.screenshot()
result = self.use_consumable() result = self.use_consumable()
""" """
logger.hr('Use consumable', level=2)
self.ui_ensure(page_item) self.ui_ensure(page_item)
self._switch_tag_to_consumables() self._switch_tag_to_consumables()
if self._search_and_select_consumable(): if self._search_and_select_consumable():
@ -43,6 +44,7 @@ class ConsumableUsageUI(UI):
continue continue
def _search_and_select_consumable(self, skip_first_screenshot=True) -> bool: 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, # 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 # 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 # taken after clicking on the "item" to determine whether to enter the "item", which may be inaccurate

View File

@ -6,6 +6,7 @@ from module.ocr.ocr import Ocr, OcrResultButton
from module.ocr.utils import split_and_pair_buttons from module.ocr.utils import split_and_pair_buttons
from tasks.daily.assets.assets_daily_reward import * from tasks.daily.assets.assets_daily_reward import *
from tasks.daily.camera import CameraUI 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.keywords import DailyQuest, DailyQuestState, KEYWORDS_DAILY_QUEST, KEYWORDS_DAILY_QUEST_STATE
from tasks.daily.synthesize import SynthesizeConsumablesUI from tasks.daily.synthesize import SynthesizeConsumablesUI
from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB 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: if KEYWORDS_DAILY_QUEST.Synthesize_Consumable_1_time in quests:
SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables() SynthesizeConsumablesUI(self.config, self.device).synthesize_consumables()
done += 1 done += 1
if KEYWORDS_DAILY_QUEST.Use_Consumables_1_time in quests:
if ConsumableUsageUI(self.config, self.device).use_consumable():
done += 1
return done return done