feat: subtract standing for syndicate purchases (#608)

This commit is contained in:
Sainan 2024-12-22 23:31:30 +01:00 committed by GitHub
parent c421c7021c
commit 412de02680
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 8 deletions

8
package-lock.json generated
View File

@ -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.9", "warframe-public-export-plus": "^0.5.10",
"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.9", "version": "0.5.10",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.9.tgz", "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.10.tgz",
"integrity": "sha512-qwQVtYI7wghatg7UrJ3CFstXba5Hsks398L6ngv16auqoTVAfw/cLBqFv9DzsEpqvcVWL22IZIH+cNWiq1JXOQ==" "integrity": "sha512-6RtWkQDMouMXoUePohkAsYYG/wGW9b/WjSIcrxCb80pWpwrMWr5lr7kzDKPMRkq1Ju8uh9sJirp/5oyeiJbyyQ=="
}, },
"node_modules/warframe-riven-info": { "node_modules/warframe-riven-info": {
"version": "0.1.2", "version": "0.1.2",

View File

@ -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.9", "warframe-public-export-plus": "^0.5.10",
"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"

View File

@ -11,10 +11,10 @@ import {
} from "@/src/services/inventoryService"; } from "@/src/services/inventoryService";
import { getVendorManifestByOid } from "@/src/services/serversideVendorsService"; import { getVendorManifestByOid } from "@/src/services/serversideVendorsService";
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; 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 { logger } from "@/src/utils/logger";
import worldState from "@/static/fixed_responses/worldState.json"; 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) => { export const getStoreItemCategory = (storeItem: string) => {
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/"); const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@ -66,6 +66,29 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
}; };
switch (purchaseRequest.PurchaseParams.Source) { 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: case 7:
if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) { if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!]; const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!];
@ -136,7 +159,7 @@ const handleStoreItemAcquisition = async (
quantity: number, quantity: number,
durability: TRarity, durability: TRarity,
ignorePurchaseQuantity: boolean = false ignorePurchaseQuantity: boolean = false
): Promise<{ InventoryChanges: IInventoryChanges }> => { ): Promise<IPurchaseResponse> => {
let purchaseResponse = { let purchaseResponse = {
InventoryChanges: {} InventoryChanges: {}
}; };

View File

@ -13,10 +13,20 @@ export interface IPurchaseParams {
Quantity: number; Quantity: number;
UsePremium: boolean; UsePremium: boolean;
ExpectedPrice: number; ExpectedPrice: number;
SyndicateTag?: string; // for Source 2
UseFreeFavor?: boolean; // for Source 2
} }
export type IInventoryChanges = Record<string, IBinChanges | object[]>; export type IInventoryChanges = Record<string, IBinChanges | object[]>;
export interface IPurchaseResponse {
InventoryChanges: IInventoryChanges;
Standing?: {
Tag: string;
Standing: number;
}[];
}
export type IBinChanges = { export type IBinChanges = {
count: number; count: number;
platinum: number; platinum: number;