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,366 +1,434 @@
const numSpaces = 4;
const maxLineLength = 160;
module.exports = { module.exports = {
env: { "env": {
node: true, "es6": true,
es6: true, "node": true
},
extends: "eslint:recommended",
parserOptions: {
ecmaVersion: 8,
sourceType: "module",
ecmaFeatures: {
experimentalObjectRestSpread: true,
}, },
}, "extends": "eslint:recommended",
rules: { "parserOptions": {
"accessor-pairs": [ "ecmaFeatures": {
"error", "experimentalObjectRestSpread": true
{ },
setWithoutGet: true, "ecmaVersion": 8,
getWithoutSet: false, "sourceType": "module"
}, },
], "rules": {
"array-bracket-newline": ["error"], "accessor-pairs": [
"array-bracket-spacing": ["error"], "error",
"array-callback-return": ["error"], {
"array-element-newline": ["error"], "getWithoutSet": false,
"arrow-body-style": ["error"], "setWithoutGet": true
"arrow-parens": ["error"], }
"arrow-spacing": ["error"], ],
"block-scoped-var": ["error"], "array-bracket-newline": ["error"],
"block-spacing": ["error"], "array-bracket-spacing": ["error"],
"brace-style": ["error"], "array-callback-return": ["error"],
"callback-return": ["error"], "array-element-newline": ["error"],
camelcase: ["error"], "arrow-body-style": ["error"],
"capitalized-comments": ["error"], "arrow-parens": ["error"],
"class-methods-use-this": ["error"], "arrow-spacing": ["error"],
"comma-dangle": ["error"], "block-scoped-var": ["error"],
"comma-spacing": ["error"], "block-spacing": ["error"],
"comma-style": ["error", "last"], "brace-style": ["error"],
complexity: ["error"], "callback-return": ["error"],
"computed-property-spacing": ["error", "never"], "camelcase": ["error"],
"consistent-return": ["error"], "capitalized-comments": ["error"],
"consistent-this": ["error"], "class-methods-use-this": ["error"],
"constructor-super": ["error"], "comma-dangle": ["error"],
curly: ["error"], "comma-spacing": ["error"],
"default-case": ["error"], "comma-style": [
"dot-location": ["error", "property"], "error",
"dot-notation": ["error"], "last"
"eol-last": ["error"], ],
eqeqeq: ["error"], "complexity": ["error"],
"for-direction": ["error"], "computed-property-spacing": [
"func-call-spacing": ["error"], "error",
"func-name-matching": ["error"], "never"
"func-names": ["error", "never"], ],
"func-style": ["error"], "consistent-return": ["error"],
"function-paren-newline": ["error"], "consistent-this": ["error"],
"generator-star-spacing": ["error", "before"], "constructor-super": ["error"],
"getter-return": [ "curly": ["error"],
"error", "default-case": ["error"],
{ "dot-location": [
allowImplicit: false, "error",
}, "property"
], ],
"global-require": ["error"], "dot-notation": ["error"],
"guard-for-in": ["error"], "eol-last": ["error"],
"handle-callback-err": ["error"], "eqeqeq": ["error"],
"id-blacklist": ["error"], "for-direction": ["error"],
"id-length": ["error"], "func-call-spacing": ["error"],
"id-match": ["error"], "func-name-matching": ["error"],
"implicit-arrow-linebreak": ["error", "beside"], "func-names": [
indent: [ "error",
"error", "never"
4, ],
{ "func-style": ["error"],
SwitchCase: 1, "function-paren-newline": ["error"],
}, "generator-star-spacing": [
], "error",
"init-declarations": ["error"], "before"
"jsx-quotes": ["error"], ],
"key-spacing": ["error"], "getter-return": [
"keyword-spacing": ["error"], "error",
"line-comment-position": ["error"], {
"linebreak-style": ["error", "windows"], "allowImplicit": false
"lines-around-comment": ["error"], }
"lines-between-class-members": ["error"], ],
"max-depth": ["error"], "global-require": ["error"],
"max-len": ["error", 160], "guard-for-in": ["error"],
"max-lines": [ "handle-callback-err": ["error"],
"error", "id-blacklist": ["error"],
{ "id-length": ["error"],
skipBlankLines: true, "id-match": ["error"],
skipComments: true, "implicit-arrow-linebreak": [
}, "error",
], "beside"
"max-nested-callbacks": ["error"], ],
"max-params": ["error"], "indent": [
"max-statements": ["error"], "error",
"max-statements-per-line": ["error"], numSpaces,
"multiline-comment-style": ["off", "starred-block"], {
"multiline-ternary": ["error", "never"], "SwitchCase": 1
"new-cap": ["error"], }
"new-parens": ["error"], ],
"newline-before-return": [ "init-declarations": ["error"],
"error", // TODO: configure this... "jsx-quotes": ["error"],
], "key-spacing": ["error"],
"newline-per-chained-call": ["error"], "keyword-spacing": ["error"],
"no-alert": ["error"], "line-comment-position": ["error"],
"no-array-constructor": ["error"], "linebreak-style": [
"no-await-in-loop": ["error"], "error",
"no-bitwise": ["error"], "windows"
"no-buffer-constructor": ["error"], ],
"no-caller": ["error"], "lines-around-comment": ["error"],
"no-case-declarations": ["error"], "lines-between-class-members": ["error"],
"no-catch-shadow": ["error"], "max-depth": ["error"],
"no-class-assign": ["error"], "max-len": [
"no-compare-neg-zero": ["error"], "error",
"no-cond-assign": ["error", "except-parens"], maxLineLength
"no-confusing-arrow": ["error"], ],
"no-console": ["error"], "max-lines": [
"no-const-assign": ["error"], "error",
"no-constant-condition": [ {
"error", "skipBlankLines": true,
{ "skipComments": true
checkLoops: false, }
}, ],
], "max-nested-callbacks": ["error"],
"no-continue": ["off"], "max-params": ["error"],
"no-control-regex": ["error"], "max-statements": ["error"],
"no-debugger": ["error"], "max-statements-per-line": ["error"],
"no-delete-var": ["error"], "multiline-comment-style": [
"no-div-regex": ["error"], "off",
"no-dupe-args": ["error"], "starred-block"
"no-dupe-class-members": ["error"], ],
"no-dupe-keys": ["error"], "multiline-ternary": [
"no-duplicate-case": ["error"], "error",
"no-duplicate-imports": [ "never"
"error", ],
{ "new-cap": ["error"],
includeExports: true, "new-parens": ["error"],
}, // TODO: configure this...
], "newline-before-return": ["error"],
"no-else-return": ["error"], "newline-per-chained-call": ["error"],
"no-empty": [ "no-alert": ["error"],
"error", "no-array-constructor": ["error"],
{ "no-await-in-loop": ["error"],
allowEmptyCatch: false, "no-bitwise": ["error"],
}, "no-buffer-constructor": ["error"],
], "no-caller": ["error"],
"no-empty-character-class": ["error"], "no-case-declarations": ["error"],
"no-empty-function": ["error"], "no-catch-shadow": ["error"],
"no-empty-pattern": ["error"], "no-class-assign": ["error"],
"no-eq-null": ["error"], "no-compare-neg-zero": ["error"],
"no-ex-assign": ["error"], "no-cond-assign": [
"no-extra-boolean-cast": ["error"], "error",
"no-extra-parens": [ "except-parens"
"error", ],
"all", "no-confusing-arrow": ["error"],
{ "no-console": ["error"],
conditionalAssign: false, "no-const-assign": ["error"],
}, "no-constant-condition": [
], "error",
"no-extra-semi": ["error"], {
"no-eval": ["error"], "checkLoops": false
"no-extend-native": ["error"], }
"no-extra-bind": ["error"], ],
"no-extra-label": ["error"], "no-continue": ["off"],
"no-extra-parens": ["error"], "no-control-regex": ["error"],
"no-fallthrough": ["error"], "no-debugger": ["error"],
"no-floating-decimal": ["error"], "no-delete-var": ["error"],
"no-func-assign": ["error"], "no-div-regex": ["error"],
"no-global-assign": ["error"], "no-dupe-args": ["error"],
"no-implicit-coercion": ["error"], "no-dupe-class-members": ["error"],
"no-implicit-globals": ["error"], "no-dupe-keys": ["error"],
"no-implied-eval": ["error"], "no-duplicate-case": ["error"],
"no-inline-comments": ["error"], "no-duplicate-imports": [
"no-inner-declarations": ["error", "both"], "error",
"no-invalid-regexp": ["error"], {
"no-invalid-this": ["error"], "includeExports": true
"no-irregular-whitespace": [ }
"error", ],
{ "no-else-return": ["error"],
skipStrings: false, "no-empty": [
skipComments: false, "error",
skipRegExps: false, {
skipTemplates: false, "allowEmptyCatch": false
}, }
], ],
"no-iterator": ["error"], "no-empty-character-class": ["error"],
"no-label-var": ["error"], "no-empty-function": ["error"],
"no-labels": ["error"], "no-empty-pattern": ["error"],
"no-lone-blocks": ["error"], "no-eq-null": ["error"],
"no-lonely-if": ["error"], "no-eval": ["error"],
"no-loop-func": ["error"], "no-ex-assign": ["error"],
"no-magic-numbers": [ "no-extend-native": ["error"],
"error", "no-extra-bind": ["error"],
{ "no-extra-boolean-cast": ["error"],
ignore: [-1, 0, 1], "no-extra-label": ["error"],
ignoreArrayIndexes: true, "no-extra-parens": [
}, "error",
], "all",
"no-mixed-operators": ["error"], {
"no-mixed-requires": ["error"], "conditionalAssign": false
"no-mixed-spaces-and-tabs": ["error"], }
"no-multi-assign": ["error"], ],
"no-multi-spaces": ["error"], "no-extra-semi": ["error"],
"no-multi-str": ["error"], "no-fallthrough": ["error"],
"no-multiple-empty-lines": [ "no-floating-decimal": ["error"],
"error", "no-func-assign": ["error"],
{ "no-global-assign": ["error"],
max: 1, "no-implicit-coercion": ["error"],
}, "no-implicit-globals": ["error"],
], "no-implied-eval": ["error"],
"no-native-reassign": ["error"], "no-inline-comments": ["error"],
"no-negated-condition": ["error"], "no-inner-declarations": [
"no-negated-in-lhs": ["error"], "error",
"no-nested-ternary": ["error"], "both"
"no-new": ["error"], ],
"no-new-func": ["error"], "no-invalid-regexp": ["error"],
"no-new-object": ["error"], "no-invalid-this": ["error"],
"no-new-require": ["error"], "no-irregular-whitespace": [
"no-new-symbol": ["error"], "error",
"no-new-wrappers": ["error"], {
"no-octal": ["error"], "skipComments": false,
"no-octal-escape": ["error"], "skipRegExps": false,
"no-obj-calls": ["error"], "skipStrings": false,
"no-param-reassign": ["error"], "skipTemplates": false
"no-path-concat": ["error"], }
"no-plusplus": [ ],
"error", "no-iterator": ["error"],
{ "no-label-var": ["error"],
allowForLoopAfterthoughts: true, "no-labels": ["error"],
}, "no-lone-blocks": ["error"],
], "no-lonely-if": ["error"],
"no-process-env": ["error"], "no-loop-func": ["error"],
"no-process-exit": ["error"], "no-magic-numbers": [
"no-proto": ["error"], "error",
"no-prototype-builtins": ["error"], {
"no-redeclare": ["error"], "ignore": [
"no-regex-spaces": ["error"], -1,
"no-restricted-globals": ["error"], 0,
"no-restricted-imports": ["error"], 1
"no-restricted-modules": ["error"], ],
"no-restricted-properties": [ "ignoreArrayIndexes": true
"error", }
{ ],
object: "console", "no-mixed-operators": ["error"],
property: "log", "no-mixed-requires": ["error"],
message: "'log' is too general, use an appropriate level when logging.", "no-mixed-spaces-and-tabs": ["error"],
}, "no-multi-assign": ["error"],
], "no-multi-spaces": ["error"],
"no-restricted-syntax": ["error"], "no-multi-str": ["error"],
"no-return-assign": ["error"], "no-multiple-empty-lines": [
"no-return-await": ["error"], "error",
"no-script-url": ["error"], {
"no-self-assign": [ "max": 1
"error", }
{ ],
props: false, "no-native-reassign": ["error"],
}, "no-negated-condition": ["error"],
], "no-negated-in-lhs": ["error"],
"no-self-compare": ["error"], "no-nested-ternary": ["error"],
"no-sequences": ["error"], "no-new": ["error"],
"no-shadow": ["error"], "no-new-func": ["error"],
"no-shadow-restricted-names": ["error"], "no-new-object": ["error"],
"no-spaced-func": ["error"], "no-new-require": ["error"],
"no-sparse-arrays": ["error"], "no-new-symbol": ["error"],
"no-sync": ["error"], "no-new-wrappers": ["error"],
"no-tabs": ["error"], "no-obj-calls": ["error"],
"no-template-curly-in-string": ["error"], "no-octal": ["error"],
"no-ternary": ["off"], "no-octal-escape": ["error"],
"no-this-before-super": ["error"], "no-param-reassign": ["error"],
"no-throw-literal": ["error"], "no-path-concat": ["error"],
"no-trailing-spaces": ["error"], "no-plusplus": [
"no-undef": ["error"], "error",
"no-undef-init": ["error"], {
"no-undefined": ["error"], "allowForLoopAfterthoughts": true
"no-underscore-dangle": ["error"], }
"no-unexpected-multiline": ["error"], ],
"no-unmodified-loop-condition": ["error"], "no-process-env": ["error"],
"no-unneeded-ternary": ["error"], "no-process-exit": ["error"],
"no-unreachable": ["error"], "no-proto": ["error"],
"no-unsafe-finally": ["error"], "no-prototype-builtins": ["error"],
"no-unsafe-negation": ["error"], "no-redeclare": ["error"],
"no-unused-expressions": ["error"], "no-regex-spaces": ["error"],
"no-unused-labels": ["error"], "no-restricted-globals": ["error"],
"no-unused-vars": ["error"], "no-restricted-imports": ["error"],
"no-use-before-define": ["error"], "no-restricted-modules": ["error"],
"no-useless-call": ["error"], "no-restricted-properties": [
"no-useless-computed-key": ["error"], "error",
"no-useless-concat": ["error"], {
"no-useless-constructor": ["error"], "message": "'log' is too general, use an appropriate level when logging.",
"no-useless-escape": ["error"], "object": "console",
"no-useless-rename": [ "property": "log"
"error", }
{ ],
ignoreDestructuring: false, "no-restricted-syntax": ["error"],
ignoreExport: false, "no-return-assign": ["error"],
ignoreImport: false, "no-return-await": ["error"],
}, "no-script-url": ["error"],
], "no-self-assign": [
"no-useless-return": ["error"], "error",
"no-var": ["error"], {
"no-void": ["error"], "props": false
"no-warning-comments": ["error"], }
"no-whitespace-before-property": ["error"], ],
"no-with": ["error"], "no-self-compare": ["error"],
"nonblock-statement-body-position": ["error", "below"], "no-sequences": ["error"],
"object-curly-newline": ["error"], "no-shadow": ["error"],
"object-curly-spacing": ["error"], "no-shadow-restricted-names": ["error"],
"object-property-newline": ["error"], "no-spaced-func": ["error"],
"object-shorthand": ["error"], "no-sparse-arrays": ["error"],
"one-var": ["off"], "no-sync": ["error"],
"one-var-declaration-per-line": ["error"], "no-tabs": ["error"],
"operator-assignment": ["error"], "no-template-curly-in-string": ["error"],
"operator-linebreak": ["error", "none"], "no-ternary": ["off"],
"padded-blocks": ["off"], "no-this-before-super": ["error"],
"padding-line-between-statements": ["error"], "no-throw-literal": ["error"],
"prefer-arrow-callback": ["error"], "no-trailing-spaces": ["error"],
"prefer-const": ["error"], "no-undef": ["error"],
"prefer-destructuring": ["off"], "no-undef-init": ["error"],
"prefer-numeric-literals": ["error"], "no-undefined": ["error"],
"prefer-promise-reject-errors": ["off"], "no-underscore-dangle": ["error"],
"prefer-reflect": ["error"], "no-unexpected-multiline": ["error"],
"prefer-rest-params": ["error"], "no-unmodified-loop-condition": ["error"],
"prefer-spread": ["error"], "no-unneeded-ternary": ["error"],
"prefer-template": ["error"], "no-unreachable": ["error"],
"quote-props": ["error"], "no-unsafe-finally": ["error"],
quotes: ["error"], "no-unsafe-negation": ["error"],
radix: ["error", "as-needed"], "no-unused-expressions": ["error"],
"require-await": ["error"], "no-unused-labels": ["error"],
"require-jsdoc": ["off"], "no-unused-vars": ["error"],
"require-yield": ["error"], "no-use-before-define": ["error"],
"rest-spread-spacing": ["error", "never"], "no-useless-call": ["error"],
semi: ["error"], "no-useless-computed-key": ["error"],
"semi-spacing": ["error"], "no-useless-concat": ["error"],
"semi-style": ["error", "last"], "no-useless-constructor": ["error"],
"sort-imports": ["error"], "no-useless-escape": ["error"],
"sort-keys": ["error"], "no-useless-rename": [
"sort-vars": ["error"], "error",
"space-before-blocks": ["error"], {
"space-before-function-paren": ["off"], "ignoreDestructuring": false,
"space-in-parens": ["error"], "ignoreExport": false,
"space-infix-ops": ["error"], "ignoreImport": false
"space-unary-ops": ["error"], }
"spaced-comment": ["error"], ],
strict: ["error"], "no-useless-return": ["error"],
"switch-colon-spacing": [ "no-var": ["error"],
"error", "no-void": ["error"],
{ "no-warning-comments": ["error"],
after: true, "no-whitespace-before-property": ["error"],
before: false, "no-with": ["error"],
}, "nonblock-statement-body-position": [
], "error",
"symbol-description": ["error"], "below"
"template-curly-spacing": ["error"], ],
"template-tag-spacing": ["error"], "object-curly-newline": ["error"],
"unicode-bom": ["error", "never"], "object-curly-spacing": ["error"],
"use-isnan": ["error"], "object-property-newline": ["error"],
"valid-jsdoc": ["error"], "object-shorthand": ["error"],
"valid-typeof": ["error"], "one-var": ["off"],
"vars-on-top": ["error"], "one-var-declaration-per-line": ["error"],
"wrap-iife": ["error", "any"], "operator-assignment": ["error"],
"wrap-regex": ["error"], "operator-linebreak": [
"yield-star-spacing": ["error", "before"], "error",
yoda: ["error", "never"], "none"
}, ],
"padded-blocks": ["off"],
"padding-line-between-statements": ["error"],
"prefer-arrow-callback": ["error"],
"prefer-const": ["error"],
"prefer-destructuring": ["off"],
"prefer-numeric-literals": ["error"],
"prefer-promise-reject-errors": ["off"],
"prefer-reflect": ["error"],
"prefer-rest-params": ["error"],
"prefer-spread": ["error"],
"prefer-template": ["error"],
"quote-props": ["error"],
"quotes": ["error"],
"radix": [
"error",
"as-needed"
],
"require-await": ["error"],
"require-jsdoc": ["off"],
"require-yield": ["error"],
"rest-spread-spacing": [
"error",
"never"
],
"semi": ["error"],
"semi-spacing": ["error"],
"semi-style": [
"error",
"last"
],
"sort-imports": ["error"],
"sort-keys": ["error"],
"sort-vars": ["error"],
"space-before-blocks": ["error"],
"space-before-function-paren": ["off"],
"space-in-parens": ["error"],
"space-infix-ops": ["error"],
"space-unary-ops": ["error"],
"spaced-comment": ["error"],
"strict": ["error"],
"switch-colon-spacing": [
"error",
{
"after": true,
"before": false
}
],
"symbol-description": ["error"],
"template-curly-spacing": ["error"],
"template-tag-spacing": ["error"],
"unicode-bom": [
"error",
"never"
],
"use-isnan": ["error"],
"valid-jsdoc": ["error"],
"valid-typeof": ["error"],
"vars-on-top": ["error"],
"wrap-iife": [
"error",
"any"
],
"wrap-regex": ["error"],
"yield-star-spacing": [
"error",
"before"
],
"yoda": [
"error",
"never"
]
}
}; };

