2021-09-16 01:50:44 +02:00
|
|
|
import { TextFile } from "../TextFile";
|
|
|
|
import { Script } from "../Script/Script";
|
|
|
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
2021-09-17 08:58:02 +02:00
|
|
|
import { IRouter } from "../ui/Router";
|
2021-09-22 07:36:17 +02:00
|
|
|
import { Settings } from "../Settings/Settings";
|
|
|
|
import { getTimestamp } from "../../utils/helpers/getTimestamp";
|
2021-09-16 01:50:44 +02:00
|
|
|
|
2021-09-16 20:43:39 +02:00
|
|
|
export class Output {
|
2021-09-16 08:52:45 +02:00
|
|
|
text: string;
|
|
|
|
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined;
|
2021-09-16 20:43:39 +02:00
|
|
|
constructor(
|
|
|
|
text: string,
|
|
|
|
color: "inherit" | "initial" | "primary" | "secondary" | "error" | "textPrimary" | "textSecondary" | undefined,
|
|
|
|
) {
|
2021-09-22 07:36:17 +02:00
|
|
|
if (Settings.EnableTimestamps) text = "[" + getTimestamp() + "] " + text;
|
2021-09-16 20:43:39 +02:00
|
|
|
this.text = text;
|
|
|
|
this.color = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Link {
|
|
|
|
hostname: string;
|
2021-09-22 17:32:04 +02:00
|
|
|
dashes: string;
|
|
|
|
constructor(dashes: string, hostname: string) {
|
|
|
|
if (Settings.EnableTimestamps) dashes = "[" + getTimestamp() + "] " + dashes;
|
2021-09-16 20:43:39 +02:00
|
|
|
this.hostname = hostname;
|
2021-09-22 17:32:04 +02:00
|
|
|
this.dashes = dashes;
|
2021-09-16 20:43:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class TTimer {
|
|
|
|
time: number;
|
|
|
|
timeLeft: number;
|
|
|
|
action: "h" | "b" | "a";
|
|
|
|
|
|
|
|
constructor(time: number, action: "h" | "b" | "a") {
|
|
|
|
this.time = time;
|
|
|
|
this.timeLeft = time;
|
|
|
|
this.action = action;
|
|
|
|
}
|
2021-09-16 08:52:45 +02:00
|
|
|
}
|
|
|
|
|
2021-09-16 01:50:44 +02:00
|
|
|
export interface ITerminal {
|
2021-09-16 20:43:39 +02:00
|
|
|
action: TTimer | null;
|
2021-09-16 02:06:48 +02:00
|
|
|
|
|
|
|
commandHistory: string[];
|
|
|
|
commandHistoryIndex: number;
|
|
|
|
|
2021-09-16 20:43:39 +02:00
|
|
|
outputHistory: (Output | Link)[];
|
2021-09-16 08:52:45 +02:00
|
|
|
|
2021-09-16 02:06:48 +02:00
|
|
|
// True if a Coding Contract prompt is opened
|
|
|
|
contractOpen: boolean;
|
|
|
|
|
|
|
|
// Full Path of current directory
|
|
|
|
// Excludes the trailing forward slash
|
|
|
|
currDir: string;
|
|
|
|
|
2021-09-16 21:49:37 +02:00
|
|
|
print(s: string): void;
|
2021-09-16 01:50:44 +02:00
|
|
|
error(s: string): void;
|
|
|
|
|
2021-09-16 08:52:45 +02:00
|
|
|
clear(): void;
|
2021-09-16 01:50:44 +02:00
|
|
|
startAnalyze(): void;
|
|
|
|
startBackdoor(player: IPlayer): void;
|
|
|
|
startHack(player: IPlayer): void;
|
2021-09-18 01:43:08 +02:00
|
|
|
finishHack(router: IRouter, player: IPlayer, cancelled?: boolean): void;
|
|
|
|
finishBackdoor(router: IRouter, player: IPlayer, cancelled?: boolean): void;
|
2021-09-16 01:50:44 +02:00
|
|
|
finishAnalyze(player: IPlayer, cancelled?: boolean): void;
|
2021-09-18 01:43:08 +02:00
|
|
|
finishAction(router: IRouter, player: IPlayer, cancelled?: boolean): void;
|
2021-09-16 01:50:44 +02:00
|
|
|
getFilepath(filename: string): string;
|
|
|
|
getFile(player: IPlayer, filename: string): Script | TextFile | string | null;
|
|
|
|
getScript(player: IPlayer, filename: string): Script | null;
|
|
|
|
getTextFile(player: IPlayer, filename: string): TextFile | null;
|
|
|
|
getLitFile(player: IPlayer, filename: string): string | null;
|
|
|
|
cwd(): string;
|
|
|
|
setcwd(dir: string): void;
|
|
|
|
runContract(player: IPlayer, name: string): void;
|
|
|
|
executeScanAnalyzeCommand(player: IPlayer, depth?: number, all?: boolean): void;
|
|
|
|
connectToServer(player: IPlayer, server: string): void;
|
2021-09-17 08:58:02 +02:00
|
|
|
executeCommand(router: IRouter, player: IPlayer, command: string): void;
|
|
|
|
executeCommands(router: IRouter, player: IPlayer, commands: string): void;
|
2021-09-16 08:52:45 +02:00
|
|
|
// If there was any changes, will return true, once.
|
2021-09-18 01:43:08 +02:00
|
|
|
process(router: IRouter, player: IPlayer, cycles: number): void;
|
2021-09-16 20:43:39 +02:00
|
|
|
prestige(): void;
|
|
|
|
getProgressText(): string;
|
2021-09-16 01:50:44 +02:00
|
|
|
}
|