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
5 changed files with 68 additions and 2 deletions
+22 -2
View File
@@ -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 (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<ISingularity> {
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<ISingularity> {
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) {