diff --git a/markdown/bitburner.singularity.getfactionworktypes.md b/markdown/bitburner.singularity.getfactionworktypes.md new file mode 100644 index 000000000..88d9dbe9a --- /dev/null +++ b/markdown/bitburner.singularity.getfactionworktypes.md @@ -0,0 +1,32 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [Singularity](./bitburner.singularity.md) > [getFactionWorkTypes](./bitburner.singularity.getfactionworktypes.md) + +## Singularity.getFactionWorkTypes() method + +Get the work types of a faction. + +**Signature:** + +```typescript +getFactionWorkTypes(faction: string): FactionWorkType[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| faction | string | Name of the faction. | + +**Returns:** + +[FactionWorkType](./bitburner.factionworktype.md)\[\] + +The work types of the faction. + +## Remarks + +RAM cost: 1 GB \* 16/4/1 + +This function returns an array containing the work types of the specified faction. + diff --git a/markdown/bitburner.singularity.md b/markdown/bitburner.singularity.md index 2af682153..29511d602 100644 --- a/markdown/bitburner.singularity.md +++ b/markdown/bitburner.singularity.md @@ -53,6 +53,7 @@ This API requires Source-File 4 to use. The RAM cost of all these functions is m | [getFactionFavorGain(faction)](./bitburner.singularity.getfactionfavorgain.md) | Get faction favor gain. | | [getFactionInviteRequirements(faction)](./bitburner.singularity.getfactioninviterequirements.md) | List conditions for being invited to a faction. | | [getFactionRep(faction)](./bitburner.singularity.getfactionrep.md) | Get faction reputation. | +| [getFactionWorkTypes(faction)](./bitburner.singularity.getfactionworktypes.md) | Get the work types of a faction. | | [getOwnedAugmentations(purchased)](./bitburner.singularity.getownedaugmentations.md) | Get a list of owned augmentation. | | [getOwnedSourceFiles()](./bitburner.singularity.getownedsourcefiles.md) | Get a list of acquired Source-Files. | | [getUpgradeHomeCoresCost()](./bitburner.singularity.getupgradehomecorescost.md) | Get the price of upgrading home cores. | diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index 4423efe96..426d2471b 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -186,6 +186,7 @@ const singularity = { checkFactionInvitations: SF4Cost(RamCostConstants.SingularityFn2), joinFaction: SF4Cost(RamCostConstants.SingularityFn2), workForFaction: SF4Cost(RamCostConstants.SingularityFn2), + getFactionWorkTypes: SF4Cost(RamCostConstants.SingularityFn2 / 3), getFactionRep: SF4Cost(RamCostConstants.SingularityFn2 / 3), getFactionFavor: SF4Cost(RamCostConstants.SingularityFn2 / 3), getFactionFavorGain: SF4Cost(RamCostConstants.SingularityFn2 / 4), diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index f11213d79..d8fdd4823 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -827,7 +827,7 @@ export function NetscriptSingularity(): InternalAPI { // if the player is in a gang and the target faction is any of the gang faction, fail if (Player.gang && faction.name === Player.getGangFaction().name) { - helpers.log(ctx, () => `You can't work for '${facName}' because youre managing a gang for it`); + helpers.log(ctx, () => `You can't work for '${facName}' because you are managing a gang for it`); return false; } @@ -913,6 +913,26 @@ export function NetscriptSingularity(): InternalAPI { return false; } }, + getFactionWorkTypes: (ctx) => (_facName) => { + helpers.checkSingularityAccess(ctx); + const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName); + // Gang does not offer normal work. + if (Player.gang?.facName === facName) { + return []; + } + const factionInfo = Factions[facName].getInfo(); + const workTypes = []; + if (factionInfo.offerHackingWork) { + workTypes.push(FactionWorkType.hacking); + } + if (factionInfo.offerFieldWork) { + workTypes.push(FactionWorkType.field); + } + if (factionInfo.offerSecurityWork) { + workTypes.push(FactionWorkType.security); + } + return workTypes; + }, getFactionRep: (ctx) => (_facName) => { helpers.checkSingularityAccess(ctx); const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName); @@ -941,7 +961,7 @@ export function NetscriptSingularity(): InternalAPI { return false; } if (Player.gang && faction.name === Player.getGangFaction().name) { - helpers.log(ctx, () => `You can't donate to '${facName}' because youre managing a gang for it`); + helpers.log(ctx, () => `You can't donate to '${facName}' because you are managing a gang for it`); return false; } if (faction.name === FactionName.ChurchOfTheMachineGod || faction.name === FactionName.Bladeburners) { diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index a4c038203..e995b1acf 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2149,6 +2149,18 @@ export interface Singularity { */ workForFaction(faction: string, workType: FactionWorkType | `${FactionWorkType}`, focus?: boolean): boolean; + /** + * Get the work types of a faction. + * @remarks + * RAM cost: 1 GB * 16/4/1 + * + * This function returns an array containing the work types of the specified faction. + * + * @param faction - Name of the faction. + * @returns The work types of the faction. + */ + getFactionWorkTypes(faction: string): FactionWorkType[]; + /** * Get faction reputation. * @remarks