From 6b114fab7d6f8e4d060556f906898decc5764d33 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 14 Oct 2021 18:45:50 -0400 Subject: [PATCH] remove unused stuff --- src/CodingContracts.ts | 2 +- src/Company/Companies.ts | 5 - src/Faction/Factions.ts | 4 +- src/Message/MessageHelpers.ts | 2 +- src/Milestones/Quest.ts | 11 --- src/NetscriptWorker.ts | 6 +- src/PersonObjects/PlayerEvents.ts | 3 - src/PersonObjects/Sleeve/data/SleeveFaq.tsx | 100 -------------------- src/StockMarket/StockMarket.tsx | 2 +- src/Terminal/DirectoryHelpers.ts | 4 +- src/ui/React/CodingContractModal.tsx | 4 +- src/ui/React/Popup.tsx | 32 ------- src/utils/StringHelperFunctions.ts | 31 +----- webpack.config.js | 13 --- 14 files changed, 11 insertions(+), 208 deletions(-) delete mode 100644 src/Milestones/Quest.ts delete mode 100644 src/PersonObjects/PlayerEvents.ts delete mode 100644 src/PersonObjects/Sleeve/data/SleeveFaq.tsx delete mode 100644 src/ui/React/Popup.tsx diff --git a/src/CodingContracts.ts b/src/CodingContracts.ts index 7f842c287..68a9e3103 100644 --- a/src/CodingContracts.ts +++ b/src/CodingContracts.ts @@ -8,7 +8,7 @@ import { CodingContractEvent } from "./ui/React/CodingContractModal"; /* tslint:disable:no-magic-numbers completed-docs max-classes-per-file no-console */ /* Represents different types of problems that a Coding Contract can have */ -export class CodingContractType { +class CodingContractType { /** * Function that generates a description of the problem */ diff --git a/src/Company/Companies.ts b/src/Company/Companies.ts index a8a742a4c..194217b10 100644 --- a/src/Company/Companies.ts +++ b/src/Company/Companies.ts @@ -45,8 +45,3 @@ export function initCompanies(): void { export function loadCompanies(saveString: string): void { Companies = JSON.parse(saveString, Reviver); } - -// Utility function to check if a string is valid company name -export function companyExists(name: string): boolean { - return Companies.hasOwnProperty(name); -} diff --git a/src/Faction/Factions.ts b/src/Faction/Factions.ts index 9fa6f3c52..4d7bcb5f0 100644 --- a/src/Faction/Factions.ts +++ b/src/Faction/Factions.ts @@ -24,7 +24,7 @@ export function loadFactions(saveString: string): void { } } -export function AddToFactions(faction: Faction): void { +function AddToFactions(faction: Faction): void { const name: string = faction.name; Factions[name] = faction; } @@ -42,7 +42,7 @@ export function initFactions(): void { //Resets a faction during (re-)initialization. Saves the favor in the new //Faction object and deletes the old Faction Object from "Factions". Then //reinserts the new Faction object -export function resetFaction(newFactionObject: Faction): void { +function resetFaction(newFactionObject: Faction): void { if (!(newFactionObject instanceof Faction)) { throw new Error("Invalid argument 'newFactionObject' passed into resetFaction()"); } diff --git a/src/Message/MessageHelpers.ts b/src/Message/MessageHelpers.ts index 90dd104d1..8635ff25c 100644 --- a/src/Message/MessageHelpers.ts +++ b/src/Message/MessageHelpers.ts @@ -217,4 +217,4 @@ function initMessages(): void { ); } -export { Messages, checkForMessagesToSend, sendMessage, showMessage, loadMessages, initMessages, Message }; +export { Messages, checkForMessagesToSend, showMessage, loadMessages, initMessages }; diff --git a/src/Milestones/Quest.ts b/src/Milestones/Quest.ts deleted file mode 100644 index 80e69b931..000000000 --- a/src/Milestones/Quest.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Milestone } from "./Milestone"; - -export class Quest { - title: string; - milestones: Milestone[]; - - constructor(title: string, milestones: Milestone[]) { - this.title = title; - this.milestones = milestones; - } -} diff --git a/src/NetscriptWorker.ts b/src/NetscriptWorker.ts index f1902f1ee..fa3d5c597 100644 --- a/src/NetscriptWorker.ts +++ b/src/NetscriptWorker.ts @@ -469,11 +469,7 @@ export function startWorkerScript(runningScript: RunningScript, server: BaseServ * @param {Server} server - Server on which the script is to be run * returns {boolean} indicating whether or not the workerScript was successfully added */ -export function createAndAddWorkerScript( - runningScriptObj: RunningScript, - server: BaseServer, - parent?: WorkerScript, -): boolean { +function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseServer, parent?: WorkerScript): boolean { // Update server's ram usage let threads = 1; if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) { diff --git a/src/PersonObjects/PlayerEvents.ts b/src/PersonObjects/PlayerEvents.ts deleted file mode 100644 index ae3c8847a..000000000 --- a/src/PersonObjects/PlayerEvents.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { EventEmitter } from "../utils/EventEmitter"; - -export const PlayerEvents = new EventEmitter<[]>(); diff --git a/src/PersonObjects/Sleeve/data/SleeveFaq.tsx b/src/PersonObjects/Sleeve/data/SleeveFaq.tsx deleted file mode 100644 index 55baf4425..000000000 --- a/src/PersonObjects/Sleeve/data/SleeveFaq.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import * as React from "react"; - -export const SleeveFaq = ( - <> - - How do Duplicate Sleeves work? - -
- Duplicate Sleeves are essentially clones. You can use them to perform any work type action, such as working for a - company/faction or committing a crime. Having sleeves perform these tasks earns you money, experience, and - reputation. -
-
- Sleeves are their own individuals, which means they each have their own experience and stats. -
-
- When a sleeve earns experience, it earns experience for itself, the player's original 'consciousness', as well as - all of the player's other sleeves. -
-
- - What is Synchronization (Sync)? - -
- Synchronization is a measure of how aligned your consciousness is with that of your Duplicate Sleeves. It is a - numerical value between 1 and 100, and it affects how much experience is earned when the sleeve is performing a - task. -
-
- Let N be the sleeve's synchronization. When the sleeve earns experience by performing a task, both the sleeve and - the player's original host consciousness earn N% of the amount of experience normally earned by the task. All of the - player's other sleeves earn ((N/100)^2 * 100)% of the experience. -
-
- Synchronization can be increased by assigning sleeves to the 'Synchronize' task. -
-
- - What is Shock? - -
- Sleeve shock is a measure of how much trauma the sleeve has due to being placed in a new body. It is a numerical - value between 0 and 99, where 99 indicates full shock and 0 indicates no shock. Shock affects the amount of - experience earned by the sleeve. -
-
- Sleeve shock slowly decreases over time. You can further increase the rate at which it decreases by assigning - sleeves to the 'Shock Recovery' task. -
-
- - Why can't I work for this company or faction? - -
- Only one of your sleeves can work for a given company/faction a time. To clarify further, if you have two sleeves - they can work for two different companies, but they cannot both work for the same company. -
-
- - Why did my Sleeve stop working? - -
- Sleeves are subject to the same time restrictions as you. This means that they automatically stop working at a - company after 8 hours, and stop working for a faction after 20 hours. -
-
- - How do I buy Augmentations for my Sleeves? - -
- Your Sleeve needs to have a Shock of 0 in order for you to buy Augmentations for it. -
-
- - Why can't I buy the X Augmentation for my sleeve? - -
- Certain Augmentations, like Bladeburner-specific ones and NeuroFlux Governor, are not available for sleeves. -
-
- - Do sleeves get reset when installing Augmentations or switching BitNodes? - -
- Sleeves are reset when switching BitNodes, but not when installing Augmentations. -
-
- - What is Memory? - -
- Sleeve memory dictates what a sleeve's synchronization will be when its reset by switching BitNodes. For example, if - a sleeve has a memory of 25, then when you switch BitNodes its synchronization will initially be set to 25, rather - than 1. -
-
- Memory can only be increased by purchasing upgrades from The Covenant. It is a persistent stat, meaning it never - gets resets back to 1. The maximum possible value for a sleeve's memory is 100. - -); diff --git a/src/StockMarket/StockMarket.tsx b/src/StockMarket/StockMarket.tsx index 054696fa1..c45064a3a 100644 --- a/src/StockMarket/StockMarket.tsx +++ b/src/StockMarket/StockMarket.tsx @@ -197,7 +197,7 @@ export function initSymbolToStockMap(): void { } } -export function stockMarketCycle(): void { +function stockMarketCycle(): void { for (const name in StockMarket) { const stock = StockMarket[name]; if (!(stock instanceof Stock)) { diff --git a/src/Terminal/DirectoryHelpers.ts b/src/Terminal/DirectoryHelpers.ts index a71feebd3..f669d6aaf 100644 --- a/src/Terminal/DirectoryHelpers.ts +++ b/src/Terminal/DirectoryHelpers.ts @@ -35,7 +35,7 @@ export function removeTrailingSlash(s: string): string { * Checks whether a string is a valid filename. Only used for the filename itself, * not the entire filepath */ -export function isValidFilename(filename: string): boolean { +function isValidFilename(filename: string): boolean { // Allows alphanumerics, hyphens, underscores, and percentage signs // Must have a file extension const regex = /^[.a-zA-Z0-9_-]+[.][a-zA-Z0-9]+(?:-\d+(?:\.\d*)?%-INC)?$/; @@ -48,7 +48,7 @@ export function isValidFilename(filename: string): boolean { * Checks whether a string is a valid directory name. Only used for the directory itself, * not an entire path */ -export function isValidDirectoryName(name: string): boolean { +function isValidDirectoryName(name: string): boolean { // Allows alphanumerics, hyphens, underscores, and percentage signs. // Name can begin with a single period, but otherwise cannot have any const regex = /^.?[a-zA-Z0-9_-]+$/; diff --git a/src/ui/React/CodingContractModal.tsx b/src/ui/React/CodingContractModal.tsx index f0d73a3f9..8d8b1aff6 100644 --- a/src/ui/React/CodingContractModal.tsx +++ b/src/ui/React/CodingContractModal.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import { KEY } from "../../utils/helpers/keyCodes"; -import { CodingContract, CodingContractType, CodingContractTypes } from "../../CodingContracts"; +import { CodingContract, CodingContractTypes } from "../../CodingContracts"; import { CopyableText } from "./CopyableText"; import { Modal } from "./Modal"; import { EventEmitter } from "../../utils/EventEmitter"; @@ -49,7 +49,7 @@ export function CodingContractModal(): React.ReactElement { setProps(null); } - const contractType: CodingContractType = CodingContractTypes[props.c.type]; + const contractType = CodingContractTypes[props.c.type]; const description = []; for (const [i, value] of contractType.desc(props.c.data).split("\n").entries()) description.push(" }}>); diff --git a/src/ui/React/Popup.tsx b/src/ui/React/Popup.tsx deleted file mode 100644 index a603e4044..000000000 --- a/src/ui/React/Popup.tsx +++ /dev/null @@ -1,32 +0,0 @@ -/** - * React component for a popup content container - * - * Takes in a prop for rendering the content inside the popup - */ -import React, { useEffect } from "react"; - -interface IProps { - content: (props: T) => React.ReactElement; - id: string; - props: T; - removePopup: () => void; -} - -export function Popup(props: IProps): React.ReactElement { - function keyDown(event: KeyboardEvent): void { - if (event.key === "Escape") props.removePopup(); - } - - useEffect(() => { - document.addEventListener("keydown", keyDown); - return () => { - document.removeEventListener("keydown", keyDown); - }; - }); - - return ( -
- {React.createElement(props.content, props.props)} -
- ); -} diff --git a/src/utils/StringHelperFunctions.ts b/src/utils/StringHelperFunctions.ts index 391cebeea..44a3cb276 100644 --- a/src/utils/StringHelperFunctions.ts +++ b/src/utils/StringHelperFunctions.ts @@ -1,13 +1,6 @@ import { EqualityFunc } from "../types"; import { isString } from "./helpers/isString"; -// Netburner String helper functions - -// Replaces the character at an index with a new character -function replaceAt(base: string, index: number, character: string): string { - return base.substr(0, index) + character + base.substr(index + character.length); -} - /* Converts a date representing time in milliseconds to a string with the format H hours M minutes and S seconds e.g. 10000 -> "10 seconds" @@ -92,20 +85,6 @@ function formatNumber(num: number, numFractionDigits = 0): string { }); } -// Checks if a string contains HTML elements -function isHTML(str: string): boolean { - const element: HTMLDivElement = document.createElement("div"); - element.innerHTML = str; - const c: NodeListOf = element.childNodes; - for (let i: number = c.length - 1; i >= 0; i--) { - if (c[i].nodeType === 1) { - return true; - } - } - - return false; -} - // Generates a random alphanumeric string with N characters function generateRandomString(n: number): string { let str = ""; @@ -118,12 +97,4 @@ function generateRandomString(n: number): string { return str; } -export { - convertTimeMsToTimeElapsedString, - longestCommonStart, - containsAllStrings, - formatNumber, - isHTML, - generateRandomString, - replaceAt, -}; +export { convertTimeMsToTimeElapsedString, longestCommonStart, containsAllStrings, formatNumber, generateRandomString }; diff --git a/webpack.config.js b/webpack.config.js index 775f1bd78..c4990b10f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,7 +4,6 @@ const webpack = require("webpack"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); -const UnusedWebpackPlugin = require("unused-webpack-plugin"); const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin"); const DeadCodePlugin = require("webpack-deadcode-plugin"); @@ -107,14 +106,6 @@ module.exports = (env, argv) => { }, }, }), - new UnusedWebpackPlugin({ - // Source directories - directories: [path.join(__dirname, "src"), path.join(__dirname, "utils")], - // Exclude patterns - exclude: ["*.test.js"], - // Root directory (optional) - root: __dirname, - }), // In dev mode, use a faster method of create sourcemaps // while keeping lines/columns accurate isDevServer && @@ -132,10 +123,6 @@ module.exports = (env, argv) => { module: true, }), isFastRefresh && new ReactRefreshWebpackPlugin(), - new DeadCodePlugin({ - patterns: ["src/**/*.(js|jsx|css|ts|tsx)"], - exclude: ["**/*.(stories|spec).(js|jsx)"], - }), ].filter(Boolean), target: "web", entry: entry,