forked from OpenWF/SpaceNinjaServer
fix: purchasing an arcane pack does not consume vosfor (#601)
This commit is contained in:
parent
ac09fcec5c
commit
9fd6ed3b21
8
package-lock.json
generated
8
package-lock.json
generated
@ -12,7 +12,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5",
|
"express": "^5",
|
||||||
"mongoose": "^8.9.2",
|
"mongoose": "^8.9.2",
|
||||||
"warframe-public-export-plus": "^0.5.8",
|
"warframe-public-export-plus": "^0.5.9",
|
||||||
"warframe-riven-info": "^0.1.2",
|
"warframe-riven-info": "^0.1.2",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0"
|
"winston-daily-rotate-file": "^5.0.0"
|
||||||
@ -3877,9 +3877,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/warframe-public-export-plus": {
|
"node_modules/warframe-public-export-plus": {
|
||||||
"version": "0.5.8",
|
"version": "0.5.9",
|
||||||
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.8.tgz",
|
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.9.tgz",
|
||||||
"integrity": "sha512-ZhHrKIkI6nhjKDlxhrNcfN8r2Yc9g+eeKLS6+9w7gzC4NscIt6TU8tH8bfjJTDeo6nRrzt88szX1/Oo3WnUY4Q=="
|
"integrity": "sha512-qwQVtYI7wghatg7UrJ3CFstXba5Hsks398L6ngv16auqoTVAfw/cLBqFv9DzsEpqvcVWL22IZIH+cNWiq1JXOQ=="
|
||||||
},
|
},
|
||||||
"node_modules/warframe-riven-info": {
|
"node_modules/warframe-riven-info": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5",
|
"express": "^5",
|
||||||
"mongoose": "^8.9.2",
|
"mongoose": "^8.9.2",
|
||||||
"warframe-public-export-plus": "^0.5.8",
|
"warframe-public-export-plus": "^0.5.9",
|
||||||
"warframe-riven-info": "^0.1.2",
|
"warframe-riven-info": "^0.1.2",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0"
|
"winston-daily-rotate-file": "^5.0.0"
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import { parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers";
|
import { parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers";
|
||||||
import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
|
import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
|
||||||
import {
|
import {
|
||||||
addItem,
|
|
||||||
addBooster,
|
addBooster,
|
||||||
|
addItem,
|
||||||
|
addMiscItems,
|
||||||
combineInventoryChanges,
|
combineInventoryChanges,
|
||||||
|
getInventory,
|
||||||
updateCurrency,
|
updateCurrency,
|
||||||
updateSlots
|
updateSlots
|
||||||
} from "@/src/services/inventoryService";
|
} from "@/src/services/inventoryService";
|
||||||
|
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
|
import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
|
import { ExportBundles, ExportGear, ExportVendors, TRarity } from "warframe-public-export-plus";
|
||||||
|
|
||||||
export const getStoreItemCategory = (storeItem: string) => {
|
export const getStoreItemCategory = (storeItem: string) => {
|
||||||
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
|
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
|
||||||
@ -43,12 +46,46 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
|
|||||||
purchaseRequest.PurchaseParams.UsePremium,
|
purchaseRequest.PurchaseParams.UsePremium,
|
||||||
accountId
|
accountId
|
||||||
);
|
);
|
||||||
|
|
||||||
purchaseResponse.InventoryChanges = {
|
purchaseResponse.InventoryChanges = {
|
||||||
...currencyChanges,
|
...currencyChanges,
|
||||||
...purchaseResponse.InventoryChanges
|
...purchaseResponse.InventoryChanges
|
||||||
};
|
};
|
||||||
|
|
||||||
|
switch (purchaseRequest.PurchaseParams.Source) {
|
||||||
|
case 7:
|
||||||
|
if (!purchaseRequest.PurchaseParams.SourceId) {
|
||||||
|
throw new Error("invalid request source");
|
||||||
|
}
|
||||||
|
if (ExportVendors[purchaseRequest.PurchaseParams.SourceId]) {
|
||||||
|
const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId];
|
||||||
|
const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
|
||||||
|
if (offer) {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
for (const item of offer.itemPrices) {
|
||||||
|
const invItem: IMiscItem = {
|
||||||
|
ItemType: item.ItemType,
|
||||||
|
ItemCount: item.ItemCount * -1
|
||||||
|
};
|
||||||
|
|
||||||
|
addMiscItems(inventory, [invItem]);
|
||||||
|
|
||||||
|
purchaseResponse.InventoryChanges.MiscItems ??= [];
|
||||||
|
const change = (purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).find(
|
||||||
|
x => x.ItemType == item.ItemType
|
||||||
|
);
|
||||||
|
if (change) {
|
||||||
|
change.ItemCount -= item.ItemCount;
|
||||||
|
} else {
|
||||||
|
(purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).push(invItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await inventory.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return purchaseResponse;
|
return purchaseResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export interface IPurchaseRequest {
|
|||||||
|
|
||||||
export interface IPurchaseParams {
|
export interface IPurchaseParams {
|
||||||
Source: number;
|
Source: number;
|
||||||
|
SourceId?: string; // for Source 7
|
||||||
StoreItem: string;
|
StoreItem: string;
|
||||||
StorePage: string;
|
StorePage: string;
|
||||||
SearchTerm: string;
|
SearchTerm: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user