Add: Link task BattlePass to Dungeon, Assignment, DailyQuest

This commit is contained in:
LmeSzinc 2023-08-31 01:06:24 +08:00
parent 5d3efe1d44
commit 51e49e2077
20 changed files with 268 additions and 19 deletions

View File

@ -106,6 +106,10 @@
"NextRun": "2020-01-01 00:00:00",
"Command": "BattlePass",
"ServerUpdate": "04:00"
},
"BattlePassStorage": {
"BattlePassLevel": {},
"BattlePassTodayQuest": {}
}
},
"Assignment": {

View File

@ -384,7 +384,7 @@
"value": {},
"display": "hide",
"stored": "StoredSimulatedUniverse",
"order": 5,
"order": 6,
"color": "#8fb5fe"
}
}
@ -834,6 +834,22 @@
"value": "04:00",
"display": "hide"
}
},
"BattlePassStorage": {
"BattlePassLevel": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredBattlePassLevel",
"order": 5,
"color": "#cbe45b"
},
"BattlePassTodayQuest": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredBattlePassTodayQuest"
}
}
},
"Assignment": {
@ -963,7 +979,7 @@
"display": "hide",
"stored": "StoredAssignment",
"order": 3,
"color": "#deba95"
"color": "#79dbc4"
}
}
}

View File

@ -117,7 +117,7 @@ DungeonStorage:
stored: StoredDungeonDouble
SimulatedUniverse:
stored: StoredSimulatedUniverse
order: 5
order: 6
color: "#8fb5fe"
AchievableQuest:
@ -135,6 +135,14 @@ DailyStorage:
DailyQuest:
stored: StoredDaily
BattlePassStorage:
BattlePassLevel:
stored: StoredBattlePassLevel
order: 5
color: "#cbe45b"
BattlePassTodayQuest:
stored: StoredBattlePassTodayQuest
Assignment:
# Options in Name_x will be injected in config updater
Name_1:
@ -155,4 +163,4 @@ Assignment:
Assignment:
stored: StoredAssignment
order: 3
color: "#deba95"
color: "#79dbc4"

View File

