fix: limit standing gain from medallions for title's max #772
@ -24,16 +24,19 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
|
|||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
addMiscItems(inventory, request.Operation.Items);
|
addMiscItems(inventory, request.Operation.Items);
|
||||||
|
|
||||||
const syndicate = inventory.Affiliations.find(x => x.Tag == request.Operation.AffiliationTag);
|
let syndicate = inventory.Affiliations.find(x => x.Tag == request.Operation.AffiliationTag);
|
||||||
if (syndicate !== undefined) {
|
if (!syndicate) {
|
||||||
syndicate.Standing += gainedStanding;
|
syndicate =
|
||||||
} else {
|
inventory.Affiliations[inventory.Affiliations.push({ Tag: request.Operation.AffiliationTag, Standing: 0 })];
|
||||||
inventory.Affiliations.push({
|
|
||||||
Tag: request.Operation.AffiliationTag,
|
|
||||||
Standing: gainedStanding
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const max = getMaxStanding(request.Operation.AffiliationTag, syndicate.Title ?? 0);
|
||||||
|
if (syndicate.Standing + gainedStanding > max) {
|
||||||
|
gainedStanding = max - syndicate.Standing;
|
||||||
|
}
|
||||||
|
|
||||||
|
syndicate.Standing += gainedStanding;
|
||||||
|
|
||||||
// TODO: Subtract from daily limit bin; maybe also a cheat to skip that.
|
// TODO: Subtract from daily limit bin; maybe also a cheat to skip that.
|
||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
@ -59,3 +62,15 @@ interface ISyndicateStandingBonusRequest {
|
|||||||
};
|
};
|
||||||
ModularWeaponId: IOid; // Seems to just be "000000000000000000000000", also note there's a "Category" query field
|
ModularWeaponId: IOid; // Seems to just be "000000000000000000000000", also note there's a "Category" query field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMaxStanding = (affiliationTag: string, title: number): number => {
|
||||||
|
const syndicate = ExportSyndicates[affiliationTag];
|
||||||
|
if (!syndicate.titles) {
|
||||||
|
// LibrarySyndicate
|
||||||
|
return 125000;
|
||||||
|
}
|
||||||
|
if (title == 0) {
|
||||||
|
return syndicate.titles.find(x => x.level == 1)!.minStanding;
|
||||||
|
}
|
||||||
|
return syndicate.titles.find(x => x.level == title)!.maxStanding;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user