diff --git a/markdown/bitburner.singularity.joinfaction.md b/markdown/bitburner.singularity.joinfaction.md index c8629ba9b..f8bdd2f68 100644 --- a/markdown/bitburner.singularity.joinfaction.md +++ b/markdown/bitburner.singularity.joinfaction.md @@ -52,7 +52,7 @@ Name of faction to join. boolean -True if player joined the faction, and false otherwise. +True if the player successfully accepts an invitation, and false otherwise. ## Remarks @@ -60,3 +60,5 @@ RAM cost: 3 GB \* 16/4/1 This function will automatically accept an invitation from a faction and join it. +Note that this function returns false if you are already a member of the specified faction. + diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index f17835655..06cb750ea 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -779,6 +779,11 @@ export function NetscriptSingularity(): InternalAPI { helpers.checkSingularityAccess(ctx); const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName); + if (Player.factions.includes(facName)) { + helpers.log(ctx, () => `You are already a member of faction '${facName}'`); + return false; + } + if (!Player.factionInvitations.includes(facName)) { helpers.log(ctx, () => `You have not been invited by faction '${facName}'`); return false; diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 13e240c4f..a67667019 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2362,8 +2362,10 @@ export interface Singularity { * * This function will automatically accept an invitation from a faction and join it. * + * Note that this function returns false if you are already a member of the specified faction. + * * @param faction - Name of faction to join. - * @returns True if player joined the faction, and false otherwise. + * @returns True if the player successfully accepts an invitation, and false otherwise. */ joinFaction(faction: FactionName): boolean;