From ae1ca8f9a6db65d1f5452601d7c3f88fdfd9ccef Mon Sep 17 00:00:00 2001 From: Paco Delozanne Date: Fri, 29 Mar 2024 00:16:54 -0500 Subject: [PATCH] NETSCRIPT: Add Singularity.getFactionEnemies() (#1192) --- ...bitburner.singularity.getfactionenemies.md | 32 +++++++++++++++++++ markdown/bitburner.singularity.md | 1 + src/Netscript/RamCostGenerator.ts | 1 + src/NetscriptFunctions/Singularity.ts | 6 ++++ src/ScriptEditor/NetscriptDefinitions.d.ts | 14 ++++++++ 5 files changed, 54 insertions(+) create mode 100644 markdown/bitburner.singularity.getfactionenemies.md 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