fix: track FreeFavorsEarned & FreeFavorsUsed (#792)

This commit is contained in:
Sainan 2025-01-17 14:43:51 +01:00 committed by GitHub
parent 79f1937483
commit 9fd2fb6ba2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 16 deletions

View File

@ -50,6 +50,13 @@ export const syndicateSacrificeController: RequestHandler = async (request, resp
syndicate.Title ??= 0;
syndicate.Title += 1;
if (syndicate.Title > 0 && manifest.favours.length != 0) {
syndicate.FreeFavorsEarned ??= [];
if (!syndicate.FreeFavorsEarned.includes(syndicate.Title)) {
syndicate.FreeFavorsEarned.push(syndicate.Title);
}
}
await inventory.save();
if (reward) {

View File

@ -80,11 +80,20 @@ export const handlePurchase = async (
switch (purchaseRequest.PurchaseParams.Source) {
case 2:
if (!purchaseRequest.PurchaseParams.UseFreeFavor!) {
{
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];
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) {
const inventory = await getInventory(accountId);
const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
@ -101,6 +110,7 @@ export const handlePurchase = async (
}
}
}
}
break;
case 7:
if (purchaseRequest.PurchaseParams.SourceId! in ExportVendors) {