Compare commits
9 Commits
c0bf3a2db5
...
1ccca86801
Author | SHA1 | Date | |
---|---|---|---|
1ccca86801 | |||
c35b764f4f | |||
256a1ce3e7 | |||
71ff93364d | |||
9506c4876b | |||
9707db393b | |||
b000032a95 | |||
d81fdd24ed | |||
ecdd4ed06c |
@ -3,7 +3,6 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
|
|||||||
import { IInventoryDatabase, IQuestKeyDatabase, IQuestStage } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IInventoryDatabase, IQuestKeyDatabase, IQuestStage } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { HydratedDocument } from "mongoose";
|
import { HydratedDocument } from "mongoose";
|
||||||
import { config } from "@/src/services/configService";
|
|
||||||
|
|
||||||
export interface IUpdateQuestRequest {
|
export interface IUpdateQuestRequest {
|
||||||
QuestKeys: Omit<IQuestKeyDatabase, "CompletionDate">[];
|
QuestKeys: Omit<IQuestKeyDatabase, "CompletionDate">[];
|
||||||
@ -23,10 +22,10 @@ export const updateQuestKey = (
|
|||||||
throw new Error("more than 1 quest key not supported");
|
throw new Error("more than 1 quest key not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
let questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType);
|
const questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType);
|
||||||
|
|
||||||
if (questKeyIndex === -1) {
|
if (questKeyIndex === -1) {
|
||||||
if (!config.unlockAllQuests) throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
|
throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
|
||||||
questKeyIndex = inventory.QuestKeys.push({ ItemType: questKeyUpdate[0].ItemType }) - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inventory.QuestKeys[questKeyIndex] = questKeyUpdate[0];
|
inventory.QuestKeys[questKeyIndex] = questKeyUpdate[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user