fmt, remove corp routing, lint

This commit is contained in:
Olivier Gagnon 2021-09-06 15:06:08 -04:00
parent 91434b7972
commit 506122f5b8
53 changed files with 1300 additions and 1610 deletions

@ -1,23 +1,26 @@
const numSpaces = 4;
const maxLineLength = 160;
module.exports = { module.exports = {
env: { "env": {
node: true, "es6": true,
es6: true, "node": true
}, },
extends: "eslint:recommended", "extends": "eslint:recommended",
parserOptions: { "parserOptions": {
ecmaVersion: 8, "ecmaFeatures": {
sourceType: "module", "experimentalObjectRestSpread": true
ecmaFeatures: {
experimentalObjectRestSpread: true,
}, },
"ecmaVersion": 8,
"sourceType": "module"
}, },
rules: { "rules": {
"accessor-pairs": [ "accessor-pairs": [
"error", "error",
{ {
setWithoutGet: true, "getWithoutSet": false,
getWithoutSet: false, "setWithoutGet": true
}, }
], ],
"array-bracket-newline": ["error"], "array-bracket-newline": ["error"],
"array-bracket-spacing": ["error"], "array-bracket-spacing": ["error"],
@ -30,35 +33,50 @@ module.exports = {
"block-spacing": ["error"], "block-spacing": ["error"],
"brace-style": ["error"], "brace-style": ["error"],
"callback-return": ["error"], "callback-return": ["error"],
camelcase: ["error"], "camelcase": ["error"],
"capitalized-comments": ["error"], "capitalized-comments": ["error"],
"class-methods-use-this": ["error"], "class-methods-use-this": ["error"],
"comma-dangle": ["error"], "comma-dangle": ["error"],
"comma-spacing": ["error"], "comma-spacing": ["error"],
"comma-style": ["error", "last"], "comma-style": [
complexity: ["error"], "error",
"computed-property-spacing": ["error", "never"], "last"
],
"complexity": ["error"],
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": ["error"], "consistent-return": ["error"],
"consistent-this": ["error"], "consistent-this": ["error"],
"constructor-super": ["error"], "constructor-super": ["error"],
curly: ["error"], "curly": ["error"],
"default-case": ["error"], "default-case": ["error"],
"dot-location": ["error", "property"], "dot-location": [
"error",
"property"
],
"dot-notation": ["error"], "dot-notation": ["error"],
"eol-last": ["error"], "eol-last": ["error"],
eqeqeq: ["error"], "eqeqeq": ["error"],
"for-direction": ["error"], "for-direction": ["error"],
"func-call-spacing": ["error"], "func-call-spacing": ["error"],
"func-name-matching": ["error"], "func-name-matching": ["error"],
"func-names": ["error", "never"], "func-names": [
"error",
"never"
],
"func-style": ["error"], "func-style": ["error"],
"function-paren-newline": ["error"], "function-paren-newline": ["error"],
"generator-star-spacing": ["error", "before"], "generator-star-spacing": [
"error",
"before"
],
"getter-return": [ "getter-return": [
"error", "error",
{ {
allowImplicit: false, "allowImplicit": false
}, }
], ],
"global-require": ["error"], "global-require": ["error"],
"guard-for-in": ["error"], "guard-for-in": ["error"],
@ -66,42 +84,56 @@ module.exports = {
"id-blacklist": ["error"], "id-blacklist": ["error"],
"id-length": ["error"], "id-length": ["error"],
"id-match": ["error"], "id-match": ["error"],
"implicit-arrow-linebreak": ["error", "beside"], "implicit-arrow-linebreak": [
indent: [
"error", "error",
4, "beside"
],
"indent": [
"error",
numSpaces,
{ {
SwitchCase: 1, "SwitchCase": 1
}, }
], ],
"init-declarations": ["error"], "init-declarations": ["error"],
"jsx-quotes": ["error"], "jsx-quotes": ["error"],
"key-spacing": ["error"], "key-spacing": ["error"],
"keyword-spacing": ["error"], "keyword-spacing": ["error"],
"line-comment-position": ["error"], "line-comment-position": ["error"],
"linebreak-style": ["error", "windows"], "linebreak-style": [
"error",
"windows"
],
"lines-around-comment": ["error"], "lines-around-comment": ["error"],
"lines-between-class-members": ["error"], "lines-between-class-members": ["error"],
"max-depth": ["error"], "max-depth": ["error"],
"max-len": ["error", 160], "max-len": [
"error",
maxLineLength
],
"max-lines": [ "max-lines": [
"error", "error",
{ {
skipBlankLines: true, "skipBlankLines": true,
skipComments: true, "skipComments": true
}, }
], ],
"max-nested-callbacks": ["error"], "max-nested-callbacks": ["error"],
"max-params": ["error"], "max-params": ["error"],
"max-statements": ["error"], "max-statements": ["error"],
"max-statements-per-line": ["error"], "max-statements-per-line": ["error"],
"multiline-comment-style": ["off", "starred-block"], "multiline-comment-style": [
"multiline-ternary": ["error", "never"], "off",
"starred-block"
],
"multiline-ternary": [
"error",
"never"
],
"new-cap": ["error"], "new-cap": ["error"],
"new-parens": ["error"], "new-parens": ["error"],
"newline-before-return": [ // TODO: configure this...
"error", // TODO: configure this... "newline-before-return": ["error"],
],
"newline-per-chained-call": ["error"], "newline-per-chained-call": ["error"],
"no-alert": ["error"], "no-alert": ["error"],
"no-array-constructor": ["error"], "no-array-constructor": ["error"],
@ -113,15 +145,18 @@ module.exports = {
"no-catch-shadow": ["error"], "no-catch-shadow": ["error"],
"no-class-assign": ["error"], "no-class-assign": ["error"],
"no-compare-neg-zero": ["error"], "no-compare-neg-zero": ["error"],
"no-cond-assign": ["error", "except-parens"], "no-cond-assign": [
"error",
"except-parens"
],
"no-confusing-arrow": ["error"], "no-confusing-arrow": ["error"],
"no-console": ["error"], "no-console": ["error"],
"no-const-assign": ["error"], "no-const-assign": ["error"],
"no-constant-condition": [ "no-constant-condition": [
"error", "error",
{ {
checkLoops: false, "checkLoops": false
}, }
], ],
"no-continue": ["off"], "no-continue": ["off"],
"no-control-regex": ["error"], "no-control-regex": ["error"],
@ -135,35 +170,34 @@ module.exports = {
"no-duplicate-imports": [ "no-duplicate-imports": [
"error", "error",
{ {
includeExports: true, "includeExports": true
}, }
], ],
"no-else-return": ["error"], "no-else-return": ["error"],
"no-empty": [ "no-empty": [
"error", "error",
{ {
allowEmptyCatch: false, "allowEmptyCatch": false
}, }
], ],
"no-empty-character-class": ["error"], "no-empty-character-class": ["error"],
"no-empty-function": ["error"], "no-empty-function": ["error"],
"no-empty-pattern": ["error"], "no-empty-pattern": ["error"],
"no-eq-null": ["error"], "no-eq-null": ["error"],
"no-eval": ["error"],
"no-ex-assign": ["error"], "no-ex-assign": ["error"],
"no-extend-native": ["error"],
"no-extra-bind": ["error"],
"no-extra-boolean-cast": ["error"], "no-extra-boolean-cast": ["error"],
"no-extra-label": ["error"],
"no-extra-parens": [ "no-extra-parens": [
"error", "error",
"all", "all",
{ {
conditionalAssign: false, "conditionalAssign": false
}, }
], ],
"no-extra-semi": ["error"], "no-extra-semi": ["error"],
"no-eval": ["error"],
"no-extend-native": ["error"],
"no-extra-bind": ["error"],
"no-extra-label": ["error"],
"no-extra-parens": ["error"],
"no-fallthrough": ["error"], "no-fallthrough": ["error"],
"no-floating-decimal": ["error"], "no-floating-decimal": ["error"],
"no-func-assign": ["error"], "no-func-assign": ["error"],
@ -172,17 +206,20 @@ module.exports = {
"no-implicit-globals": ["error"], "no-implicit-globals": ["error"],
"no-implied-eval": ["error"], "no-implied-eval": ["error"],
"no-inline-comments": ["error"], "no-inline-comments": ["error"],
"no-inner-declarations": ["error", "both"], "no-inner-declarations": [
"error",
"both"
],
"no-invalid-regexp": ["error"], "no-invalid-regexp": ["error"],
"no-invalid-this": ["error"], "no-invalid-this": ["error"],
"no-irregular-whitespace": [ "no-irregular-whitespace": [
"error", "error",
{ {
skipStrings: false, "skipComments": false,
skipComments: false, "skipRegExps": false,
skipRegExps: false, "skipStrings": false,
skipTemplates: false, "skipTemplates": false
}, }
], ],
"no-iterator": ["error"], "no-iterator": ["error"],
"no-label-var": ["error"], "no-label-var": ["error"],
@ -193,9 +230,13 @@ module.exports = {
"no-magic-numbers": [ "no-magic-numbers": [
"error", "error",
{ {
ignore: [-1, 0, 1], "ignore": [
ignoreArrayIndexes: true, -1,
}, 0,
1
],
"ignoreArrayIndexes": true
}
], ],
"no-mixed-operators": ["error"], "no-mixed-operators": ["error"],
"no-mixed-requires": ["error"], "no-mixed-requires": ["error"],
@ -206,8 +247,8 @@ module.exports = {
"no-multiple-empty-lines": [ "no-multiple-empty-lines": [
"error", "error",
{ {
max: 1, "max": 1
}, }
], ],
"no-native-reassign": ["error"], "no-native-reassign": ["error"],
"no-negated-condition": ["error"], "no-negated-condition": ["error"],
@ -219,16 +260,16 @@ module.exports = {
"no-new-require": ["error"], "no-new-require": ["error"],
"no-new-symbol": ["error"], "no-new-symbol": ["error"],
"no-new-wrappers": ["error"], "no-new-wrappers": ["error"],
"no-obj-calls": ["error"],
"no-octal": ["error"], "no-octal": ["error"],
"no-octal-escape": ["error"], "no-octal-escape": ["error"],
"no-obj-calls": ["error"],
"no-param-reassign": ["error"], "no-param-reassign": ["error"],
"no-path-concat": ["error"], "no-path-concat": ["error"],
"no-plusplus": [ "no-plusplus": [
"error", "error",
{ {
allowForLoopAfterthoughts: true, "allowForLoopAfterthoughts": true
}, }
], ],
"no-process-env": ["error"], "no-process-env": ["error"],
"no-process-exit": ["error"], "no-process-exit": ["error"],
@ -242,10 +283,10 @@ module.exports = {
"no-restricted-properties": [ "no-restricted-properties": [
"error", "error",
{ {
object: "console", "message": "'log' is too general, use an appropriate level when logging.",
property: "log", "object": "console",
message: "'log' is too general, use an appropriate level when logging.", "property": "log"
}, }
], ],
"no-restricted-syntax": ["error"], "no-restricted-syntax": ["error"],
"no-return-assign": ["error"], "no-return-assign": ["error"],
@ -254,8 +295,8 @@ module.exports = {
"no-self-assign": [ "no-self-assign": [
"error", "error",
{ {
props: false, "props": false
}, }
], ],
"no-self-compare": ["error"], "no-self-compare": ["error"],
"no-sequences": ["error"], "no-sequences": ["error"],
@ -292,10 +333,10 @@ module.exports = {
"no-useless-rename": [ "no-useless-rename": [
"error", "error",
{ {
ignoreDestructuring: false, "ignoreDestructuring": false,
ignoreExport: false, "ignoreExport": false,
ignoreImport: false, "ignoreImport": false
}, }
], ],
"no-useless-return": ["error"], "no-useless-return": ["error"],
"no-var": ["error"], "no-var": ["error"],
@ -303,7 +344,10 @@ module.exports = {
"no-warning-comments": ["error"], "no-warning-comments": ["error"],
"no-whitespace-before-property": ["error"], "no-whitespace-before-property": ["error"],
"no-with": ["error"], "no-with": ["error"],
"nonblock-statement-body-position": ["error", "below"], "nonblock-statement-body-position": [
"error",
"below"
],
"object-curly-newline": ["error"], "object-curly-newline": ["error"],
"object-curly-spacing": ["error"], "object-curly-spacing": ["error"],
"object-property-newline": ["error"], "object-property-newline": ["error"],
@ -311,7 +355,10 @@ module.exports = {
"one-var": ["off"], "one-var": ["off"],
"one-var-declaration-per-line": ["error"], "one-var-declaration-per-line": ["error"],
"operator-assignment": ["error"], "operator-assignment": ["error"],
"operator-linebreak": ["error", "none"], "operator-linebreak": [
"error",
"none"
],
"padded-blocks": ["off"], "padded-blocks": ["off"],
"padding-line-between-statements": ["error"], "padding-line-between-statements": ["error"],
"prefer-arrow-callback": ["error"], "prefer-arrow-callback": ["error"],
@ -324,15 +371,24 @@ module.exports = {
"prefer-spread": ["error"], "prefer-spread": ["error"],
"prefer-template": ["error"], "prefer-template": ["error"],
"quote-props": ["error"], "quote-props": ["error"],
quotes: ["error"], "quotes": ["error"],
radix: ["error", "as-needed"], "radix": [
"error",
"as-needed"
],
"require-await": ["error"], "require-await": ["error"],
"require-jsdoc": ["off"], "require-jsdoc": ["off"],
"require-yield": ["error"], "require-yield": ["error"],
"rest-spread-spacing": ["error", "never"], "rest-spread-spacing": [
semi: ["error"], "error",
"never"
],
"semi": ["error"],
"semi-spacing": ["error"], "semi-spacing": ["error"],
"semi-style": ["error", "last"], "semi-style": [
"error",
"last"
],
"sort-imports": ["error"], "sort-imports": ["error"],
"sort-keys": ["error"], "sort-keys": ["error"],
"sort-vars": ["error"], "sort-vars": ["error"],
@ -342,25 +398,37 @@ module.exports = {
"space-infix-ops": ["error"], "space-infix-ops": ["error"],
"space-unary-ops": ["error"], "space-unary-ops": ["error"],
"spaced-comment": ["error"], "spaced-comment": ["error"],
strict: ["error"], "strict": ["error"],
"switch-colon-spacing": [ "switch-colon-spacing": [
"error", "error",
{ {
after: true, "after": true,
before: false, "before": false
}, }
], ],
"symbol-description": ["error"], "symbol-description": ["error"],
"template-curly-spacing": ["error"], "template-curly-spacing": ["error"],
"template-tag-spacing": ["error"], "template-tag-spacing": ["error"],
"unicode-bom": ["error", "never"], "unicode-bom": [
"error",
"never"
],
"use-isnan": ["error"], "use-isnan": ["error"],
"valid-jsdoc": ["error"], "valid-jsdoc": ["error"],
"valid-typeof": ["error"], "valid-typeof": ["error"],
"vars-on-top": ["error"], "vars-on-top": ["error"],
"wrap-iife": ["error", "any"], "wrap-iife": [
"error",
"any"
],
"wrap-regex": ["error"], "wrap-regex": ["error"],
"yield-star-spacing": ["error", "before"], "yield-star-spacing": [
yoda: ["error", "never"], "error",
}, "before"
],
"yoda": [
"error",
"never"
]
}
}; };

@ -8,8 +8,7 @@ const path = require("path");
const exec = require("child_process").exec; const exec = require("child_process").exec;
const semver = require("./semver"); const semver = require("./semver");
const getPackageJson = () => const getPackageJson = () => new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
try { try {
/* eslint-disable-next-line global-require */ /* eslint-disable-next-line global-require */
resolve(require(path.resolve(process.cwd(), "package.json"))); resolve(require(path.resolve(process.cwd(), "package.json")));
@ -18,8 +17,7 @@ const getPackageJson = () =>
} }
}); });
const getEngines = (data) => const getEngines = (data) => new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
let versions = null; let versions = null;
if (data.engines) { if (data.engines) {
@ -33,8 +31,7 @@ const getEngines = (data) =>
} }
}); });
const checkNpmVersion = (engines) => const checkNpmVersion = (engines) => new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
exec("npm -v", (error, stdout, stderr) => { exec("npm -v", (error, stdout, stderr) => {
if (error) { if (error) {
reject(`Unable to find NPM version\n${stderr}`); reject(`Unable to find NPM version\n${stderr}`);
@ -46,23 +43,18 @@ const checkNpmVersion = (engines) =>
if (semver.satisfies(npmVersion, engineVersion)) { if (semver.satisfies(npmVersion, engineVersion)) {
resolve(); resolve();
} else { } else {
reject( reject(`Incorrect npm version\n'package.json' specifies "${engineVersion}", you are currently running "${npmVersion}".`);
`Incorrect npm version\n'package.json' specifies "${engineVersion}", you are currently running "${npmVersion}".`,
);
} }
}); });
}); });
const checkNodeVersion = (engines) => const checkNodeVersion = (engines) => new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
const nodeVersion = process.version.substring(1); const nodeVersion = process.version.substring(1);
if (semver.satisfies(nodeVersion, engines.node)) { if (semver.satisfies(nodeVersion, engines.node)) {
resolve(engines); resolve(engines);
} else { } else {
reject( reject(`Incorrect node version\n'package.json' specifies "${engines.node}", you are currently running "${process.version}".`);
`Incorrect node version\n'package.json' specifies "${engines.node}", you are currently running "${process.version}".`,
);
} }
}); });
@ -77,5 +69,5 @@ getPackageJson()
/* eslint-disable no-console, no-process-exit */ /* eslint-disable no-console, no-process-exit */
console.error(error); console.error(error);
process.exit(1); process.exit(1);
}, }
); );

