Upd: Remove today's battle pass quests

This commit is contained in:
LmeSzinc 2023-12-28 02:03:26 +08:00
parent a78ed0a869
commit 064e0547b2
18 changed files with 74 additions and 77 deletions

View File

@ -113,7 +113,7 @@
},
"BattlePassStorage": {
"BattlePassLevel": {},
"BattlePassTodayQuest": {}
"BattlePassWeeklyQuest": {}
}
},
"Assignment": {

View File

@ -702,7 +702,7 @@ class KeywordExtract:
self.generate_shadow_with_characters()
self.load_keywords(['奖励', '任务', ])
self.write_keywords(keyword_class='BattlePassTab', output_file='./tasks/battle_pass/keywords/tab.py')
self.load_keywords(['日任务', '周任务', '本期任务'])
self.load_keywords(['周任务', '本期任务'])
self.write_keywords(keyword_class='BattlePassMissionTab',
output_file='./tasks/battle_pass/keywords/mission_tab.py')
self.generate_assignments()

View File

@ -905,11 +905,11 @@
"order": 5,
"color": "#cbe45b"
},
"BattlePassTodayQuest": {
"BattlePassWeeklyQuest": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredBattlePassTodayQuest"
"stored": "StoredBattlePassWeeklyQuest"
}
}
},

View File

@ -160,8 +160,8 @@ BattlePassStorage:
stored: StoredBattlePassLevel
order: 5
color: "#cbe45b"
BattlePassTodayQuest:
stored: StoredBattlePassTodayQuest
BattlePassWeeklyQuest:
stored: StoredBattlePassWeeklyQuest
Assignment:
# Options in Name_x will be injected in config updater

View File

