mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
commit
043aaeab8a
24
dist/vendor.bundle.js
vendored
24
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -16,6 +16,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
interface IProps {
|
interface IProps {
|
||||||
StartingDifficulty: number;
|
StartingDifficulty: number;
|
||||||
Difficulty: number;
|
Difficulty: number;
|
||||||
|
Reward: number;
|
||||||
MaxLevel: number;
|
MaxLevel: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +113,7 @@ export function Game(props: IProps): React.ReactElement {
|
|||||||
<Victory
|
<Victory
|
||||||
StartingDifficulty={props.StartingDifficulty}
|
StartingDifficulty={props.StartingDifficulty}
|
||||||
Difficulty={props.Difficulty}
|
Difficulty={props.Difficulty}
|
||||||
|
Reward={props.Reward}
|
||||||
MaxLevel={props.MaxLevel}
|
MaxLevel={props.MaxLevel}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -4,18 +4,35 @@ import { Intro } from "./Intro";
|
|||||||
import { Game } from "./Game";
|
import { Game } from "./Game";
|
||||||
import { Location } from "../../Locations/Location";
|
import { Location } from "../../Locations/Location";
|
||||||
import { use } from "../../ui/Context";
|
import { use } from "../../ui/Context";
|
||||||
|
import { calculateSkill } from "../../PersonObjects/formulas/skill";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
location: Location;
|
location: Location;
|
||||||
}
|
}
|
||||||
function calcDifficulty(player: IPlayer, startingDifficulty: number): number {
|
|
||||||
const totalStats = player.strength + player.defense + player.dexterity + player.agility + player.charisma;
|
function calcRawDiff(player: IPlayer, stats: number, startingDifficulty: number): number {
|
||||||
const difficulty = startingDifficulty - Math.pow(totalStats, 0.9) / 250 - player.intelligence / 1600;
|
const difficulty = startingDifficulty - Math.pow(stats, 0.9) / 250 - player.intelligence / 1600;
|
||||||
if (difficulty < 0) return 0;
|
if (difficulty < 0) return 0;
|
||||||
if (difficulty > 3) return 3;
|
if (difficulty > 3) return 3;
|
||||||
return difficulty;
|
return difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calcDifficulty(player: IPlayer, startingDifficulty: number): number {
|
||||||
|
const totalStats = player.strength + player.defense + player.dexterity + player.agility + player.charisma;
|
||||||
|
return calcRawDiff(player, totalStats, startingDifficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcReward(player: IPlayer, startingDifficulty: number): number {
|
||||||
|
const xpMult = 10 * 60 * 15;
|
||||||
|
const total =
|
||||||
|
calculateSkill(player.strength_exp_mult * xpMult, player.strength_mult) +
|
||||||
|
calculateSkill(player.defense_exp_mult * xpMult, player.defense_mult) +
|
||||||
|
calculateSkill(player.agility_exp_mult * xpMult, player.agility_mult) +
|
||||||
|
calculateSkill(player.dexterity_exp_mult * xpMult, player.dexterity_mult) +
|
||||||
|
calculateSkill(player.charisma_exp_mult * xpMult, player.charisma_mult);
|
||||||
|
return calcRawDiff(player, total, startingDifficulty);
|
||||||
|
}
|
||||||
|
|
||||||
export function InfiltrationRoot(props: IProps): React.ReactElement {
|
export function InfiltrationRoot(props: IProps): React.ReactElement {
|
||||||
const player = use.Player();
|
const player = use.Player();
|
||||||
const router = use.Router();
|
const router = use.Router();
|
||||||
@ -24,6 +41,8 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
|
|||||||
if (props.location.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location.");
|
if (props.location.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location.");
|
||||||
const startingDifficulty = props.location.infiltrationData.startingSecurityLevel;
|
const startingDifficulty = props.location.infiltrationData.startingSecurityLevel;
|
||||||
const difficulty = calcDifficulty(player, startingDifficulty);
|
const difficulty = calcDifficulty(player, startingDifficulty);
|
||||||
|
const reward = calcReward(player, startingDifficulty);
|
||||||
|
console.log(`${difficulty} ${reward}`);
|
||||||
|
|
||||||
function cancel(): void {
|
function cancel(): void {
|
||||||
router.toCity();
|
router.toCity();
|
||||||
@ -45,6 +64,7 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
|
|||||||
<Game
|
<Game
|
||||||
StartingDifficulty={startingDifficulty}
|
StartingDifficulty={startingDifficulty}
|
||||||
Difficulty={difficulty}
|
Difficulty={difficulty}
|
||||||
|
Reward={reward}
|
||||||
MaxLevel={props.location.infiltrationData.maxClearanceLevel}
|
MaxLevel={props.location.infiltrationData.maxClearanceLevel}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -13,6 +13,7 @@ import Select, { SelectChangeEvent } from "@mui/material/Select";
|
|||||||
interface IProps {
|
interface IProps {
|
||||||
StartingDifficulty: number;
|
StartingDifficulty: number;
|
||||||
Difficulty: number;
|
Difficulty: number;
|
||||||
|
Reward: number;
|
||||||
MaxLevel: number;
|
MaxLevel: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,14 +29,14 @@ export function Victory(props: IProps): React.ReactElement {
|
|||||||
const levelBonus = props.MaxLevel * Math.pow(1.01, props.MaxLevel);
|
const levelBonus = props.MaxLevel * Math.pow(1.01, props.MaxLevel);
|
||||||
|
|
||||||
const repGain =
|
const repGain =
|
||||||
Math.pow(props.Difficulty + 1, 1.1) *
|
Math.pow(props.Reward + 1, 1.1) *
|
||||||
Math.pow(props.StartingDifficulty, 1.2) *
|
Math.pow(props.StartingDifficulty, 1.2) *
|
||||||
30 *
|
30 *
|
||||||
levelBonus *
|
levelBonus *
|
||||||
BitNodeMultipliers.InfiltrationRep;
|
BitNodeMultipliers.InfiltrationRep;
|
||||||
|
|
||||||
const moneyGain =
|
const moneyGain =
|
||||||
Math.pow(props.Difficulty + 1, 2) *
|
Math.pow(props.Reward + 1, 2) *
|
||||||
Math.pow(props.StartingDifficulty, 3) *
|
Math.pow(props.StartingDifficulty, 3) *
|
||||||
3e3 *
|
3e3 *
|
||||||
levelBonus *
|
levelBonus *
|
||||||
|
@ -14,7 +14,7 @@ import { calculateHackingTime, calculateGrowTime, calculateWeakenTime } from "..
|
|||||||
|
|
||||||
function requireHackingLevel(lvl: number) {
|
function requireHackingLevel(lvl: number) {
|
||||||
return function (p: IPlayer) {
|
return function (p: IPlayer) {
|
||||||
return p.hacking >= lvl;
|
return p.hacking + p.intelligence / 2 >= lvl;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ export function scriptCalculateOfflineProduction(runningScript: RunningScript):
|
|||||||
//designated server, and false otherwise
|
//designated server, and false otherwise
|
||||||
export function findRunningScript(
|
export function findRunningScript(
|
||||||
filename: string,
|
filename: string,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
): RunningScript | null {
|
): RunningScript | null {
|
||||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||||
|
@ -31,7 +31,7 @@ export function ParseCommands(commands: string): string[] {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ParseCommand(command: string): (string | number)[] {
|
export function ParseCommand(command: string): (string | number | boolean)[] {
|
||||||
// This will be used to keep track of whether we're in a quote. This is for situations
|
// This will be used to keep track of whether we're in a quote. This is for situations
|
||||||
// like the alias command:
|
// like the alias command:
|
||||||
// alias run="run NUKE.exe"
|
// alias run="run NUKE.exe"
|
||||||
@ -101,6 +101,10 @@ export function ParseCommand(command: string): (string | number)[] {
|
|||||||
// If this is a number, convert it from a string to number
|
// If this is a number, convert it from a string to number
|
||||||
if (isNumber(arg)) {
|
if (isNumber(arg)) {
|
||||||
args.push(parseFloat(arg));
|
args.push(parseFloat(arg));
|
||||||
|
} else if (arg === "true") {
|
||||||
|
args.push(true);
|
||||||
|
} else if (arg === "false") {
|
||||||
|
args.push(false);
|
||||||
} else {
|
} else {
|
||||||
args.push(arg);
|
args.push(arg);
|
||||||
}
|
}
|
||||||
@ -117,6 +121,10 @@ export function ParseCommand(command: string): (string | number)[] {
|
|||||||
// If this is a number, convert it from string to number
|
// If this is a number, convert it from string to number
|
||||||
if (isNumber(arg)) {
|
if (isNumber(arg)) {
|
||||||
args.push(parseFloat(arg));
|
args.push(parseFloat(arg));
|
||||||
|
} else if (arg === "true") {
|
||||||
|
args.push(true);
|
||||||
|
} else if (arg === "false") {
|
||||||
|
args.push(false);
|
||||||
} else {
|
} else {
|
||||||
args.push(arg);
|
args.push(arg);
|
||||||
}
|
}
|
||||||
|
@ -507,14 +507,16 @@ export class Terminal implements ITerminal {
|
|||||||
if (s.hasAdminRights) {
|
if (s.hasAdminRights) {
|
||||||
c = "YES";
|
c = "YES";
|
||||||
}
|
}
|
||||||
this.print(
|
let out = `${dashes}Root Access: ${c}${
|
||||||
`${dashes}Root Access: ${c}${!isHacknet ? ", Required hacking skill: " + (s as any).requiredHackingSkill : ""}`,
|
!isHacknet ? ", Required hacking skill: " + (s as any).requiredHackingSkill : ""
|
||||||
);
|
}`;
|
||||||
|
|
||||||
if (s.hasOwnProperty("numOpenPortsRequired")) {
|
if (s.hasOwnProperty("numOpenPortsRequired")) {
|
||||||
this.print(dashes + "Number of open ports required to NUKE: " + (s as any).numOpenPortsRequired);
|
out += "\n" + dashes + "Number of open ports required to NUKE: " + (s as any).numOpenPortsRequired;
|
||||||
}
|
}
|
||||||
this.print(dashes + "RAM: " + numeralWrapper.formatRAM(s.maxRam));
|
out += "\n" + dashes + "RAM: " + numeralWrapper.formatRAM(s.maxRam);
|
||||||
this.print(" ");
|
out += "\n" + " ";
|
||||||
|
this.print(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +718,7 @@ export class Terminal implements ITerminal {
|
|||||||
/****************** END INTERACTIVE TUTORIAL ******************/
|
/****************** END INTERACTIVE TUTORIAL ******************/
|
||||||
/* Command parser */
|
/* Command parser */
|
||||||
const commandName = commandArray[0];
|
const commandName = commandArray[0];
|
||||||
if (typeof commandName === "number") {
|
if (typeof commandName === "number" || typeof commandName === "boolean") {
|
||||||
this.error(`Command ${commandArray[0]} not found`);
|
this.error(`Command ${commandArray[0]} not found`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -727,7 +729,7 @@ export class Terminal implements ITerminal {
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
) => void;
|
) => void;
|
||||||
} = {
|
} = {
|
||||||
"scan-analyze": scananalyze,
|
"scan-analyze": scananalyze,
|
||||||
|
@ -9,7 +9,7 @@ export function alias(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
printAliases();
|
printAliases();
|
||||||
|
@ -8,7 +8,7 @@ export function analyze(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of analyze command. Usage: analyze");
|
terminal.error("Incorrect usage of analyze command. Usage: analyze");
|
||||||
|
@ -10,7 +10,7 @@ export function backdoor(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of backdoor command. Usage: backdoor");
|
terminal.error("Incorrect usage of backdoor command. Usage: backdoor");
|
||||||
|
@ -11,7 +11,7 @@ export function buy(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (!GetServer(SpecialServers.DarkWeb)) {
|
if (!GetServer(SpecialServers.DarkWeb)) {
|
||||||
terminal.error(
|
terminal.error(
|
||||||
|
@ -10,7 +10,7 @@ export function cat(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
terminal.error("Incorrect usage of cat command. Usage: cat [file]");
|
terminal.error("Incorrect usage of cat command. Usage: cat [file]");
|
||||||
|
@ -10,7 +10,7 @@ export function cd(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
terminal.error("Incorrect number of arguments. Usage: cd [dir]");
|
terminal.error("Incorrect number of arguments. Usage: cd [dir]");
|
||||||
|
@ -10,7 +10,7 @@ export function check(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
terminal.error("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]...");
|
terminal.error("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]...");
|
||||||
|
@ -9,7 +9,7 @@ export function connect(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
// Disconnect from current server in terminal and connect to new one
|
// Disconnect from current server in terminal and connect to new one
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
|
@ -9,7 +9,7 @@ export function cp(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if (args.length !== 2) {
|
if (args.length !== 2) {
|
||||||
|
@ -11,7 +11,7 @@ export function download(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
@ -24,7 +24,7 @@ export function download(
|
|||||||
const matchEnding = fn.length == 1 || fn === "*.*" ? null : fn.slice(1); // Treat *.* the same as *
|
const matchEnding = fn.length == 1 || fn === "*.*" ? null : fn.slice(1); // Treat *.* the same as *
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
// Helper function to zip any file contents whose name matches the pattern
|
// Helper function to zip any file contents whose name matches the pattern
|
||||||
let zipFiles = (fileNames: string[], fileContents: string[]) => {
|
const zipFiles = (fileNames: string[], fileContents: string[]) => {
|
||||||
for (let i = 0; i < fileContents.length; ++i) {
|
for (let i = 0; i < fileContents.length; ++i) {
|
||||||
let name = fileNames[i];
|
let name = fileNames[i];
|
||||||
if (name.startsWith("/")) name = name.slice(1);
|
if (name.startsWith("/")) name = name.slice(1);
|
||||||
@ -34,13 +34,18 @@ export function download(
|
|||||||
};
|
};
|
||||||
// In the case of script files, we pull from the server.scripts array
|
// In the case of script files, we pull from the server.scripts array
|
||||||
if (!matchEnding || isScriptFilename(matchEnding))
|
if (!matchEnding || isScriptFilename(matchEnding))
|
||||||
zipFiles(server.scripts.map(s => s.filename), server.scripts.map(s => s.code));
|
zipFiles(
|
||||||
|
server.scripts.map((s) => s.filename),
|
||||||
|
server.scripts.map((s) => s.code),
|
||||||
|
);
|
||||||
// In the case of text files, we pull from the server.scripts array
|
// In the case of text files, we pull from the server.scripts array
|
||||||
if (!matchEnding || matchEnding.endsWith(".txt"))
|
if (!matchEnding || matchEnding.endsWith(".txt"))
|
||||||
zipFiles(server.textFiles.map(s => s.fn), server.textFiles.map(s => s.text));
|
zipFiles(
|
||||||
|
server.textFiles.map((s) => s.fn),
|
||||||
|
server.textFiles.map((s) => s.text),
|
||||||
|
);
|
||||||
// Return an error if no files matched, rather than an empty zip folder
|
// Return an error if no files matched, rather than an empty zip folder
|
||||||
if (Object.keys(zip.files).length == 0)
|
if (Object.keys(zip.files).length == 0) return terminal.error(`No files match the pattern ${fn}`);
|
||||||
return terminal.error(`No files match the pattern ${fn}`);
|
|
||||||
const zipFn = `bitburner${isScriptFilename(fn) ? "Scripts" : fn === "*.txt" ? "Texts" : "Files"}.zip`;
|
const zipFn = `bitburner${isScriptFilename(fn) ? "Scripts" : fn === "*.txt" ? "Texts" : "Files"}.zip`;
|
||||||
zip.generateAsync({ type: "blob" }).then((content: any) => FileSaver.saveAs(content, zipFn));
|
zip.generateAsync({ type: "blob" }).then((content: any) => FileSaver.saveAs(content, zipFn));
|
||||||
return;
|
return;
|
||||||
|
@ -8,7 +8,7 @@ export function expr(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
terminal.error("Incorrect usage of expr command. Usage: expr [math expression]");
|
terminal.error("Incorrect usage of expr command. Usage: expr [math expression]");
|
||||||
|
@ -9,7 +9,7 @@ export function free(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of free command. Usage: free");
|
terminal.error("Incorrect usage of free command. Usage: free");
|
||||||
|
@ -9,7 +9,7 @@ export function grow(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of grow command. Usage: grow");
|
terminal.error("Incorrect usage of grow command. Usage: grow");
|
||||||
|
@ -9,7 +9,7 @@ export function hack(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of hack command. Usage: hack");
|
terminal.error("Incorrect usage of hack command. Usage: hack");
|
||||||
|
@ -9,7 +9,7 @@ export function help(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0 && args.length !== 1) {
|
if (args.length !== 0 && args.length !== 1) {
|
||||||
terminal.error("Incorrect usage of help command. Usage: help");
|
terminal.error("Incorrect usage of help command. Usage: help");
|
||||||
@ -18,7 +18,7 @@ export function help(
|
|||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
TerminalHelpText.forEach((line) => terminal.print(line));
|
TerminalHelpText.forEach((line) => terminal.print(line));
|
||||||
} else {
|
} else {
|
||||||
const cmd = args[0];
|
const cmd = args[0] + "";
|
||||||
const txt = HelpTexts[cmd];
|
const txt = HelpTexts[cmd];
|
||||||
if (txt == null) {
|
if (txt == null) {
|
||||||
terminal.error("No help topics match '" + cmd + "'");
|
terminal.error("No help topics match '" + cmd + "'");
|
||||||
|
@ -8,7 +8,7 @@ export function home(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of home command. Usage: home");
|
terminal.error("Incorrect usage of home command. Usage: home");
|
||||||
|
@ -8,7 +8,7 @@ export function hostname(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of hostname command. Usage: hostname");
|
terminal.error("Incorrect usage of hostname command. Usage: hostname");
|
||||||
|
@ -9,13 +9,16 @@ export function kill(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
terminal.error("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]...");
|
terminal.error("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof args[0] === "boolean") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Kill by PID
|
// Kill by PID
|
||||||
if (typeof args[0] === "number") {
|
if (typeof args[0] === "number") {
|
||||||
|
@ -10,7 +10,7 @@ export function ls(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
const numArgs = args.length;
|
const numArgs = args.length;
|
||||||
function incorrectUsage(): void {
|
function incorrectUsage(): void {
|
||||||
|
@ -9,7 +9,7 @@ export function mem(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if (args.length !== 1 && args.length !== 3) {
|
if (args.length !== 1 && args.length !== 3) {
|
||||||
|
@ -11,7 +11,7 @@ export function mv(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 2) {
|
if (args.length !== 2) {
|
||||||
terminal.error(`Incorrect number of arguments. Usage: mv [src] [dest]`);
|
terminal.error(`Incorrect number of arguments. Usage: mv [src] [dest]`);
|
||||||
|
@ -10,7 +10,7 @@ export function nano(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
terminal.error("Incorrect usage of nano command. Usage: nano [scriptname]");
|
terminal.error("Incorrect usage of nano command. Usage: nano [scriptname]");
|
||||||
|
@ -8,7 +8,7 @@ export function ps(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of ps command. Usage: ps");
|
terminal.error("Incorrect usage of ps command. Usage: ps");
|
||||||
|
@ -9,7 +9,7 @@ export function rm(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
terminal.error("Incorrect number of arguments. Usage: rm [program/script]");
|
terminal.error("Incorrect number of arguments. Usage: rm [program/script]");
|
||||||
|
@ -11,7 +11,7 @@ export function run(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
// Run a program or a script
|
// Run a program or a script
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
|
@ -9,7 +9,7 @@ export function runProgram(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
return;
|
return;
|
||||||
|
@ -14,7 +14,7 @@ export function runScript(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
commandArgs: (string | number)[],
|
commandArgs: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (commandArgs.length < 1) {
|
if (commandArgs.length < 1) {
|
||||||
terminal.error(
|
terminal.error(
|
||||||
|
@ -9,7 +9,7 @@ export function scan(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of netstat/scan command. Usage: netstat/scan");
|
terminal.error("Incorrect usage of netstat/scan command. Usage: netstat/scan");
|
||||||
|
@ -9,7 +9,7 @@ export function scananalyze(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
terminal.executeScanAnalyzeCommand(player, 1);
|
terminal.executeScanAnalyzeCommand(player, 1);
|
||||||
|
@ -10,7 +10,7 @@ export function scp(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if (args.length !== 2) {
|
if (args.length !== 2) {
|
||||||
|
@ -8,7 +8,7 @@ export function sudov(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect number of arguments. Usage: sudov");
|
terminal.error("Incorrect number of arguments. Usage: sudov");
|
||||||
|
@ -12,7 +12,7 @@ export function tail(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
commandArray: (string | number)[],
|
commandArray: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if (commandArray.length < 1) {
|
if (commandArray.length < 1) {
|
||||||
@ -67,7 +67,7 @@ export function tail(
|
|||||||
|
|
||||||
// if there's no candidate then we just don't know.
|
// if there's no candidate then we just don't know.
|
||||||
terminal.error("No such script exists.");
|
terminal.error("No such script exists.");
|
||||||
} else {
|
} else if (typeof commandArray[0] === "number") {
|
||||||
const runningScript = findRunningScriptByPid(commandArray[0], server);
|
const runningScript = findRunningScriptByPid(commandArray[0], server);
|
||||||
if (runningScript == null) {
|
if (runningScript == null) {
|
||||||
terminal.error("No such script exists");
|
terminal.error("No such script exists");
|
||||||
|
@ -10,7 +10,7 @@ export function top(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of top command. Usage: top");
|
terminal.error("Incorrect usage of top command. Usage: top");
|
||||||
|
@ -9,7 +9,7 @@ export function unalias(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 1) {
|
if (args.length !== 1) {
|
||||||
terminal.error("Incorrect usage of unalias name. Usage: unalias [alias]");
|
terminal.error("Incorrect usage of unalias name. Usage: unalias [alias]");
|
||||||
|
@ -9,7 +9,7 @@ export function weaken(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 0) {
|
if (args.length !== 0) {
|
||||||
terminal.error("Incorrect usage of weaken command. Usage: weaken");
|
terminal.error("Incorrect usage of weaken command. Usage: weaken");
|
||||||
|
@ -9,7 +9,7 @@ export function wget(
|
|||||||
router: IRouter,
|
router: IRouter,
|
||||||
player: IPlayer,
|
player: IPlayer,
|
||||||
server: BaseServer,
|
server: BaseServer,
|
||||||
args: (string | number)[],
|
args: (string | number | boolean)[],
|
||||||
): void {
|
): void {
|
||||||
if (args.length !== 2) {
|
if (args.length !== 2) {
|
||||||
terminal.error("Incorrect usage of wget command. Usage: wget [url] [target file]");
|
terminal.error("Incorrect usage of wget command. Usage: wget [url] [target file]");
|
||||||
|
@ -265,13 +265,6 @@ export async function determineAllPossibilitiesForTabCompletion(
|
|||||||
return allPos;
|
return allPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCommand("kill") || isCommand("tail") || isCommand("mem") || isCommand("check")) {
|
|
||||||
addAllScripts();
|
|
||||||
addAllDirectories();
|
|
||||||
|
|
||||||
return allPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCommand("nano")) {
|
if (isCommand("nano")) {
|
||||||
addAllScripts();
|
addAllScripts();
|
||||||
addAllTextFiles();
|
addAllTextFiles();
|
||||||
@ -292,7 +285,7 @@ export async function determineAllPossibilitiesForTabCompletion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function scriptAutocomplete(): Promise<string[] | undefined> {
|
async function scriptAutocomplete(): Promise<string[] | undefined> {
|
||||||
if (!isCommand("run")) return;
|
if (!isCommand("run") && !isCommand("tail") && !isCommand("kill")) return;
|
||||||
const commands = ParseCommands(input);
|
const commands = ParseCommands(input);
|
||||||
if (commands.length === 0) return;
|
if (commands.length === 0) return;
|
||||||
const command = ParseCommand(commands[commands.length - 1]);
|
const command = ParseCommand(commands[commands.length - 1]);
|
||||||
@ -348,6 +341,13 @@ export async function determineAllPossibilitiesForTabCompletion(
|
|||||||
addAllDirectories();
|
addAllDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCommand("kill") || isCommand("tail") || isCommand("mem") || isCommand("check")) {
|
||||||
|
addAllScripts();
|
||||||
|
addAllDirectories();
|
||||||
|
|
||||||
|
return allPos;
|
||||||
|
}
|
||||||
|
|
||||||
if (isCommand("cat")) {
|
if (isCommand("cat")) {
|
||||||
addAllMessages();
|
addAllMessages();
|
||||||
addAllLitFiles();
|
addAllLitFiles();
|
||||||
|
@ -159,7 +159,7 @@ function LogWindow(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Draggable handle=".drag">
|
<Draggable bounds="body" handle=".drag">
|
||||||
<Paper
|
<Paper
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
@ -4,7 +4,6 @@ export function formatTime(fmt: string): string {
|
|||||||
try {
|
try {
|
||||||
return format(new Date(), fmt);
|
return format(new Date(), fmt);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error(err);
|
|
||||||
return "format error";
|
return "format error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user