diff --git a/markdown/bitburner.singularity.getfactionenemies.md b/markdown/bitburner.singularity.getfactionenemies.md new file mode 100644 index 000000000..03744a279 --- /dev/null +++ b/markdown/bitburner.singularity.getfactionenemies.md @@ -0,0 +1,32 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [Singularity](./bitburner.singularity.md) > [getFactionEnemies](./bitburner.singularity.getfactionenemies.md) + +## Singularity.getFactionEnemies() method + +Get a list of enemies of a faction. + +**Signature:** + +```typescript +getFactionEnemies(faction: string): string[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| faction | string | Name of faction. | + +**Returns:** + +string\[\] + +Array containing the names of all enemies of the faction. + +## Remarks + +RAM cost: 3 GB \* 16/4/1 + +Returns an array containing the names (as strings) of all factions that are enemies of the specified faction. + diff --git a/markdown/bitburner.singularity.md b/markdown/bitburner.singularity.md index 75579c6ec..2af682153 100644 --- a/markdown/bitburner.singularity.md +++ b/markdown/bitburner.singularity.md @@ -48,6 +48,7 @@ This API requires Source-File 4 to use. The RAM cost of all these functions is m | [getCurrentWork()](./bitburner.singularity.getcurrentwork.md) | Get the current work the player is doing. | | [getDarkwebProgramCost(programName)](./bitburner.singularity.getdarkwebprogramcost.md) | Check the price of an exploit on the dark web | | [getDarkwebPrograms()](./bitburner.singularity.getdarkwebprograms.md) | Get a list of programs offered on the dark web. | +| [getFactionEnemies(faction)](./bitburner.singularity.getfactionenemies.md) | Get a list of enemies of a faction. | | [getFactionFavor(faction)](./bitburner.singularity.getfactionfavor.md) | Get faction favor. | | [getFactionFavorGain(faction)](./bitburner.singularity.getfactionfavorgain.md) | Get faction favor gain. | | [getFactionInviteRequirements(faction)](./bitburner.singularity.getfactioninviterequirements.md) | List conditions for being invited to a faction. | diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 9b0f5cfd6..e8e3a8a45 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -182,6 +182,7 @@ const singularity = { getCompanyFavor: SF4Cost(RamCostConstants.SingularityFn2 / 3), getCompanyFavorGain: SF4Cost(RamCostConstants.SingularityFn2 / 4), getFactionInviteRequirements: SF4Cost(RamCostConstants.SingularityFn2), + getFactionEnemies: SF4Cost(RamCostConstants.SingularityFn2), checkFactionInvitations: SF4Cost(RamCostConstants.SingularityFn2), joinFaction: SF4Cost(RamCostConstants.SingularityFn2), workForFaction: SF4Cost(RamCostConstants.SingularityFn2), diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index afbf1d020..61b169493 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -768,6 +768,12 @@ export function NetscriptSingularity(): InternalAPI { const fac = Factions[facName]; return [...fac.getInfo().inviteReqs].map((condition) => condition.toJSON()); }, + getFactionEnemies: (ctx) => (_facName) => { + helpers.checkSingularityAccess(ctx); + const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName); + const fac = Factions[facName]; + return fac.getInfo().enemies.slice(); + }, checkFactionInvitations: (ctx) => () => { helpers.checkSingularityAccess(ctx); // Manually trigger a check for faction invites diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 72ae88bad..2c4256bbf 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2077,6 +2077,20 @@ export interface Singularity { */ getFactionInviteRequirements(faction: string): PlayerRequirement[]; + /** + * Get a list of enemies of a faction. + * @remarks + * RAM cost: 3 GB * 16/4/1 + * + * + * Returns an array containing the names (as strings) of all factions + * that are enemies of the specified faction. + * + * @param faction - Name of faction. + * @returns Array containing the names of all enemies of the faction. + */ + getFactionEnemies(faction: string): string[]; + /** * List all current faction invitations. * @remarks