@ -8,74 +8,66 @@ 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")));
} catch (error) { } catch (error) {
reject(error); reject(error);
} }
}); });
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) {
versions = data.engines; versions = data.engines;
} }
if (versions) { if (versions) {
resolve(versions); resolve(versions);
} else { } else {
reject("Missing or improper 'engines' property in 'package.json'"); reject("Missing or improper 'engines' property in 'package.json'");
} }
}); });
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}`);
} }
const npmVersion = stdout.trim(); const npmVersion = stdout.trim();
const engineVersion = engines.npm || ">=0"; const engineVersion = engines.npm || ">=0";
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}".`,
);
} }
}); });
getPackageJson() getPackageJson()
.then(getEngines) .then(getEngines)
.then(checkNodeVersion) .then(checkNodeVersion)
.then(checkNpmVersion) .then(checkNpmVersion)
.then( .then(
() => true, () => true,
(error) => { (error) => {
// Specifically disable these as the error message gets lost in the normal unhandled output. // Specifically disable these as the error message gets lost in the normal unhandled output.
/* 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);
}, }
); );

File diff suppressed because it is too large Load Diff

@ -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(
<CityTab (office: OfficeSpace | 0) => office !== 0 && (
current={props.city === cityName} <CityTab
key={cityName} current={city === office.loc}
name={cityName} key={office.loc}
onClick={props.onClicks[cityName]} name={office.loc}
/> 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,60 +1,60 @@
// 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> <>
<HeaderTab <div>
current={props.routing.isOnOverviewPage()}
key={"overview"}
onClick={overviewOnClick}
text={props.corp.name}
/>
{props.corp.divisions.map((division: IIndustry) => (
<HeaderTab <HeaderTab
current={props.routing.isOn(division.name)} current={divisionName === "Overview"}
key={division.name} key={"overview"}
onClick={() => { onClick={() => setDivisionName("Overview")}
props.routing.routeTo(division.name); text={props.corp.name}
props.corp.rerender(props.player);
}}
text={division.name}
/> />
))} {props.corp.divisions.map((division: IIndustry) => (
<HeaderTab <HeaderTab
current={false} current={division.name === divisionName}
onClick={openNewIndustryPopup} key={division.name}
text={"Expand into new Industry"} onClick={() => setDivisionName(division.name)}
text={division.name}
/>
))}
<HeaderTab
current={false}
onClick={openNewIndustryPopup}
text={"Expand into new Industry"}
/>
</div>
<MainPanel
corp={props.corp}
divisionName={divisionName}
player={props.player}
/> />
</div> </>
); );
} }

@ -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();
} }