mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 06:48:42 +02:00
most terminal converted to ts
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
import { IPlayer, IProgramCreate } from "../Program";
|
||||
import { IProgramCreate } from "../Program";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
import { Server } from "../../Server/Server";
|
||||
import { ITerminal } from "../../Terminal/ITerminal";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||
import { convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions";
|
||||
import { getServer } from "../../Server/ServerHelpers";
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { createPopup } from "../../ui/React/createPopup";
|
||||
import { BitFlumePopup } from "../../BitNode/ui/BitFlumePopup";
|
||||
|
||||
import { calculateHackingTime, calculateGrowTime, calculateWeakenTime } from "../../Hacking";
|
||||
|
||||
function requireHackingLevel(lvl: number) {
|
||||
return function (p: IPlayer) {
|
||||
@@ -17,6 +30,7 @@ export interface IProgramCreationParams {
|
||||
key: string;
|
||||
name: string;
|
||||
create: IProgramCreate | null;
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer, args: string[]) => void;
|
||||
}
|
||||
|
||||
export const programsMetadata: IProgramCreationParams[] = [
|
||||
@@ -29,6 +43,25 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(1),
|
||||
time: CONSTANTS.MillisecondsPerFiveMinutes,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer): void => {
|
||||
if (!(server instanceof Server)) {
|
||||
terminal.error("Cannot nuke this kind of server.");
|
||||
return;
|
||||
}
|
||||
if (server.hasAdminRights) {
|
||||
terminal.print("You already have root access to this computer. There is no reason to run NUKE.exe");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.openPortCount >= player.getCurrentServer().numOpenPortsRequired) {
|
||||
server.hasAdminRights = true;
|
||||
terminal.print("NUKE successful! Gained root access to " + player.getCurrentServer().hostname);
|
||||
// TODO: Make this take time rather than be instant
|
||||
return;
|
||||
}
|
||||
|
||||
terminal.print("NUKE unsuccessful. Not enough ports have been opened");
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "BruteSSHProgram",
|
||||
@@ -39,6 +72,20 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(50),
|
||||
time: CONSTANTS.MillisecondsPerFiveMinutes * 2,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer): void => {
|
||||
if (!(server instanceof Server)) {
|
||||
terminal.error("Cannot run BruteSSH.exe on this kind of server.");
|
||||
return;
|
||||
}
|
||||
if (server.sshPortOpen) {
|
||||
terminal.print("SSH Port (22) is already open!");
|
||||
return;
|
||||
}
|
||||
|
||||
server.sshPortOpen = true;
|
||||
terminal.print("Opened SSH Port(22)!");
|
||||
server.openPortCount++;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "FTPCrackProgram",
|
||||
@@ -49,6 +96,20 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(100),
|
||||
time: CONSTANTS.MillisecondsPerHalfHour,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer): void => {
|
||||
if (!(server instanceof Server)) {
|
||||
terminal.error("Cannot run FTPCrack.exe on this kind of server.");
|
||||
return;
|
||||
}
|
||||
if (server.ftpPortOpen) {
|
||||
terminal.print("FTP Port (21) is already open!");
|
||||
return;
|
||||
}
|
||||
|
||||
server.ftpPortOpen = true;
|
||||
terminal.print("Opened FTP Port (21)!");
|
||||
server.openPortCount++;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "RelaySMTPProgram",
|
||||
@@ -59,6 +120,20 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(250),
|
||||
time: CONSTANTS.MillisecondsPer2Hours,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer): void => {
|
||||
if (!(server instanceof Server)) {
|
||||
terminal.error("Cannot run relaySMTP.exe on this kind of server.");
|
||||
return;
|
||||
}
|
||||
if (server.smtpPortOpen) {
|
||||
terminal.print("SMTP Port (25) is already open!");
|
||||
return;
|
||||
}
|
||||
|
||||
server.smtpPortOpen = true;
|
||||
terminal.print("Opened SMTP Port (25)!");
|
||||
server.openPortCount++;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "HTTPWormProgram",
|
||||
@@ -69,6 +144,20 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(500),
|
||||
time: CONSTANTS.MillisecondsPer4Hours,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer): void => {
|
||||
if (!(server instanceof Server)) {
|
||||
terminal.error("Cannot run HTTPWorm.exe on this kind of server.");
|
||||
return;
|
||||
}
|
||||
if (server.httpPortOpen) {
|
||||
terminal.print("HTTP Port (80) is already open!");
|
||||
return;
|
||||
}
|
||||
|
||||
server.httpPortOpen = true;
|
||||
terminal.print("Opened HTTP Port (80)!");
|
||||
server.openPortCount++;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "SQLInjectProgram",
|
||||
@@ -79,6 +168,20 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(750),
|
||||
time: CONSTANTS.MillisecondsPer8Hours,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer): void => {
|
||||
if (!(server instanceof Server)) {
|
||||
terminal.error("Cannot run SQLInject.exe on this kind of server.");
|
||||
return;
|
||||
}
|
||||
if (server.sqlPortOpen) {
|
||||
terminal.print("SQL Port (1433) is already open!");
|
||||
return;
|
||||
}
|
||||
|
||||
server.sqlPortOpen = true;
|
||||
terminal.print("Opened SQL Port (1433)!");
|
||||
server.openPortCount++;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "DeepscanV1",
|
||||
@@ -89,6 +192,10 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(75),
|
||||
time: CONSTANTS.MillisecondsPerQuarterHour,
|
||||
},
|
||||
run: (terminal: ITerminal): void => {
|
||||
terminal.print("This executable cannot be run.");
|
||||
terminal.print("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5.");
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "DeepscanV2",
|
||||
@@ -99,6 +206,10 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(400),
|
||||
time: CONSTANTS.MillisecondsPer2Hours,
|
||||
},
|
||||
run: (terminal: ITerminal): void => {
|
||||
terminal.print("This executable cannot be run.");
|
||||
terminal.print("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10.");
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "ServerProfiler",
|
||||
@@ -109,6 +220,46 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(75),
|
||||
time: CONSTANTS.MillisecondsPerHalfHour,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer, server: BaseServer, args: string[]): void => {
|
||||
if (args.length !== 1) {
|
||||
terminal.print("Must pass a server hostname or IP as an argument for ServerProfiler.exe");
|
||||
return;
|
||||
}
|
||||
|
||||
const targetServer = getServer(args[0]);
|
||||
if (targetServer == null) {
|
||||
terminal.print("Invalid server IP/hostname");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetServer instanceof HacknetServer) {
|
||||
terminal.print(`ServerProfiler.exe cannot be run on a Hacknet Server.`);
|
||||
return;
|
||||
}
|
||||
|
||||
terminal.print(targetServer.hostname + ":");
|
||||
terminal.print("Server base security level: " + targetServer.baseDifficulty);
|
||||
terminal.print("Server current security level: " + targetServer.hackDifficulty);
|
||||
terminal.print("Server growth rate: " + targetServer.serverGrowth);
|
||||
terminal.print(
|
||||
`Netscript hack() execution time: ${convertTimeMsToTimeElapsedString(
|
||||
calculateHackingTime(targetServer, player) * 1000,
|
||||
true,
|
||||
)}`,
|
||||
);
|
||||
terminal.print(
|
||||
`Netscript grow() execution time: ${convertTimeMsToTimeElapsedString(
|
||||
calculateGrowTime(targetServer, player) * 1000,
|
||||
true,
|
||||
)}`,
|
||||
);
|
||||
terminal.print(
|
||||
`Netscript weaken() execution time: ${convertTimeMsToTimeElapsedString(
|
||||
calculateWeakenTime(targetServer, player) * 1000,
|
||||
true,
|
||||
)}`,
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "AutoLink",
|
||||
@@ -119,6 +270,11 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: requireHackingLevel(25),
|
||||
time: CONSTANTS.MillisecondsPerQuarterHour,
|
||||
},
|
||||
run: (terminal: ITerminal): void => {
|
||||
terminal.print("This executable cannot be run.");
|
||||
terminal.print("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'.");
|
||||
terminal.print("When using scan-analyze, click on a server's hostname to connect to it.");
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "BitFlume",
|
||||
@@ -129,10 +285,31 @@ export const programsMetadata: IProgramCreationParams[] = [
|
||||
req: bitFlumeRequirements(),
|
||||
time: CONSTANTS.MillisecondsPerFiveMinutes / 20,
|
||||
},
|
||||
run: (terminal: ITerminal, player: IPlayer): void => {
|
||||
const popupId = "bitflume-popup";
|
||||
createPopup(popupId, BitFlumePopup, {
|
||||
player: player,
|
||||
popupId: popupId,
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "Flight",
|
||||
name: "fl1ght.exe",
|
||||
create: null,
|
||||
run: (terminal: ITerminal, player: IPlayer): void => {
|
||||
const numAugReq = Math.round(BitNodeMultipliers.DaedalusAugsRequirement * 30);
|
||||
const fulfilled =
|
||||
player.augmentations.length >= numAugReq && player.money.gt(1e11) && player.hacking_skill >= 2500;
|
||||
if (!fulfilled) {
|
||||
terminal.print(`Augmentations: ${player.augmentations.length} / ${numAugReq}`);
|
||||
terminal.print(`Money: ${numeralWrapper.formatMoney(player.money.toNumber())} / $100b`);
|
||||
terminal.print(`Hacking skill: ${player.hacking_skill} / 2500`);
|
||||
return;
|
||||
}
|
||||
|
||||
terminal.print("We will contact you.");
|
||||
terminal.print("-- Daedalus --");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user