From dcd9023b93ac18b5f028954f4ee70916f174b350 Mon Sep 17 00:00:00 2001 From: Snarling <84951833+Snarling@users.noreply.github.com> Date: Tue, 20 Sep 2022 00:26:56 -0400 Subject: [PATCH] Remove more unused interfaces --- src/IEngine.ts | 28 --------- src/Terminal/ITerminal.tsx | 105 ------------------------------- src/Terminal/OutputTypes.tsx | 51 +++++++++++++++ src/Terminal/Terminal.ts | 4 +- src/Terminal/ui/TerminalRoot.tsx | 2 +- 5 files changed, 54 insertions(+), 136 deletions(-) delete mode 100644 src/IEngine.ts delete mode 100644 src/Terminal/ITerminal.tsx create mode 100644 src/Terminal/OutputTypes.tsx diff --git a/src/IEngine.ts b/src/IEngine.ts deleted file mode 100644 index 5f99fdf97..000000000 --- a/src/IEngine.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * TypeScript interface for the game engine (engine.js), which can't be converted - * to TypeScript at the moment - */ -export interface IEngine { - _lastUpdate: number; - updateGame: (numCycles?: number) => void; - Counters: { - [key: string]: number | undefined; - autoSaveCounter: number; - updateSkillLevelsCounter: number; - updateDisplays: number; - updateDisplaysLong: number; - updateActiveScriptsDisplay: number; - createProgramNotifications: number; - augmentationsNotifications: number; - checkFactionInvitations: number; - passiveFactionGrowth: number; - messages: number; - mechanicProcess: number; - contractGeneration: number; - achievementsCounter: number; - }; - decrementAllCounters: (numCycles?: number) => void; - checkCounters: () => void; - load: (saveString: string) => void; - start: () => void; -} diff --git a/src/Terminal/ITerminal.tsx b/src/Terminal/ITerminal.tsx deleted file mode 100644 index c76e9e5b2..000000000 --- a/src/Terminal/ITerminal.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import React from "react"; -import { TextFile } from "../TextFile"; -import { Script } from "../Script/Script"; -import { Settings } from "../Settings/Settings"; -import { formatTime } from "../utils/helpers/formatTime"; -import { BaseServer } from "../Server/BaseServer"; - -export class Output { - text: string; - color: "primary" | "error" | "success" | "info" | "warn"; - constructor(text: string, color: "primary" | "error" | "success" | "info" | "warn") { - if (Settings.TimestampsFormat) text = "[" + formatTime(Settings.TimestampsFormat) + "] " + text; - this.text = text; - this.color = color; - } -} - -export class RawOutput { - raw: React.ReactNode; - constructor(node: React.ReactNode) { - if (Settings.TimestampsFormat) - node = ( - <> - [{formatTime(Settings.TimestampsFormat)}] {node} - - ); - this.raw = node; - } -} - -export class Link { - hostname: string; - dashes: string; - constructor(dashes: string, hostname: string) { - if (Settings.TimestampsFormat) dashes = "[" + formatTime(Settings.TimestampsFormat) + "] " + dashes; - this.hostname = hostname; - this.dashes = dashes; - } -} - -export class TTimer { - time: number; - timeLeft: number; - action: "h" | "b" | "a" | "g" | "w"; - server?: BaseServer; - - constructor(time: number, action: "h" | "b" | "a" | "g" | "w", server?: BaseServer) { - this.time = time; - this.timeLeft = time; - this.action = action; - this.server = server; - } -} - -export interface ITerminal { - action: TTimer | null; - - commandHistory: string[]; - commandHistoryIndex: number; - - outputHistory: (Output | Link | RawOutput)[]; - - // True if a Coding Contract prompt is opened - contractOpen: boolean; - - // Full Path of current directory - // Excludes the trailing forward slash - currDir: string; - - print(s: string): void; - printRaw(node: React.ReactNode): void; - error(s: string): void; - success(s: string): void; - info(s: string): void; - warn(s: string): void; - - clear(): void; - startAnalyze(): void; - startBackdoor(): void; - startHack(): void; - startGrow(): void; - startWeaken(): void; - finishHack(server: BaseServer, cancelled?: boolean): void; - finishGrow(server: BaseServer, cancelled?: boolean): void; - finishWeaken(server: BaseServer, cancelled?: boolean): void; - finishBackdoor(server: BaseServer, cancelled?: boolean): void; - finishAnalyze(server: BaseServer, cancelled?: boolean): void; - finishAction(cancelled?: boolean): void; - getFilepath(filename: string): string; - getFile(filename: string): Script | TextFile | string | null; - getScript(filename: string): Script | null; - getTextFile(filename: string): TextFile | null; - getLitFile(filename: string): string | null; - cwd(): string; - setcwd(dir: string): void; - runContract(name: string): void; - executeScanAnalyzeCommand(depth?: number, all?: boolean): void; - connectToServer(server: string): void; - executeCommand(command: string): void; - executeCommands(commands: string): void; - // If there was any changes, will return true, once. - process(cycles: number): void; - prestige(): void; - getProgressText(): string; -} diff --git a/src/Terminal/OutputTypes.tsx b/src/Terminal/OutputTypes.tsx new file mode 100644 index 000000000..9f6148b87 --- /dev/null +++ b/src/Terminal/OutputTypes.tsx @@ -0,0 +1,51 @@ +import React from "react"; +import { Settings } from "../Settings/Settings"; +import { formatTime } from "../utils/helpers/formatTime"; +import { BaseServer } from "../Server/BaseServer"; + +export class Output { + text: string; + color: "primary" | "error" | "success" | "info" | "warn"; + constructor(text: string, color: "primary" | "error" | "success" | "info" | "warn") { + if (Settings.TimestampsFormat) text = "[" + formatTime(Settings.TimestampsFormat) + "] " + text; + this.text = text; + this.color = color; + } +} + +export class RawOutput { + raw: React.ReactNode; + constructor(node: React.ReactNode) { + if (Settings.TimestampsFormat) + node = ( + <> + [{formatTime(Settings.TimestampsFormat)}] {node} + + ); + this.raw = node; + } +} + +export class Link { + hostname: string; + dashes: string; + constructor(dashes: string, hostname: string) { + if (Settings.TimestampsFormat) dashes = "[" + formatTime(Settings.TimestampsFormat) + "] " + dashes; + this.hostname = hostname; + this.dashes = dashes; + } +} + +export class TTimer { + time: number; + timeLeft: number; + action: "h" | "b" | "a" | "g" | "w"; + server?: BaseServer; + + constructor(time: number, action: "h" | "b" | "a" | "g" | "w", server?: BaseServer) { + this.time = time; + this.timeLeft = time; + this.action = action; + this.server = server; + } +} diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts index 61c4a259c..9e56f6a19 100644 --- a/src/Terminal/Terminal.ts +++ b/src/Terminal/Terminal.ts @@ -1,4 +1,4 @@ -import { ITerminal, Output, Link, RawOutput, TTimer } from "./ITerminal"; +import { Output, Link, RawOutput, TTimer } from "./OutputTypes"; import { Router } from "../ui/GameRoot"; import { Player } from "../Player"; import { HacknetServer } from "../Hacknet/HacknetServer"; @@ -75,7 +75,7 @@ import { hash } from "../hash/hash"; import { apr1 } from "./commands/apr1"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; -export class Terminal implements ITerminal { +export class Terminal { // Flags to determine whether the player is currently running a hack or an analyze action: TTimer | null = null; diff --git a/src/Terminal/ui/TerminalRoot.tsx b/src/Terminal/ui/TerminalRoot.tsx index 6eab48a5a..7f983b0af 100644 --- a/src/Terminal/ui/TerminalRoot.tsx +++ b/src/Terminal/ui/TerminalRoot.tsx @@ -7,7 +7,7 @@ import { Theme } from "@mui/material/styles"; import makeStyles from "@mui/styles/makeStyles"; import createStyles from "@mui/styles/createStyles"; import Box from "@mui/material/Box"; -import { Output, Link, RawOutput } from "../ITerminal"; +import { Output, Link, RawOutput } from "../OutputTypes"; import { Terminal } from "../../Terminal"; import { TerminalInput } from "./TerminalInput"; import { TerminalEvents, TerminalClearEvents } from "../TerminalEvents";