SINGULARITY: Add ns.singularity.getFactionWorkTypes (#1425)

This commit is contained in:
catloversg 2024-06-25 10:43:36 +07:00 committed by GitHub
parent 0d8cc54c99
commit 5a8f0e99af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 68 additions and 2 deletions

@ -0,0 +1,32 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Singularity](./bitburner.singularity.md) &gt; [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.

@ -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. | | [getFactionFavorGain(faction)](./bitburner.singularity.getfactionfavorgain.md) | Get faction favor gain. |
| [getFactionInviteRequirements(faction)](./bitburner.singularity.getfactioninviterequirements.md) | List conditions for being invited to a faction. | | [getFactionInviteRequirements(faction)](./bitburner.singularity.getfactioninviterequirements.md) | List conditions for being invited to a faction. |
| [getFactionRep(faction)](./bitburner.singularity.getfactionrep.md) | Get faction reputation. | | [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. | | [getOwnedAugmentations(purchased)](./bitburner.singularity.getownedaugmentations.md) | Get a list of owned augmentation. |
| [getOwnedSourceFiles()](./bitburner.singularity.getownedsourcefiles.md) | Get a list of acquired Source-Files. | | [getOwnedSourceFiles()](./bitburner.singularity.getownedsourcefiles.md) | Get a list of acquired Source-Files. |
| [getUpgradeHomeCoresCost()](./bitburner.singularity.getupgradehomecorescost.md) | Get the price of upgrading home cores. | | [getUpgradeHomeCoresCost()](./bitburner.singularity.getupgradehomecorescost.md) | Get the price of upgrading home cores. |

@ -186,6 +186,7 @@ const singularity = {
checkFactionInvitations: SF4Cost(RamCostConstants.SingularityFn2), checkFactionInvitations: SF4Cost(RamCostConstants.SingularityFn2),
joinFaction: SF4Cost(RamCostConstants.SingularityFn2), joinFaction: SF4Cost(RamCostConstants.SingularityFn2),
workForFaction: SF4Cost(RamCostConstants.SingularityFn2), workForFaction: SF4Cost(RamCostConstants.SingularityFn2),
getFactionWorkTypes: SF4Cost(RamCostConstants.SingularityFn2 / 3),
getFactionRep: SF4Cost(RamCostConstants.SingularityFn2 / 3), getFactionRep: SF4Cost(RamCostConstants.SingularityFn2 / 3),
getFactionFavor: SF4Cost(RamCostConstants.SingularityFn2 / 3), getFactionFavor: SF4Cost(RamCostConstants.SingularityFn2 / 3),
getFactionFavorGain: SF4Cost(RamCostConstants.SingularityFn2 / 4), getFactionFavorGain: SF4Cost(RamCostConstants.SingularityFn2 / 4),

@ -827,7 +827,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
// if the player is in a gang and the target faction is any of the gang faction, fail // 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) { 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; return false;
} }
@ -913,6 +913,26 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return false; 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) => { getFactionRep: (ctx) => (_facName) => {
helpers.checkSingularityAccess(ctx); helpers.checkSingularityAccess(ctx);
const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName); const facName = getEnumHelper("FactionName").nsGetMember(ctx, _facName);
@ -941,7 +961,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
return false; return false;
} }
if (Player.gang && faction.name === Player.getGangFaction().name) { 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; return false;
} }
if (faction.name === FactionName.ChurchOfTheMachineGod || faction.name === FactionName.Bladeburners) { if (faction.name === FactionName.ChurchOfTheMachineGod || faction.name === FactionName.Bladeburners) {

@ -2149,6 +2149,18 @@ export interface Singularity {
*/ */
workForFaction(faction: string, workType: FactionWorkType | `${FactionWorkType}`, focus?: boolean): boolean; 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. * Get faction reputation.
* @remarks * @remarks