mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:07:36 +08:00
Add: war archives support for app
This commit is contained in:
parent
5cb9ee1895
commit
d9cec4134e
5
alas.py
5
alas.py
@ -153,6 +153,11 @@ class AzurLaneAutoScript:
|
||||
from module.sos.sos import CampaignSos
|
||||
CampaignSos(config=self.config, device=self.device).run()
|
||||
|
||||
def war_archives(self):
|
||||
from module.war_archives.war_archives import CampaignWarArchives
|
||||
CampaignWarArchives(config=self.config, device=self.device).run(
|
||||
name=self.config.Campaign_Name, folder=self.config.Campaign_Event, mode=self.config.Campaign_Mode)
|
||||
|
||||
def event_ab(self):
|
||||
from module.event.campaign_ab import CampaignAB
|
||||
CampaignAB(config=self.config, device=self.device).run()
|
||||
|
@ -58,11 +58,11 @@ class CampaignBase(CampaignBase_):
|
||||
if entrance is not None:
|
||||
return entrance
|
||||
|
||||
backup = self.config.cover(DEVICE_CONTROL_METHOD='minitouch')
|
||||
# backup = self.config.cover(DEVICE_CONTROL_METHOD='minitouch')
|
||||
p1, p2 = random_rectangle_vector(
|
||||
(0, -275), box=detection_area, random_range=(-50, -50, 50, 50), padding=20)
|
||||
self.device.drag(p1, p2, segments=2, shake=(0, 25), point_random=(0, 0, 0, 0), shake_random=(0, -5, 0, 5))
|
||||
backup.recover()
|
||||
# backup.recover()
|
||||
self.device.sleep(0.3)
|
||||
|
||||
logger.warning('Failed to find archives entrance')
|
||||
@ -82,13 +82,11 @@ class CampaignBase(CampaignBase_):
|
||||
result = self.ui_ensure(destination=page_archives)
|
||||
|
||||
WAR_ARCHIVES_SWITCH.set(mode, main=self)
|
||||
self.handle_stage_icon_spawn()
|
||||
|
||||
entrance = self._search_archives_entrance(self.config.WAR_ARCHIVES_NAME)
|
||||
entrance = self._search_archives_entrance(self.config.Campaign_Event)
|
||||
if entrance is not None:
|
||||
self.ui_click(entrance, appear_button=WAR_ARCHIVES_CHECK, check_button=WAR_ARCHIVES_CAMPAIGN_CHECK,
|
||||
skip_first_screenshot=True)
|
||||
self.handle_stage_icon_spawn()
|
||||
else:
|
||||
logger.critical('Respective server may not yet support the chosen War Archives campaign, '
|
||||
'check back in the next app update')
|
||||
|
@ -93,7 +93,7 @@ class CampaignUI(UI, CampaignOcr):
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
|
||||
elif chapter in ['a', 'b', 'c', 'd', 'ex_sp', 'as', 'bs', 'cs', 'ds']:
|
||||
self.ui_goto(page_event)
|
||||
self.ui_goto_event()
|
||||
if chapter in ['a', 'b', 'as', 'bs']:
|
||||
self.campaign_ensure_mode('normal')
|
||||
elif chapter in ['c', 'd', 'cs', 'ds']:
|
||||
@ -103,7 +103,7 @@ class CampaignUI(UI, CampaignOcr):
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto(page_sp)
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
|
||||
else:
|
||||
|
@ -144,8 +144,23 @@ class InfoHandler(ModuleBase):
|
||||
return False
|
||||
|
||||
if self.appear(USE_DATA_KEY, offset=(20, 20)):
|
||||
self.device.click(USE_DATA_KEY_NOTIFIED)
|
||||
self.device.sleep((0.5, 0.8))
|
||||
skip_first_screenshot = True
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
enabled = self.image_color_count(USE_DATA_KEY_NOTIFIED,
|
||||
color=(140, 207, 66), threshold=180, count=10)
|
||||
if enabled:
|
||||
break
|
||||
|
||||
if self.appear(USE_DATA_KEY, interval=5):
|
||||
self.device.click(USE_DATA_KEY_NOTIFIED)
|
||||
continue
|
||||
|
||||
self.config.USE_DATA_KEY = False # Reset on success as task can be stopped before can be recovered
|
||||
return self.handle_popup_confirm('USE_DATA_KEY')
|
||||
|
||||
return False
|
||||
|
@ -211,6 +211,12 @@ class UI(InfoHandler):
|
||||
def ui_goto_main(self):
|
||||
return self.ui_ensure(destination=page_main)
|
||||
|
||||
def ui_goto_event(self):
|
||||
return self.ui_ensure(destination=page_event)
|
||||
|
||||
def ui_goto_sp(self):
|
||||
return self.ui_ensure(destination=page_sp)
|
||||
|
||||
def ui_ensure_index(self, index, letter, next_button, prev_button, skip_first_screenshot=False, fast=True,
|
||||
interval=(0.2, 0.3), step_sleep=(0.2, 0.3), finish_sleep=(0.5, 0.8)):
|
||||
"""
|
||||
|
@ -5,8 +5,6 @@ from module.ocr.ocr import DigitCounter
|
||||
from module.war_archives.assets import OCR_DATA_KEY_CAMPAIGN, WAR_ARCHIVES_CAMPAIGN_CHECK
|
||||
|
||||
DATA_KEY_CAMPAIGN = DigitCounter(OCR_DATA_KEY_CAMPAIGN, letter=(255, 247, 247), threshold=64)
|
||||
RECORD_SINCE = (0,)
|
||||
RECORD_OPTION = ('DailyRecord', 'war_archives')
|
||||
|
||||
class CampaignWarArchives(CampaignRun, CampaignBase):
|
||||
def triggered_stop_condition(self, oil_check=True):
|
||||
@ -22,25 +20,8 @@ class CampaignWarArchives(CampaignRun, CampaignBase):
|
||||
# Else, check other stop conditions
|
||||
return super().triggered_stop_condition(oil_check)
|
||||
|
||||
def run_war_archives_daily(self):
|
||||
"""
|
||||
Returns:
|
||||
bool: If executed.
|
||||
"""
|
||||
self.reward_backup_daily_reward_settings()
|
||||
backup = self.config.cover(STOP_IF_COUNT_GREATER_THAN=4) # 4 data keys daily
|
||||
if not self.config.record_executed_since(option=RECORD_OPTION, since=RECORD_SINCE):
|
||||
self.run(self.config.WAR_ARCHIVES_STAGE, folder=self.config.WAR_ARCHIVES_NAME)
|
||||
self.config.record_save(option=RECORD_OPTION)
|
||||
executed = True
|
||||
else:
|
||||
executed = False
|
||||
|
||||
backup.recover()
|
||||
self.reward_recover_daily_reward_settings()
|
||||
return executed
|
||||
|
||||
def run(self, name=None, folder='campaign_main', total=0):
|
||||
backup = self.config.cover(USE_DATA_KEY=True)
|
||||
super().run(name, folder, total)
|
||||
def run(self, name=None, folder='campaign_main', mode='normal', total=0):
|
||||
backup = self.config.temporary(USE_DATA_KEY=True)
|
||||
super().run(name, folder, mode, total)
|
||||
backup.recover()
|
||||
self.ui_goto_main() # Go to main, as remaining in page can throw off Event task
|
||||
|
Loading…
Reference in New Issue
Block a user