feat: implement aya costs for varzia offers (#606)

This commit is contained in:
Sainan 2024-12-22 23:28:59 +01:00 committed by GitHub
parent d1d221bb58
commit c421c7021c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 1 deletions

View File

@ -605,6 +605,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
PremiumCreditsFree: Number,
//Endo
FusionPoints: Number,
//Regal Aya
PrimeTokens: Number,
//Slots
SuitBin: slotsBinSchema,

View File

@ -13,6 +13,7 @@ import { getVendorManifestByOid } from "@/src/services/serversideVendorsService"
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
import { IPurchaseRequest, 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";
export const getStoreItemCategory = (storeItem: string) => {
@ -94,6 +95,36 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
}
}
break;
case 18: {
if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
throw new Error("invalid request source");
}
const offer =
worldState.PrimeVaultTraders[0].Manifest.find(
x => x.ItemType == purchaseRequest.PurchaseParams.StoreItem
) ??
worldState.PrimeVaultTraders[0].EvergreenManifest.find(
x => x.ItemType == purchaseRequest.PurchaseParams.StoreItem
);
if (offer) {
const inventory = await getInventory(accountId);
if (offer.RegularPrice) {
const invItem: IMiscItem = {
ItemType: "/Lotus/Types/Items/MiscItems/SchismKey",
ItemCount: offer.RegularPrice * purchaseRequest.PurchaseParams.Quantity * -1
};
addMiscItems(inventory, [invItem]);
purchaseResponse.InventoryChanges.MiscItems ??= [];
(purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).push(invItem);
} else {
inventory.PrimeTokens -= offer.PrimePrice! * purchaseRequest.PurchaseParams.Quantity;
}
await inventory.save();
}
break;
}
}
return purchaseResponse;

View File

@ -125,6 +125,7 @@ export interface IInventoryResponse {
PremiumCredits: number;
PremiumCreditsFree: number;
FusionPoints: number;
PrimeTokens: number;
SuitBin: ISlots;
WeaponBin: ISlots;
SentinelBin: ISlots;

View File

@ -5,7 +5,7 @@ export interface IPurchaseRequest {
export interface IPurchaseParams {
Source: number;
SourceId?: string; // for Source 7
SourceId?: string; // for Source 7 & 18
StoreItem: string;
StorePage: string;
SearchTerm: string;