返回提交历史
Modified
src/services/questService.ts
+4
-3
XFEstudio/SpaceNinjaServer
fix: add missing quest keys at updateQuestKey (#958)
it's possible the quest key was not in already in the inventory but the quest was still available due to unlockAllQuests Closes #957 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/958
87cc2594
代码差异
1 个文件
+4
-3
@@ -3,6 +3,7 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
3
3
import { IInventoryDatabase, IQuestKeyDatabase, IQuestStage } from "@/src/types/inventoryTypes/inventoryTypes";
4
4
import { logger } from "@/src/utils/logger";
5
5
import { HydratedDocument } from "mongoose";
6
import { config } from "@/src/services/configService";
6
7
7
8
export interface IUpdateQuestRequest {
8
9
QuestKeys: Omit<IQuestKeyDatabase, "CompletionDate">[];
@@ -22,10 +23,10 @@ export const updateQuestKey = (
22
23
throw new Error("more than 1 quest key not supported");
23
24
}
24
25
25
const questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType);
26
26
let questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType);
27
27
if (questKeyIndex === -1) {
28
throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
28
if (!config.unlockAllQuests) throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
29
questKeyIndex = inventory.QuestKeys.push({ ItemType: questKeyUpdate[0].ItemType }) - 1;
29
30
}
30
31
31
32
inventory.QuestKeys[questKeyIndex] = questKeyUpdate[0];