From efcaaa56c43ad0cf7dd69b3dc9083a672d4bbe32 Mon Sep 17 00:00:00 2001 From: Sainan Date: Fri, 24 Jan 2025 14:18:05 +0100 Subject: [PATCH] fix: tell client when it has used a free favor (#850) --- src/services/purchaseService.ts | 9 ++++++++- src/types/purchaseTypes.ts | 12 ++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index dc2fadf41..fab6c4115 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -98,7 +98,14 @@ export const handlePurchase = async ( const inventory = await getInventory(accountId); const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag)!; affiliation.FreeFavorsUsed ??= []; - affiliation.FreeFavorsUsed.push(affiliation.FreeFavorsEarned![affiliation.FreeFavorsUsed.length]); + const lastTitle = affiliation.FreeFavorsEarned![affiliation.FreeFavorsUsed.length]; + affiliation.FreeFavorsUsed.push(lastTitle); + purchaseResponse.FreeFavorsUsed = [ + { + Tag: syndicateTag, + Title: lastTitle + } + ]; await inventory.save(); } else { const syndicate = ExportSyndicates[syndicateTag]; diff --git a/src/types/purchaseTypes.ts b/src/types/purchaseTypes.ts index e8f6d090e..94e1d1971 100644 --- a/src/types/purchaseTypes.ts +++ b/src/types/purchaseTypes.ts @@ -34,12 +34,16 @@ export type IInventoryChanges = { IBinChanges | number | object[] | IInfestedFoundryClient >; +export interface IAffiliationMods { + Tag: string; + Standing?: number; + Title?: number; +} + export interface IPurchaseResponse { InventoryChanges: IInventoryChanges; - Standing?: { - Tag: string; - Standing: number; - }[]; + Standing?: IAffiliationMods[]; + FreeFavorsUsed?: IAffiliationMods[]; BoosterPackItems?: string; }