@ -146,18 +146,21 @@
"order": 0,
"color": "#777777"
},
"BattlePassTodayQuest": {
"name": "BattlePassTodayQuest",
"path": "BattlePass.BattlePassStorage.BattlePassTodayQuest",
"i18n": "BattlePassStorage.BattlePassTodayQuest.name",
"stored": "StoredBattlePassTodayQuest",
"BattlePassWeeklyQuest": {
"name": "BattlePassWeeklyQuest",
"path": "BattlePass.BattlePassStorage.BattlePassWeeklyQuest",
"i18n": "BattlePassStorage.BattlePassWeeklyQuest.name",
"stored": "StoredBattlePassWeeklyQuest",
"attrs": {
"time": "2020-01-01 00:00:00",
"quest1": "",
"quest2": "",
"quest3": "",
"quest4": "",
"total": 4,
"quest5": "",
"quest6": "",
"quest7": "",
"total": 7,
"value": 0
},
"order": 0,

View File

@ -508,7 +508,7 @@ class AzurLaneConfig(ConfigUpdater, ManualConfig, GeneratedConfig, ConfigWatcher
Raises:
TaskEnd: Call task `BattlePass` and stop current task
"""
if self.stored.BattlePassTodayQuest.is_expired():
if self.stored.BattlePassWeeklyQuest.is_expired():
if self.stored.BattlePassLevel.is_full():
logger.info('BattlePassLevel full, no updates')
else:

View File

@ -103,7 +103,7 @@ class GeneratedConfig:
# Group `BattlePassStorage`
BattlePassStorage_BattlePassLevel = {}
BattlePassStorage_BattlePassTodayQuest = {}
BattlePassStorage_BattlePassWeeklyQuest = {}
# 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

View File

@ -689,7 +689,7 @@
"name": "Honor",
"help": ""
},
"BattlePassTodayQuest": {
"BattlePassWeeklyQuest": {
"name": "Honor Mission",
"help": ""
}

View File

@ -689,7 +689,7 @@
"name": "Honor",
"help": ""
},
"BattlePassTodayQuest": {
"BattlePassWeeklyQuest": {
"name": "Misión de Honor",
"help": ""
}

View File

@ -689,9 +689,9 @@
"name": "BattlePassStorage.BattlePassLevel.name",
"help": "BattlePassStorage.BattlePassLevel.help"
},
"BattlePassTodayQuest": {
"name": "BattlePassStorage.BattlePassTodayQuest.name",
"help": "BattlePassStorage.BattlePassTodayQuest.help"
"BattlePassWeeklyQuest": {
"name": "BattlePassStorage.BattlePassWeeklyQuest.name",
"help": "BattlePassStorage.BattlePassWeeklyQuest.help"
}
},
"Assignment": {

View File

@ -689,7 +689,7 @@
"name": "无名勋礼",
"help": ""
},
"BattlePassTodayQuest": {
"BattlePassWeeklyQuest": {
"name": "无名勋礼任务",
"help": ""
}

View File

@ -689,7 +689,7 @@
"name": "無名勳禮",
"help": ""
},
"BattlePassTodayQuest": {
"BattlePassWeeklyQuest": {
"name": "無名勳禮任務",
"help": ""
}

View File

@ -285,13 +285,16 @@ class StoredBattlePassLevel(StoredCounter):
FIXED_TOTAL = 70
class StoredBattlePassTodayQuest(StoredCounter, StoredExpiredAt0400):
class StoredBattlePassWeeklyQuest(StoredCounter, StoredExpiredAt0400):
quest1 = ''
quest2 = ''
quest3 = ''
quest4 = ''
quest5 = ''
quest6 = ''
quest7 = ''
FIXED_TOTAL = 4
FIXED_TOTAL = 7
def load_quests(self):
"""
@ -301,7 +304,7 @@ class StoredBattlePassTodayQuest(StoredCounter, StoredExpiredAt0400):
# BattlePassQuest should be lazy loaded
from tasks.battle_pass.keywords import BattlePassQuest
quests = []
for name in [self.quest1, self.quest2, self.quest3, self.quest4]:
for name in [self.quest1, self.quest2, self.quest3, self.quest4, self.quest5, self.quest6, self.quest7]:
if not name:
continue
try:
@ -336,3 +339,15 @@ class StoredBattlePassTodayQuest(StoredCounter, StoredExpiredAt0400):
self.quest4 = quests[3]
except IndexError:
self.quest4 = ''
try:
self.quest5 = quests[4]
except IndexError:
self.quest5 = ''
try:
self.quest6 = quests[5]
except IndexError:
self.quest6 = ''
try:
self.quest7 = quests[6]
except IndexError:
self.quest7 = ''

View File

@ -2,7 +2,7 @@ from module.config.stored.classes import (
StoredAssignment,
StoredBase,
StoredBattlePassLevel,
StoredBattlePassTodayQuest,
StoredBattlePassWeeklyQuest,
StoredCounter,
StoredDaily,
StoredDailyActivity,
@ -29,7 +29,7 @@ class StoredGenerated:
DailyActivity = StoredDailyActivity("DailyQuest.DailyStorage.DailyActivity")
DailyQuest = StoredDaily("DailyQuest.DailyStorage.DailyQuest")
BattlePassLevel = StoredBattlePassLevel("BattlePass.BattlePassStorage.BattlePassLevel")
BattlePassTodayQuest = StoredBattlePassTodayQuest("BattlePass.BattlePassStorage.BattlePassTodayQuest")
BattlePassWeeklyQuest = StoredBattlePassWeeklyQuest("BattlePass.BattlePassStorage.BattlePassWeeklyQuest")
Assignment = StoredAssignment("Assignment.Assignment.Assignment")
Credit = StoredInt("DataUpdate.ItemStorage.Credit")
StallerJade = StoredInt("DataUpdate.ItemStorage.StallerJade")

View File

@ -47,11 +47,6 @@ class BattlePassMissionTab(Switch):
SWITCH_BATTLE_PASS_MISSION_TAB = BattlePassMissionTab('BattlePassMissionTab', is_selector=True)
SWITCH_BATTLE_PASS_MISSION_TAB.add_state(
KEYWORD_BATTLE_PASS_MISSION_TAB.Today_Missions,
check_button=TODAY_MISSION_CLICK,
click_button=TODAY_MISSION_CLICK
)
SWITCH_BATTLE_PASS_MISSION_TAB.add_state(
KEYWORD_BATTLE_PASS_MISSION_TAB.This_Week_Missions,
check_button=WEEK_MISSION_CLICK,
@ -126,7 +121,7 @@ class BattlePassUI(UI):
if SWITCH_BATTLE_PASS_TAB.set(state, main=self):
logger.info(f'Tab goto {state}, wait until loaded')
if state == KEYWORD_BATTLE_PASS_TAB.Missions:
self._battle_pass_wait_missions_loaded(has_scroll=False)
self._battle_pass_wait_missions_loaded()
if state == KEYWORD_BATTLE_PASS_TAB.Rewards:
self._battle_pass_wait_rewards_loaded()
@ -134,8 +129,6 @@ class BattlePassUI(UI):
self.battle_pass_goto(KEYWORD_BATTLE_PASS_TAB.Missions)
if SWITCH_BATTLE_PASS_MISSION_TAB.set(state, main=self):
logger.info(f'Tab goto {state}, wait until loaded')
if state == KEYWORD_BATTLE_PASS_MISSION_TAB.Today_Missions:
self._battle_pass_wait_missions_loaded(has_scroll=False)
if state == KEYWORD_BATTLE_PASS_MISSION_TAB.This_Week_Missions:
self._battle_pass_wait_missions_loaded()
if state == KEYWORD_BATTLE_PASS_MISSION_TAB.This_Period_Missions:
@ -238,15 +231,20 @@ class BattlePassUI(UI):
self.claim_battle_pass_rewards()
"""
logger.hr('Quest recognise', level=1)
# Update quests
with self.config.multi_set():
# Update level
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)
# Update quests
self.battle_pass_mission_tab_goto(
KEYWORD_BATTLE_PASS_MISSION_TAB.This_Week_Missions)
quests = self.battle_pass_quests_recognition()
self.config.stored.BattlePassWeeklyQuest.write_quests(quests)
if previous_level == self.MAX_LEVEL:
return previous_level
# Claim rewards
claimed_exp = self._claim_exp()
current_level = self._get_battle_pass_level()
self.config.stored.BattlePassLevel.set(current_level)
@ -268,35 +266,25 @@ 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) -> list[BattlePassQuest]:
"""
Args:
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:
Pages:
in: page_battle_pass, KEYWORD_BATTLE_PASS_TAB.Missions, weekly or period
"""
logger.info(f"Recognizing battle pass quests at {page}")
self.battle_pass_mission_tab_goto(page)
if not has_scroll:
results = self.ocr_single_page()
results = [result.matched_keyword for result in results]
else:
scroll = Scroll(MISSION_PAGE_SCROLL, color=(198, 198, 198))
scroll.set_top(main=self)
results = self.ocr_single_page()
while not scroll.at_bottom(main=self):
logger.hr('Quest recognise', level=2)
scroll = Scroll(MISSION_PAGE_SCROLL, color=(198, 198, 198))
scroll.set_top(main=self)
results = []
while 1:
results += [result for result in self.ocr_single_page() if result not in results]
if scroll.at_bottom(main=self):
logger.info('Quest list reached bottom')
break
else:
scroll.next_page(main=self)
results += [result for result in self.ocr_single_page() if result not in results]
results = [result.matched_keyword for result in results]
results = [result.matched_keyword for result in results]
return results
def has_battle_pass_entrance(self, skip_first_screenshot=True):
@ -325,7 +313,7 @@ class BattlePassUI(UI):
def run(self):
self.ui_ensure(page_main)
if not self.has_battle_pass_entrance():
self.config.stored.BattlePassTodayQuest.set(0)
self.config.stored.BattlePassWeeklyQuest.set(0)
self.config.task_delay(server_update=True)
self.config.task_stop()

View File

@ -3,17 +3,8 @@ from .classes import BattlePassMissionTab
# This file was auto-generated, do not modify it manually. To generate:
# ``` python -m dev_tools.keyword_extract ```
Today_Missions = BattlePassMissionTab(
id=1,
name='Today_Missions',
cn='本日任务',
cht='本日任務',
en="Today's Missions",
jp='本日のクエスト',
es='Misiones de hoy',
)
This_Week_Missions = BattlePassMissionTab(
id=2,
id=1,
name='This_Week_Missions',
cn='本周任务',
cht='本週任務',
@ -22,7 +13,7 @@ This_Week_Missions = BattlePassMissionTab(
es='Misiones de esta semana',
)
This_Period_Missions = BattlePassMissionTab(
id=3,
id=2,
name='This_Period_Missions',
cn='本期任务',
cht='本期任務',

View File

@ -322,7 +322,7 @@ class DailyQuestUI(DungeonUI, RouteLoader):
with self.config.multi_set():
# Check battle pass
if self.config.stored.DailyActivity.value == 500:
quests = self.config.stored.BattlePassTodayQuest.load_quests()
quests = self.config.stored.BattlePassWeeklyQuest.load_quests()
if KEYWORD_BATTLE_PASS_QUEST.Consume_a_total_of_1_Trailblaze_Power_1400_Trailblazer_Power_max in quests:
logger.info('Achieved battle pass quest Consume_a_total_of_1_Trailblaze_Power_1400_Trailblazer_Power_max')
if self.config.stored.BattlePassLevel.is_full():

View File

@ -267,7 +267,7 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat):
logger.attr('achieved_daily_quest', self.achieved_daily_quest)
with self.config.multi_set():
# Check battle pass
quests = self.config.stored.BattlePassTodayQuest.load_quests()
quests = self.config.stored.BattlePassWeeklyQuest.load_quests()
if KEYWORD_BATTLE_PASS_QUEST.Consume_a_total_of_1_Trailblaze_Power_1400_Trailblazer_Power_max in quests:
logger.info('Probably achieved battle pass quest Consume_a_total_of_1_Trailblaze_Power_1400_Trailblazer_Power_max')
if self.config.stored.BattlePassLevel.is_full():