From 064e0547b2d486b3816c126c1d9d23762c4989e4 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Thu, 28 Dec 2023 02:03:26 +0800 Subject: [PATCH] Upd: Remove today's battle pass quests --- config/template.json | 2 +- dev_tools/keyword_extract.py | 2 +- module/config/argument/args.json | 4 +- module/config/argument/argument.yaml | 4 +- module/config/argument/stored.json | 15 +++--- module/config/config.py | 2 +- module/config/config_generated.py | 2 +- module/config/i18n/en-US.json | 2 +- module/config/i18n/es-ES.json | 2 +- module/config/i18n/ja-JP.json | 6 +-- module/config/i18n/zh-CN.json | 2 +- module/config/i18n/zh-TW.json | 2 +- module/config/stored/classes.py | 21 ++++++-- module/config/stored/stored_generated.py | 4 +- tasks/battle_pass/battle_pass.py | 64 +++++++++-------------- tasks/battle_pass/keywords/mission_tab.py | 13 +---- tasks/daily/daily_quest.py | 2 +- tasks/dungeon/dungeon.py | 2 +- 18 files changed, 74 insertions(+), 77 deletions(-) diff --git a/config/template.json b/config/template.json index 1a8648a3b..b328c0f90 100644 --- a/config/template.json +++ b/config/template.json @@ -113,7 +113,7 @@ }, "BattlePassStorage": { "BattlePassLevel": {}, - "BattlePassTodayQuest": {} + "BattlePassWeeklyQuest": {} } }, "Assignment": { diff --git a/dev_tools/keyword_extract.py b/dev_tools/keyword_extract.py index 7c9ef4f52..b7fe5892c 100644 --- a/dev_tools/keyword_extract.py +++ b/dev_tools/keyword_extract.py @@ -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() diff --git a/module/config/argument/args.json b/module/config/argument/args.json index ae3ced226..a04a8c746 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -905,11 +905,11 @@ "order": 5, "color": "#cbe45b" }, - "BattlePassTodayQuest": { + "BattlePassWeeklyQuest": { "type": "stored", "value": {}, "display": "hide", - "stored": "StoredBattlePassTodayQuest" + "stored": "StoredBattlePassWeeklyQuest" } } }, diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 0a55d2796..fd96e4320 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -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 diff --git a/module/config/argument/stored.json b/module/config/argument/stored.json index 08522e811..30d344a0d 100644 --- a/module/config/argument/stored.json +++ b/module/config/argument/stored.json @@ -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, diff --git a/module/config/config.py b/module/config/config.py index 028a2c541..8a276ff90 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -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: diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 4c65759a9..feb883afb 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -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 diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 76e48e315..8af2f0400 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -689,7 +689,7 @@ "name": "Honor", "help": "" }, - "BattlePassTodayQuest": { + "BattlePassWeeklyQuest": { "name": "Honor Mission", "help": "" } diff --git a/module/config/i18n/es-ES.json b/module/config/i18n/es-ES.json index dc822dede..da2ec281b 100644 --- a/module/config/i18n/es-ES.json +++ b/module/config/i18n/es-ES.json @@ -689,7 +689,7 @@ "name": "Honor", "help": "" }, - "BattlePassTodayQuest": { + "BattlePassWeeklyQuest": { "name": "Misión de Honor", "help": "" } diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index a1e1eb95c..47afd4ce3 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -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": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 57f597c58..964a15f11 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -689,7 +689,7 @@ "name": "无名勋礼", "help": "" }, - "BattlePassTodayQuest": { + "BattlePassWeeklyQuest": { "name": "无名勋礼任务", "help": "" } diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 13713b373..025d1cf1e 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -689,7 +689,7 @@ "name": "無名勳禮", "help": "" }, - "BattlePassTodayQuest": { + "BattlePassWeeklyQuest": { "name": "無名勳禮任務", "help": "" } diff --git a/module/config/stored/classes.py b/module/config/stored/classes.py index a1ff451c3..42f0f4e5c 100644 --- a/module/config/stored/classes.py +++ b/module/config/stored/classes.py @@ -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 = '' diff --git a/module/config/stored/stored_generated.py b/module/config/stored/stored_generated.py index c91cc8e78..2ff299140 100644 --- a/module/config/stored/stored_generated.py +++ b/module/config/stored/stored_generated.py @@ -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") diff --git a/tasks/battle_pass/battle_pass.py b/tasks/battle_pass/battle_pass.py index 2f5c53d51..486170fd5 100644 --- a/tasks/battle_pass/battle_pass.py +++ b/tasks/battle_pass/battle_pass.py @@ -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() diff --git a/tasks/battle_pass/keywords/mission_tab.py b/tasks/battle_pass/keywords/mission_tab.py index 7f82e153c..71d7eec89 100644 --- a/tasks/battle_pass/keywords/mission_tab.py +++ b/tasks/battle_pass/keywords/mission_tab.py @@ -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='本期任務', diff --git a/tasks/daily/daily_quest.py b/tasks/daily/daily_quest.py index 127f07a17..6e6a864c9 100644 --- a/tasks/daily/daily_quest.py +++ b/tasks/daily/daily_quest.py @@ -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(): diff --git a/tasks/dungeon/dungeon.py b/tasks/dungeon/dungeon.py index d03112af8..fa93ea86e 100644 --- a/tasks/dungeon/dungeon.py +++ b/tasks/dungeon/dungeon.py @@ -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():