fix: identify correct offer for when teshin has 2 kuva offers up (#797)

This commit is contained in:
Sainan 2025-01-17 14:43:09 +01:00 committed by GitHub
parent b3d2345894
commit 0ace5eb446
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -49,15 +49,16 @@ export const handlePurchase = async (
if (purchaseRequest.PurchaseParams.Source == 7) {
const manifest = getVendorManifestByOid(purchaseRequest.PurchaseParams.SourceId!);
if (manifest) {
const offer = manifest.VendorInfo.ItemManifest.find(
x => x.StoreItem == purchaseRequest.PurchaseParams.StoreItem
);
if (offer) {
if (!manifest) {
throw new Error(`unknown vendor id: ${purchaseRequest.PurchaseParams.SourceId!}`);
}
const ItemId = (JSON.parse(purchaseRequest.PurchaseParams.ExtraPurchaseInfoJson!) as { ItemId: string }).ItemId;
const offer = manifest.VendorInfo.ItemManifest.find(x => x.Id.$oid == ItemId);
if (!offer) {
throw new Error(`unknown vendor offer: ${ItemId}`);
}
purchaseRequest.PurchaseParams.Quantity *= offer.QuantityMultiplier;
}
}
}
const purchaseResponse = await handleStoreItemAcquisition(
purchaseRequest.PurchaseParams.StoreItem,

View File

@ -17,6 +17,8 @@ export interface IPurchaseParams {
ExpectedPrice: number;
SyndicateTag?: string; // for Source 2
UseFreeFavor?: boolean; // for Source 2
ExtraPurchaseInfoJson?: string; // for Source 7
IsWeekly?: boolean; // for Source 7
}
export interface ICurrencyChanges {