@ -6,7 +6,7 @@
"stored": "StoredTrailblazePower",
"attrs": {
"time": "2020-01-01 00:00:00",
"total": 180,
"total": 240,
"value": 0
},
"order": 1,
@ -36,7 +36,20 @@
"value": 0
},
"order": 3,
"color": "#deba95"
"color": "#79dbc4"
},
"BattlePassLevel": {
"name": "BattlePassLevel",
"path": "BattlePass.BattlePassStorage.BattlePassLevel",
"i18n": "BattlePassStorage.BattlePassLevel.name",
"stored": "StoredBattlePassLevel",
"attrs": {
"time": "2020-01-01 00:00:00",
"total": 50,
"value": 0
},
"order": 5,
"color": "#cbe45b"
},
"SimulatedUniverse": {
"name": "SimulatedUniverse",
@ -48,7 +61,7 @@
"total": 0,
"value": 0
},
"order": 5,
"order": 6,
"color": "#8fb5fe"
},
"DungeonDouble": {
@ -76,7 +89,26 @@
"quest3": "",
"quest4": "",
"quest5": "",
"quest6": ""
"quest6": "",
"total": 6,
"value": 0
},
"order": 0,
"color": "#777777"
},
"BattlePassTodayQuest": {
"name": "BattlePassTodayQuest",
"path": "BattlePass.BattlePassStorage.BattlePassTodayQuest",
"i18n": "BattlePassStorage.BattlePassTodayQuest.name",
"stored": "StoredBattlePassTodayQuest",
"attrs": {
"time": "2020-01-01 00:00:00",
"quest1": "",
"quest2": "",
"quest3": "",
"quest4": "",
"total": 4,
"value": 0
},
"order": 0,
"color": "#777777"

View File

@ -34,6 +34,7 @@ Daily:
- DailyStorage
BattlePass:
- Scheduler
- BattlePassStorage
Assignment:
- Scheduler
- Assignment

View File

@ -490,14 +490,24 @@ class AzurLaneConfig(ConfigUpdater, ManualConfig, GeneratedConfig, ConfigWatcher
TaskEnd: Call task `DailyQuest` and stop current task
"""
if self.stored.DailyActivity.is_expired():
logger.info('Daily activity expired, call task to update')
logger.info('DailyActivity expired, call task to update')
self.task_call('DailyQuest')
self.task_stop()
if self.stored.DailyQuest.is_expired():
logger.info('Daily quests expired, call task to update')
logger.info('DailyQuest expired, call task to update')
self.task_call('DailyQuest')
self.task_stop()
def update_battle_pass_quests(self):
"""
Raises:
TaskEnd: Call task `BattlePass` and stop current task
"""
if self.stored.BattlePassTodayQuest.is_expired():
logger.info('BattlePassTodayQuest expired, call task to update')
self.task_call('BattlePass')
self.task_stop()
@property
def DEVICE_SCREENSHOT_METHOD(self):
return self.Emulator_ScreenshotMethod

View File

@ -90,6 +90,10 @@ class GeneratedConfig:
DailyStorage_DailyActivity = {}
DailyStorage_DailyQuest = {}
# Group `BattlePassStorage`
BattlePassStorage_BattlePassLevel = {}
BattlePassStorage_BattlePassTodayQuest = {}
# Group `Assignment`
Assignment_Name_1 = 'Nameless_Land_Nameless_People' # Nine_Billion_Names, Destruction_of_the_Destroyer, Winter_Soldiers, Born_to_Obey, Root_Out_the_Turpitude, Fire_Lord_Inflames_Blades_of_War, Nameless_Land_Nameless_People, Akashic_Records, The_Invisible_Hand, Abandoned_and_Insulted, Spring_of_Life, The_Land_of_Gold, The_Blossom_in_the_Storm, Legend_of_the_Puppet_Master, The_Wages_of_Humanity
Assignment_Name_2 = 'Akashic_Records' # Nine_Billion_Names, Destruction_of_the_Destroyer, Winter_Soldiers, Born_to_Obey, Root_Out_the_Turpitude, Fire_Lord_Inflames_Blades_of_War, Nameless_Land_Nameless_People, Akashic_Records, The_Invisible_Hand, Abandoned_and_Insulted, Spring_of_Life, The_Land_of_Gold, The_Blossom_in_the_Storm, Legend_of_the_Puppet_Master, The_Wages_of_Humanity

View File

@ -8,7 +8,7 @@ class ManualConfig:
SCHEDULER_PRIORITY = """
Restart
> DailyQuest > Dungeon > Assignment > BattlePass
> BattlePass > DailyQuest > Dungeon > Assignment
"""
"""

View File

@ -570,6 +570,20 @@
"help": ""
}
},
"BattlePassStorage": {
"_info": {
"name": "BattlePassStorage._info.name",
"help": "BattlePassStorage._info.help"
},
"BattlePassLevel": {
"name": "Honor",
"help": ""
},
"BattlePassTodayQuest": {
"name": "Honor Mission",
"help": ""
}
},
"Assignment": {
"_info": {
"name": "Assignment Settings",

View File

@ -570,6 +570,20 @@
"help": "DailyStorage.DailyQuest.help"
}
},
"BattlePassStorage": {
"_info": {
"name": "BattlePassStorage._info.name",
"help": "BattlePassStorage._info.help"
},
"BattlePassLevel": {
"name": "BattlePassStorage.BattlePassLevel.name",
"help": "BattlePassStorage.BattlePassLevel.help"
},
"BattlePassTodayQuest": {
"name": "BattlePassStorage.BattlePassTodayQuest.name",
"help": "BattlePassStorage.BattlePassTodayQuest.help"
}
},
"Assignment": {
"_info": {
"name": "依頼設定",

View File

@ -570,6 +570,20 @@
"help": ""
}
},
"BattlePassStorage": {
"_info": {
"name": "BattlePassStorage._info.name",
"help": "BattlePassStorage._info.help"
},
"BattlePassLevel": {
"name": "无名勋礼",
"help": ""
},
"BattlePassTodayQuest": {
"name": "无名勋礼任务",
"help": ""
}
},
"Assignment": {
"_info": {
"name": "委托设置",

View File

@ -570,6 +570,20 @@
"help": ""
}
},
"BattlePassStorage": {
"_info": {
"name": "BattlePassStorage._info.name",
"help": "BattlePassStorage._info.help"
},
"BattlePassLevel": {
"name": "無名勳禮",
"help": ""
},
"BattlePassTodayQuest": {
"name": "無名勳禮任務",
"help": ""
}
},
"Assignment": {
"_info": {
"name": "委託設定",

View File

@ -177,7 +177,7 @@ class StoredAssignment(StoredCounter):
pass
class StoredDaily(StoredExpiredAt0400):
class StoredDaily(StoredCounter, StoredExpiredAt0400):
quest1 = ''
quest2 = ''
quest3 = ''
@ -185,6 +185,8 @@ class StoredDaily(StoredExpiredAt0400):
quest5 = ''
quest6 = ''
FIXED_TOTAL = 6
def load_quests(self):
"""
Returns:
@ -211,6 +213,7 @@ class StoredDaily(StoredExpiredAt0400):
from tasks.daily.keywords import DailyQuest
quests = [q.name if isinstance(q, DailyQuest) else q for q in quests]
with self._config.multi_set():
self.set(value=max(self.FIXED_TOTAL - len(quests), 0))
try:
self.quest1 = quests[0]
except IndexError:
@ -240,3 +243,60 @@ class StoredDaily(StoredExpiredAt0400):
class StoredDungeonDouble(StoredExpiredAt0400):
calyx = 0
relic = 0
class StoredBattlePassLevel(StoredCounter):
FIXED_TOTAL = 50
class StoredBattlePassTodayQuest(StoredCounter, StoredExpiredAt0400):
quest1 = ''
quest2 = ''
quest3 = ''
quest4 = ''
FIXED_TOTAL = 4
def load_quests(self):
"""
Returns:
list[DailyQuest]: Note that must check if quests are expired
"""
# BattlePassQuest should be lazy loaded
from tasks.battle_pass.keywords import BattlePassQuest
quests = []
for name in [self.quest1, self.quest2, self.quest3, self.quest4]:
if not name:
continue
try:
quest = BattlePassQuest.find(name)
quests.append(quest)
except ScriptError:
pass
return quests
def write_quests(self, quests):
"""
Args:
quests (list[DailyQuest, str]):
"""
from tasks.battle_pass.keywords import BattlePassQuest
quests = [q.name if isinstance(q, BattlePassQuest) else q for q in quests]
with self._config.multi_set():
self.set(value=max(self.FIXED_TOTAL - len(quests), 0))
try:
self.quest1 = quests[0]
except IndexError:
self.quest1 = ''
try:
self.quest2 = quests[1]
except IndexError:
self.quest2 = ''
try:
self.quest3 = quests[2]
except IndexError:
self.quest3 = ''
try:
self.quest4 = quests[3]
except IndexError:
self.quest4 = ''

View File

@ -1,6 +1,8 @@
from module.config.stored.classes import (
StoredAssignment,
StoredBase,
StoredBattlePassLevel,
StoredBattlePassTodayQuest,
StoredCounter,
StoredDaily,
StoredDailyActivity,
@ -21,4 +23,6 @@ class StoredGenerated:
SimulatedUniverse = StoredSimulatedUniverse("Dungeon.DungeonStorage.SimulatedUniverse")
DailyActivity = StoredDailyActivity("DailyQuest.DailyStorage.DailyActivity")
DailyQuest = StoredDaily("DailyQuest.DailyStorage.DailyQuest")
BattlePassLevel = StoredBattlePassLevel("BattlePass.BattlePassStorage.BattlePassLevel")
BattlePassTodayQuest = StoredBattlePassTodayQuest("BattlePass.BattlePassStorage.BattlePassTodayQuest")
Assignment = StoredAssignment("Assignment.Assignment.Assignment")

View File

@ -587,6 +587,9 @@ class AlasGUI(Frame):
put_text(t("Gui.Overview.NoTask")).style("--overview-notask-text--")
for arg, arg_dict in self.ALAS_STORED.items():
# Skip order=0
if not arg_dict.get("order", 0):
continue
path = arg_dict["path"]
if self.scope_expired_then_add(f"dashboard-time-value-{arg}", [
deep_get(self.alas_config.data, keys=f"{path}.value"),

View File

@ -13,12 +13,14 @@ from tasks.assignment.keywords import (
KEYWORDS_ASSIGNMENT_GROUP,
)
from tasks.base.page import page_assignment, page_menu
from tasks.battle_pass.keywords import KEYWORD_BATTLE_PASS_QUEST
from tasks.daily.keywords import KEYWORDS_DAILY_QUEST
from tasks.daily.synthesize import SynthesizeUI
class Assignment(AssignmentClaim, SynthesizeUI):
def run(self, assignments: list[AssignmentEntry] = None, duration: int = None):
self.config.update_battle_pass_quests()
self.config.update_daily_quests()
if assignments is None:
@ -35,6 +37,7 @@ class Assignment(AssignmentClaim, SynthesizeUI):
duration = self.config.Assignment_Duration
self.dispatched = dict()
self.has_new_dispatch = False
self.ensure_scroll_top(page_menu)
self.ui_ensure(page_assignment)
# Iterate in user-specified order, return undispatched ones
@ -52,13 +55,22 @@ class Assignment(AssignmentClaim, SynthesizeUI):
self._dispatch_remain(duration, remain - len(undispatched))
# Scheduler
logger.attr('has_new_dispatch', self.has_new_dispatch)
delay = min(self.dispatched.values())
logger.info(f'Delay assignment check to {str(delay)}')
with self.config.multi_set():
# Check battle pass
quests = self.config.stored.BattlePassTodayQuest.load_quests()
if self.has_new_dispatch:
if KEYWORD_BATTLE_PASS_QUEST.Dispatch_1_assignments in quests:
logger.info('Achieved battle pass quest Dispatch_1_assignments')
self.config.task_call('BattlePass')
# Check daily
quests = self.config.stored.DailyQuest.load_quests()
if KEYWORDS_DAILY_QUEST.Go_on_assignment_1_time in quests:
logger.info('Achieved daily quest Go_on_assignment_1_time')
self.config.task_call('DailyQuest')
# Delay self
self.config.task_delay(target=delay)
def _check_inlist(self, assignments: list[AssignmentEntry], duration: int):

View File

@ -19,6 +19,7 @@ ASSIGNMENT_DURATION_SWITCH.add_state('20', DURATION_20)
class AssignmentDispatch(AssignmentUI):
dispatched: dict[AssignmentEntry, datetime] = dict()
has_new_dispatch: bool = False
def dispatch(self, assignment: AssignmentEntry, duration: int):
"""
@ -39,6 +40,7 @@ class AssignmentDispatch(AssignmentUI):
self._wait_until_assignment_started()
self.dispatched[assignment] = datetime.now() + \
timedelta(hours=duration)
self.has_new_dispatch = True
def _select_characters(self):
"""

View File

@ -232,11 +232,18 @@ class BattlePassUI(UI):
self.device.screenshot()
self.claim_battle_pass_rewards()
"""
with self.config.multi_set():
previous_level = self._get_battle_pass_level()
self.config.stored.BattlePassLevel.set(previous_level)
quests = self.battle_pass_quests_recognition(
KEYWORD_BATTLE_PASS_MISSION_TAB.Today_Missions, has_scroll=False)
self.config.stored.BattlePassTodayQuest.write_quests(quests)
if previous_level == self.MAX_LEVEL:
return previous_level
claimed_exp = self._claim_exp()
current_level = self._get_battle_pass_level()
self.config.stored.BattlePassLevel.set(current_level)
if claimed_exp and current_level > previous_level:
logger.info("Upgraded, go to claim rewards")
self._claim_rewards()
@ -255,11 +262,17 @@ class BattlePassUI(UI):
return [incomplete_quest for incomplete_quest, _ in
split_and_pair_buttons(results, split_func=completed_state, relative_area=(0, 0, 800, 100))]
def battle_pass_quests_recognition(self, page: KEYWORD_BATTLE_PASS_MISSION_TAB,
has_scroll=True) -> list[BattlePassQuest]:
def battle_pass_quests_recognition(
self,
page: KEYWORD_BATTLE_PASS_MISSION_TAB,
has_scroll=True,
) -> list[BattlePassQuest]:
"""
Args:
page:
page: One of the followings:
KEYWORD_BATTLE_PASS_MISSION_TAB.Today_Missions
KEYWORD_BATTLE_PASS_MISSION_TAB.This_Week_Missions
KEYWORD_BATTLE_PASS_MISSION_TAB.This_Period_Missions
has_scroll: need to scroll to recognize all quests
Returns:

View File

@ -6,7 +6,12 @@ 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.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, SynthesizeMaterialUI
from tasks.daily.use_technique import UseTechniqueUI
from tasks.dungeon.assets.assets_dungeon_ui import DAILY_TRAINING_CHECK
@ -14,6 +19,7 @@ from tasks.dungeon.keywords import KEYWORDS_DUNGEON_TAB
from tasks.dungeon.ui import DungeonUI
from tasks.item.consumable_usage import ConsumableUsageUI
from tasks.item.relics import RelicsUI
from tasks.battle_pass.keywords import KEYWORD_BATTLE_PASS_QUEST
class DailyQuestOcr(Ocr):
@ -231,6 +237,8 @@ class DailyQuestUI(DungeonUI):
return done
def run(self):
self.config.update_battle_pass_quests()
for _ in range(5):
got = self.get_daily_rewards()
if got:
@ -241,4 +249,12 @@ class DailyQuestUI(DungeonUI):
break
# Scheduler
with self.config.multi_set():
# Check battle pass
if self.config.stored.DailyActivity.value == 500:
quests = self.config.stored.BattlePassTodayQuest.load_quests()
if KEYWORD_BATTLE_PASS_QUEST.Reach_500_on_Daily_Training_Activity in quests:
logger.info('Achieved battle pass quest Reach_500_on_Daily_Training_Activity')
self.config.task_call('BattlePass')
# Delay self
self.config.task_delay(server_update=True)

View File

@ -5,7 +5,7 @@ from tasks.daily.keywords import KEYWORDS_DAILY_QUEST
from tasks.dungeon.event import DungeonEvent
from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_LIST, KEYWORDS_DUNGEON_TAB
from tasks.dungeon.ui import DungeonUI
from tasks.battle_pass.keywords import KEYWORD_BATTLE_PASS_QUEST
class Dungeon(DungeonUI, DungeonEvent, Combat):
called_daily_support = False
@ -117,6 +117,7 @@ class Dungeon(DungeonUI, DungeonEvent, Combat):
support_character=support_character)
def run(self):
self.config.update_battle_pass_quests()
self.config.update_daily_quests()
self.called_daily_support = False
self.achieved_daily_quest = False
@ -220,8 +221,15 @@ class Dungeon(DungeonUI, DungeonEvent, Combat):
logger.info(f'Currently has {current} need {cover} minutes to reach {limit}')
logger.attr('achieved_daily_quest', self.achieved_daily_quest)
with self.config.multi_set():
# Check battle pass
quests = self.config.stored.BattlePassTodayQuest.load_quests()
if KEYWORD_BATTLE_PASS_QUEST.Consume_1_Trailblaze_Power in quests:
logger.info('Probably achieved battle pass quest Consume_1_Trailblaze_Power')
self.config.task_call('BattlePass')
# Check daily
if self.achieved_daily_quest:
self.config.task_call('DailyQuest')
# Delay self
self.config.task_delay(minute=cover)
self.config.task_stop()