diff --git a/package-lock.json b/package-lock.json index 5f7cbf66..bce8ae13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.2", - "warframe-public-export-plus": "^0.5.9", + "warframe-public-export-plus": "^0.5.10", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" @@ -3877,9 +3877,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.9.tgz", - "integrity": "sha512-qwQVtYI7wghatg7UrJ3CFstXba5Hsks398L6ngv16auqoTVAfw/cLBqFv9DzsEpqvcVWL22IZIH+cNWiq1JXOQ==" + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.10.tgz", + "integrity": "sha512-6RtWkQDMouMXoUePohkAsYYG/wGW9b/WjSIcrxCb80pWpwrMWr5lr7kzDKPMRkq1Ju8uh9sJirp/5oyeiJbyyQ==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index ce81953a..683b5f49 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.2", - "warframe-public-export-plus": "^0.5.9", + "warframe-public-export-plus": "^0.5.10", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 3252cc20..336d70ba 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -11,10 +11,10 @@ import { } from "@/src/services/inventoryService"; import { getVendorManifestByOid } from "@/src/services/serversideVendorsService"; import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; -import { IPurchaseRequest, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes"; +import { IPurchaseRequest, IPurchaseResponse, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes"; import { logger } from "@/src/utils/logger"; import worldState from "@/static/fixed_responses/worldState.json"; -import { ExportBundles, ExportGear, ExportVendors, TRarity } from "warframe-public-export-plus"; +import { ExportBundles, ExportGear, ExportSyndicates, ExportVendors, TRarity } from "warframe-public-export-plus"; export const getStoreItemCategory = (storeItem: string) => { const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); @@ -66,6 +66,29 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI }; switch (purchaseRequest.PurchaseParams.Source) { + case 2: + if (!purchaseRequest.PurchaseParams.UseFreeFavor!) { + const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!; + const syndicate = ExportSyndicates[syndicateTag]; + if (syndicate) { + const favour = syndicate.favours.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem); + if (favour) { + const inventory = await getInventory(accountId); + const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag); + if (affiliation) { + purchaseResponse.Standing = [ + { + Tag: syndicateTag, + Standing: favour.standingCost + } + ]; + affiliation.Standing -= favour.standingCost; + await inventory.save(); + } + } + } + } + break; case 7: if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) { const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!]; @@ -136,7 +159,7 @@ const handleStoreItemAcquisition = async ( quantity: number, durability: TRarity, ignorePurchaseQuantity: boolean = false -): Promise<{ InventoryChanges: IInventoryChanges }> => { +): Promise => { let purchaseResponse = { InventoryChanges: {} }; diff --git a/src/types/purchaseTypes.ts b/src/types/purchaseTypes.ts index c09dff33..b746b4fc 100644 --- a/src/types/purchaseTypes.ts +++ b/src/types/purchaseTypes.ts @@ -13,10 +13,20 @@ export interface IPurchaseParams { Quantity: number; UsePremium: boolean; ExpectedPrice: number; + SyndicateTag?: string; // for Source 2 + UseFreeFavor?: boolean; // for Source 2 } export type IInventoryChanges = Record; +export interface IPurchaseResponse { + InventoryChanges: IInventoryChanges; + Standing?: { + Tag: string; + Standing: number; + }[]; +} + export type IBinChanges = { count: number; platinum: number;