返回提交历史
Modified
src/services/inventoryService.ts
+8
-2
Modified
src/types/purchaseTypes.ts
+7
-1
XFEstudio/SpaceNinjaServer
chore: improve IInventoryChanges (#654)
9e211054
代码差异
2 个文件
+15
-3
@@ -81,7 +81,7 @@ export const combineInventoryChanges = (InventoryChanges: IInventoryChanges, del
81
81
for (const item of right) {
82
82
left.push(item);
83
83
}
84
} else {
84
} else if (typeof delta[key] == "object") {
85
85
console.assert(key.substring(-3) == "Bin");
86
86
const left = InventoryChanges[key] as IBinChanges;
87
87
const right: IBinChanges = delta[key];
@@ -92,6 +92,8 @@ export const combineInventoryChanges = (InventoryChanges: IInventoryChanges, del
92
92
left.Extra ??= 0;
93
93
left.Extra += right.Extra;
94
94
}
95
} else {
96
logger.warn(`inventory change not merged: ${key}`);
95
97
}
96
98
}
97
99
};
@@ -476,7 +478,11 @@ export const updateSlots = async (accountId: string, slotName: SlotNames, slotAm
476
478
await inventory.save();
477
479
};
478
480
479
export const updateCurrency = async (price: number, usePremium: boolean, accountId: string) => {
481
export const updateCurrency = async (
482
price: number,
483
usePremium: boolean,
484
accountId: string
485
): Promise<IInventoryChanges> => {
480
486
if (usePremium ? config.infinitePlatinum : config.infiniteCredits) {
481
487
return {};
482
488
}
@@ -17,7 +17,13 @@ export interface IPurchaseParams {
17
17
UseFreeFavor?: boolean; // for Source 2
18
18
}
19
19
20
export type IInventoryChanges = Record<string, IBinChanges | object[]>;
20
export type IInventoryChanges = {
21
[_ in SlotNames]?: IBinChanges;
22
} & {
23
RegularCredits?: number;
24
PremiumCredits?: number;
25
PremiumCreditsFree?: number;
26
} & Record<string, IBinChanges | number | object[]>;
21
27
22
28
export interface IPurchaseResponse {
23
29
InventoryChanges: IInventoryChanges;