@ -140,9 +140,9 @@ src[
] = `[v=\\s]*(${src[XRANGEIDENTIFIER]})(?:\\.(${src[XRANGEIDENTIFIER]})(?:\\.(${src[XRANGEIDENTIFIER]})(?:${src[PRERELEASE]})?${src[BUILD]}?)?)?`; ] = `[v=\\s]*(${src[XRANGEIDENTIFIER]})(?:\\.(${src[XRANGEIDENTIFIER]})(?:\\.(${src[XRANGEIDENTIFIER]})(?:${src[PRERELEASE]})?${src[BUILD]}?)?)?`;
/* eslint-disable-next-line max-len */ /* eslint-disable-next-line max-len */
src[ src[XRANGEPLAINLOOSE] =
XRANGEPLAINLOOSE `[v=\\s]*(${src[XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[XRANGEIDENTIFIERLOOSE]})` +
] = `[v=\\s]*(${src[XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[XRANGEIDENTIFIERLOOSE]})(?:${src[PRERELEASELOOSE]})?${src[BUILD]}?)?)?`; `(?:\\.(${src[XRANGEIDENTIFIERLOOSE]})(?:${src[PRERELEASELOOSE]})?${src[BUILD]}?)?)?`;
src[XRANGE] = `^${src[GTLT]}\\s*${src[XRANGEPLAIN]}$`; src[XRANGE] = `^${src[GTLT]}\\s*${src[XRANGEPLAIN]}$`;
src[XRANGELOOSE] = `^${src[GTLT]}\\s*${src[XRANGEPLAINLOOSE]}$`; src[XRANGELOOSE] = `^${src[GTLT]}\\s*${src[XRANGEPLAINLOOSE]}$`;
@ -470,6 +470,7 @@ function parseComparator(comp, loose) {
} }
class SemVer { class SemVer {
/** /**
* A semantic version. * A semantic version.
* @param {string} version The version. * @param {string} version The version.
@ -513,7 +514,7 @@ class SemVer {
// Numberify any prerelease numeric ids // Numberify any prerelease numeric ids
if (matches[4]) { if (matches[4]) {
this.prerelease = matches[4].split(".").map((id) => { this.prerelease = matches[4].split(".").map((id) => {
if (/^[0-9]+$/.test(id)) { if ((/^[0-9]+$/).test(id)) {
const num = Number(id); const num = Number(id);
if (num >= 0 && num < MAX_SAFE_INTEGER) { if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num; return num;
@ -557,9 +558,7 @@ class SemVer {
} }
return ( return (
compareIdentifiers(this.major, other.major) || compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch)
compareIdentifiers(this.minor, other.minor) ||
compareIdentifiers(this.patch, other.patch)
); );
} }
@ -599,20 +598,13 @@ class SemVer {
} }
} }
const compare = (leftVersion, rightVersion, loose) => const compare = (leftVersion, rightVersion, loose) => new SemVer(leftVersion, loose).compare(new SemVer(rightVersion, loose));
new SemVer(leftVersion, loose).compare(new SemVer(rightVersion, loose)); const gt = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) > 0;
const gt = (leftVersion, rightVersion, loose) => const lt = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) < 0;
compare(leftVersion, rightVersion, loose) > 0; const eq = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) === 0;
const lt = (leftVersion, rightVersion, loose) => const neq = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) !== 0;
compare(leftVersion, rightVersion, loose) < 0; const gte = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) >= 0;
const eq = (leftVersion, rightVersion, loose) => const lte = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) <= 0;
compare(leftVersion, rightVersion, loose) === 0;
const neq = (leftVersion, rightVersion, loose) =>
compare(leftVersion, rightVersion, loose) !== 0;
const gte = (leftVersion, rightVersion, loose) =>
compare(leftVersion, rightVersion, loose) >= 0;
const lte = (leftVersion, rightVersion, loose) =>
compare(leftVersion, rightVersion, loose) <= 0;
function cmp(left, op, right, loose) { function cmp(left, op, right, loose) {
let ret; let ret;
@ -679,9 +671,7 @@ function testSet(set, version) {
if (set[idx].semver.prerelease.length > 0) { if (set[idx].semver.prerelease.length > 0) {
const allowed = set[idx].semver; const allowed = set[idx].semver;
if ( if (
allowed.major === version.major && allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch
allowed.minor === version.minor &&
allowed.patch === version.patch
) { ) {
return true; return true;
} }

@ -139,8 +139,7 @@ function initAugmentations() {
"unpredictable results based on your circadian rhythm.", "unpredictable results based on your circadian rhythm.",
}; };
Object.keys(randomBonuses.bonuses).forEach( Object.keys(randomBonuses.bonuses).forEach(
(key) => (key) => (UnstableCircadianModulatorParams[key] = randomBonuses.bonuses[key]),
(UnstableCircadianModulatorParams[key] = randomBonuses.bonuses[key]),
); );
const UnstableCircadianModulator = new Augmentation( const UnstableCircadianModulator = new Augmentation(
UnstableCircadianModulatorParams, UnstableCircadianModulatorParams,

@ -2472,9 +2472,10 @@ export class Bladeburner implements IBladeburner {
case ActionTypes["Diplomacy"]: case ActionTypes["Diplomacy"]:
case ActionTypes["Hyperbolic Regeneration Chamber"]: case ActionTypes["Hyperbolic Regeneration Chamber"]:
return [1, 1]; return [1, 1];
case ActionTypes["Recruitment"]: case ActionTypes["Recruitment"]: {
const recChance = this.getRecruitmentSuccessChance(player); const recChance = this.getRecruitmentSuccessChance(player);
return [recChance, recChance]; return [recChance, recChance];
}
default: default:
workerScript.log( workerScript.log(
"bladeburner.getActionEstimatedSuccessChance", "bladeburner.getActionEstimatedSuccessChance",

@ -22,8 +22,7 @@ export function BlackOpList(props: IProps): React.ReactElement {
}); });
blackops = blackops.filter( blackops = blackops.filter(
(blackop: BlackOperation, i: number) => (blackop: BlackOperation, i: number) => !(
!(
props.bladeburner.blackops[blackops[i].name] == null && props.bladeburner.blackops[blackops[i].name] == null &&
i !== 0 && i !== 0 &&
props.bladeburner.blackops[blackops[i - 1].name] == null props.bladeburner.blackops[blackops[i - 1].name] == null

@ -2,7 +2,6 @@ import * as React from "react";
import { BlackOpList } from "./BlackOpList"; import { BlackOpList } from "./BlackOpList";
import { IBladeburner } from "../IBladeburner"; import { IBladeburner } from "../IBladeburner";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { CopyableText } from "../../ui/React/CopyableText";
interface IProps { interface IProps {
bladeburner: IBladeburner; bladeburner: IBladeburner;

@ -26,7 +26,6 @@ export function ContractElem(props: IProps): React.ReactElement {
const estimatedSuccessChance = props.action.getEstSuccessChance( const estimatedSuccessChance = props.action.getEstSuccessChance(
props.bladeburner, props.bladeburner,
); );
const successChance = props.action.getSuccessChance(props.bladeburner);
const computedActionTimeCurrent = Math.min( const computedActionTimeCurrent = Math.min(
props.bladeburner.actionTimeCurrent + props.bladeburner.actionTimeOverflow, props.bladeburner.actionTimeCurrent + props.bladeburner.actionTimeOverflow,
props.bladeburner.actionTimeToComplete, props.bladeburner.actionTimeToComplete,

@ -3,8 +3,6 @@
* *
* Constants for specific mechanics or features will NOT be here. * Constants for specific mechanics or features will NOT be here.
*/ */
import { IMap } from "./types";
export const CONSTANTS: { export const CONSTANTS: {
Version: string; Version: string;
_idleSpeed: number; _idleSpeed: number;

@ -25,7 +25,7 @@ export function NewIndustry(
const cost = IndustryStartingCosts[industry]; const cost = IndustryStartingCosts[industry];
if (cost === undefined) { if (cost === undefined) {
throw new Error("Invalid industry: ${industry}"); throw new Error(`Invalid industry: '${industry}'`);
} }
if (corporation.funds.lt(cost)) { if (corporation.funds.lt(cost)) {
throw new Error( throw new Error(

@ -32,7 +32,6 @@ import { removeElementById } from "../../utils/uiHelpers/removeElementById";
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import { CorporationRoot } from "./ui/Root"; import { CorporationRoot } from "./ui/Root";
import { CorporationRouting } from "./ui/Routing";
import Decimal from "decimal.js"; import Decimal from "decimal.js";
@ -40,7 +39,6 @@ interface IParams {
name?: string; name?: string;
} }
let corpRouting: CorporationRouting;
let companyManagementDiv: HTMLDivElement | null = null; let companyManagementDiv: HTMLDivElement | null = null;
export class Corporation { export class Corporation {
@ -483,22 +481,20 @@ export class Corporation {
const game = document.getElementById("entire-game-container"); const game = document.getElementById("entire-game-container");
if (game) game.appendChild(companyManagementDiv); if (game) game.appendChild(companyManagementDiv);
corpRouting = new CorporationRouting(this);
this.rerender(player); this.rerender(player);
} }
rerender(player: IPlayer): void { rerender(player: IPlayer): void {
if (companyManagementDiv == null || corpRouting == null) { if (companyManagementDiv == null) {
console.warn( console.warn(
`Corporation.rerender() called when companyManagementDiv, corpRouting, or eventHandler is null`, `Corporation.rerender() called when companyManagementDiv is null`,
); );
return; return;
} }
if (!routing.isOn(Page.Corporation)) return; if (!routing.isOn(Page.Corporation)) return;
ReactDOM.render( ReactDOM.render(
<CorporationRoot corp={this} routing={corpRouting} player={player} />, <CorporationRoot corp={this} player={player} />,
companyManagementDiv, companyManagementDiv,
); );
} }

@ -1,50 +1,67 @@
// React Components for the Corporation UI's City navigation tabs // React Components for the Corporation UI's City navigation tabs
// These allow player to navigate between different cities for each industry // These allow player to navigate between different cities for each industry
import React from "react"; import React, { useState } from "react";
import { CityTab } from "./CityTab"; import { CityTab } from "./CityTab";
import { ExpandNewCityPopup } from "./ExpandNewCityPopup"; import { ExpandNewCityPopup } from "./ExpandNewCityPopup";
import { createPopup } from "../../ui/React/createPopup"; import { createPopup } from "../../ui/React/createPopup";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { CorporationRouting } from "./Routing"; import { IIndustry } from "../IIndustry";
import { OfficeSpace } from "../OfficeSpace";
import { Industry } from "./Industry";
import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
routing: CorporationRouting; city: string;
onClicks: { [key: string]: () => void }; division: IIndustry;
city: string; // currentCity
cityStateSetter: (city: string) => void;
corp: ICorporation; corp: ICorporation;
player: IPlayer;
} }
export function CityTabs(props: IProps): React.ReactElement { export function CityTabs(props: IProps): React.ReactElement {
const division = props.routing.currentDivision; const [city, setCity] = useState(props.city);
function openExpandNewCityModal(): void { function openExpandNewCityModal(): void {
if (division === null) return;
const popupId = "cmpy-mgmt-expand-city-popup"; const popupId = "cmpy-mgmt-expand-city-popup";
createPopup(popupId, ExpandNewCityPopup, { createPopup(popupId, ExpandNewCityPopup, {
popupId: popupId, popupId: popupId,
corp: props.corp, corp: props.corp,
division: division, division: props.division,
cityStateSetter: props.cityStateSetter, cityStateSetter: setCity,
}); });
} }
const office = props.division.offices[city];
if (office === 0) {
setCity("Sector-12");
return <></>;
}
return ( return (
<> <>
{Object.keys(props.onClicks).map((cityName: string) => ( {Object.values(props.division.offices).map(
(office: OfficeSpace | 0) => office !== 0 && (
<CityTab <CityTab
current={props.city === cityName} current={city === office.loc}
key={cityName} key={office.loc}
name={cityName} name={office.loc}
onClick={props.onClicks[cityName]} onClick={() => setCity(office.loc)}
/> />
))} ),
)}
<CityTab <CityTab
current={false} current={false}
key={"Expand into new City"} key={"Expand into new City"}
name={"Expand into new City"} name={"Expand into new City"}
onClick={openExpandNewCityModal} onClick={openExpandNewCityModal}
/> />
<Industry
corp={props.corp}
division={props.division}
city={city}
warehouse={props.division.warehouses[city]}
office={office}
player={props.player}
/>
</> </>
); );
} }

@ -4,7 +4,6 @@ import { numeralWrapper } from "../../ui/numeralFormat";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { OfficeSpace } from "../OfficeSpace";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { NewCity } from "../Actions"; import { NewCity } from "../Actions";

@ -1,52 +1,46 @@
// React Components for the Corporation UI's navigation tabs // React Components for the Corporation UI's navigation tabs
// These are the tabs at the top of the UI that let you switch to different // These are the tabs at the top of the UI that let you switch to different
// divisions, see an overview of your corporation, or create a new industry // divisions, see an overview of your corporation, or create a new industry
import React from "react"; import React, { useState } from "react";
import { HeaderTab } from "./HeaderTab"; import { HeaderTab } from "./HeaderTab";
import { IIndustry } from "../IIndustry"; import { IIndustry } from "../IIndustry";
import { NewIndustryPopup } from "./NewIndustryPopup"; import { NewIndustryPopup } from "./NewIndustryPopup";
import { createPopup } from "../../ui/React/createPopup"; import { createPopup } from "../../ui/React/createPopup";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { CorporationRouting } from "./Routing";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { MainPanel } from "./MainPanel";
interface IProps { interface IProps {
corp: ICorporation; corp: ICorporation;
routing: CorporationRouting;
player: IPlayer; player: IPlayer;
} }
export function HeaderTabs(props: IProps): React.ReactElement { export function HeaderTabs(props: IProps): React.ReactElement {
function overviewOnClick(): void { const [divisionName, setDivisionName] = useState("Overview");
props.routing.routeToOverviewPage();
props.corp.rerender(props.player);
}
function openNewIndustryPopup(): void { function openNewIndustryPopup(): void {
const popupId = "cmpy-mgmt-expand-industry-popup"; const popupId = "cmpy-mgmt-expand-industry-popup";
createPopup(popupId, NewIndustryPopup, { createPopup(popupId, NewIndustryPopup, {
corp: props.corp, corp: props.corp,
routing: props.routing, setDivisionName: setDivisionName,
popupId: popupId, popupId: popupId,
}); });
} }
return ( return (
<>
<div> <div>
<HeaderTab <HeaderTab
current={props.routing.isOnOverviewPage()} current={divisionName === "Overview"}
key={"overview"} key={"overview"}
onClick={overviewOnClick} onClick={() => setDivisionName("Overview")}
text={props.corp.name} text={props.corp.name}
/> />
{props.corp.divisions.map((division: IIndustry) => ( {props.corp.divisions.map((division: IIndustry) => (
<HeaderTab <HeaderTab
current={props.routing.isOn(division.name)} current={division.name === divisionName}
key={division.name} key={division.name}
onClick={() => { onClick={() => setDivisionName(division.name)}
props.routing.routeTo(division.name);
props.corp.rerender(props.player);
}}
text={division.name} text={division.name}
/> />
))} ))}
@ -56,5 +50,11 @@ export function HeaderTabs(props: IProps): React.ReactElement {
text={"Expand into new Industry"} text={"Expand into new Industry"}
/> />
</div> </div>
<MainPanel
corp={props.corp}
divisionName={divisionName}
player={props.player}
/>
</>
); );
} }

@ -5,14 +5,18 @@ import React from "react";
import { IndustryOffice } from "./IndustryOffice"; import { IndustryOffice } from "./IndustryOffice";
import { IndustryOverview } from "./IndustryOverview"; import { IndustryOverview } from "./IndustryOverview";
import { IndustryWarehouse } from "./IndustryWarehouse"; import { IndustryWarehouse } from "./IndustryWarehouse";
import { Warehouse } from "../Warehouse";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { CorporationRouting } from "./Routing"; import { OfficeSpace } from "../OfficeSpace";
import { IIndustry } from "../IIndustry";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
interface IProps { interface IProps {
routing: CorporationRouting;
corp: ICorporation; corp: ICorporation;
currentCity: string; division: IIndustry;
city: string;
warehouse: Warehouse | 0;
office: OfficeSpace;
player: IPlayer; player: IPlayer;
} }
@ -22,23 +26,25 @@ export function Industry(props: IProps): React.ReactElement {
<div className={"cmpy-mgmt-industry-left-panel"}> <div className={"cmpy-mgmt-industry-left-panel"}>
<IndustryOverview <IndustryOverview
player={props.player} player={props.player}
routing={props.routing}
corp={props.corp} corp={props.corp}
currentCity={props.currentCity} division={props.division}
currentCity={props.city}
office={props.office}
/> />
<IndustryOffice <IndustryOffice
player={props.player} player={props.player}
routing={props.routing}
corp={props.corp} corp={props.corp}
currentCity={props.currentCity} division={props.division}
office={props.office}
/> />
</div> </div>
<div className={"cmpy-mgmt-industry-right-panel"}> <div className={"cmpy-mgmt-industry-right-panel"}>
<IndustryWarehouse <IndustryWarehouse
player={props.player} player={props.player}
corp={props.corp} corp={props.corp}
routing={props.routing} currentCity={props.city}
currentCity={props.currentCity} division={props.division}
warehouse={props.warehouse}
/> />
</div> </div>
</div> </div>

@ -3,6 +3,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { OfficeSpace } from "../OfficeSpace"; import { OfficeSpace } from "../OfficeSpace";
import { IIndustry } from "../IIndustry";
import { Employee } from "../Employee"; import { Employee } from "../Employee";
import { EmployeePositions } from "../EmployeePositions"; import { EmployeePositions } from "../EmployeePositions";
@ -15,20 +16,17 @@ import { HireEmployeePopup } from "./HireEmployeePopup";
import { ThrowPartyPopup } from "./ThrowPartyPopup"; import { ThrowPartyPopup } from "./ThrowPartyPopup";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { CorporationRouting } from "./Routing";
interface IProps { interface IProps {
routing: CorporationRouting;
corp: ICorporation; corp: ICorporation;
currentCity: string; division: IIndustry;
office: OfficeSpace;
player: IPlayer; player: IPlayer;
} }
export function IndustryOffice(props: IProps): React.ReactElement { export function IndustryOffice(props: IProps): React.ReactElement {
const [employeeManualAssignMode, setEmployeeManualAssignMode] = const [employeeManualAssignMode, setEmployeeManualAssignMode] =
useState(false); useState(false);
const [city, setCity] = useState("");
const [divisionName, setDivisionName] = useState("");
const [employee, setEmployee] = useState<Employee | null>(null); const [employee, setEmployee] = useState<Employee | null>(null);
const [numEmployees, setNumEmployees] = useState(0); const [numEmployees, setNumEmployees] = useState(0);
const [numOperations, setNumOperations] = useState(0); const [numOperations, setNumOperations] = useState(0);
@ -51,28 +49,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
function updateEmployeeCount(): void { function updateEmployeeCount(): void {
const division = props.routing.currentDivision;
if (division == null) {
throw new Error(
`Routing does not hold reference to the current Industry`,
);
}
const office = division.offices[props.currentCity];
if (!(office instanceof OfficeSpace)) {
throw new Error(
`Current City (${props.currentCity}) for UI does not have an OfficeSpace object`,
);
}
// If we're in a new city, we have to reset the state
if (division.name !== divisionName || props.currentCity !== city) {
resetEmployeeCount();
setDivisionName(division.name);
setCity(props.currentCity);
}
// Calculate how many NEW employees we need to account for // Calculate how many NEW employees we need to account for
const currentNumEmployees = office.employees.length; const currentNumEmployees = props.office.employees.length;
let newOperations = numOperations; let newOperations = numOperations;
let newEngineers = numEngineers; let newEngineers = numEngineers;
@ -83,8 +61,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
let newTraining = numTraining; let newTraining = numTraining;
// Record the number of employees in each position, for NEW employees only // Record the number of employees in each position, for NEW employees only
for (let i = numEmployees; i < office.employees.length; ++i) { for (let i = numEmployees; i < props.office.employees.length; ++i) {
switch (office.employees[i].pos) { switch (props.office.employees[i].pos) {
case EmployeePositions.Operations: case EmployeePositions.Operations:
newOperations++; newOperations++;
break; break;
@ -108,7 +86,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
break; break;
default: default:
console.error( console.error(
"Unrecognized employee position: " + office.employees[i].pos, "Unrecognized employee position: " + props.office.employees[i].pos,
); );
break; break;
} }
@ -139,10 +117,6 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
function renderAutomaticEmployeeManagement(): React.ReactElement { function renderAutomaticEmployeeManagement(): React.ReactElement {
const division = props.routing.currentDivision; // Validated in constructor
if (division === null) return <></>;
const office = division.offices[props.currentCity]; // Validated in constructor
if (office === 0) return <></>;
const vechain = props.corp.unlockUpgrades[4] === 1; // Has Vechain upgrade const vechain = props.corp.unlockUpgrades[4] === 1; // Has Vechain upgrade
function switchModeOnClick(): void { function switchModeOnClick(): void {
@ -156,26 +130,24 @@ export function IndustryOffice(props: IProps): React.ReactElement {
totalHappiness = 0, totalHappiness = 0,
totalEnergy = 0, totalEnergy = 0,
totalSalary = 0; totalSalary = 0;
for (let i = 0; i < office.employees.length; ++i) { for (let i = 0; i < props.office.employees.length; ++i) {
totalMorale += office.employees[i].mor; totalMorale += props.office.employees[i].mor;
totalHappiness += office.employees[i].hap; totalHappiness += props.office.employees[i].hap;
totalEnergy += office.employees[i].ene; totalEnergy += props.office.employees[i].ene;
totalSalary += office.employees[i].sal; totalSalary += props.office.employees[i].sal;
} }
let avgMorale = 0, let avgMorale = 0,
avgHappiness = 0, avgHappiness = 0,
avgEnergy = 0; avgEnergy = 0;
if (office.employees.length > 0) { if (props.office.employees.length > 0) {
avgMorale = totalMorale / office.employees.length; avgMorale = totalMorale / props.office.employees.length;
avgHappiness = totalHappiness / office.employees.length; avgHappiness = totalHappiness / props.office.employees.length;
avgEnergy = totalEnergy / office.employees.length; avgEnergy = totalEnergy / props.office.employees.length;
} }
// Helper functions for (re-)assigning employees to different positions // Helper functions for (re-)assigning employees to different positions
function assignEmployee(to: string): void { function assignEmployee(to: string): void {
if (office === 0) return;
if (division === null) return;
if (numUnassigned <= 0) { if (numUnassigned <= 0) {
console.warn( console.warn(
"Cannot assign employee. No unassigned employees available", "Cannot assign employee. No unassigned employees available",
@ -211,14 +183,12 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
setNumUnassigned((n) => n - 1); setNumUnassigned((n) => n - 1);
office.assignEmployeeToJob(to); props.office.assignEmployeeToJob(to);
office.calculateEmployeeProductivity(props.corp, division); props.office.calculateEmployeeProductivity(props.corp, props.division);
props.corp.rerender(props.player); props.corp.rerender(props.player);
} }
function unassignEmployee(from: string): void { function unassignEmployee(from: string): void {
if (office === 0) return;
if (division === null) return;
function logWarning(pos: string): void { function logWarning(pos: string): void {
console.warn( console.warn(
`Cannot unassign from ${pos} because there is nobody assigned to that position`, `Cannot unassign from ${pos} because there is nobody assigned to that position`,
@ -271,8 +241,8 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
setNumUnassigned((n) => n + 1); setNumUnassigned((n) => n + 1);
office.unassignEmployeeFromJob(from); props.office.unassignEmployeeFromJob(from);
office.calculateEmployeeProductivity(props.corp, division); props.office.calculateEmployeeProductivity(props.corp, props.division);
props.corp.rerender(props.player); props.corp.rerender(props.player);
} }
@ -375,7 +345,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
<p className={"tooltip"} style={{ display: "inline-block" }}> <p className={"tooltip"} style={{ display: "inline-block" }}>
Material Production:{" "} Material Production:{" "}
{numeralWrapper.format( {numeralWrapper.format(
division.getOfficeProductivity(office), props.division.getOfficeProductivity(props.office),
"0.000", "0.000",
)} )}
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
@ -391,7 +361,9 @@ export function IndustryOffice(props: IProps): React.ReactElement {
<p className={"tooltip"} style={{ display: "inline-block" }}> <p className={"tooltip"} style={{ display: "inline-block" }}>
Product Production:{" "} Product Production:{" "}
{numeralWrapper.format( {numeralWrapper.format(
division.getOfficeProductivity(office, { forProduct: true }), props.division.getOfficeProductivity(props.office, {
forProduct: true,
}),
"0.000", "0.000",
)} )}
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
@ -406,7 +378,10 @@ export function IndustryOffice(props: IProps): React.ReactElement {
{vechain && ( {vechain && (
<p className={"tooltip"} style={{ display: "inline-block" }}> <p className={"tooltip"} style={{ display: "inline-block" }}>
Business Multiplier: x Business Multiplier: x
{numeralWrapper.format(division.getBusinessFactor(office), "0.000")} {numeralWrapper.format(
props.division.getBusinessFactor(props.office),
"0.000",
)}
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
The effect this office's 'Business' employees has on boosting The effect this office's 'Business' employees has on boosting
sales sales
@ -542,12 +517,6 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
function renderManualEmployeeManagement(): React.ReactElement { function renderManualEmployeeManagement(): React.ReactElement {
const corp = props.corp;
const division = props.routing.currentDivision; // Validated in constructor
if (division === null) return <></>;
const office = division.offices[props.currentCity]; // Validated in constructor
if (office === 0) return <></>;
function switchModeOnClick(): void { function switchModeOnClick(): void {
setEmployeeManualAssignMode(false); setEmployeeManualAssignMode(false);
props.corp.rerender(props.player); props.corp.rerender(props.player);
@ -561,10 +530,10 @@ export function IndustryOffice(props: IProps): React.ReactElement {
// Employee Selector // Employee Selector
const employees = []; const employees = [];
for (let i = 0; i < office.employees.length; ++i) { for (let i = 0; i < props.office.employees.length; ++i) {
employees.push( employees.push(
<option key={office.employees[i].name}> <option key={props.office.employees[i].name}>
{office.employees[i].name} {props.office.employees[i].name}
</option>, </option>,
); );
} }
@ -572,16 +541,15 @@ export function IndustryOffice(props: IProps): React.ReactElement {
function employeeSelectorOnChange( function employeeSelectorOnChange(
e: React.ChangeEvent<HTMLSelectElement>, e: React.ChangeEvent<HTMLSelectElement>,
): void { ): void {
if (office === 0) return;
const name = getSelectText(e.target); const name = getSelectText(e.target);
for (let i = 0; i < office.employees.length; ++i) { for (let i = 0; i < props.office.employees.length; ++i) {
if (name === office.employees[i].name) { if (name === props.office.employees[i].name) {
setEmployee(office.employees[i]); setEmployee(props.office.employees[i]);
break; break;
} }
} }
corp.rerender(props.player); props.corp.rerender(props.player);
} }
// Employee Positions Selector // Employee Positions Selector
@ -607,7 +575,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
const pos = getSelectText(e.target); const pos = getSelectText(e.target);
employee.pos = pos; employee.pos = pos;
resetEmployeeCount(); resetEmployeeCount();
corp.rerender(props.player); props.corp.rerender(props.player);
} }
// Numeraljs formatter // Numeraljs formatter
@ -616,23 +584,23 @@ export function IndustryOffice(props: IProps): React.ReactElement {
// Employee stats (after applying multipliers) // Employee stats (after applying multipliers)
const effCre = emp const effCre = emp
? emp.cre * ? emp.cre *
corp.getEmployeeCreMultiplier() * props.corp.getEmployeeCreMultiplier() *
division.getEmployeeCreMultiplier() props.division.getEmployeeCreMultiplier()
: 0; : 0;
const effCha = emp const effCha = emp
? emp.cha * ? emp.cha *
corp.getEmployeeChaMultiplier() * props.corp.getEmployeeChaMultiplier() *
division.getEmployeeChaMultiplier() props.division.getEmployeeChaMultiplier()
: 0; : 0;
const effInt = emp const effInt = emp
? emp.int * ? emp.int *
corp.getEmployeeIntMultiplier() * props.corp.getEmployeeIntMultiplier() *
division.getEmployeeIntMultiplier() props.division.getEmployeeIntMultiplier()
: 0; : 0;
const effEff = emp const effEff = emp
? emp.eff * ? emp.eff *
corp.getEmployeeEffMultiplier() * props.corp.getEmployeeEffMultiplier() *
division.getEmployeeEffMultiplier() props.division.getEmployeeEffMultiplier()
: 0; : 0;
return ( return (
@ -682,30 +650,25 @@ export function IndustryOffice(props: IProps): React.ReactElement {
); );
} }
const division = props.routing.currentDivision; // Validated in constructor
if (division === null) return <></>;
const office = division.offices[props.currentCity]; // Validated in constructor
if (office === 0) return <></>;
const buttonStyle = { const buttonStyle = {
fontSize: "13px", fontSize: "13px",
}; };
// Hire Employee button // Hire Employee button
let hireEmployeeButtonClass = "tooltip"; let hireEmployeeButtonClass = "tooltip";
if (office.atCapacity()) { if (props.office.atCapacity()) {
hireEmployeeButtonClass += " a-link-button-inactive"; hireEmployeeButtonClass += " a-link-button-inactive";
} else { } else {
hireEmployeeButtonClass += " std-button"; hireEmployeeButtonClass += " std-button";
if (office.employees.length === 0) { if (props.office.employees.length === 0) {
hireEmployeeButtonClass += " flashing-button"; hireEmployeeButtonClass += " flashing-button";
} }
} }
function openHireEmployeePopup(): void { function openHireEmployeePopup(): void {
if (office === 0) return;
const popupId = "cmpy-mgmt-hire-employee-popup"; const popupId = "cmpy-mgmt-hire-employee-popup";
createPopup(popupId, HireEmployeePopup, { createPopup(popupId, HireEmployeePopup, {
office: office, office: props.office,
corp: props.corp, corp: props.corp,
popupId: popupId, popupId: popupId,
player: props.player, player: props.player,
@ -714,23 +677,21 @@ export function IndustryOffice(props: IProps): React.ReactElement {
// Autohire employee button // Autohire employee button
let autohireEmployeeButtonClass = "tooltip"; let autohireEmployeeButtonClass = "tooltip";
if (office.atCapacity()) { if (props.office.atCapacity()) {
autohireEmployeeButtonClass += " a-link-button-inactive"; autohireEmployeeButtonClass += " a-link-button-inactive";
} else { } else {
autohireEmployeeButtonClass += " std-button"; autohireEmployeeButtonClass += " std-button";
} }
function autohireEmployeeButtonOnClick(): void { function autohireEmployeeButtonOnClick(): void {
if (office === 0) return; if (props.office.atCapacity()) return;
if (office.atCapacity()) return; props.office.hireRandomEmployee();
office.hireRandomEmployee();
props.corp.rerender(props.player); props.corp.rerender(props.player);
} }
function openUpgradeOfficeSizePopup(): void { function openUpgradeOfficeSizePopup(): void {
if (office === 0) return;
const popupId = "cmpy-mgmt-upgrade-office-size-popup"; const popupId = "cmpy-mgmt-upgrade-office-size-popup";
createPopup(popupId, UpgradeOfficeSizePopup, { createPopup(popupId, UpgradeOfficeSizePopup, {
office: office, office: props.office,
corp: props.corp, corp: props.corp,
popupId: popupId, popupId: popupId,
player: props.player, player: props.player,
@ -738,10 +699,9 @@ export function IndustryOffice(props: IProps): React.ReactElement {
} }
function openThrowPartyPopup(): void { function openThrowPartyPopup(): void {
if (office === 0) return;
const popupId = "cmpy-mgmt-throw-office-party-popup"; const popupId = "cmpy-mgmt-throw-office-party-popup";
createPopup(popupId, ThrowPartyPopup, { createPopup(popupId, ThrowPartyPopup, {
office: office, office: props.office,
corp: props.corp, corp: props.corp,
popupId: popupId, popupId: popupId,
}); });
@ -751,7 +711,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
<div className={"cmpy-mgmt-employee-panel"}> <div className={"cmpy-mgmt-employee-panel"}>
<h1 style={{ margin: "4px 0px 5px 0px" }}>Office Space</h1> <h1 style={{ margin: "4px 0px 5px 0px" }}>Office Space</h1>
<p> <p>
Size: {office.employees.length} / {office.size} employees Size: {props.office.employees.length} / {props.office.size} employees
</p> </p>
<button <button
className={hireEmployeeButtonClass} className={hireEmployeeButtonClass}
@ -759,7 +719,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
style={buttonStyle} style={buttonStyle}
> >
Hire Employee Hire Employee
{office.employees.length === 0 && ( {props.office.employees.length === 0 && (
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
You'll need to hire some employees to get your operations started! You'll need to hire some employees to get your operations started!
It's recommended to have at least one employee in every position It's recommended to have at least one employee in every position
@ -787,7 +747,7 @@ export function IndustryOffice(props: IProps): React.ReactElement {
Upgrade the office's size so that it can hold more employees! Upgrade the office's size so that it can hold more employees!
</span> </span>
</button> </button>
{!division.hasResearch("AutoPartyManager") && ( {!props.division.hasResearch("AutoPartyManager") && (
<button <button
className={"std-button tooltip"} className={"std-button tooltip"}
onClick={openThrowPartyPopup} onClick={openThrowPartyPopup}

@ -5,6 +5,7 @@ import React from "react";
import { OfficeSpace } from "../OfficeSpace"; import { OfficeSpace } from "../OfficeSpace";
import { Industries } from "../IndustryData"; import { Industries } from "../IndustryData";
import { IndustryUpgrades } from "../IndustryUpgrades"; import { IndustryUpgrades } from "../IndustryUpgrades";
import { IIndustry } from "../IIndustry";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { createProgressBarText } from "../../../utils/helpers/createProgressBarText"; import { createProgressBarText } from "../../../utils/helpers/createProgressBarText";
@ -14,22 +15,20 @@ import { createPopup } from "../../ui/React/createPopup";
import { Money } from "../../ui/React/Money"; import { Money } from "../../ui/React/Money";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { CorporationRouting } from "./Routing";
interface IProps { interface IProps {
routing: CorporationRouting;
corp: ICorporation; corp: ICorporation;
currentCity: string; currentCity: string;
division: IIndustry;
office: OfficeSpace;
player: IPlayer; player: IPlayer;
} }
export function IndustryOverview(props: IProps): React.ReactElement { export function IndustryOverview(props: IProps): React.ReactElement {
function renderMakeProductButton(): React.ReactElement { function renderMakeProductButton(): React.ReactElement {
const division = props.routing.currentDivision; // Validated inside render()
if (division === null) return <></>;
let createProductButtonText = ""; let createProductButtonText = "";
let createProductPopupText = ""; let createProductPopupText = "";
switch (division.type) { switch (props.division.type) {
case Industries.Food: case Industries.Food:
createProductButtonText = "Build Restaurant"; createProductButtonText = "Build Restaurant";
createProductPopupText = "Build and manage a new restaurant!"; createProductPopupText = "Build and manage a new restaurant!";
@ -80,7 +79,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
"the product. Investing money in its design will result in a superior product. " + "the product. Investing money in its design will result in a superior product. " +
"Investing money in marketing the product will help the product's sales."; "Investing money in marketing the product will help the product's sales.";
const hasMaxProducts = division.hasMaximumNumberProducts(); const hasMaxProducts = props.division.hasMaximumNumberProducts();
const className = hasMaxProducts const className = hasMaxProducts
? "a-link-button-inactive tooltip" ? "a-link-button-inactive tooltip"
@ -91,11 +90,10 @@ export function IndustryOverview(props: IProps): React.ReactElement {
}; };
function openMakeProductPopup(): void { function openMakeProductPopup(): void {
if (division === null) return;
const popupId = "cmpy-mgmt-create-product-popup"; const popupId = "cmpy-mgmt-create-product-popup";
createPopup(popupId, MakeProductPopup, { createPopup(popupId, MakeProductPopup, {
popupText: createProductPopupText, popupText: createProductPopupText,
division: division, division: props.division,
corp: props.corp, corp: props.corp,
popupId: popupId, popupId: popupId,
}); });
@ -111,7 +109,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
{hasMaxProducts && ( {hasMaxProducts && (
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
You have reached the maximum number of products:{" "} You have reached the maximum number of products:{" "}
{division.getMaximumNumberProducts()} {props.division.getMaximumNumberProducts()}
</span> </span>
)} )}
</button> </button>
@ -119,16 +117,13 @@ export function IndustryOverview(props: IProps): React.ReactElement {
} }
function renderText(): React.ReactElement { function renderText(): React.ReactElement {
const corp = props.corp; const vechain = props.corp.unlockUpgrades[4] === 1;
const division = props.routing.currentDivision; // Validated inside render() const profit = props.division.lastCycleRevenue
if (division === null) return <></>; .minus(props.division.lastCycleExpenses)
const vechain = corp.unlockUpgrades[4] === 1;
const profit = division.lastCycleRevenue
.minus(division.lastCycleExpenses)
.toNumber(); .toNumber();
let advertisingInfo = false; let advertisingInfo = false;
const advertisingFactors = division.getAdvertisingFactors(); const advertisingFactors = props.division.getAdvertisingFactors();
const awarenessFac = advertisingFactors[1]; const awarenessFac = advertisingFactors[1];
const popularityFac = advertisingFactors[2]; const popularityFac = advertisingFactors[2];
const ratioFac = advertisingFactors[3]; const ratioFac = advertisingFactors[3];
@ -138,7 +133,6 @@ export function IndustryOverview(props: IProps): React.ReactElement {
} }
function productionMultHelpTipOnClick(): void { function productionMultHelpTipOnClick(): void {
if (division === null) return;
// Wrapper for createProgressBarText() // Wrapper for createProgressBarText()
// Converts the industry's "effectiveness factors" // Converts the industry's "effectiveness factors"
// into a graphic (string) depicting how high that effectiveness is // into a graphic (string) depicting how high that effectiveness is
@ -163,34 +157,41 @@ export function IndustryOverview(props: IProps): React.ReactElement {
"Below are approximations for how effective each material is at boosting " + "Below are approximations for how effective each material is at boosting " +
"this industry's production multiplier (Bigger bars = more effective):<br><br>" + "this industry's production multiplier (Bigger bars = more effective):<br><br>" +
`Hardware:&nbsp;&nbsp;&nbsp; ${convertEffectFacToGraphic( `Hardware:&nbsp;&nbsp;&nbsp; ${convertEffectFacToGraphic(
division.hwFac, props.division.hwFac,
)}<br>` + )}<br>` +
`Robots:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${convertEffectFacToGraphic( `Robots:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${convertEffectFacToGraphic(
division.robFac, props.division.robFac,
)}<br>` + )}<br>` +
`AI Cores:&nbsp;&nbsp;&nbsp; ${convertEffectFacToGraphic( `AI Cores:&nbsp;&nbsp;&nbsp; ${convertEffectFacToGraphic(
division.aiFac, props.division.aiFac,
)}<br>` + )}<br>` +
`Real Estate: ${convertEffectFacToGraphic(division.reFac)}`, `Real Estate: ${convertEffectFacToGraphic(props.division.reFac)}`,
); );
} }
function openResearchPopup(): void { function openResearchPopup(): void {
if (division === null) return;
const popupId = "corporation-research-popup-box"; const popupId = "corporation-research-popup-box";
createPopup(popupId, ResearchPopup, { createPopup(popupId, ResearchPopup, {
industry: division, industry: props.division,
popupId: popupId, popupId: popupId,
}); });
} }
return ( return (
<div> <div>
Industry: {division.type} (Corp Funds:{" "} Industry: {props.division.type} (Corp Funds:{" "}
<Money money={corp.funds.toNumber()} />) <Money money={props.corp.funds.toNumber()} />)
<br /> <br /> <br /> <br />
Awareness: {numeralWrapper.format(division.awareness, "0.000")} <br /> Awareness: {numeralWrapper.format(
Popularity: {numeralWrapper.format(division.popularity, "0.000")} <br /> props.division.awareness,
"0.000",
)}{" "}
<br />
Popularity: {numeralWrapper.format(
props.division.popularity,
"0.000",
)}{" "}
<br />
{advertisingInfo !== false && ( {advertisingInfo !== false && (
<p className={"tooltip"}> <p className={"tooltip"}>
Advertising Multiplier: x Advertising Multiplier: x
@ -213,16 +214,17 @@ export function IndustryOverview(props: IProps): React.ReactElement {
{advertisingInfo} {advertisingInfo}
<br /> <br />
<br /> <br />
Revenue: <Money money={division.lastCycleRevenue.toNumber()} /> / s{" "} Revenue: <Money money={props.division.lastCycleRevenue.toNumber()} /> /
<br /> s <br />
Expenses: <Money Expenses: <Money
money={division.lastCycleExpenses.toNumber()} money={props.division.lastCycleExpenses.toNumber()}
/> /s <br /> />{" "}
/s <br />
Profit: <Money money={profit} /> / s Profit: <Money money={profit} /> / s
<br /> <br /> <br /> <br />
<p className={"tooltip"}> <p className={"tooltip"}>
Production Multiplier:{" "} Production Multiplier:{" "}
{numeralWrapper.format(division.prodMult, "0.00")} {numeralWrapper.format(props.division.prodMult, "0.00")}
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
Production gain from owning production-boosting materials such as Production gain from owning production-boosting materials such as
hardware, Robots, AI Cores, and Real Estate hardware, Robots, AI Cores, and Real Estate
@ -234,7 +236,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
<br /> <br /> <br /> <br />
<p className={"tooltip"}> <p className={"tooltip"}>
Scientific Research:{" "} Scientific Research:{" "}
{numeralWrapper.format(division.sciResearch.qty, "0.000a")} {numeralWrapper.format(props.division.sciResearch.qty, "0.000a")}
<span className={"tooltiptext"}> <span className={"tooltiptext"}>
Scientific Research increases the quality of the materials and Scientific Research increases the quality of the materials and
products that you produce. products that you produce.
@ -248,22 +250,12 @@ export function IndustryOverview(props: IProps): React.ReactElement {
} }
function renderUpgrades(): React.ReactElement[] { function renderUpgrades(): React.ReactElement[] {
const corp = props.corp;
const division = props.routing.currentDivision; // Validated inside render()
if (division === null) return [<></>];
const office = division.offices[props.currentCity];
if (!(office instanceof OfficeSpace)) {
throw new Error(
`Current City (${props.currentCity}) for UI does not have an OfficeSpace object`,
);
}
const upgrades = []; const upgrades = [];
for (const index in IndustryUpgrades) { for (const index in IndustryUpgrades) {
const upgrade = IndustryUpgrades[index]; const upgrade = IndustryUpgrades[index];
// AutoBrew research disables the Coffee upgrade // AutoBrew research disables the Coffee upgrade
if (division.hasResearch("AutoBrew") && upgrade[4] === "Coffee") { if (props.division.hasResearch("AutoBrew") && upgrade[4] === "Coffee") {
continue; continue;
} }
@ -273,26 +265,24 @@ export function IndustryOverview(props: IProps): React.ReactElement {
let cost = 0; let cost = 0;
switch (i) { switch (i) {
case 0: //Coffee, cost is static per employee case 0: //Coffee, cost is static per employee
cost = office.employees.length * baseCost; cost = props.office.employees.length * baseCost;
break; break;
default: default:
cost = baseCost * Math.pow(priceMult, division.upgrades[i]); cost = baseCost * Math.pow(priceMult, props.division.upgrades[i]);
break; break;
} }
function onClick(): void { function onClick(): void {
if (office === 0) return; if (props.corp.funds.lt(cost)) {
if (division === null) return;
if (corp.funds.lt(cost)) {
dialogBoxCreate("Insufficient funds"); dialogBoxCreate("Insufficient funds");
} else { } else {
corp.funds = corp.funds.minus(cost); props.corp.funds = props.corp.funds.minus(cost);
division.upgrade(upgrade, { props.division.upgrade(upgrade, {
corporation: corp, corporation: props.corp,
office: office, office: props.office,
}); });
// corp.displayDivisionContent(division, city); // corp.displayDivisionContent(division, city);
corp.rerender(props.player); props.corp.rerender(props.player);
} }
} }
@ -335,11 +325,6 @@ export function IndustryOverview(props: IProps): React.ReactElement {
); );
} }
const division = props.routing.currentDivision;
if (division == null) {
throw new Error(`Routing does not hold reference to the current Industry`);
}
const makeProductButton = renderMakeProductButton(); const makeProductButton = renderMakeProductButton();
return ( return (
@ -351,7 +336,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
</u> </u>
<br /> <br />
{renderUpgrades()} <br /> {renderUpgrades()} <br />
{division.makesProducts && makeProductButton} {props.division.makesProducts && makeProductButton}
</div> </div>
); );
} }

@ -23,7 +23,6 @@ import { createPopup } from "../../ui/React/createPopup";
import { isString } from "../../../utils/helpers/isString"; import { isString } from "../../../utils/helpers/isString";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry"; import { IIndustry } from "../IIndustry";
import { CorporationRouting } from "./Routing";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { SetSmartSupply } from "../Actions"; import { SetSmartSupply } from "../Actions";
@ -438,7 +437,8 @@ function MaterialComponent(props: IMaterialProps): React.ReactElement {
interface IProps { interface IProps {
corp: ICorporation; corp: ICorporation;
routing: CorporationRouting; division: IIndustry;
warehouse: Warehouse | 0;
currentCity: string; currentCity: string;
player: IPlayer; player: IPlayer;
} }
@ -464,53 +464,49 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
} }
function renderWarehouseUI(): React.ReactElement { function renderWarehouseUI(): React.ReactElement {
const corp = props.corp; if (props.warehouse === 0) return <></>;
const division = props.routing.currentDivision; // Validated in render()
if (division === null) return <></>;
const warehouse = division.warehouses[props.currentCity]; // Validated in render()
if (warehouse === 0) return <></>;
// General Storage information at the top // General Storage information at the top
const sizeUsageStyle = { const sizeUsageStyle = {
color: warehouse.sizeUsed >= warehouse.size ? "red" : "white", color: props.warehouse.sizeUsed >= props.warehouse.size ? "red" : "white",
margin: "5px", margin: "5px",
}; };
// Upgrade Warehouse size button // Upgrade Warehouse size button
const sizeUpgradeCost = const sizeUpgradeCost =
CorporationConstants.WarehouseUpgradeBaseCost * CorporationConstants.WarehouseUpgradeBaseCost *
Math.pow(1.07, warehouse.level + 1); Math.pow(1.07, props.warehouse.level + 1);
const canAffordUpgrade = corp.funds.gt(sizeUpgradeCost); const canAffordUpgrade = props.corp.funds.gt(sizeUpgradeCost);
const upgradeWarehouseClass = canAffordUpgrade const upgradeWarehouseClass = canAffordUpgrade
? "std-button" ? "std-button"
: "a-link-button-inactive"; : "a-link-button-inactive";
function upgradeWarehouseOnClick(): void { function upgradeWarehouseOnClick(): void {
if (division === null) return; if (props.division === null) return;
if (warehouse === 0) return; if (props.warehouse === 0) return;
++warehouse.level; ++props.warehouse.level;
warehouse.updateSize(corp, division); props.warehouse.updateSize(props.corp, props.division);
corp.funds = corp.funds.minus(sizeUpgradeCost); props.corp.funds = props.corp.funds.minus(sizeUpgradeCost);
corp.rerender(props.player); props.corp.rerender(props.player);
} }
// Industry material Requirements // Industry material Requirements
let generalReqsText = let generalReqsText =
"This Industry uses [" + "This Industry uses [" +
Object.keys(division.reqMats).join(", ") + Object.keys(props.division.reqMats).join(", ") +
"] in order to "; "] in order to ";
if (division.prodMats.length > 0) { if (props.division.prodMats.length > 0) {
generalReqsText += "produce [" + division.prodMats.join(", ") + "] "; generalReqsText +=
if (division.makesProducts) { "produce [" + props.division.prodMats.join(", ") + "] ";
generalReqsText += " and " + division.getProductDescriptionText(); if (props.division.makesProducts) {
generalReqsText += " and " + props.division.getProductDescriptionText();
} }
} else if (division.makesProducts) { } else if (props.division.makesProducts) {
generalReqsText += division.getProductDescriptionText() + "."; generalReqsText += props.division.getProductDescriptionText() + ".";
} }
const ratioLines = []; const ratioLines = [];
for (const matName in division.reqMats) { for (const matName in props.division.reqMats) {
if (division.reqMats.hasOwnProperty(matName)) { if (props.division.reqMats.hasOwnProperty(matName)) {
const text = [" *", division.reqMats[matName], matName].join(" "); const text = [" *", props.division.reqMats[matName], matName].join(" ");
ratioLines.push( ratioLines.push(
<div key={matName}> <div key={matName}>
<p>{text}</p> <p>{text}</p>
@ -520,19 +516,21 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
} }
let createdItemsText = "in order to create "; let createdItemsText = "in order to create ";
if (division.prodMats.length > 0) { if (props.division.prodMats.length > 0) {
createdItemsText += createdItemsText +=
"one of each produced Material (" + division.prodMats.join(", ") + ") "; "one of each produced Material (" +
if (division.makesProducts) { props.division.prodMats.join(", ") +
") ";
if (props.division.makesProducts) {
createdItemsText += "or to create one of its Products"; createdItemsText += "or to create one of its Products";
} }
} else if (division.makesProducts) { } else if (props.division.makesProducts) {
createdItemsText += "one of its Products"; createdItemsText += "one of its Products";
} }
// Current State: // Current State:
let stateText; let stateText;
switch (division.state) { switch (props.division.state) {
case "START": case "START":
stateText = "Current state: Preparing..."; stateText = "Current state: Preparing...";
break; break;
@ -549,32 +547,32 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
stateText = "Current state: Exporting materials and/or products..."; stateText = "Current state: Exporting materials and/or products...";
break; break;
default: default:
console.error(`Invalid state: ${division.state}`); console.error(`Invalid state: ${props.division.state}`);
break; break;
} }
// Smart Supply Checkbox // Smart Supply Checkbox
const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox"; const smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox";
function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void { function smartSupplyOnChange(e: React.ChangeEvent<HTMLInputElement>): void {
if (warehouse === 0) return; if (props.warehouse === 0) return;
SetSmartSupply(warehouse, e.target.checked); SetSmartSupply(props.warehouse, e.target.checked);
corp.rerender(props.player); props.corp.rerender(props.player);
} }
// Create React components for materials // Create React components for materials
const mats = []; const mats = [];
for (const matName in warehouse.materials) { for (const matName in props.warehouse.materials) {
if (warehouse.materials[matName] instanceof Material) { if (props.warehouse.materials[matName] instanceof Material) {
// Only create UI for materials that are relevant for the industry // Only create UI for materials that are relevant for the industry
if (isRelevantMaterial(matName, division)) { if (isRelevantMaterial(matName, props.division)) {
mats.push( mats.push(
<MaterialComponent <MaterialComponent
city={props.currentCity} city={props.currentCity}
corp={corp} corp={props.corp}
division={division} division={props.division}
key={matName} key={matName}
mat={warehouse.materials[matName]} mat={props.warehouse.materials[matName]}
warehouse={warehouse} warehouse={props.warehouse}
/>, />,
); );
} }
@ -583,16 +581,19 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
// Create React components for products // Create React components for products
const products = []; const products = [];
if (division.makesProducts && Object.keys(division.products).length > 0) { if (
for (const productName in division.products) { props.division.makesProducts &&
const product = division.products[productName]; Object.keys(props.division.products).length > 0
) {
for (const productName in props.division.products) {
const product = props.division.products[productName];
if (product instanceof Product) { if (product instanceof Product) {
products.push( products.push(
<ProductComponent <ProductComponent
player={props.player} player={props.player}
city={props.currentCity} city={props.currentCity}
corp={corp} corp={props.corp}
division={division} division={props.division}
key={productName} key={productName}
product={product} product={product}
/>, />,
@ -604,11 +605,11 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
return ( return (
<div className={"cmpy-mgmt-warehouse-panel"}> <div className={"cmpy-mgmt-warehouse-panel"}>
<p className={"tooltip"} style={sizeUsageStyle}> <p className={"tooltip"} style={sizeUsageStyle}>
Storage: {numeralWrapper.formatBigNumber(warehouse.sizeUsed)} /{" "} Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "}
{numeralWrapper.formatBigNumber(warehouse.size)} {numeralWrapper.formatBigNumber(props.warehouse.size)}
<span <span
className={"tooltiptext"} className={"tooltiptext"}
dangerouslySetInnerHTML={{ __html: warehouse.breakdown }} dangerouslySetInnerHTML={{ __html: props.warehouse.breakdown }}
></span> ></span>
</p> </p>
@ -632,7 +633,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
<p>{stateText}</p> <p>{stateText}</p>
{corp.unlockUpgrades[1] && ( {props.corp.unlockUpgrades[1] && (
<div> <div>
<label style={{ color: "white" }} htmlFor={smartSupplyCheckboxId}> <label style={{ color: "white" }} htmlFor={smartSupplyCheckboxId}>
Enable Smart Supply Enable Smart Supply
@ -642,7 +643,7 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
id={smartSupplyCheckboxId} id={smartSupplyCheckboxId}
onChange={smartSupplyOnChange} onChange={smartSupplyOnChange}
style={{ margin: "3px" }} style={{ margin: "3px" }}
checked={warehouse.smartSupplyEnabled} checked={props.warehouse.smartSupplyEnabled}
/> />
</div> </div>
)} )}
@ -654,12 +655,6 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
); );
} }
const division = props.routing.currentDivision;
if (division == null) {
throw new Error(`Routing does not hold reference to the current Industry`);
}
const warehouse = division.warehouses[props.currentCity];
function purchaseWarehouse(division: IIndustry, city: string): void { function purchaseWarehouse(division: IIndustry, city: string): void {
if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) { if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) {
dialogBoxCreate("You do not have enough funds to do this!"); dialogBoxCreate("You do not have enough funds to do this!");
@ -677,14 +672,14 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
} }
} }
if (warehouse instanceof Warehouse) { if (props.warehouse instanceof Warehouse) {
return renderWarehouseUI(); return renderWarehouseUI();
} else { } else {
return ( return (
<div className={"cmpy-mgmt-warehouse-panel"}> <div className={"cmpy-mgmt-warehouse-panel"}>
<button <button
className={"std-button"} className={"std-button"}
onClick={() => purchaseWarehouse(division, props.currentCity)} onClick={() => purchaseWarehouse(props.division, props.currentCity)}
> >
Purchase Warehouse ( Purchase Warehouse (
{numeralWrapper.formatMoney( {numeralWrapper.formatMoney(

@ -1,7 +1,6 @@
// React components for the levelable upgrade buttons on the overview panel // React components for the levelable upgrade buttons on the overview panel
import React from "react"; import React from "react";
import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";

@ -1,100 +1,46 @@
// React Component for the element that contains the actual info/data // React Component for the element that contains the actual info/data
// for the Corporation UI. This panel lies below the header tabs and will // for the Corporation UI. This panel lies below the header tabs and will
// be filled with whatever is needed based on the routing/navigation // be filled with whatever is needed based on the routing/navigation
import React, { useState } from "react"; import React from "react";
import { CityTabs } from "./CityTabs"; import { CityTabs } from "./CityTabs";
import { Industry } from "./Industry"; import { IIndustry } from "../IIndustry";
import { Overview } from "./Overview"; import { Overview } from "./Overview";
import { OfficeSpace } from "../OfficeSpace";
import { CityName } from "../../Locations/data/CityNames"; import { CityName } from "../../Locations/data/CityNames";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { CorporationRouting } from "./Routing";
interface IProps { interface IProps {
corp: ICorporation; corp: ICorporation;
routing: CorporationRouting;
player: IPlayer; player: IPlayer;
divisionName: string;
} }
export function MainPanel(props: IProps): React.ReactElement { export function MainPanel(props: IProps): React.ReactElement {
const [division, setDivision] = useState(""); const division =
const [city, setCity] = useState<string>(CityName.Sector12); props.divisionName !== "Overview"
? props.corp.divisions.find(
(division: IIndustry) => division.name === props.divisionName,
)
: undefined; // use undefined because find returns undefined
// We can pass this setter to child components if (division === undefined) {
function changeCityState(newCity: string): void {
if (Object.values(CityName).includes(newCity as CityName)) {
setCity(newCity);
} else {
console.error(
`Tried to change MainPanel's city state to an invalid city: ${newCity}`,
);
}
}
function renderOverviewPage(): React.ReactElement {
return ( return (
<div id="cmpy-mgmt-panel"> <div id="cmpy-mgmt-panel">
<Overview {...props} /> <Overview {...props} />
</div> </div>
); );
} } else {
function renderDivisionPage(): React.ReactElement {
// Note: Division is the same thing as Industry...I wasn't consistent with naming
const division = props.routing.currentDivision;
if (division == null) {
throw new Error(
`Routing does not hold reference to the current Industry`,
);
}
// City tabs
const onClicks: { [key: string]: () => void } = {};
for (const cityName in division.offices) {
if (division.offices[cityName] instanceof OfficeSpace) {
onClicks[cityName] = () => {
setCity(cityName);
props.corp.rerender(props.player);
};
}
}
const cityTabs = (
<CityTabs
{...props}
corp={props.corp}
city={city}
onClicks={onClicks}
cityStateSetter={changeCityState}
/>
);
return ( return (
<div id="cmpy-mgmt-panel"> <div id="cmpy-mgmt-panel">
{cityTabs} <CityTabs
<Industry {...props} currentCity={city} /> division={division}
corp={props.corp}
city={CityName.Sector12}
player={props.player}
/>
</div> </div>
); );
} }
if (props.routing.isOnOverviewPage()) {
// Corporation overview Content
return renderOverviewPage();
} else {
// Division content
// First, check if we're at a new division. If so, we need to reset the city to Sector-12
// Otherwise, just switch the 'city' state
const currentDivision = props.routing.current();
if (currentDivision !== division) {
setDivision(currentDivision);
setCity(CityName.Sector12);
}
return renderDivisionPage();
}
} }

@ -1,21 +1,15 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { import { Industries, IndustryDescriptions } from "../IndustryData";
Industries,
IndustryStartingCosts,
IndustryDescriptions,
} from "../IndustryData";
import { Industry } from "../Industry";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry"; import { IIndustry } from "../IIndustry";
import { CorporationRouting } from "./Routing";
import { NewIndustry } from "../Actions"; import { NewIndustry } from "../Actions";
interface IProps { interface IProps {
corp: ICorporation; corp: ICorporation;
popupId: string; popupId: string;
routing: CorporationRouting; setDivisionName: (name: string) => void;
} }
// Create a popup that lets the player create a new industry. // Create a popup that lets the player create a new industry.
// This is created when the player clicks the "Expand into new Industry" header tab // This is created when the player clicks the "Expand into new Industry" header tab
@ -23,8 +17,7 @@ export function NewIndustryPopup(props: IProps): React.ReactElement {
const allIndustries = Object.keys(Industries).sort(); const allIndustries = Object.keys(Industries).sort();
const possibleIndustries = allIndustries const possibleIndustries = allIndustries
.filter( .filter(
(industryType: string) => (industryType: string) => props.corp.divisions.find(
props.corp.divisions.find(
(division: IIndustry) => division.type === industryType, (division: IIndustry) => division.type === industryType,
) === undefined, ) === undefined,
) )
@ -43,7 +36,7 @@ export function NewIndustryPopup(props: IProps): React.ReactElement {
} }
// Set routing to the new division so that the UI automatically switches to it // Set routing to the new division so that the UI automatically switches to it
props.routing.routeTo(name); props.setDivisionName(name);
removePopup(props.popupId); removePopup(props.popupId);
} }

@ -33,10 +33,6 @@ interface IProps {
player: IPlayer; player: IPlayer;
} }
interface GeneralBtns {
bribeFactions: React.ReactElement;
}
export function Overview(props: IProps): React.ReactElement { export function Overview(props: IProps): React.ReactElement {
// Generic Function for Creating a button // Generic Function for Creating a button
interface ICreateButtonProps { interface ICreateButtonProps {
@ -64,26 +60,6 @@ export function Overview(props: IProps): React.ReactElement {
); );
} }
function createButton(props: ICreateButtonProps): React.ReactElement {
let className = props.class ? props.class : "std-button";
const displayStyle = props.display ? props.display : "block";
const hasTooltip = props.tooltip != null;
if (hasTooltip) {
className += " tooltip";
}
return (
<a
className={className}
onClick={props.onClick}
style={{ display: displayStyle }}
>
{props.text}
{hasTooltip && <span className={"tooltiptext"}>{props.tooltip}</span>}
</a>
);
}
function openBribeFactionPopup(): void { function openBribeFactionPopup(): void {
const popupId = "corp-bribe-popup"; const popupId = "corp-bribe-popup";
createPopup(popupId, BribeFactionPopup, { createPopup(popupId, BribeFactionPopup, {
@ -97,7 +73,7 @@ export function Overview(props: IProps): React.ReactElement {
.minus(props.corp.expenses) .minus(props.corp.expenses)
.toNumber(); .toNumber();
function DividendsStats() { function DividendsStats(): React.ReactElement {
if (props.corp.dividendPercentage <= 0 || profit <= 0) return <></>; if (props.corp.dividendPercentage <= 0 || profit <= 0) return <></>;
const totalDividends = (props.corp.dividendPercentage / 100) * profit; const totalDividends = (props.corp.dividendPercentage / 100) * profit;
const retainedEarnings = profit - totalDividends; const retainedEarnings = profit - totalDividends;
@ -330,8 +306,7 @@ export function Overview(props: IProps): React.ReactElement {
<h1 className={"cmpy-mgmt-upgrade-header"}> Unlocks </h1> <h1 className={"cmpy-mgmt-upgrade-header"}> Unlocks </h1>
{Object.values(CorporationUnlockUpgrades) {Object.values(CorporationUnlockUpgrades)
.filter( .filter(
(upgrade: CorporationUnlockUpgrade) => (upgrade: CorporationUnlockUpgrade) => props.corp.unlockUpgrades[upgrade[0]] === 0,
props.corp.unlockUpgrades[upgrade[0]] === 0,
) )
.map((upgrade: CorporationUnlockUpgrade) => ( .map((upgrade: CorporationUnlockUpgrade) => (
<UnlockUpgrade <UnlockUpgrade

@ -2,30 +2,18 @@
import React from "react"; import React from "react";
import { HeaderTabs } from "./HeaderTabs"; import { HeaderTabs } from "./HeaderTabs";
import { MainPanel } from "./MainPanel";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";
import { CorporationRouting } from "./Routing";
interface IProps { interface IProps {
corp: ICorporation; corp: ICorporation;
routing: CorporationRouting;
player: IPlayer; player: IPlayer;
} }
export function CorporationRoot(props: IProps): React.ReactElement { export function CorporationRoot(props: IProps): React.ReactElement {
return ( return (
<div> <div>
<HeaderTabs <HeaderTabs corp={props.corp} player={props.player} />
corp={props.corp}
routing={props.routing}
player={props.player}
/>
<MainPanel
corp={props.corp}
routing={props.routing}
player={props.player}
/>
</div> </div>
); );
} }

@ -1,90 +0,0 @@
import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry";
export const overviewPage = "Overview";
/**
* Keeps track of what content is currently being displayed for the Corporation UI
*/
export class CorporationRouting {
private currentPage: string = overviewPage;
// Stores a reference to the Corporation instance
private corp: ICorporation;
// Stores a reference to the Division instance that the routing is currently on
// This will be null if routing is on the overview page
currentDivision: IIndustry | null = null;
constructor(corp: ICorporation) {
this.corp = corp;
}
current(): string {
return this.currentPage;
}
/**
* Checks that the specified page has a valid value
*/
isValidPage(page: string): boolean {
if (page === overviewPage) {
return true;
}
for (const division of this.corp.divisions) {
if (division.name === page) {
return true;
}
}
return false;
}
/**
* Returns a boolean indicating whether or not the player is on the given page
*/
isOn(page: string): boolean {
if (!this.isValidPage(page)) {
return false;
}
return page === this.currentPage;
}
isOnOverviewPage(): boolean {
return this.currentPage === overviewPage;
}
/**
* Routes to the specified page
*/
routeTo(page: string): void {
if (!this.isValidPage(page)) {
return;
}
this.currentDivision = null;
if (page !== overviewPage) {
// Iterate through Corporation data to get a reference to the current division
for (let i = 0; i < this.corp.divisions.length; ++i) {
if (this.corp.divisions[i].name === page) {
this.currentDivision = this.corp.divisions[i];
}
}
// 'currentDivision' should not be null, since the routing is either on
// the overview page or a division page
if (this.currentDivision == null) {
console.warn(`Routing could not find division ${page}`);
}
}
this.currentPage = page;
}
routeToOverviewPage(): void {
this.currentPage = overviewPage;
this.currentDivision = null;
}
}

@ -1,7 +1,6 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { removePopup } from "../../ui/React/createPopup"; import { removePopup } from "../../ui/React/createPopup";
import { Cities } from "../../Locations/Cities";
import { Product } from "../Product"; import { Product } from "../Product";
import { SellProduct } from "../Actions"; import { SellProduct } from "../Actions";

@ -1,7 +1,6 @@
// React Components for the Unlock upgrade buttons on the overview page // React Components for the Unlock upgrade buttons on the overview page
import React from "react"; import React from "react";
import { numeralWrapper } from "../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../utils/DialogBox"; import { dialogBoxCreate } from "../../../utils/DialogBox";
import { CorporationUnlockUpgrade } from "../data/CorporationUnlockUpgrades"; import { CorporationUnlockUpgrade } from "../data/CorporationUnlockUpgrades";
import { ICorporation } from "../ICorporation"; import { ICorporation } from "../ICorporation";

@ -746,8 +746,7 @@ class DevMenuComponent extends Component {
} }
let sourceFiles = []; let sourceFiles = [];
validSFN.forEach((i) => validSFN.forEach((i) => sourceFiles.push(
sourceFiles.push(
<tr key={"sf-" + i}> <tr key={"sf-" + i}>
<td> <td>
<span className="text">SF-{i}:</span> <span className="text">SF-{i}:</span>

@ -1,7 +1,5 @@
import React from "react"; import React from "react";
import { AllServers } from "../Server/AllServers"; import { AllServers } from "../Server/AllServers";
import { Script } from "../Script/Script";
import { TextFile } from "../TextFile";
import { Accordion } from "../ui/React/Accordion"; import { Accordion } from "../ui/React/Accordion";
import { numeralWrapper } from "../ui/numeralFormat"; import { numeralWrapper } from "../ui/numeralFormat";
@ -61,9 +59,7 @@ export function ServerAccordion(props: IServerProps): React.ReactElement {
); );
} }
interface IProps {} export function FileDiagnosticPopup(): React.ReactElement {
export function FileDiagnosticPopup(props: IProps): React.ReactElement {
const ips: string[] = []; const ips: string[] = [];
for (const ip of Object.keys(AllServers)) { for (const ip of Object.keys(AllServers)) {
ips.push(ip); ips.push(ip);

@ -1,4 +1,3 @@
import { CONSTANTS } from "../Constants";
import { FactionInfo, FactionInfos } from "./FactionInfo"; import { FactionInfo, FactionInfos } from "./FactionInfo";
import { favorToRep, repToFavor } from "./formulas/favor"; import { favorToRep, repToFavor } from "./formulas/favor";
import { import {

@ -124,8 +124,7 @@ export class AugmentationsPage extends React.Component<IProps, IState> {
render(): React.ReactNode { render(): React.ReactNode {
const augs = this.getAugsSorted(); const augs = this.getAugsSorted();
const purchasable = augs.filter( const purchasable = augs.filter(
(aug: string) => (aug: string) => aug === AugmentationNames.NeuroFluxGovernor ||
aug === AugmentationNames.NeuroFluxGovernor ||
(!this.props.p.augmentations.some((a) => a.name === aug) && (!this.props.p.augmentations.some((a) => a.name === aug) &&
!this.props.p.queuedAugmentations.some((a) => a.name === aug)), !this.props.p.queuedAugmentations.some((a) => a.name === aug)),
); );
@ -142,8 +141,7 @@ export class AugmentationsPage extends React.Component<IProps, IState> {
); );
}; };
const augListElems = purchasable.map((aug) => const augListElems = purchasable.map((aug) => purchaseableAugmentation(aug),
purchaseableAugmentation(aug),
); );
let ownedElem = <></>; let ownedElem = <></>;
@ -172,20 +170,17 @@ export class AugmentationsPage extends React.Component<IProps, IState> {
will enhance your abilities. will enhance your abilities.
</p> </p>
<StdButton <StdButton
onClick={() => onClick={() => this.switchSortOrder(PurchaseAugmentationsOrderSetting.Cost)
this.switchSortOrder(PurchaseAugmentationsOrderSetting.Cost)
} }
text={"Sort by Cost"} text={"Sort by Cost"}
/> />
<StdButton <StdButton
onClick={() => onClick={() => this.switchSortOrder(PurchaseAugmentationsOrderSetting.Reputation)
this.switchSortOrder(PurchaseAugmentationsOrderSetting.Reputation)
} }
text={"Sort by Reputation"} text={"Sort by Reputation"}
/> />
<StdButton <StdButton
onClick={() => onClick={() => this.switchSortOrder(PurchaseAugmentationsOrderSetting.Default)
this.switchSortOrder(PurchaseAugmentationsOrderSetting.Default)
} }
text={"Sort by Default Order"} text={"Sort by Default Order"}
/> />

@ -31,8 +31,6 @@ const inputStyleMarkup = {
height: "26px", height: "26px",
}; };
const blockStyle = { display: "block" };
export function DonateOption(props: IProps): React.ReactElement { export function DonateOption(props: IProps): React.ReactElement {
const [donateAmt, setDonateAmt] = useState<number | null>(null); const [donateAmt, setDonateAmt] = useState<number | null>(null);
const digits = (CONSTANTS.DonateMoneyToRepDivisor + "").length - 1; const digits = (CONSTANTS.DonateMoneyToRepDivisor + "").length - 1;

@ -33,8 +33,7 @@ export function GangMemberList(props: IProps): React.ReactElement {
} }
const members = props.gang.members.filter( const members = props.gang.members.filter(
(member: GangMember) => (member: GangMember) => member.name.indexOf(filter) > -1 || member.task.indexOf(filter) > -1,
member.name.indexOf(filter) > -1 || member.task.indexOf(filter) > -1,
); );
return ( return (

@ -90,8 +90,7 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
id="warfare" id="warfare"
type="checkbox" type="checkbox"
style={{ display: "inline-block", margin: "2px" }} style={{ display: "inline-block", margin: "2px" }}
onChange={(event) => onChange={(event) => (props.gang.territoryWarfareEngaged = event.target.checked)
(props.gang.territoryWarfareEngaged = event.target.checked)
} }
/> />
<label <label
@ -125,8 +124,7 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
id="notify" id="notify"
type="checkbox" type="checkbox"
style={{ display: "inline-block", margin: "2px" }} style={{ display: "inline-block", margin: "2px" }}
onChange={(event) => onChange={(event) => (props.gang.notifyMemberDeath = event.target.checked)
(props.gang.notifyMemberDeath = event.target.checked)
} }
/> />
<label <label

@ -11,7 +11,6 @@ import { AddToAllServers, createUniqueRandomIp } from "../Server/AllServers";
import { safetlyCreateUniqueServer } from "../Server/ServerHelpers"; import { safetlyCreateUniqueServer } from "../Server/ServerHelpers";
import { import {
getPurchaseServerCost, getPurchaseServerCost,
purchaseRamForHomeComputer,
purchaseServer, purchaseServer,
} from "../Server/ServerPurchases"; } from "../Server/ServerPurchases";
import { SpecialServerIps } from "../Server/SpecialServerIps"; import { SpecialServerIps } from "../Server/SpecialServerIps";

@ -1,15 +1,6 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Location } from "../Location";
import {
createPurchaseServerPopup,
createUpgradeHomeCoresPopup,
purchaseTorRouter,
} from "../LocationsHelpers";
import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased"; import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
import { StdButton } from "../../ui/React/StdButton"; import { StdButton } from "../../ui/React/StdButton";
@ -48,23 +39,6 @@ export function CoresButton(props: IProps): React.ReactElement {
homeComputer.cpuCores++; homeComputer.cpuCores++;
rerender(); rerender();
} }
const settings = {
CommonHTML: {
scale: 90,
},
"HTML-CSS": {
scale: 90,
},
NativeMML: {
scale: 90,
},
SVG: {
scale: 90,
},
PreviewHTML: {
scale: 90,
},
};
return ( return (
<StdButton <StdButton

@ -1,12 +1,5 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Location } from "../Location";
import {
createPurchaseServerPopup,
createUpgradeHomeCoresPopup,
purchaseTorRouter,
} from "../LocationsHelpers";
import { CONSTANTS } from "../../Constants"; import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases"; import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";

@ -6,20 +6,14 @@
import * as React from "react"; import * as React from "react";
import { Location } from "../Location"; import { Location } from "../Location";
import { import { createPurchaseServerPopup } from "../LocationsHelpers";
createPurchaseServerPopup,
createUpgradeHomeCoresPopup,
purchaseTorRouter,
} from "../LocationsHelpers";
import { RamButton } from "./RamButton"; import { RamButton } from "./RamButton";
import { TorButton } from "./TorButton"; import { TorButton } from "./TorButton";
import { CoresButton } from "./CoresButton"; import { CoresButton } from "./CoresButton";
import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { getPurchaseServerCost } from "../../Server/ServerPurchases"; import { getPurchaseServerCost } from "../../Server/ServerPurchases";
import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
import { StdButton } from "../../ui/React/StdButton"; import { StdButton } from "../../ui/React/StdButton";
import { Money } from "../../ui/React/Money"; import { Money } from "../../ui/React/Money";

@ -1,15 +1,9 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Location } from "../Location"; import { purchaseTorRouter } from "../LocationsHelpers";
import {
createPurchaseServerPopup,
createUpgradeHomeCoresPopup,
purchaseTorRouter,
} from "../LocationsHelpers";
import { CONSTANTS } from "../../Constants"; import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { purchaseRamForHomeComputer } from "../../Server/ServerPurchases";
import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased"; import { StdButtonPurchased } from "../../ui/React/StdButtonPurchased";
import { StdButton } from "../../ui/React/StdButton"; import { StdButton } from "../../ui/React/StdButton";

@ -149,8 +149,7 @@ export const RamCosts: IMap<any> = {
purchase4SMarketData: () => RamCostConstants.ScriptBuySellStockRamCost, purchase4SMarketData: () => RamCostConstants.ScriptBuySellStockRamCost,
purchase4SMarketDataTixApi: () => RamCostConstants.ScriptBuySellStockRamCost, purchase4SMarketDataTixApi: () => RamCostConstants.ScriptBuySellStockRamCost,
getPurchasedServerLimit: () => RamCostConstants.ScriptGetPurchasedServerLimit, getPurchasedServerLimit: () => RamCostConstants.ScriptGetPurchasedServerLimit,
getPurchasedServerMaxRam: () => getPurchasedServerMaxRam: () => RamCostConstants.ScriptGetPurchasedServerMaxRam,
RamCostConstants.ScriptGetPurchasedServerMaxRam,
getPurchasedServerCost: () => RamCostConstants.ScriptGetPurchaseServerRamCost, getPurchasedServerCost: () => RamCostConstants.ScriptGetPurchaseServerRamCost,
purchaseServer: () => RamCostConstants.ScriptPurchaseServerRamCost, purchaseServer: () => RamCostConstants.ScriptPurchaseServerRamCost,
deleteServer: () => RamCostConstants.ScriptPurchaseServerRamCost, deleteServer: () => RamCostConstants.ScriptPurchaseServerRamCost,
@ -189,8 +188,7 @@ export const RamCosts: IMap<any> = {
manualHack: () => RamCostConstants.ScriptSingularityFn1RamCost, manualHack: () => RamCostConstants.ScriptSingularityFn1RamCost,
installBackdoor: () => RamCostConstants.ScriptSingularityFn1RamCost, installBackdoor: () => RamCostConstants.ScriptSingularityFn1RamCost,
getStats: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, getStats: () => RamCostConstants.ScriptSingularityFn1RamCost / 4,
getCharacterInformation: () => getCharacterInformation: () => RamCostConstants.ScriptSingularityFn1RamCost / 4,
RamCostConstants.ScriptSingularityFn1RamCost / 4,
getPlayer: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, getPlayer: () => RamCostConstants.ScriptSingularityFn1RamCost / 4,
hospitalize: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, hospitalize: () => RamCostConstants.ScriptSingularityFn1RamCost / 4,
isBusy: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, isBusy: () => RamCostConstants.ScriptSingularityFn1RamCost / 4,
@ -215,8 +213,7 @@ export const RamCosts: IMap<any> = {
getCrimeStats: () => RamCostConstants.ScriptSingularityFn3RamCost, getCrimeStats: () => RamCostConstants.ScriptSingularityFn3RamCost,
getOwnedAugmentations: () => RamCostConstants.ScriptSingularityFn3RamCost, getOwnedAugmentations: () => RamCostConstants.ScriptSingularityFn3RamCost,
getOwnedSourceFiles: () => RamCostConstants.ScriptSingularityFn3RamCost, getOwnedSourceFiles: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationsFromFaction: () => getAugmentationsFromFaction: () => RamCostConstants.ScriptSingularityFn3RamCost,
RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationPrereq: () => RamCostConstants.ScriptSingularityFn3RamCost, getAugmentationPrereq: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationCost: () => RamCostConstants.ScriptSingularityFn3RamCost, getAugmentationCost: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationStats: () => RamCostConstants.ScriptSingularityFn3RamCost, getAugmentationStats: () => RamCostConstants.ScriptSingularityFn3RamCost,
@ -230,8 +227,7 @@ export const RamCosts: IMap<any> = {
inGang: () => RamCostConstants.ScriptGangApiBaseRamCost / 4, inGang: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
getMemberNames: () => RamCostConstants.ScriptGangApiBaseRamCost / 4, getMemberNames: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
getGangInformation: () => RamCostConstants.ScriptGangApiBaseRamCost / 2, getGangInformation: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
getOtherGangInformation: () => getOtherGangInformation: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
RamCostConstants.ScriptGangApiBaseRamCost / 2,
getMemberInformation: () => RamCostConstants.ScriptGangApiBaseRamCost / 2, getMemberInformation: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
canRecruitMember: () => RamCostConstants.ScriptGangApiBaseRamCost / 4, canRecruitMember: () => RamCostConstants.ScriptGangApiBaseRamCost / 4,
recruitMember: () => RamCostConstants.ScriptGangApiBaseRamCost / 2, recruitMember: () => RamCostConstants.ScriptGangApiBaseRamCost / 2,
@ -251,30 +247,21 @@ export const RamCosts: IMap<any> = {
// Bladeburner API // Bladeburner API
bladeburner: { bladeburner: {
getContractNames: () => getContractNames: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10, getOperationNames: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getOperationNames: () => getBlackOpNames: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getBlackOpNames: () =>
RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getBlackOpRank: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2, getBlackOpRank: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2,
getGeneralActionNames: () => getGeneralActionNames: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getSkillNames: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10, getSkillNames: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
startAction: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, startAction: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
stopBladeburnerAction: () => stopBladeburnerAction: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2,
RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2, getCurrentAction: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost / 4,
getCurrentAction: () =>
RamCostConstants.ScriptBladeburnerApiBaseRamCost / 4,
getActionTime: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getActionTime: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionEstimatedSuccessChance: () => getActionEstimatedSuccessChance: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionRepGain: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getActionRepGain: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionCountRemaining: () => getActionCountRemaining: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionMaxLevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getActionMaxLevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionCurrentLevel: () => getActionCurrentLevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionAutolevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getActionAutolevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
setActionAutolevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, setActionAutolevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
setActionLevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, setActionLevel: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
@ -285,18 +272,14 @@ export const RamCosts: IMap<any> = {
upgradeSkill: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, upgradeSkill: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getTeamSize: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getTeamSize: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
setTeamSize: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, setTeamSize: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCityEstimatedPopulation: () => getCityEstimatedPopulation: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
RamCostConstants.ScriptBladeburnerApiBaseRamCost, getCityEstimatedCommunities: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCityEstimatedCommunities: () =>
RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCityChaos: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getCityChaos: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCity: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getCity: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
switchCity: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, switchCity: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getStamina: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost, getStamina: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
joinBladeburnerFaction: () => joinBladeburnerFaction: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
RamCostConstants.ScriptBladeburnerApiBaseRamCost, joinBladeburnerDivision: () => RamCostConstants.ScriptBladeburnerApiBaseRamCost,
joinBladeburnerDivision: () =>
RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getBonusTime: () => 0, getBonusTime: () => 0,
}, },
@ -306,8 +289,7 @@ export const RamCosts: IMap<any> = {
getContractType: () => RamCostConstants.ScriptCodingContractBaseRamCost / 2, getContractType: () => RamCostConstants.ScriptCodingContractBaseRamCost / 2,
getData: () => RamCostConstants.ScriptCodingContractBaseRamCost / 2, getData: () => RamCostConstants.ScriptCodingContractBaseRamCost / 2,
getDescription: () => RamCostConstants.ScriptCodingContractBaseRamCost / 2, getDescription: () => RamCostConstants.ScriptCodingContractBaseRamCost / 2,
getNumTriesRemaining: () => getNumTriesRemaining: () => RamCostConstants.ScriptCodingContractBaseRamCost / 5,
RamCostConstants.ScriptCodingContractBaseRamCost / 5,
}, },
// Duplicate Sleeve API // Duplicate Sleeve API

@ -29,8 +29,7 @@ export async function executeJSScript(scripts = [], workerScript) {
script.markUpdated(); script.markUpdated();
urls = _getScriptUrls(script, scripts, []); urls = _getScriptUrls(script, scripts, []);
script.url = urls[urls.length - 1].url; script.url = urls[urls.length - 1].url;
script.module = new Promise((resolve) => script.module = new Promise((resolve) => resolve(eval("import(urls[urls.length - 1].url)")),
resolve(eval("import(urls[urls.length - 1].url)")),
); );
script.dependencies = urls; script.dependencies = urls;
} }

@ -125,8 +125,7 @@ async function parseOnlyRamCalculate(otherScripts, code, workerScript) {
// Finally, walk the reference map and generate a ram cost. The initial set of keys to scan // Finally, walk the reference map and generate a ram cost. The initial set of keys to scan
// are those that start with __SPECIAL_INITIAL_MODULE__. // are those that start with __SPECIAL_INITIAL_MODULE__.
let ram = RamCostConstants.ScriptBaseRamCost; let ram = RamCostConstants.ScriptBaseRamCost;
const unresolvedRefs = Object.keys(dependencyMap).filter((s) => const unresolvedRefs = Object.keys(dependencyMap).filter((s) => s.startsWith(initialModule),
s.startsWith(initialModule),
); );
const resolvedRefs = new Set(); const resolvedRefs = new Set();
while (unresolvedRefs.length > 0) { while (unresolvedRefs.length > 0) {
@ -148,8 +147,7 @@ async function parseOnlyRamCalculate(otherScripts, code, workerScript) {
if (ref.endsWith(".*")) { if (ref.endsWith(".*")) {
// A prefix reference. We need to find all matching identifiers. // A prefix reference. We need to find all matching identifiers.
const prefix = ref.slice(0, ref.length - 2); const prefix = ref.slice(0, ref.length - 2);
for (let ident of Object.keys(dependencyMap).filter((k) => for (let ident of Object.keys(dependencyMap).filter((k) => k.startsWith(prefix),
k.startsWith(prefix),
)) { )) {
for (let dep of dependencyMap[ident] || []) { for (let dep of dependencyMap[ident] || []) {
if (!resolvedRefs.has(dep)) unresolvedRefs.push(dep); if (!resolvedRefs.has(dep)) unresolvedRefs.push(dep);

@ -1,32 +1,11 @@
import { Script } from "./Script";
import { RamCalculationErrorCode } from "./RamCalculationErrorCodes";
import { calculateRamUsage } from "./RamCalculations";
import { isScriptFilename } from "./ScriptHelpersTS";
import { CONSTANTS } from "../Constants"; import { CONSTANTS } from "../Constants";
import { Engine } from "../engine";
import { parseFconfSettings } from "../Fconf/Fconf";
import {
iTutorialSteps,
iTutorialNextStep,
ITutorial,
} from "../InteractiveTutorial";
import { Player } from "../Player"; import { Player } from "../Player";
import { CursorPositions } from "../ScriptEditor/CursorPositions";
import { AllServers } from "../Server/AllServers"; import { AllServers } from "../Server/AllServers";
import { processSingleServerGrowth } from "../Server/ServerHelpers"; import { processSingleServerGrowth } from "../Server/ServerHelpers";
import { Settings } from "../Settings/Settings";
import { EditorSetting } from "../Settings/SettingEnums";
import { isValidFilePath } from "../Terminal/DirectoryHelpers";
import { TextFile } from "../TextFile";
import { Page, routing } from "../ui/navigationTracking";
import { numeralWrapper } from "../ui/numeralFormat"; import { numeralWrapper } from "../ui/numeralFormat";
import { dialogBoxCreate } from "../../utils/DialogBox";
import { compareArrays } from "../../utils/helpers/compareArrays"; import { compareArrays } from "../../utils/helpers/compareArrays";
import { createElement } from "../../utils/uiHelpers/createElement";
export function scriptCalculateOfflineProduction(runningScriptObj) { export function scriptCalculateOfflineProduction(runningScriptObj) {
//The Player object stores the last update time from when we were online //The Player object stores the last update time from when we were online

@ -13,7 +13,7 @@ export function OptionsPopup(props: IProps): React.ReactElement {
const [theme, setTheme] = useState(props.options.theme); const [theme, setTheme] = useState(props.options.theme);
const [insertSpaces, setInsertSpaces] = useState(props.options.insertSpaces); const [insertSpaces, setInsertSpaces] = useState(props.options.insertSpaces);
function save() { function save(): void {
props.save({ props.save({
theme: theme, theme: theme,
insertSpaces: insertSpaces, insertSpaces: insertSpaces,

@ -23,7 +23,6 @@ import { libSource } from "../NetscriptDefinitions";
import { NetscriptFunctions } from "../../NetscriptFunctions"; import { NetscriptFunctions } from "../../NetscriptFunctions";
import { WorkerScript } from "../../Netscript/WorkerScript"; import { WorkerScript } from "../../Netscript/WorkerScript";
import { Settings } from "../../Settings/Settings"; import { Settings } from "../../Settings/Settings";
import { GetServerByHostname } from "../../Server/ServerHelpers";
import { import {
iTutorialNextStep, iTutorialNextStep,
ITutorial, ITutorial,
@ -287,7 +286,7 @@ export function Root(props: IProps): React.ReactElement {
}, [code]); }, [code]);
useEffect(() => { useEffect(() => {
function maybeSave(event: KeyboardEvent) { function maybeSave(event: KeyboardEvent): void {
if (Settings.DisableHotkeys) return; if (Settings.DisableHotkeys) return;
//Ctrl + b //Ctrl + b
if (event.keyCode == 66 && (event.ctrlKey || event.metaKey)) { if (event.keyCode == 66 && (event.ctrlKey || event.metaKey)) {

@ -130,8 +130,7 @@ export function initForeignServers(homeComputer: Server): void {
server2.serversOnNetwork.push(server1.ip); server2.serversOnNetwork.push(server1.ip);
}; };
const getRandomArrayItem = (arr: any[]): any => const getRandomArrayItem = (arr: any[]): any => arr[Math.floor(Math.random() * arr.length)];
arr[Math.floor(Math.random() * arr.length)];
const linkNetworkLayers = ( const linkNetworkLayers = (
network1: Server[], network1: Server[],
@ -145,8 +144,7 @@ export function initForeignServers(homeComputer: Server): void {
// Connect the first tier of servers to the player's home computer // Connect the first tier of servers to the player's home computer
linkNetworkLayers(networkLayers[0], () => homeComputer); linkNetworkLayers(networkLayers[0], () => homeComputer);
for (let i = 1; i < networkLayers.length; i++) { for (let i = 1; i < networkLayers.length; i++) {
linkNetworkLayers(networkLayers[i], () => linkNetworkLayers(networkLayers[i], () => getRandomArrayItem(networkLayers[i - 1]),
getRandomArrayItem(networkLayers[i - 1]),
); );
} }
} }

@ -1,9 +1,5 @@
import { ISelfInitializer, ISelfLoading } from "../types"; import { ISelfInitializer, ISelfLoading } from "../types";
import { import {
AceKeybindingSetting,
CodeMirrorKeybindingSetting,
CodeMirrorThemeSetting,
EditorSetting,
OwnedAugmentationsOrderSetting, OwnedAugmentationsOrderSetting,
PurchaseAugmentationsOrderSetting, PurchaseAugmentationsOrderSetting,
} from "./SettingEnums"; } from "./SettingEnums";

@ -97,7 +97,6 @@ import * as JSZip from "jszip";
import * as FileSaver from "file-saver"; import * as FileSaver from "file-saver";
import * as libarg from "arg"; import * as libarg from "arg";
import React from "react"; import React from "react";
import ReactDOM from "react-dom";
function postNetburnerText() { function postNetburnerText() {
post("Bitburner v" + CONSTANTS.Version); post("Bitburner v" + CONSTANTS.Version);
@ -1166,8 +1165,7 @@ let Terminal = {
const server = Player.getCurrentServer(); const server = Player.getCurrentServer();
if ( if (
!server.scripts.some((script) => !server.scripts.some((script) => script.filename.startsWith(evaledDir),
script.filename.startsWith(evaledDir),
) && ) &&
!server.textFiles.some((file) => file.fn.startsWith(evaledDir)) !server.textFiles.some((file) => file.fn.startsWith(evaledDir))
) { ) {

@ -1,5 +1,6 @@
import { setTimeoutRef } from "./utils/SetTimeoutRef"; import { setTimeoutRef } from "./utils/SetTimeoutRef";
import { dialogBoxCreate } from "../utils/DialogBox"; import { dialogBoxCreate } from "../utils/DialogBox";
import { BaseServer } from "./Server/BaseServer";
import { import {
Generic_fromJSON, Generic_fromJSON,
Generic_toJSON, Generic_toJSON,
@ -103,7 +104,7 @@ Reviver.constructors.TextFile = TextFile;
* @returns The file object, or null if it couldn't find it. * @returns The file object, or null if it couldn't find it.
*/ */
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function getTextFile(fn: string, server: any): TextFile | null { export function getTextFile(fn: string, server: BaseServer): TextFile | null {
const filename: string = !fn.endsWith(".txt") ? `${fn}.txt` : fn; const filename: string = !fn.endsWith(".txt") ? `${fn}.txt` : fn;
for (const file of server.textFiles as TextFile[]) { for (const file of server.textFiles as TextFile[]) {
@ -126,7 +127,7 @@ export function getTextFile(fn: string, server: any): TextFile | null {
export function createTextFile( export function createTextFile(
fn: string, fn: string,
txt: string, txt: string,
server: any, server: BaseServer,
): TextFile | undefined { ): TextFile | undefined {
if (getTextFile(fn, server) !== null) { if (getTextFile(fn, server) !== null) {
// This should probably be a `throw`... // This should probably be a `throw`...

@ -158,8 +158,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
d += "&nbsp;&nbsp;&nbsp;&nbsp;[\n"; d += "&nbsp;&nbsp;&nbsp;&nbsp;[\n";
d += n d += n
.map( .map(
(line: number[]) => (line: number[]) => "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[" +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[" +
line.map((x: number) => `${x}`.padStart(2, " ")).join(",") + line.map((x: number) => `${x}`.padStart(2, " ")).join(",") +
"]", "]",
) )

@ -53,7 +53,6 @@ import {
loadAllRunningScripts, loadAllRunningScripts,
updateOnlineScriptTimes, updateOnlineScriptTimes,
} from "./NetscriptWorker"; } from "./NetscriptWorker";
import { GetServerByHostname } from "./Server/ServerHelpers";
import { Player } from "./Player"; import { Player } from "./Player";
import { prestigeAugmentation } from "./Prestige"; import { prestigeAugmentation } from "./Prestige";
import { import {

@ -4,7 +4,6 @@
*/ */
import * as React from "react"; import * as React from "react";
import { WorkerScriptAccordion } from "./WorkerScriptAccordion";
import { Accordion } from "../React/Accordion"; import { Accordion } from "../React/Accordion";
import { ServerAccordionContent } from "./ServerAccordionContent"; import { ServerAccordionContent } from "./ServerAccordionContent";
@ -33,12 +32,6 @@ export function ServerAccordion(props: IProps): React.ReactElement {
}; };
const headerTxt = `${paddedName} ${createProgressBarText(barOptions)}`; const headerTxt = `${paddedName} ${createProgressBarText(barOptions)}`;
const scripts = props.workerScripts.map((ws) => {
return (
<WorkerScriptAccordion key={`${ws.name}_${ws.args}`} workerScript={ws} />
);
});
return ( return (
<Accordion <Accordion
headerContent={<pre>{headerTxt}</pre>} headerContent={<pre>{headerTxt}</pre>}

@ -9,8 +9,7 @@ interface IProps {
} }
function randomize(char: string): string { function randomize(char: string): string {
const randFrom = (str: string): string => const randFrom = (str: string): string => str[Math.floor(Math.random() * str.length)];
str[Math.floor(Math.random() * str.length)];
const classes = [ const classes = [
"abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",

@ -48,7 +48,7 @@ function ScriptLogPopup(props: IProps): React.ReactElement {
} }
useEffect(() => { useEffect(() => {
function closeHandler(event: KeyboardEvent) { function closeHandler(event: KeyboardEvent): void {
if (event.keyCode === 27) { if (event.keyCode === 27) {
close(); close();
} }