add PurchaseSource enum
This commit is contained in:
parent
444c92f0c6
commit
b4e04a97b0
@ -11,13 +11,13 @@ import {
|
|||||||
import { getAccountForRequest, getSuffixedName } from "@/src/services/loginService";
|
import { getAccountForRequest, getSuffixedName } from "@/src/services/loginService";
|
||||||
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
|
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
|
||||||
import { IOid } from "@/src/types/commonTypes";
|
import { IOid } from "@/src/types/commonTypes";
|
||||||
import { IInventoryChanges, IPurchaseParams } from "@/src/types/purchaseTypes";
|
import { IInventoryChanges, IPurchaseParams, PurchaseSource } from "@/src/types/purchaseTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { ExportBundles, ExportFlavour } from "warframe-public-export-plus";
|
import { ExportBundles, ExportFlavour } from "warframe-public-export-plus";
|
||||||
|
|
||||||
export const giftingController: RequestHandler = async (req, res) => {
|
export const giftingController: RequestHandler = async (req, res) => {
|
||||||
const data = getJSONfromString<IGiftingRequest>(String(req.body));
|
const data = getJSONfromString<IGiftingRequest>(String(req.body));
|
||||||
if (data.PurchaseParams.Source != 0 || !data.PurchaseParams.UsePremium) {
|
if (data.PurchaseParams.Source != PurchaseSource.Market || !data.PurchaseParams.UsePremium) {
|
||||||
throw new Error(`unexpected purchase params in gifting request: ${String(req.body)}`);
|
throw new Error(`unexpected purchase params in gifting request: ${String(req.body)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,13 @@ import {
|
|||||||
import { getRandomWeightedRewardUc } from "@/src/services/rngService";
|
import { getRandomWeightedRewardUc } from "@/src/services/rngService";
|
||||||
import { applyStandingToVendorManifest, getVendorManifestByOid } from "@/src/services/serversideVendorsService";
|
import { applyStandingToVendorManifest, getVendorManifestByOid } from "@/src/services/serversideVendorsService";
|
||||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IPurchaseRequest, IPurchaseResponse, SlotPurchase, IInventoryChanges } from "@/src/types/purchaseTypes";
|
import {
|
||||||
|
IPurchaseRequest,
|
||||||
|
IPurchaseResponse,
|
||||||
|
SlotPurchase,
|
||||||
|
IInventoryChanges,
|
||||||
|
PurchaseSource
|
||||||
|
} from "@/src/types/purchaseTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import worldState from "@/static/fixed_responses/worldState/worldState.json";
|
import worldState from "@/static/fixed_responses/worldState/worldState.json";
|
||||||
import {
|
import {
|
||||||
@ -52,7 +58,7 @@ export const handlePurchase = async (
|
|||||||
|
|
||||||
const prePurchaseInventoryChanges: IInventoryChanges = {};
|
const prePurchaseInventoryChanges: IInventoryChanges = {};
|
||||||
let seed: bigint | undefined;
|
let seed: bigint | undefined;
|
||||||
if (purchaseRequest.PurchaseParams.Source == 7) {
|
if (purchaseRequest.PurchaseParams.Source == PurchaseSource.Vendor) {
|
||||||
let manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
|
let manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
|
||||||
if (manifest) {
|
if (manifest) {
|
||||||
manifest = applyStandingToVendorManifest(inventory, manifest);
|
manifest = applyStandingToVendorManifest(inventory, manifest);
|
||||||
@ -177,7 +183,7 @@ export const handlePurchase = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
switch (purchaseRequest.PurchaseParams.Source) {
|
switch (purchaseRequest.PurchaseParams.Source) {
|
||||||
case 1: {
|
case PurchaseSource.VoidTrader: {
|
||||||
if (purchaseRequest.PurchaseParams.SourceId! != worldState.VoidTraders[0]._id.$oid) {
|
if (purchaseRequest.PurchaseParams.SourceId! != worldState.VoidTraders[0]._id.$oid) {
|
||||||
throw new Error("invalid request source");
|
throw new Error("invalid request source");
|
||||||
}
|
}
|
||||||
@ -207,7 +213,7 @@ export const handlePurchase = async (
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case PurchaseSource.SyndicateFavor:
|
||||||
{
|
{
|
||||||
const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!;
|
const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!;
|
||||||
if (purchaseRequest.PurchaseParams.UseFreeFavor!) {
|
if (purchaseRequest.PurchaseParams.UseFreeFavor!) {
|
||||||
@ -244,7 +250,7 @@ export const handlePurchase = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case PurchaseSource.Vendor:
|
||||||
if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
|
if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
|
||||||
const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!];
|
const vendor = ExportVendors[purchaseRequest.PurchaseParams.SourceId!];
|
||||||
const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
|
const offer = vendor.items.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
|
||||||
@ -275,7 +281,7 @@ export const handlePurchase = async (
|
|||||||
throw new Error(`vendor purchase should not have an expected price`);
|
throw new Error(`vendor purchase should not have an expected price`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 18: {
|
case PurchaseSource.PrimeVaultTrader: {
|
||||||
if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
|
if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
|
||||||
throw new Error("invalid request source");
|
throw new Error("invalid request source");
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,41 @@ import {
|
|||||||
ICrewMemberClient
|
ICrewMemberClient
|
||||||
} from "./inventoryTypes/inventoryTypes";
|
} from "./inventoryTypes/inventoryTypes";
|
||||||
|
|
||||||
|
export enum PurchaseSource {
|
||||||
|
Market = 0,
|
||||||
|
VoidTrader = 1,
|
||||||
|
SyndicateFavor = 2,
|
||||||
|
DailyDeal = 3,
|
||||||
|
Arsenal = 4,
|
||||||
|
Profile = 5,
|
||||||
|
Hub = 6,
|
||||||
|
Vendor = 7,
|
||||||
|
AppearancePreview = 8,
|
||||||
|
Museum = 9,
|
||||||
|
Operator = 10,
|
||||||
|
PlayerShip = 11,
|
||||||
|
Crewship = 12,
|
||||||
|
MenuStyle = 13,
|
||||||
|
MenuHud = 14,
|
||||||
|
Chat = 15,
|
||||||
|
Inventory = 16,
|
||||||
|
StarChart = 17,
|
||||||
|
PrimeVaultTrader = 18,
|
||||||
|
Incubator = 19,
|
||||||
|
Prompt = 20,
|
||||||
|
Kaithe = 21,
|
||||||
|
DuviriWeapon = 22,
|
||||||
|
UpdateScreen = 23,
|
||||||
|
Motorcycle = 24
|
||||||
|
}
|
||||||
|
|
||||||
export interface IPurchaseRequest {
|
export interface IPurchaseRequest {
|
||||||
PurchaseParams: IPurchaseParams;
|
PurchaseParams: IPurchaseParams;
|
||||||
buildLabel: string;
|
buildLabel: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPurchaseParams {
|
export interface IPurchaseParams {
|
||||||
Source: number;
|
Source: PurchaseSource;
|
||||||
SourceId?: string; // for Source 1, 7 & 18
|
SourceId?: string; // for Source 1, 7 & 18
|
||||||
StoreItem: string;
|
StoreItem: string;
|
||||||
StorePage: string;
|
StorePage: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user