Add: UI switching to Himeko trial
BIN
assets/share/daily/trial/CHARACTER_TRIAL.BUTTON.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
assets/share/daily/trial/CHARACTER_TRIAL.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
assets/share/daily/trial/HIMEKO_CHECK.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
assets/share/daily/trial/HIMEKO_CLICK.SEARCH.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
assets/share/daily/trial/HIMEKO_CLICK.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
assets/share/daily/trial/INFO_CLOSE.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
assets/share/daily/trial/REGULAR_GACHA_CHECK.SEARCH.png
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
assets/share/daily/trial/REGULAR_GACHA_CHECK.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
assets/share/daily/trial/REGULAR_GACHA_CLICK.SEARCH.png
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
assets/share/daily/trial/REGULAR_GACHA_CLICK.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
assets/share/daily/trial/START_TRIAL.BUTTON.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
assets/share/daily/trial/START_TRIAL.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
75
tasks/daily/assets/assets_daily_trial.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
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 ```
|
||||||
|
|
||||||
|
CHARACTER_TRIAL = ButtonWrapper(
|
||||||
|
name='CHARACTER_TRIAL',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/CHARACTER_TRIAL.png',
|
||||||
|
area=(416, 672, 559, 677),
|
||||||
|
search=(396, 652, 579, 697),
|
||||||
|
color=(238, 238, 239),
|
||||||
|
button=(414, 649, 561, 678),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
HIMEKO_CHECK = ButtonWrapper(
|
||||||
|
name='HIMEKO_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/HIMEKO_CHECK.png',
|
||||||
|
area=(597, 165, 646, 192),
|
||||||
|
search=(577, 145, 666, 212),
|
||||||
|
color=(207, 137, 123),
|
||||||
|
button=(597, 165, 646, 192),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
HIMEKO_CLICK = ButtonWrapper(
|
||||||
|
name='HIMEKO_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/HIMEKO_CLICK.png',
|
||||||
|
area=(88, 142, 125, 178),
|
||||||
|
search=(42, 124, 176, 425),
|
||||||
|
color=(202, 144, 136),
|
||||||
|
button=(88, 142, 125, 178),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
INFO_CLOSE = ButtonWrapper(
|
||||||
|
name='INFO_CLOSE',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/INFO_CLOSE.png',
|
||||||
|
area=(1129, 222, 1159, 252),
|
||||||
|
search=(1109, 202, 1179, 272),
|
||||||
|
color=(69, 69, 70),
|
||||||
|
button=(1129, 222, 1159, 252),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
REGULAR_GACHA_CHECK = ButtonWrapper(
|
||||||
|
name='REGULAR_GACHA_CHECK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/REGULAR_GACHA_CHECK.png',
|
||||||
|
area=(69, 332, 124, 367),
|
||||||
|
search=(15, 146, 150, 478),
|
||||||
|
color=(100, 92, 82),
|
||||||
|
button=(69, 332, 124, 367),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
REGULAR_GACHA_CLICK = ButtonWrapper(
|
||||||
|
name='REGULAR_GACHA_CLICK',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/REGULAR_GACHA_CLICK.png',
|
||||||
|
area=(63, 324, 118, 349),
|
||||||
|
search=(15, 146, 150, 478),
|
||||||
|
color=(36, 34, 30),
|
||||||
|
button=(63, 324, 118, 349),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
START_TRIAL = ButtonWrapper(
|
||||||
|
name='START_TRIAL',
|
||||||
|
share=Button(
|
||||||
|
file='./assets/share/daily/trial/START_TRIAL.png',
|
||||||
|
area=(905, 634, 919, 674),
|
||||||
|
search=(885, 614, 939, 694),
|
||||||
|
color=(240, 238, 238),
|
||||||
|
button=(919, 636, 1191, 672),
|
||||||
|
),
|
||||||
|
)
|
119
tasks/daily/trail.py
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
from module.base.timer import Timer
|
||||||
|
from module.logger import logger
|
||||||
|
from tasks.base.assets.assets_base_page import CLOSE, MAP_EXIT
|
||||||
|
from tasks.base.page import page_gacha
|
||||||
|
from tasks.base.ui import UI
|
||||||
|
from tasks.daily.assets.assets_daily_trial import *
|
||||||
|
|
||||||
|
|
||||||
|
class CharacterTrial(UI):
|
||||||
|
def enter_himeko_trial(self):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: Any
|
||||||
|
out: page_main, in himeko trial
|
||||||
|
"""
|
||||||
|
logger.info('Enter Himeko trial')
|
||||||
|
switched = False
|
||||||
|
if self.match_template_color(HIMEKO_CHECK):
|
||||||
|
logger.info(f'Already at {HIMEKO_CHECK}')
|
||||||
|
elif self.match_template_color(REGULAR_GACHA_CHECK):
|
||||||
|
logger.info(f'Already at {REGULAR_GACHA_CHECK}')
|
||||||
|
elif self.ui_page_appear(page_gacha):
|
||||||
|
logger.info(f'Already at {page_gacha}')
|
||||||
|
else:
|
||||||
|
switched = self.ui_ensure(page_gacha)
|
||||||
|
|
||||||
|
# page_gacha -> in himeko trial
|
||||||
|
skip_first_screenshot = True
|
||||||
|
info_closed = False
|
||||||
|
info_timeout = Timer(2, count=4).start()
|
||||||
|
first_gacha = switched
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if self.is_in_main():
|
||||||
|
if info_closed:
|
||||||
|
logger.info('In Himeko trial')
|
||||||
|
break
|
||||||
|
if info_timeout.reached():
|
||||||
|
logger.info('In Himeko trial (wait INFO_CLOSE timeout)')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
info_timeout.reset()
|
||||||
|
|
||||||
|
# In map
|
||||||
|
if self.appear_then_click(INFO_CLOSE):
|
||||||
|
info_closed = True
|
||||||
|
continue
|
||||||
|
# Switch to Himeko trial
|
||||||
|
if self.appear(START_TRIAL) \
|
||||||
|
and not self.appear(HIMEKO_CHECK) \
|
||||||
|
and self.appear_then_click(HIMEKO_CLICK, interval=2):
|
||||||
|
continue
|
||||||
|
if self.appear(HIMEKO_CHECK) \
|
||||||
|
and self.match_template_color(START_TRIAL, interval=2):
|
||||||
|
self.device.click(START_TRIAL)
|
||||||
|
continue
|
||||||
|
# Switch to regular trial
|
||||||
|
if self.match_template_color(REGULAR_GACHA_CHECK) \
|
||||||
|
and self.match_color(CHARACTER_TRIAL, interval=2):
|
||||||
|
self.device.click(CHARACTER_TRIAL)
|
||||||
|
continue
|
||||||
|
if self.match_template_color(REGULAR_GACHA_CLICK, interval=2):
|
||||||
|
# Poor sleep indeed, clicks won't be response unless other elements are loaded
|
||||||
|
# Waiting for gacha banner moving
|
||||||
|
if first_gacha:
|
||||||
|
self.device.sleep(0.3)
|
||||||
|
first_gacha = False
|
||||||
|
self.device.click(REGULAR_GACHA_CLICK)
|
||||||
|
continue
|
||||||
|
|
||||||
|
def exit_trial(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: page_main, in trial
|
||||||
|
out: START_TRIAL
|
||||||
|
"""
|
||||||
|
logger.info('Exit trial')
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
if self.match_template_color(START_TRIAL):
|
||||||
|
break
|
||||||
|
if self.appear_then_click(MAP_EXIT):
|
||||||
|
continue
|
||||||
|
if self.handle_popup_confirm():
|
||||||
|
continue
|
||||||
|
|
||||||
|
def exit_trial_to_main(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: START_TRIAL
|
||||||
|
out: page_main
|
||||||
|
"""
|
||||||
|
logger.info('Exit trial to main')
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
if self.is_in_main():
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.match_template_color(START_TRIAL, interval=2):
|
||||||
|
logger.info(f'{START_TRIAL} -> {CLOSE}')
|
||||||
|
self.device.click(CLOSE)
|
||||||
|
continue
|
||||||
|
if self.match_color(CHARACTER_TRIAL, interval=2):
|
||||||
|
logger.info(f'{CHARACTER_TRIAL} -> {CLOSE}')
|
||||||
|
self.device.click(CLOSE)
|
||||||
|
continue
|