mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 21:25:47 +01:00
Removed redPillFlag and minor refactors to MessageHelpers.ts
Removed redPillFlag, replacing its use with appropriate UI checks. converted MessageFilenames to enum and removed unnecessary type checks.
This commit is contained in:
parent
eaf0098cc7
commit
001e8f6d06
@ -1,9 +1,10 @@
|
||||
import { Message } from "./Message";
|
||||
import { Augmentations } from "../Augmentation/Augmentations";
|
||||
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
||||
import { Router } from "../ui/GameRoot";
|
||||
import { Programs } from "../Programs/Programs";
|
||||
import { Player } from "../Player";
|
||||
import { redPillFlag } from "../RedPill";
|
||||
import { Page } from "../ui/Router";
|
||||
import { GetServer } from "../Server/AllServers";
|
||||
import { Settings } from "../Settings/Settings";
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
@ -51,7 +52,7 @@ function addMessageToServer(msg: Message, serverHostname: string): void {
|
||||
|
||||
//Checks if any of the 'timed' messages should be sent
|
||||
function checkForMessagesToSend(): void {
|
||||
if (redPillFlag) return;
|
||||
if (Router.page() === Page.BitVerse) return;
|
||||
const jumper0 = Messages[MessageFilenames.Jumper0];
|
||||
const jumper1 = Messages[MessageFilenames.Jumper1];
|
||||
const jumper2 = Messages[MessageFilenames.Jumper2];
|
||||
@ -67,33 +68,33 @@ function checkForMessagesToSend(): void {
|
||||
redpillOwned = true;
|
||||
}
|
||||
|
||||
if (redpill && redpillOwned && Player.sourceFiles.length === 0 && !redPillFlag) {
|
||||
if (redpillOwned && Player.sourceFiles.length === 0 && Router.page() !== Page.BitVerse) {
|
||||
sendMessage(redpill, true);
|
||||
} else if (redpill && redpillOwned) {
|
||||
} else if (redpillOwned) {
|
||||
//If player has already destroyed a BitNode, message is not forced
|
||||
if (!redPillFlag) {
|
||||
if (Router.page() !== Page.BitVerse) {
|
||||
sendMessage(redpill);
|
||||
}
|
||||
} else if (jumper0 && !jumper0.recvd && Player.hacking >= 25) {
|
||||
} else if (!jumper0.recvd && Player.hacking >= 25) {
|
||||
sendMessage(jumper0);
|
||||
const flightName = Programs.Flight.name;
|
||||
const homeComp = Player.getHomeComputer();
|
||||
if (!homeComp.programs.includes(flightName)) {
|
||||
homeComp.programs.push(flightName);
|
||||
}
|
||||
} else if (jumper1 && !jumper1.recvd && Player.hacking >= 40) {
|
||||
} else if (!jumper1.recvd && Player.hacking >= 40) {
|
||||
sendMessage(jumper1);
|
||||
} else if (cybersecTest && !cybersecTest.recvd && Player.hacking >= 50) {
|
||||
} else if (!cybersecTest.recvd && Player.hacking >= 50) {
|
||||
sendMessage(cybersecTest);
|
||||
} else if (jumper2 && !jumper2.recvd && Player.hacking >= 175) {
|
||||
} else if (!jumper2.recvd && Player.hacking >= 175) {
|
||||
sendMessage(jumper2);
|
||||
} else if (nitesecTest && !nitesecTest.recvd && Player.hacking >= 200) {
|
||||
} else if (!nitesecTest.recvd && Player.hacking >= 200) {
|
||||
sendMessage(nitesecTest);
|
||||
} else if (jumper3 && !jumper3.recvd && Player.hacking >= 350) {
|
||||
} else if (!jumper3.recvd && Player.hacking >= 350) {
|
||||
sendMessage(jumper3);
|
||||
} else if (jumper4 && !jumper4.recvd && Player.hacking >= 490) {
|
||||
} else if (!jumper4.recvd && Player.hacking >= 490) {
|
||||
sendMessage(jumper4);
|
||||
} else if (bitrunnersTest && !bitrunnersTest.recvd && Player.hacking >= 500) {
|
||||
} else if (!bitrunnersTest.recvd && Player.hacking >= 500) {
|
||||
sendMessage(bitrunnersTest);
|
||||
}
|
||||
}
|
||||
@ -102,23 +103,23 @@ function AddToAllMessages(msg: Message): void {
|
||||
Messages[msg.filename] = msg;
|
||||
}
|
||||
|
||||
let Messages: { [key: string]: Message | undefined } = {};
|
||||
let Messages: { [key: string]: Message } = {};
|
||||
|
||||
function loadMessages(saveString: string): void {
|
||||
Messages = JSON.parse(saveString, Reviver);
|
||||
}
|
||||
|
||||
const MessageFilenames = {
|
||||
Jumper0: "j0.msg",
|
||||
Jumper1: "j1.msg",
|
||||
Jumper2: "j2.msg",
|
||||
Jumper3: "j3.msg",
|
||||
Jumper4: "j4.msg",
|
||||
CyberSecTest: "csec-test.msg",
|
||||
NiteSecTest: "nitesec-test.msg",
|
||||
BitRunnersTest: "19dfj3l1nd.msg",
|
||||
RedPill: "icarus.msg",
|
||||
};
|
||||
enum MessageFilenames {
|
||||
Jumper0 = "j0.msg",
|
||||
Jumper1 = "j1.msg",
|
||||
Jumper2 = "j2.msg",
|
||||
Jumper3 = "j3.msg",
|
||||
Jumper4 = "j4.msg",
|
||||
CyberSecTest = "csec-test.msg",
|
||||
NiteSecTest = "nitesec-test.msg",
|
||||
BitRunnersTest = "19dfj3l1nd.msg",
|
||||
RedPill = "icarus.msg",
|
||||
}
|
||||
|
||||
function initMessages(): void {
|
||||
//Reset
|
||||
|
@ -11,12 +11,6 @@ import { SourceFiles } from "./SourceFile/SourceFiles";
|
||||
import { dialogBoxCreate } from "./ui/React/DialogBox";
|
||||
import { IRouter } from "./ui/Router";
|
||||
|
||||
export let redPillFlag = false;
|
||||
|
||||
export function setRedPillFlag(b: boolean): void {
|
||||
redPillFlag = b;
|
||||
}
|
||||
|
||||
function giveSourceFile(bitNodeNumber: number): void {
|
||||
const sourceFileKey = "SourceFile" + bitNodeNumber.toString();
|
||||
const sourceFile = SourceFiles[sourceFileKey];
|
||||
@ -82,7 +76,6 @@ export function enterBitNode(router: IRouter, flume: boolean, destroyedBitNode:
|
||||
if (newBitNode === 5 && Player.intelligence === 0) {
|
||||
Player.intelligence = 1;
|
||||
}
|
||||
redPillFlag = false;
|
||||
// Set new Bit Node
|
||||
Player.bitNodeN = newBitNode;
|
||||
|
||||
|
@ -51,7 +51,6 @@ import { CONSTANTS } from "../../Constants";
|
||||
import { iTutorialSteps, iTutorialNextStep, ITutorial } from "../../InteractiveTutorial";
|
||||
import { getAvailableCreatePrograms } from "../../Programs/ProgramHelpers";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { redPillFlag } from "../../RedPill";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
|
||||
import { ProgramsSeen } from "../../Programs/ui/ProgramsRoot";
|
||||
@ -275,7 +274,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
// Alt-o - Options
|
||||
function handleShortcuts(this: Document, event: KeyboardEvent): any {
|
||||
if (Settings.DisableHotkeys) return;
|
||||
if ((props.player.isWorking && props.player.focus) || redPillFlag) return;
|
||||
if ((props.player.isWorking && props.player.focus) || props.router.page() === Page.BitVerse) return;
|
||||
if (event.key === KEY.T && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickTerminal();
|
||||
|
Loading…
Reference in New Issue
Block a user