From a62bdcafefbb353a2d5ec55d7e95a56e9612376e Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:06:57 +0700 Subject: [PATCH] BUGFIX: Fix a bug in ns.singularity.getAugmentationFactions (#1418) --- src/NetscriptFunctions/Singularity.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index b401fb1ed..c35e2fa03 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -100,7 +100,29 @@ export function NetscriptSingularity(): InternalAPI { helpers.checkSingularityAccess(ctx); const augName = getEnumHelper("AugmentationName").nsGetMember(ctx, _augName); const aug = Augmentations[augName]; - return aug.factions.slice(); + const factions = aug.factions.slice(); + if (!Player.gang) { + return factions; + } + const gangFactionName = Player.gang.facName; + const augmentationListOfGangFaction = getFactionAugmentationsFiltered(Factions[gangFactionName]); + /** + * If the gang faction does not offer this augmentation, we need to remove the gang faction from the faction list. + * Example: "NeuroFlux Governor" + */ + if (!augmentationListOfGangFaction.includes(augName)) { + return factions.filter((factionName) => factionName !== gangFactionName); + } + /** + * If the gang faction offers this augmentation, but the faction list does not contain the gang faction, we need + * to add the gang faction to that list. + * Example: "The Red Pill" in BN2 + */ + if (augmentationListOfGangFaction.includes(augName) && !factions.includes(gangFactionName)) { + factions.push(gangFactionName); + return factions; + } + return factions; }, getAugmentationsFromFaction: (ctx) => (_facName) => { helpers.checkSingularityAccess(ctx);