Files should be saved on the server that opened them.

This commit is contained in:
Olivier Gagnon 2021-12-13 20:08:58 -05:00
parent 50bc9496ec
commit e5b4dd8e90
2 changed files with 30 additions and 3 deletions

@ -29,6 +29,9 @@ import { N00dles } from "../../utils/helpers/N00dles";
import { Exploit } from "../../Exploits/Exploit"; import { Exploit } from "../../Exploits/Exploit";
import { applyAugmentation } from "../../Augmentation/AugmentationHelpers"; import { applyAugmentation } from "../../Augmentation/AugmentationHelpers";
import { CorruptableText } from "../../ui/React/CorruptableText"; import { CorruptableText } from "../../ui/React/CorruptableText";
import { HacknetNode } from "../../Hacknet/HacknetNode";
import { HacknetServer } from "../../Hacknet/HacknetServer";
import { GetServer } from "../../Server/AllServers";
type IProps = { type IProps = {
loc: Location; loc: Location;
@ -84,11 +87,34 @@ export function SpecialLocation(props: IProps): React.ReactElement {
function renderNoodleBar(): React.ReactElement { function renderNoodleBar(): React.ReactElement {
function EatNoodles(): void { function EatNoodles(): void {
SnackbarEvents.emit("You ate some delicious noodles and feel refreshed", "success"); SnackbarEvents.emit("You ate some delicious noodles and feel refreshed", "success");
N00dles(); N00dles(); // This is the true power of the noodles.
if (player.sourceFiles.length > 0) player.giveExploit(Exploit.N00dles); if (player.sourceFiles.length > 0) player.giveExploit(Exploit.N00dles);
if (player.sourceFileLvl(5) > 0 || player.bitNodeN === 5) { if (player.sourceFileLvl(5) > 0 || player.bitNodeN === 5) {
player.intelligence_exp *= 1.0000000000000002; player.intelligence_exp *= 1.0000000000000002;
} }
player.hacking_exp *= 1.0000000000000002;
player.strength_exp *= 1.0000000000000002;
player.defense_exp *= 1.0000000000000002;
player.agility_exp *= 1.0000000000000002;
player.dexterity_exp *= 1.0000000000000002;
player.charisma_exp *= 1.0000000000000002;
for (const node of player.hacknetNodes) {
if (node instanceof HacknetNode) {
player.gainMoney(node.moneyGainRatePerSecond * 0.001, "other");
} else {
const server = GetServer(node);
if (!(server instanceof HacknetServer)) throw new Error(`Server ${node} is not a hacknet server.`);
player.hashManager.storeHashes(server.hashRate * 0.001);
}
}
if (player.bladeburner) {
player.bladeburner.rank += 0.00001;
}
if (player.corporation) {
player.corporation.funds += player.corporation.revenue * 0.01;
}
} }
return ( return (

@ -23,6 +23,7 @@ import { iTutorialNextStep, ITutorial, iTutorialSteps } from "../../InteractiveT
import { debounce } from "lodash"; import { debounce } from "lodash";
import { saveObject } from "../../SaveObject"; import { saveObject } from "../../SaveObject";
import { loadThemes } from "./themes"; import { loadThemes } from "./themes";
import { GetServer } from "../../Server/AllServers";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
@ -146,7 +147,7 @@ export function Root(props: IProps): React.ReactElement {
} }
//Save the script //Save the script
const server = props.player.getCurrentServer(); const server = GetServer(hostname);
if (server === null) throw new Error("Server should not be null but it is."); if (server === null) throw new Error("Server should not be null but it is.");
let found = false; let found = false;
for (let i = 0; i < server.scripts.length; i++) { for (let i = 0; i < server.scripts.length; i++) {
@ -180,7 +181,7 @@ export function Root(props: IProps): React.ReactElement {
return; return;
} }
const server = props.player.getCurrentServer(); const server = GetServer(hostname);
if (server === null) throw new Error("Server should not be null but it is."); if (server === null) throw new Error("Server should not be null but it is.");
if (isScriptFilename(filename)) { if (isScriptFilename(filename)) {
//If the current script already exists on the server, overwrite it //If the current script already exists on the server, overwrite it