Merge branch 'feature/add-infiltration-faction' into feature/refactor-augmentation

This commit is contained in:
phyzical
2022-04-15 14:26:00 +08:00
19 changed files with 232 additions and 98 deletions
+32 -19
View File
@@ -24,7 +24,6 @@ import { findCrime } from "../Crime/CrimeHelpers";
import { CompanyPosition } from "../Company/CompanyPosition";
import { CompanyPositions } from "../Company/CompanyPositions";
import { DarkWebItems } from "../DarkWeb/DarkWebItems";
import { AllGangs } from "../Gang/AllGangs";
import { CityName } from "../Locations/data/CityNames";
import { LocationName } from "../Locations/data/LocationNames";
import { Router } from "../ui/GameRoot";
@@ -50,6 +49,7 @@ import { FactionInfos } from "../Faction/FactionInfo";
import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
import { BlackOperationNames } from "../Bladeburner/data/BlackOperationNames";
import { enterBitNode } from "../RedPill";
import { FactionNames } from "../Faction/data/FactionNames";
export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript): InternalAPI<ISingularity> {
const getAugmentation = function (_ctx: NetscriptContext, name: string): Augmentation {
@@ -1048,11 +1048,14 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
const facName = _ctx.helper.string("facName", _facName);
const type = _ctx.helper.string("type", _type);
const focus = _ctx.helper.boolean(_focus);
getFaction(_ctx, facName);
const faction = getFaction(_ctx, facName);
// if the player is in a gang and the target faction is any of the gang faction, fail
if (player.inGang() && AllGangs[facName] !== undefined) {
workerScript.log("workForFaction", () => `Faction '${facName}' does not offer work at the moment.`);
if (player.inGang() && faction.name === player.getGangFaction().name) {
workerScript.log(
"workForFaction",
() => `You can't work for '${facName}' because youre managing a gang for it`,
);
return false;
}
@@ -1067,21 +1070,18 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
workerScript.log("workForFaction", () => txt);
}
const fac = Factions[facName];
// Arrays listing factions that allow each time of work
switch (type.toLowerCase()) {
case "hacking":
case "hacking contracts":
case "hackingcontracts":
if (!FactionInfos[fac.name].offerHackingWork) {
if (!FactionInfos[faction.name].offerHackingWork) {
workerScript.log(
"workForFaction",
() => `Faction '${fac.name}' do not need help with hacking contracts.`,
() => `Faction '${faction.name}' do not need help with hacking contracts.`,
);
return false;
}
player.startFactionHackWork(fac);
player.startFactionHackWork(faction);
if (focus) {
player.startFocusing();
Router.toWork();
@@ -1089,16 +1089,19 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
player.stopFocusing();
Router.toTerminal();
}
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${fac.name}'`);
workerScript.log("workForFaction", () => `Started carrying out hacking contracts for '${faction.name}'`);
return true;
case "field":
case "fieldwork":
case "field work":
if (!FactionInfos[fac.name].offerFieldWork) {
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with field missions.`);
if (!FactionInfos[faction.name].offerFieldWork) {
workerScript.log(
"workForFaction",
() => `Faction '${faction.name}' do not need help with field missions.`,
);
return false;
}
player.startFactionFieldWork(fac);
player.startFactionFieldWork(faction);
if (focus) {
player.startFocusing();
Router.toWork();
@@ -1106,16 +1109,19 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
player.stopFocusing();
Router.toTerminal();
}
workerScript.log("workForFaction", () => `Started carrying out field missions for '${fac.name}'`);
workerScript.log("workForFaction", () => `Started carrying out field missions for '${faction.name}'`);
return true;
case "security":
case "securitywork":
case "security work":
if (!FactionInfos[fac.name].offerSecurityWork) {
workerScript.log("workForFaction", () => `Faction '${fac.name}' do not need help with security work.`);
if (!FactionInfos[faction.name].offerSecurityWork) {
workerScript.log(
"workForFaction",
() => `Faction '${faction.name}' do not need help with security work.`,
);
return false;
}
player.startFactionSecurityWork(fac);
player.startFactionSecurityWork(faction);
if (focus) {
player.startFocusing();
Router.toWork();
@@ -1123,7 +1129,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
player.stopFocusing();
Router.toTerminal();
}
workerScript.log("workForFaction", () => `Started carrying out security work for '${fac.name}'`);
workerScript.log("workForFaction", () => `Started carrying out security work for '${faction.name}'`);
return true;
default:
workerScript.log("workForFaction", () => `Invalid work type: '${type}`);
@@ -1168,6 +1174,13 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
);
return false;
}
if (faction.name === FactionNames.ChurchOfTheMachineGod || faction.name === FactionNames.Bladeburners) {
workerScript.log(
"donateToFaction",
() => `You can't donate to '${facName}' because they do not accept donations`,
);
return false;
}
if (typeof amt !== "number" || amt <= 0 || isNaN(amt)) {
workerScript.log("donateToFaction", () => `Invalid donation amount: '${amt}'.`);
return false;