error when quest key is missing & unlockAllQuests is false
All checks were successful
Build / build (18) (push) Successful in 59s
Build / build (18) (pull_request) Successful in 39s
Build / build (20) (pull_request) Successful in 58s
Build / build (22) (pull_request) Successful in 1m7s
Build / build (22) (push) Successful in 35s
Build / build (20) (push) Successful in 1m7s
All checks were successful
Build / build (18) (push) Successful in 59s
Build / build (18) (pull_request) Successful in 39s
Build / build (20) (pull_request) Successful in 58s
Build / build (22) (pull_request) Successful in 1m7s
Build / build (22) (push) Successful in 35s
Build / build (20) (push) Successful in 1m7s
This commit is contained in:
parent
0b29d33652
commit
cbc1d2942a
@ -3,6 +3,7 @@ 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">[];
|
||||||
@ -24,7 +25,7 @@ export const updateQuestKey = (
|
|||||||
|
|
||||||
let questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType);
|
let questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType);
|
||||||
if (questKeyIndex === -1) {
|
if (questKeyIndex === -1) {
|
||||||
// it's possible the quest key was not in already in the inventory but the quest was still available due to unlockAllQuests
|
if (!config.unlockAllQuests) throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
|
||||||
questKeyIndex = inventory.QuestKeys.push({ ItemType: questKeyUpdate[0].ItemType }) - 1;
|
questKeyIndex = inventory.QuestKeys.push({ ItemType: questKeyUpdate[0].ItemType }) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user