Add: Daily synthesize material (#27)

This commit is contained in:
Driver-C 2023-06-23 22:31:00 +08:00 committed by GitHub
parent e1954801db
commit ab7351ab2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 180 additions and 46 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -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),
),
)

View File

@ -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,7 +178,10 @@ 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()
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():

View File

@ -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)