Merge branch 'dev' into bugfix/corp-updates

This commit is contained in:
hydroflame
2022-04-13 16:20:22 -04:00
committed by GitHub
38 changed files with 345 additions and 271 deletions
+5
View File
@@ -3,11 +3,13 @@ import { IPlayer } from "../PersonObjects/IPlayer";
import { Exploit } from "../Exploits/Exploit";
import * as bcrypt from "bcryptjs";
import { INetscriptHelper } from "./INetscriptHelper";
import { Apr1Events as devMenu } from "../ui/Apr1";
export interface INetscriptExtra {
heart: {
break(): number;
};
openDevMenu(): void;
exploit(): void;
bypass(doc: Document): void;
alterReality(): void;
@@ -22,6 +24,9 @@ export function NetscriptExtra(player: IPlayer, workerScript: WorkerScript, help
return player.karma;
},
},
openDevMenu: function (): void {
devMenu.emit();
},
exploit: function (): void {
player.giveExploit(Exploit.UndocumentedFunctionCall);
},
+11 -4
View File
@@ -4,7 +4,7 @@ import { CityName } from "../Locations/data/CityNames";
import { getRamCost } from "../Netscript/RamCostGenerator";
import { WorkerScript } from "../Netscript/WorkerScript";
import { GraftableAugmentation } from "../PersonObjects/Grafting/GraftableAugmentation";
import { getAvailableAugs } from "../PersonObjects/Grafting/ui/GraftingRoot";
import { getGraftingAvailableAugs } from "../PersonObjects/Grafting/GraftingHelpers";
import { IPlayer } from "../PersonObjects/IPlayer";
import { Grafting as IGrafting } from "../ScriptEditor/NetscriptDefinitions";
import { Router } from "../ui/GameRoot";
@@ -28,7 +28,7 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
updateRam("getAugmentationGraftPrice");
const augName = helper.string("getAugmentationGraftPrice", "augName", _augName);
checkGraftingAPIAccess("getAugmentationGraftPrice");
if (!Augmentations.hasOwnProperty(augName)) {
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftPrice", `Invalid aug: ${augName}`);
}
const craftableAug = new GraftableAugmentation(Augmentations[augName]);
@@ -39,13 +39,20 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
updateRam("getAugmentationGraftTime");
const augName = helper.string("getAugmentationGraftTime", "augName", _augName);
checkGraftingAPIAccess("getAugmentationGraftTime");
if (!Augmentations.hasOwnProperty(augName)) {
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftTime", `Invalid aug: ${augName}`);
}
const craftableAug = new GraftableAugmentation(Augmentations[augName]);
return craftableAug.time;
},
getGraftableAugmentations: (): string[] => {
updateRam("getGraftableAugmentations");
checkGraftingAPIAccess("getGraftableAugmentations");
const graftableAugs = getGraftingAvailableAugs(player);
return graftableAugs;
},
graftAugmentation: (_augName: string, _focus: unknown = true): boolean => {
updateRam("graftAugmentation");
const augName = helper.string("graftAugmentation", "augName", _augName);
@@ -57,7 +64,7 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
"You must be in New Tokyo to begin grafting an Augmentation.",
);
}
if (!getAvailableAugs(player).includes(augName)) {
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
workerScript.log("grafting.graftAugmentation", () => `Invalid aug: ${augName}`);
return false;
}
+13
View File
@@ -580,6 +580,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
throw _ctx.helper.makeRuntimeErrorMsg(`Invalid hostname: '${hostname}'`);
}
//Home case
if (hostname === "home") {
player.getCurrentServer().isConnectedTo = false;
player.currentServer = player.getHomeComputer().hostname;
@@ -588,6 +589,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
return true;
}
//Adjacent server case
const server = player.getCurrentServer();
for (let i = 0; i < server.serversOnNetwork.length; i++) {
const other = getServerOnNetwork(server, i);
@@ -601,6 +603,17 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
}
}
//Backdoor case
const other = GetServer(hostname);
if (other !== null && other instanceof Server && other.backdoorInstalled) {
player.getCurrentServer().isConnectedTo = false;
player.currentServer = target.hostname;
player.getCurrentServer().isConnectedTo = true;
Terminal.setcwd("/");
return true;
}
//Failure case
return false;
},
manualHack: (_ctx: NetscriptContext) =>