chore: consider IInventoryChanges being able to contain currency changes
This commit is contained in:
parent
e909216001
commit
4b8bae258d
@ -82,10 +82,10 @@ export const combineInventoryChanges = (InventoryChanges: IInventoryChanges, del
|
||||
for (const item of right) {
|
||||
left.push(item);
|
||||
}
|
||||
} else {
|
||||
} else if (typeof delta[key] == "object") {
|
||||
console.assert(key.substring(-3) == "Bin");
|
||||
const left = InventoryChanges[key] as IBinChanges;
|
||||
const right: IBinChanges = delta[key] as IBinChanges;
|
||||
const right: IBinChanges = delta[key];
|
||||
left.count += right.count;
|
||||
left.platinum += right.platinum;
|
||||
left.Slots += right.Slots;
|
||||
@ -93,6 +93,8 @@ export const combineInventoryChanges = (InventoryChanges: IInventoryChanges, del
|
||||
left.Extra ??= 0;
|
||||
left.Extra += right.Extra;
|
||||
}
|
||||
} else {
|
||||
logger.warn(`inventory change not merged: ${key}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -477,7 +479,11 @@ export const updateSlots = async (accountId: string, slotName: SlotNames, slotAm
|
||||
await inventory.save();
|
||||
};
|
||||
|
||||
export const updateCurrency = async (price: number, usePremium: boolean, accountId: string) => {
|
||||
export const updateCurrency = async (
|
||||
price: number,
|
||||
usePremium: boolean,
|
||||
accountId: string
|
||||
): Promise<IInventoryChanges> => {
|
||||
if (usePremium ? config.infinitePlatinum : config.infiniteCredits) {
|
||||
return {};
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ export interface IPurchaseParams {
|
||||
|
||||
export type IInventoryChanges = {
|
||||
[_ in SlotNames]?: IBinChanges;
|
||||
} & {
|
||||
RegularCredits?: number;
|
||||
PremiumCredits?: number;
|
||||
PremiumCreditsFree?: number;
|
||||
} & Record<string, IBinChanges | number | object[]>;
|
||||
|
||||
export interface IPurchaseResponse {
|
||||
|
Loading…
x
Reference in New Issue
Block a user