feat(webui): give all quests (#981)

Reviewed-on: OpenWF/SpaceNinjaServer#981
Co-authored-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
Co-committed-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
This commit is contained in:
Ordis 2025-02-21 05:30:13 -08:00 committed by OrdisPrime
parent 4d7b3b543b
commit a259afe912
3 changed files with 20 additions and 10 deletions

View File

@ -13,7 +13,8 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
| "completeAll"
| "ResetAll"
| "completeAllUnlocked"
| "updateKey";
| "updateKey"
| "giveAll";
const questKeyUpdate = req.body as IUpdateQuestRequest["QuestKeys"];
const allQuestKeys: string[] = [];
@ -71,6 +72,7 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
for (const questKey of inventory.QuestKeys) {
questKey.Completed = false;
questKey.Progress = [];
questKey.CompletionDate = undefined;
}
inventory.ActiveQuest = "";
break;
@ -78,7 +80,6 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
case "completeAllUnlocked": {
logger.info("completing all unlocked quests..");
for (const questKey of inventory.QuestKeys) {
console.log("size of questkeys", inventory.QuestKeys.length);
try {
await completeQuest(inventory, questKey.ItemType);
} catch (error) {
@ -105,6 +106,12 @@ export const manageQuestsController: RequestHandler = async (req, res) => {
inventory.ActiveQuest = "";
break;
}
case "giveAll": {
for (const questKey of allQuestKeys) {
addQuestKey(inventory, { ItemType: questKey });
}
break;
}
}
await inventory.save();

View File

@ -539,10 +539,12 @@
</form>
<h5 class="mt-3" data-loc="cheats_quests"></h6>
<div class="mb-2 d-flex flex-wrap gap-2">
<button class="btn btn-primary" onclick="doQuestUpdate('unlockAll');" data-loc="cheats_quests_UnlockAll"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('completeAll');" data-loc="cheats_quests_CompleteAll"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('completeAllUnlocked');" data-loc="cheats_quests_CompleteAllUnlocked"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('ResetAll');" data-loc="cheats_quests_ResetAll"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('unlockAll');" data-loc="cheats_quests_unlockAll"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('completeAll');" data-loc="cheats_quests_completeAll"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('completeAllUnlocked');" data-loc="cheats_quests_completeAllUnlocked"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('ResetAll');" data-loc="cheats_quests_resetAll"></button>
<button class="btn btn-primary" onclick="doQuestUpdate('giveAll');" data-loc="cheats_quests_giveAll"></button>
</div>
</div>
</div>

View File

@ -118,10 +118,11 @@ dict = {
cheats_changeButton: `Change`,
cheats_none: `None`,
cheats_quests: `Quests`,
cheats_quests_UnlockAll: `Unlock All Quests`,
cheats_quests_CompleteAll: `Complete All Quests`,
cheats_quests_CompleteAllUnlocked: `Complete All Unlocked Quests`,
cheats_quests_ResetAll: `Reset All Quests`,
cheats_quests_unlockAll: `Unlock All Quests`,
cheats_quests_completeAll: `Complete All Quests`,
cheats_quests_completeAllUnlocked: `Complete All Unlocked Quests`,
cheats_quests_resetAll: `Reset All Quests`,
cheats_quests_giveAll: `Give All Quests`,
import_importNote: `You can provide a full or partial inventory response (client respresentation) here. All fields that are supported by the importer <b>will be overwritten</b> in your account.`,
import_submit: `Submit`
};