fix: don't throw an error if questKey already exists
This commit is contained in:
parent
045d933458
commit
9a646e0022
@ -333,7 +333,7 @@ export const addItem = async (
|
|||||||
const key = addQuestKey(inventory, { ItemType: typeName });
|
const key = addQuestKey(inventory, { ItemType: typeName });
|
||||||
if (key) {
|
if (key) {
|
||||||
return { InventoryChanges: { QuestKeys: [key] } };
|
return { InventoryChanges: { QuestKeys: [key] } };
|
||||||
}
|
} else return { InventoryChanges: {} };
|
||||||
} else {
|
} else {
|
||||||
const key = { ItemType: typeName, ItemCount: quantity };
|
const key = { ItemType: typeName, ItemCount: quantity };
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export const updateQuestStage = (
|
|||||||
|
|
||||||
export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase) => {
|
export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase) => {
|
||||||
if (inventory.QuestKeys.some(q => q.ItemType === questKey.ItemType)) {
|
if (inventory.QuestKeys.some(q => q.ItemType === questKey.ItemType)) {
|
||||||
logger.error(`quest key ${questKey.ItemType} already exists`);
|
logger.warn(`Quest key ${questKey.ItemType} already exists. It will not be added`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const index = inventory.QuestKeys.push(questKey);
|
const index = inventory.QuestKeys.push(questKey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user