feat: implement aya costs for varzia offers #606
@ -605,6 +605,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
				
			|||||||
        PremiumCreditsFree: Number,
 | 
					        PremiumCreditsFree: Number,
 | 
				
			||||||
        //Endo
 | 
					        //Endo
 | 
				
			||||||
        FusionPoints: Number,
 | 
					        FusionPoints: Number,
 | 
				
			||||||
 | 
					        //Regal Aya
 | 
				
			||||||
 | 
					        PrimeTokens: Number,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //Slots
 | 
					        //Slots
 | 
				
			||||||
        SuitBin: slotsBinSchema,
 | 
					        SuitBin: slotsBinSchema,
 | 
				
			||||||
 | 
				
			|||||||
@ -12,6 +12,7 @@ import {
 | 
				
			|||||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					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 worldState from "@/static/fixed_responses/worldState.json";
 | 
				
			||||||
import { ExportBundles, ExportGear, ExportVendors, 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) => {
 | 
				
			||||||
@ -64,7 +65,7 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
 | 
				
			|||||||
                    for (const item of offer.itemPrices) {
 | 
					                    for (const item of offer.itemPrices) {
 | 
				
			||||||
                        const invItem: IMiscItem = {
 | 
					                        const invItem: IMiscItem = {
 | 
				
			||||||
                            ItemType: item.ItemType,
 | 
					                            ItemType: item.ItemType,
 | 
				
			||||||
                            ItemCount: item.ItemCount * -1
 | 
					                            ItemCount: item.ItemCount * purchaseRequest.PurchaseParams.Quantity * -1
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        addMiscItems(inventory, [invItem]);
 | 
					                        addMiscItems(inventory, [invItem]);
 | 
				
			||||||
@ -74,7 +75,7 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
 | 
				
			|||||||
                            x => x.ItemType == item.ItemType
 | 
					                            x => x.ItemType == item.ItemType
 | 
				
			||||||
                        );
 | 
					                        );
 | 
				
			||||||
                        if (change) {
 | 
					                        if (change) {
 | 
				
			||||||
                            change.ItemCount -= item.ItemCount;
 | 
					                            change.ItemCount += invItem.ItemCount;
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            (purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).push(invItem);
 | 
					                            (purchaseResponse.InventoryChanges.MiscItems as IMiscItem[]).push(invItem);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
@ -84,6 +85,36 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            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;
 | 
					    return purchaseResponse;
 | 
				
			||||||
 | 
				
			|||||||
@ -125,6 +125,7 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    PremiumCredits: number;
 | 
					    PremiumCredits: number;
 | 
				
			||||||
    PremiumCreditsFree: number;
 | 
					    PremiumCreditsFree: number;
 | 
				
			||||||
    FusionPoints: number;
 | 
					    FusionPoints: number;
 | 
				
			||||||
 | 
					    PrimeTokens: number;
 | 
				
			||||||
    SuitBin: ISlots;
 | 
					    SuitBin: ISlots;
 | 
				
			||||||
    WeaponBin: ISlots;
 | 
					    WeaponBin: ISlots;
 | 
				
			||||||
    SentinelBin: ISlots;
 | 
					    SentinelBin: ISlots;
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,7 @@ export interface IPurchaseRequest {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export interface IPurchaseParams {
 | 
					export interface IPurchaseParams {
 | 
				
			||||||
    Source: number;
 | 
					    Source: number;
 | 
				
			||||||
    SourceId?: string; // for Source 7
 | 
					    SourceId?: string; // for Source 7 & 18
 | 
				
			||||||
    StoreItem: string;
 | 
					    StoreItem: string;
 | 
				
			||||||
    StorePage: string;
 | 
					    StorePage: string;
 | 
				
			||||||
    SearchTerm: string;
 | 
					    SearchTerm: string;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user