fix: track FreeFavorsUsed
This commit is contained in:
parent
8c5225886e
commit
cb9b5222f4
@ -79,11 +79,20 @@ export const handlePurchase = async (
|
|||||||
|
|
||||||
switch (purchaseRequest.PurchaseParams.Source) {
|
switch (purchaseRequest.PurchaseParams.Source) {
|
||||||
case 2:
|
case 2:
|
||||||
if (!purchaseRequest.PurchaseParams.UseFreeFavor!) {
|
{
|
||||||
const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!;
|
const syndicateTag = purchaseRequest.PurchaseParams.SyndicateTag!;
|
||||||
|
if (purchaseRequest.PurchaseParams.UseFreeFavor!) {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag)!;
|
||||||
|
affiliation.FreeFavorsUsed ??= [];
|
||||||
|
affiliation.FreeFavorsUsed.push(affiliation.FreeFavorsEarned![affiliation.FreeFavorsUsed.length]);
|
||||||
|
await inventory.save();
|
||||||
|
} else {
|
||||||
const syndicate = ExportSyndicates[syndicateTag];
|
const syndicate = ExportSyndicates[syndicateTag];
|
||||||
if (syndicate) {
|
if (syndicate) {
|
||||||
const favour = syndicate.favours.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
|
const favour = syndicate.favours.find(
|
||||||
|
x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem
|
||||||
|
);
|
||||||
if (favour) {
|
if (favour) {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
|
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
|
||||||
@ -100,6 +109,7 @@ export const handlePurchase = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
|
if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user