From 0ab9fc2c2e3bab756a2a4ba4725f29114c9020be Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:30:43 +0800 Subject: [PATCH] Add: Echo of War settings --- config/template.json | 13 ++++++ module/config/argument/args.json | 59 ++++++++++++++++++++++++ module/config/argument/argument.yaml | 13 ++++++ module/config/argument/default.yaml | 3 ++ module/config/argument/menu.json | 1 + module/config/argument/stored.json | 13 ++++++ module/config/argument/task.yaml | 3 ++ module/config/config_generated.py | 5 ++ module/config/config_manual.py | 2 +- module/config/config_updater.py | 14 +++++- module/config/i18n/en-US.json | 35 +++++++++++++- module/config/i18n/es-ES.json | 33 ++++++++++++- module/config/i18n/ja-JP.json | 31 +++++++++++++ module/config/i18n/zh-CN.json | 31 +++++++++++++ module/config/i18n/zh-TW.json | 31 +++++++++++++ module/config/stored/classes.py | 15 +++++- module/config/stored/stored_generated.py | 3 ++ module/config/utils.py | 28 +++++++++++ 18 files changed, 327 insertions(+), 6 deletions(-) diff --git a/config/template.json b/config/template.json index 41dfb1136..93e03b139 100644 --- a/config/template.json +++ b/config/template.json @@ -59,9 +59,22 @@ "DungeonStorage": { "TrailblazePower": {}, "DungeonDouble": {}, + "EchoOfWar": {}, "SimulatedUniverse": {} } }, + "Weekly": { + "Scheduler": { + "Enable": true, + "NextRun": "2020-01-01 00:00:00", + "Command": "Weekly", + "ServerUpdate": "04:00" + }, + "Weekly": { + "Name": "Echo_of_War_Divine_Seed", + "Team": 1 + } + }, "DailyQuest": { "Scheduler": { "Enable": true, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index adf07c25f..282ea13a3 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -393,6 +393,14 @@ "display": "hide", "stored": "StoredDungeonDouble" }, + "EchoOfWar": { + "type": "stored", + "value": {}, + "display": "hide", + "stored": "StoredEchoOfWar", + "order": 4, + "color": "#85e7f2" + }, "SimulatedUniverse": { "type": "stored", "value": {}, @@ -403,6 +411,57 @@ } } }, + "Weekly": { + "Scheduler": { + "Enable": { + "type": "checkbox", + "value": true, + "option": [ + true, + false + ] + }, + "NextRun": { + "type": "datetime", + "value": "2020-01-01 00:00:00", + "validate": "datetime" + }, + "Command": { + "type": "input", + "value": "Weekly", + "display": "hide" + }, + "ServerUpdate": { + "type": "input", + "value": "04:00", + "display": "hide" + } + }, + "Weekly": { + "Name": { + "type": "select", + "value": "Echo_of_War_Divine_Seed", + "options": [], + "option": [ + "Echo_of_War_Destruction_Beginning", + "Echo_of_War_End_of_the_Eternal_Freeze", + "Echo_of_War_Divine_Seed" + ] + }, + "Team": { + "type": "select", + "value": 1, + "option": [ + 1, + 2, + 3, + 4, + 5, + 6 + ] + } + } + }, "DailyQuest": { "Scheduler": { "Enable": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index fb10caf59..cbc4945db 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -118,11 +118,24 @@ DungeonStorage: color: "#eb8efe" DungeonDouble: stored: StoredDungeonDouble + EchoOfWar: + stored: StoredEchoOfWar + order: 4 + color: "#85e7f2" SimulatedUniverse: stored: StoredSimulatedUniverse order: 6 color: "#8fb5fe" +Weekly: + Name: + # Dungeon names will be injected in config updater + value: Echo_of_War_Divine_Seed + options: [] + Team: + value: 1 + option: [ 1, 2, 3, 4, 5, 6 ] + AchievableQuest: # Quests will be injected in config updater # Complete_1_Daily_Mission: diff --git a/module/config/argument/default.yaml b/module/config/argument/default.yaml index 643678441..5292fee54 100644 --- a/module/config/argument/default.yaml +++ b/module/config/argument/default.yaml @@ -10,6 +10,9 @@ Dungeon: Scheduler: Enable: true +Weekly: + Scheduler: + Enable: true DailyQuest: Scheduler: Enable: true diff --git a/module/config/argument/menu.json b/module/config/argument/menu.json index 20b29b051..91ecb58e4 100644 --- a/module/config/argument/menu.json +++ b/module/config/argument/menu.json @@ -12,6 +12,7 @@ "page": "setting", "tasks": [ "Dungeon", + "Weekly", "DailyQuest", "BattlePass", "Assignment", diff --git a/module/config/argument/stored.json b/module/config/argument/stored.json index 9fa7a416b..734347e84 100644 --- a/module/config/argument/stored.json +++ b/module/config/argument/stored.json @@ -38,6 +38,19 @@ "order": 3, "color": "#79dbc4" }, + "EchoOfWar": { + "name": "EchoOfWar", + "path": "Dungeon.DungeonStorage.EchoOfWar", + "i18n": "DungeonStorage.EchoOfWar.name", + "stored": "StoredEchoOfWar", + "attrs": { + "time": "2020-01-01 00:00:00", + "total": 3, + "value": 0 + }, + "order": 4, + "color": "#85e7f2" + }, "BattlePassLevel": { "name": "BattlePassLevel", "path": "BattlePass.BattlePassStorage.BattlePassLevel", diff --git a/module/config/argument/task.yaml b/module/config/argument/task.yaml index 6cb0515c5..e7bf3662c 100644 --- a/module/config/argument/task.yaml +++ b/module/config/argument/task.yaml @@ -28,6 +28,9 @@ Daily: - DungeonDaily - DungeonSupport - DungeonStorage + Weekly: + - Scheduler + - Weekly DailyQuest: - Scheduler - AchievableQuest diff --git a/module/config/config_generated.py b/module/config/config_generated.py index da2b7a8da..67b48dba3 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -58,8 +58,13 @@ class GeneratedConfig: # Group `DungeonStorage` DungeonStorage_TrailblazePower = {} DungeonStorage_DungeonDouble = {} + DungeonStorage_EchoOfWar = {} DungeonStorage_SimulatedUniverse = {} + # Group `Weekly` + Weekly_Name = 'Echo_of_War_Divine_Seed' # Echo_of_War_Destruction_Beginning, Echo_of_War_End_of_the_Eternal_Freeze, Echo_of_War_Divine_Seed + Weekly_Team = 1 # 1, 2, 3, 4, 5, 6 + # Group `AchievableQuest` AchievableQuest_Complete_1_Daily_Mission = 'achievable' # achievable, not_set, not_supported AchievableQuest_Clear_Calyx_Golden_1_times = 'achievable' # achievable, not_set, not_supported diff --git a/module/config/config_manual.py b/module/config/config_manual.py index 051e15c86..1d2cc8458 100644 --- a/module/config/config_manual.py +++ b/module/config/config_manual.py @@ -11,7 +11,7 @@ class ManualConfig: SCHEDULER_PRIORITY = """ Restart > BattlePass > DailyQuest > Assignment > DataUpdate - > Dungeon + > Weekly > Dungeon """ """ diff --git a/module/config/config_updater.py b/module/config/config_updater.py index c73d44143..1e54ecf0e 100644 --- a/module/config/config_updater.py +++ b/module/config/config_updater.py @@ -86,6 +86,9 @@ class ConfigGenerator: option_add( keys='DungeonDaily.CavernOfCorrosion.option', options=[dungeon.name for dungeon in DungeonList.instances.values() if dungeon.is_Cavern_of_Corrosion]) + option_add( + keys='Weekly.Name.option', + options=[dungeon.name for dungeon in DungeonList.instances.values() if dungeon.is_Echo_of_War]) # Insert characters from tasks.character.keywords import CharacterList unsupported_characters = [] @@ -352,9 +355,9 @@ class ConfigGenerator: # deep_set(new, keys=path, value=f'[{prefix}] {_list[index]}') # Dungeon names + from tasks.dungeon.keywords import DungeonList if lang not in ['zh-CN', 'zh-TW', 'en-US', 'es-ES']: ingame_lang = gui_lang_to_ingame_lang(lang) - from tasks.dungeon.keywords import DungeonList dailies = deep_get(self.argument, keys='Dungeon.Name.option') for dungeon in DungeonList.instances.values(): if dungeon.name in dailies: @@ -399,6 +402,15 @@ class ConfigGenerator: value = deep_get(new, keys=['AchievableQuest', copy_from, option]) deep_set(new, keys=['AchievableQuest', quest.name, option], value=value) + # Echo of War + from tasks.map.keywords import MapWorld + dungeons = [d for d in DungeonList.instances.values() if d.is_Echo_of_War] + for world, dungeon in zip(MapWorld.instances.values(), dungeons): + world_name = world.__getattribute__(ingame_lang) + dungeon_name = dungeon.__getattribute__(ingame_lang) + value = f'{dungeon_name} ({world_name})' + deep_set(new, keys=['Weekly', 'Name', dungeon.name], value=value) + # GUI i18n for path, _ in deep_iter(self.gui, depth=2): group, key = path diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 81c5be155..c37b3d1ab 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -26,6 +26,10 @@ "name": "Dungeon", "help": "" }, + "Weekly": { + "name": "Echo of War", + "help": "" + }, "DailyQuest": { "name": "Daily Quest", "help": "" @@ -394,9 +398,36 @@ "name": "Dungeon Double", "help": "" }, - "SimulatedUniverse": { - "name": "Sim.Uni.", + "EchoOfWar": { + "name": "Echo.", "help": "" + }, + "SimulatedUniverse": { + "name": "Sim.Univ.", + "help": "" + } + }, + "Weekly": { + "_info": { + "name": "Echo of War Settings", + "help": "Echo of War is still able to challenge if limit is reached. Consume no trailblaze power, get no reward, but complete daily quests." + }, + "Name": { + "name": "Dungeon Name", + "help": "", + "Echo_of_War_Destruction_Beginning": "Destruction's Beginning (Herta Space Station)", + "Echo_of_War_End_of_the_Eternal_Freeze": "End of the Eternal Freeze (Jarilo-VI)", + "Echo_of_War_Divine_Seed": "Divine Seed (The Xianzhou Luofu)" + }, + "Team": { + "name": "Dungeon Team", + "help": "", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6" } }, "AchievableQuest": { diff --git a/module/config/i18n/es-ES.json b/module/config/i18n/es-ES.json index 9e1f8270e..91600c4e9 100644 --- a/module/config/i18n/es-ES.json +++ b/module/config/i18n/es-ES.json @@ -26,6 +26,10 @@ "name": "Mazmorra", "help": "" }, + "Weekly": { + "name": "Ecos de la guerra", + "help": "" + }, "DailyQuest": { "name": "Misión diaria", "help": "" @@ -387,18 +391,45 @@ "help": "DungeonStorage._info.help" }, "TrailblazePower": { - "name": "Poder trazacaminos", + "name": "Poder", "help": "" }, "DungeonDouble": { "name": "Mazmorra x2", "help": "" }, + "EchoOfWar": { + "name": "Ecos.", + "help": "" + }, "SimulatedUniverse": { "name": "Univ.Sim.", "help": "" } }, + "Weekly": { + "_info": { + "name": "Ajustes de Ecos de la guerra", + "help": "" + }, + "Name": { + "name": "Nombre de la Mazmorra", + "help": "", + "Echo_of_War_Destruction_Beginning": "El principio de la Destrucción (Estación Espacial Herta)", + "Echo_of_War_End_of_the_Eternal_Freeze": "El fin del Hielo Eterno (Jarilo-VI)", + "Echo_of_War_Divine_Seed": "Semilla divina (El Luofu de Xianzhou)" + }, + "Team": { + "name": "Equipo de mazmorra", + "help": "", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6" + } + }, "AchievableQuest": { "_info": { "name": "Misiones completables", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index f20352d19..941bb89fb 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -26,6 +26,10 @@ "name": "Task.Dungeon.name", "help": "Task.Dungeon.help" }, + "Weekly": { + "name": "Task.Weekly.name", + "help": "Task.Weekly.help" + }, "DailyQuest": { "name": "Task.DailyQuest.name", "help": "Task.DailyQuest.help" @@ -394,11 +398,38 @@ "name": "DungeonStorage.DungeonDouble.name", "help": "DungeonStorage.DungeonDouble.help" }, + "EchoOfWar": { + "name": "DungeonStorage.EchoOfWar.name", + "help": "DungeonStorage.EchoOfWar.help" + }, "SimulatedUniverse": { "name": "DungeonStorage.SimulatedUniverse.name", "help": "DungeonStorage.SimulatedUniverse.help" } }, + "Weekly": { + "_info": { + "name": "Weekly._info.name", + "help": "Weekly._info.help" + }, + "Name": { + "name": "Weekly.Name.name", + "help": "Weekly.Name.help", + "Echo_of_War_Destruction_Beginning": "歴戦余韻・壊滅の始まり (宇宙ステーション「ヘルタ」)", + "Echo_of_War_End_of_the_Eternal_Freeze": "歴戦余韻・寒波の幕切れ (ヤリーロ-VI)", + "Echo_of_War_Divine_Seed": "歴戦余韻・不死の神実 (仙舟「羅浮」)" + }, + "Team": { + "name": "Weekly.Team.name", + "help": "Weekly.Team.help", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6" + } + }, "AchievableQuest": { "_info": { "name": "AchievableQuest._info.name", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 184925b6f..fb48e5905 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -26,6 +26,10 @@ "name": "每日副本", "help": "" }, + "Weekly": { + "name": "历战余响", + "help": "" + }, "DailyQuest": { "name": "每日任务", "help": "" @@ -394,11 +398,38 @@ "name": "副本双倍", "help": "" }, + "EchoOfWar": { + "name": "历战余响", + "help": "" + }, "SimulatedUniverse": { "name": "模拟宇宙", "help": "" } }, + "Weekly": { + "_info": { + "name": "历战余响设置", + "help": "历战余响每周次数耗尽后仍然可以继续挑战,不消耗体力不获得奖励但是可以完成每日任务" + }, + "Name": { + "name": "副本名称", + "help": "", + "Echo_of_War_Destruction_Beginning": "毁灭的开端•历战余响 (空间站「黑塔」)", + "Echo_of_War_End_of_the_Eternal_Freeze": "寒潮的落幕•历战余响 (雅利洛-Ⅵ)", + "Echo_of_War_Divine_Seed": "不死的神实•历战余响 (仙舟「罗浮」)" + }, + "Team": { + "name": "打本队伍", + "help": "", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6" + } + }, "AchievableQuest": { "_info": { "name": "可完成的任务", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index f12a426a5..d0bf47d6e 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -26,6 +26,10 @@ "name": "每日副本", "help": "" }, + "Weekly": { + "name": "歷戰餘響", + "help": "" + }, "DailyQuest": { "name": "每日任務", "help": "" @@ -394,11 +398,38 @@ "name": "副本雙倍", "help": "" }, + "EchoOfWar": { + "name": "歷戰餘響", + "help": "" + }, "SimulatedUniverse": { "name": "模擬宇宙", "help": "" } }, + "Weekly": { + "_info": { + "name": "歷戰餘響設定", + "help": "歷戰餘響每週次數耗儘後仍可繼續挑戰,不消耗體力不獲得獎勵但是可以完成每日任務" + }, + "Name": { + "name": "副本名稱", + "help": "", + "Echo_of_War_Destruction_Beginning": "毀滅的開端•歷戰餘響 (太空站「黑塔」)", + "Echo_of_War_End_of_the_Eternal_Freeze": "寒潮的落幕•歷戰餘響 (雅利洛-Ⅵ)", + "Echo_of_War_Divine_Seed": "不死的神實•歷戰餘響 (仙舟「羅浮」)" + }, + "Team": { + "name": "打本隊伍", + "help": "", + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "5": "5", + "6": "6" + } + }, "AchievableQuest": { "_info": { "name": "可完成的任務", diff --git a/module/config/stored/classes.py b/module/config/stored/classes.py index e292e4931..0ee3ceb18 100644 --- a/module/config/stored/classes.py +++ b/module/config/stored/classes.py @@ -2,7 +2,7 @@ from datetime import datetime from functools import cached_property as functools_cached_property from module.base.decorator import cached_property -from module.config.utils import DEFAULT_TIME, deep_get, get_server_last_update +from module.config.utils import DEFAULT_TIME, deep_get, get_server_last_monday_update, get_server_last_update from module.exception import ScriptError @@ -120,6 +120,15 @@ class StoredExpiredAt0400(StoredBase): return expired +class StoredExpiredAtMonday0400(StoredBase): + def is_expired(self): + from module.logger import logger + self.show() + expired = self.time < get_server_last_monday_update('04:00') + logger.attr(f'{self._name} expired', expired) + return expired + + class StoredInt(StoredBase): value = 0 @@ -245,6 +254,10 @@ class StoredDungeonDouble(StoredExpiredAt0400): relic = 0 +class StoredEchoOfWar(StoredCounter, StoredExpiredAtMonday0400): + FIXED_TOTAL = 3 + + class StoredBattlePassLevel(StoredCounter): FIXED_TOTAL = 50 diff --git a/module/config/stored/stored_generated.py b/module/config/stored/stored_generated.py index 20b62f871..bd30c6831 100644 --- a/module/config/stored/stored_generated.py +++ b/module/config/stored/stored_generated.py @@ -7,7 +7,9 @@ from module.config.stored.classes import ( StoredDaily, StoredDailyActivity, StoredDungeonDouble, + StoredEchoOfWar, StoredExpiredAt0400, + StoredExpiredAtMonday0400, StoredInt, StoredSimulatedUniverse, StoredTrailblazePower, @@ -20,6 +22,7 @@ from module.config.stored.classes import ( class StoredGenerated: TrailblazePower = StoredTrailblazePower("Dungeon.DungeonStorage.TrailblazePower") DungeonDouble = StoredDungeonDouble("Dungeon.DungeonStorage.DungeonDouble") + EchoOfWar = StoredEchoOfWar("Dungeon.DungeonStorage.EchoOfWar") SimulatedUniverse = StoredSimulatedUniverse("Dungeon.DungeonStorage.SimulatedUniverse") DailyActivity = StoredDailyActivity("DailyQuest.DailyStorage.DailyActivity") DailyQuest = StoredDaily("DailyQuest.DailyStorage.DailyQuest") diff --git a/module/config/utils.py b/module/config/utils.py index 1c4a1b69c..8748e157a 100644 --- a/module/config/utils.py +++ b/module/config/utils.py @@ -535,6 +535,34 @@ def get_server_last_update(daily_trigger): return update +def get_server_last_monday_update(daily_trigger): + """ + Args: + daily_trigger (list[str], str): [ "00:00", "12:00", "18:00",] + + Returns: + datetime.datetime + """ + update = get_server_next_update(daily_trigger) + diff = update.weekday() + update = update - timedelta(days=diff) + return update + + +def get_server_next_monday_update(daily_trigger): + """ + Args: + daily_trigger (list[str], str): [ "00:00", "12:00", "18:00",] + + Returns: + datetime.datetime + """ + update = get_server_next_update(daily_trigger) + diff = (7 - update.weekday()) % 7 + update = update + timedelta(days=diff) + return update + + def nearest_future(future, interval=120): """ Get the neatest future time.