separate quest and level keys

This commit is contained in:
AMelonInsideLemon 2024-12-01 08:43:49 +01:00
parent 46f39c5211
commit 78aaecbb7d

View File

@ -304,15 +304,28 @@ export const addItem = async (
} }
if (typeName in ExportKeys) { if (typeName in ExportKeys) {
if (typeName.toLocaleLowerCase().includes("quest")) {
const changes = { const changes = {
ItemType: typeName ItemType: typeName
}; };
addKey(typeName, accountId); addQuestKey(typeName, accountId);
return { return {
InventoryChanges: { InventoryChanges: {
QuestKeys: [changes] QuestKeys: [changes]
} }
}; };
} else {
const changes = {
ItemType: typeName,
ItemCount: quantity
};
addLevelKey(typeName, quantity, accountId);
return {
InventoryChanges: {
LevelKeys: [changes]
}
};
}
} }
// Path-based duck typing // Path-based duck typing
@ -549,13 +562,20 @@ export const addKubrowEgg = async (
return changedInventory.KubrowPetEggs[index - 1]; return changedInventory.KubrowPetEggs[index - 1];
}; };
export const addKey = async (typeName: string, accountId: string): Promise<IQuestKeyResponse> => { export const addQuestKey = async (typeName: string, accountId: string): Promise<IQuestKeyResponse> => {
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const index = inventory.QuestKeys.push({ ItemType: typeName }) - 1; const index = inventory.QuestKeys.push({ ItemType: typeName }) - 1;
const changedInventory = await inventory.save(); const changedInventory = await inventory.save();
return changedInventory.QuestKeys[index].toJSON(); return changedInventory.QuestKeys[index].toJSON();
}; };
export const addLevelKey = async (typeName: string, quantity: number, accountId: string): Promise<IConsumable> => {
const inventory = await getInventory(accountId);
const index = inventory.LevelKeys.push({ ItemType: typeName, ItemCount: quantity }) - 1;
const changedInventory = await inventory.save();
return changedInventory.LevelKeys[index];
};
const addGearExpByCategory = ( const addGearExpByCategory = (
inventory: IInventoryDatabaseDocument, inventory: IInventoryDatabaseDocument,
gearArray: IEquipmentClient[] | undefined, gearArray: IEquipmentClient[] | undefined,