forked from OpenWF/SpaceNinjaServer
		
	fix: track FreeFavorsEarned & FreeFavorsUsed (#792)
This commit is contained in:
		
							parent
							
								
									79f1937483
								
							
						
					
					
						commit
						9fd2fb6ba2
					
				@ -50,6 +50,13 @@ export const syndicateSacrificeController: RequestHandler = async (request, resp
 | 
				
			|||||||
    syndicate.Title ??= 0;
 | 
					    syndicate.Title ??= 0;
 | 
				
			||||||
    syndicate.Title += 1;
 | 
					    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();
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (reward) {
 | 
					    if (reward) {
 | 
				
			||||||
 | 
				
			|||||||
@ -80,23 +80,33 @@ 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!;
 | 
				
			||||||
                const syndicate = ExportSyndicates[syndicateTag];
 | 
					                if (purchaseRequest.PurchaseParams.UseFreeFavor!) {
 | 
				
			||||||
                if (syndicate) {
 | 
					                    const inventory = await getInventory(accountId);
 | 
				
			||||||
                    const favour = syndicate.favours.find(x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem);
 | 
					                    const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag)!;
 | 
				
			||||||
                    if (favour) {
 | 
					                    affiliation.FreeFavorsUsed ??= [];
 | 
				
			||||||
                        const inventory = await getInventory(accountId);
 | 
					                    affiliation.FreeFavorsUsed.push(affiliation.FreeFavorsEarned![affiliation.FreeFavorsUsed.length]);
 | 
				
			||||||
                        const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
 | 
					                    await inventory.save();
 | 
				
			||||||
                        if (affiliation) {
 | 
					                } else {
 | 
				
			||||||
                            purchaseResponse.Standing = [
 | 
					                    const syndicate = ExportSyndicates[syndicateTag];
 | 
				
			||||||
                                {
 | 
					                    if (syndicate) {
 | 
				
			||||||
                                    Tag: syndicateTag,
 | 
					                        const favour = syndicate.favours.find(
 | 
				
			||||||
                                    Standing: favour.standingCost
 | 
					                            x => x.storeItem == purchaseRequest.PurchaseParams.StoreItem
 | 
				
			||||||
                                }
 | 
					                        );
 | 
				
			||||||
                            ];
 | 
					                        if (favour) {
 | 
				
			||||||
                            affiliation.Standing -= favour.standingCost;
 | 
					                            const inventory = await getInventory(accountId);
 | 
				
			||||||
                            await inventory.save();
 | 
					                            const affiliation = inventory.Affiliations.find(x => x.Tag == syndicateTag);
 | 
				
			||||||
 | 
					                            if (affiliation) {
 | 
				
			||||||
 | 
					                                purchaseResponse.Standing = [
 | 
				
			||||||
 | 
					                                    {
 | 
				
			||||||
 | 
					                                        Tag: syndicateTag,
 | 
				
			||||||
 | 
					                                        Standing: favour.standingCost
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                ];
 | 
				
			||||||
 | 
					                                affiliation.Standing -= favour.standingCost;
 | 
				
			||||||
 | 
					                                await inventory.save();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user