From 2a13db39c769c601956b4bcef5e2a2f40514bcbd Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Wed, 8 Sep 2021 23:47:34 -0400 Subject: [PATCH] fix sleeve memory bug --- .prettierrc | 3 +- babel.config.js | 6 +- css/_theme.scss | 4 +- css/hacknetnodes.scss | 3 +- cypress/integration/netscript.spec.ts | 10 +- cypress/integration/tutorial.spec.ts | 8 +- cypress/plugins/index.js | 2 +- index.html | 554 +++-- scripts/.eslintrc.js | 789 +++---- scripts/engines-check.js | 84 +- scripts/semver.js | 1028 +++++---- src/Augmentation/Augmentation.tsx | 80 +- src/Augmentation/AugmentationHelpers.jsx | 174 +- .../ui/InstalledAugmentations.tsx | 5 +- .../InstalledAugmentationsAndSourceFiles.tsx | 11 +- src/Augmentation/ui/OwnedSourceFiles.tsx | 5 +- src/Augmentation/ui/PlayerMultipliers.tsx | 149 +- .../ui/PurchasedAugmentations.tsx | 7 +- src/Augmentation/ui/Root.tsx | 20 +- src/Augmentation/ui/SourceFileMinus1.tsx | 4 +- src/Bladeburner/Action.ts | 70 +- src/Bladeburner/ActionIdentifier.ts | 6 +- src/Bladeburner/BlackOperation.ts | 6 +- src/Bladeburner/BlackOperations.ts | 4 +- src/Bladeburner/Bladeburner.ts | 644 ++---- src/Bladeburner/City.ts | 24 +- src/Bladeburner/Contract.ts | 6 +- src/Bladeburner/IAction.ts | 5 +- src/Bladeburner/IBladeburner.ts | 53 +- src/Bladeburner/Operation.ts | 10 +- src/Bladeburner/Skill.ts | 13 +- src/Bladeburner/Skills.ts | 15 +- src/Bladeburner/data/Constants.ts | 9 +- src/Bladeburner/data/Icons.tsx | 8 +- src/Bladeburner/ui/AllPages.tsx | 31 +- src/Bladeburner/ui/BlackOpElem.tsx | 34 +- src/Bladeburner/ui/BlackOpList.tsx | 9 +- src/Bladeburner/ui/BlackOpPage.tsx | 14 +- src/Bladeburner/ui/Console.tsx | 15 +- src/Bladeburner/ui/ContractElem.tsx | 79 +- src/Bladeburner/ui/ContractList.tsx | 6 +- src/Bladeburner/ui/ContractPage.tsx | 10 +- src/Bladeburner/ui/GeneralActionElem.tsx | 31 +- src/Bladeburner/ui/GeneralActionList.tsx | 6 +- src/Bladeburner/ui/GeneralActionPage.tsx | 9 +- src/Bladeburner/ui/OperationElem.tsx | 85 +- src/Bladeburner/ui/OperationList.tsx | 6 +- src/Bladeburner/ui/OperationPage.tsx | 20 +- src/Bladeburner/ui/Root.tsx | 6 +- src/Bladeburner/ui/SkillElem.tsx | 22 +- src/Bladeburner/ui/SkillList.tsx | 6 +- src/Bladeburner/ui/SkillPage.tsx | 92 +- src/Bladeburner/ui/Stats.tsx | 103 +- src/Bladeburner/ui/SuccessChance.tsx | 3 +- src/Bladeburner/ui/TeamSizePopup.tsx | 10 +- src/Bladeburner/ui/TravelPopup.tsx | 11 +- src/Casino/Blackjack.tsx | 42 +- src/Casino/CoinFlip.tsx | 19 +- src/Casino/Game.tsx | 4 +- src/Casino/Roulette.tsx | 230 +- src/Casino/utils.ts | 4 +- src/CinematicText.js | 15 +- src/CodingContractGenerator.ts | 35 +- src/CodingContracts.ts | 23 +- src/Company/Company.ts | 20 +- src/Company/CompanyPosition.ts | 53 +- src/Company/GetJobRequirementText.ts | 24 +- src/Company/GetNextCompanyPosition.ts | 4 +- src/Company/data/CompaniesMetadata.ts | 169 +- src/Company/data/companypositionnames.ts | 33 +- src/Corporation/Actions.ts | 74 +- src/Corporation/Corporation.tsx | 89 +- src/Corporation/CorporationState.ts | 14 +- src/Corporation/Employee.ts | 63 +- src/Corporation/IIndustry.ts | 26 +- src/Corporation/Industry.ts | 298 +-- src/Corporation/IndustryData.tsx | 57 +- src/Corporation/IndustryUpgrades.ts | 9 +- src/Corporation/Material.ts | 6 +- src/Corporation/OfficeSpace.ts | 24 +- src/Corporation/Product.ts | 52 +- src/Corporation/ResearchTree.ts | 17 +- src/Corporation/Warehouse.ts | 22 +- src/Corporation/data/Constants.ts | 20 +- src/Corporation/data/CorporationUpgrades.ts | 9 +- src/Corporation/data/ResearchMetadata.ts | 8 +- src/Corporation/ui/BribeFactionPopup.tsx | 30 +- src/Corporation/ui/BuybackSharesPopup.tsx | 34 +- src/Corporation/ui/CityTabs.tsx | 9 +- .../ui/DiscontinueProductPopup.tsx | 5 +- src/Corporation/ui/ExpandNewCityPopup.tsx | 8 +- src/Corporation/ui/ExportPopup.tsx | 54 +- src/Corporation/ui/FindInvestorsPopup.tsx | 14 +- src/Corporation/ui/GoPublicPopup.tsx | 22 +- src/Corporation/ui/HeaderTabs.tsx | 19 +- src/Corporation/ui/Helpers.tsx | 5 +- src/Corporation/ui/HireEmployeePopup.tsx | 4 +- src/Corporation/ui/Industry.tsx | 7 +- src/Corporation/ui/IndustryOffice.tsx | 173 +- src/Corporation/ui/IndustryOverview.tsx | 95 +- src/Corporation/ui/IndustryWarehouse.tsx | 151 +- src/Corporation/ui/IssueDividendsPopup.tsx | 29 +- src/Corporation/ui/IssueNewSharesPopup.tsx | 36 +- src/Corporation/ui/LevelableUpgrade.tsx | 6 +- .../ui/LimitProductProductionPopup.tsx | 4 +- src/Corporation/ui/MainPanel.tsx | 11 +- src/Corporation/ui/MakeProductPopup.tsx | 15 +- src/Corporation/ui/MaterialMarketTaPopup.tsx | 45 +- src/Corporation/ui/MoneyCost.tsx | 12 +- src/Corporation/ui/NewIndustryPopup.tsx | 19 +- src/Corporation/ui/Overview.tsx | 137 +- src/Corporation/ui/ProductMarketTaPopup.tsx | 49 +- src/Corporation/ui/PurchaseMaterialPopup.tsx | 21 +- src/Corporation/ui/ResearchPopup.tsx | 8 +- src/Corporation/ui/SellMaterialPopup.tsx | 29 +- src/Corporation/ui/SellProductPopup.tsx | 33 +- src/Corporation/ui/SellSharesPopup.tsx | 34 +- src/Corporation/ui/SmartSupplyPopup.tsx | 24 +- src/Corporation/ui/ThrowPartyPopup.tsx | 22 +- src/Corporation/ui/UnlockUpgrade.tsx | 6 +- src/Corporation/ui/UpgradeOfficeSizePopup.tsx | 45 +- src/Crime/Crime.ts | 38 +- src/Crime/CrimeHelpers.ts | 10 +- src/Crime/Crimes.ts | 216 +- src/Crime/formulas/crime.ts | 5 +- src/DarkWeb/DarkWeb.tsx | 9 +- src/DarkWeb/DarkWebItems.ts | 48 +- src/DevMenu.jsx | 273 +-- src/Diagnostic/FileDiagnosticPopup.tsx | 5 +- src/Exploits/unclickable.ts | 7 +- src/Faction/Faction.ts | 6 +- src/Faction/FactionHelpers.d.ts | 16 +- src/Faction/FactionHelpers.jsx | 72 +- src/Faction/FactionInfo.ts | 106 +- src/Faction/Factions.ts | 4 +- src/Faction/ui/AugmentationsPage.tsx | 31 +- src/Faction/ui/DonateOption.tsx | 16 +- src/Faction/ui/FactionList.tsx | 12 +- src/Faction/ui/Info.tsx | 33 +- src/Faction/ui/Option.tsx | 5 +- src/Faction/ui/PurchaseableAugmentation.tsx | 30 +- src/Faction/ui/Root.tsx | 69 +- src/Fconf/Fconf.js | 62 +- src/Gang/Gang.ts | 61 +- src/Gang/GangMember.ts | 88 +- src/Gang/GangMemberTask.ts | 19 +- src/Gang/GangMemberTasks.ts | 8 +- src/Gang/GangMemberUpgrade.ts | 91 +- src/Gang/GangMemberUpgrades.ts | 7 +- src/Gang/Helpers.tsx | 11 +- src/Gang/ui/AscensionPopup.tsx | 6 +- src/Gang/ui/BonusTime.tsx | 5 +- src/Gang/ui/GangMemberAccordion.tsx | 4 +- src/Gang/ui/GangMemberAccordionContent.tsx | 12 +- src/Gang/ui/GangMemberList.tsx | 11 +- src/Gang/ui/GangMemberStats.tsx | 58 +- src/Gang/ui/GangMemberUpgradePopup.tsx | 102 +- src/Gang/ui/GangStats.tsx | 31 +- src/Gang/ui/ManagementSubpage.tsx | 24 +- src/Gang/ui/RecruitButton.tsx | 11 +- src/Gang/ui/Root.tsx | 6 +- src/Gang/ui/TaskDescription.tsx | 4 +- src/Gang/ui/TaskSelector.tsx | 25 +- src/Gang/ui/TerritorySubpage.tsx | 72 +- src/Hacking.ts | 30 +- src/Hacknet/HacknetHelpers.jsx | 226 +- src/Hacknet/HacknetNode.ts | 28 +- src/Hacknet/HacknetServer.ts | 38 +- src/Hacknet/HashManager.ts | 22 +- src/Hacknet/data/HashUpgradesMetadata.tsx | 18 +- src/Hacknet/formulas/HacknetNodes.ts | 38 +- src/Hacknet/formulas/HacknetServers.ts | 38 +- src/Hacknet/ui/GeneralInfo.jsx | 5 +- src/Hacknet/ui/HacknetNode.jsx | 56 +- src/Hacknet/ui/HacknetServer.jsx | 71 +- src/Hacknet/ui/HashUpgradePopup.jsx | 18 +- src/Hacknet/ui/MultiplierButtons.jsx | 5 +- src/Hacknet/ui/PlayerInfo.jsx | 3 +- src/Hacknet/ui/PurchaseButton.jsx | 5 +- src/Hacknet/ui/Root.jsx | 22 +- src/Hospital/Hospital.ts | 5 +- src/IEngine.ts | 6 +- src/Infiltration/Helper.tsx | 12 +- src/Infiltration/ui/CheatCodeGame.tsx | 3 +- src/Infiltration/ui/Cyberpunk2077Game.tsx | 11 +- src/Infiltration/ui/Difficulty.ts | 12 +- src/Infiltration/ui/Game.tsx | 16 +- src/Infiltration/ui/Intro.tsx | 10 +- src/Infiltration/ui/MinesweeperGame.tsx | 7 +- src/Infiltration/ui/SlashGame.tsx | 4 +- src/Infiltration/ui/Victory.tsx | 5 +- src/Infiltration/ui/WireCuttingGame.tsx | 17 +- src/InteractiveTutorial.js | 25 +- src/JSInterpreter.js | 673 +----- src/Literature/Literatures.ts | 3 +- src/Locations/Locations.ts | 8 +- src/Locations/LocationsHelpers.tsx | 48 +- src/Locations/ui/ApplyToJobButton.tsx | 5 +- src/Locations/ui/CasinoLocation.tsx | 25 +- src/Locations/ui/City.tsx | 5 +- src/Locations/ui/CompanyLocation.tsx | 83 +- src/Locations/ui/CoresButton.tsx | 17 +- src/Locations/ui/GenericLocation.tsx | 49 +- src/Locations/ui/GymLocation.tsx | 9 +- src/Locations/ui/HospitalLocation.tsx | 6 +- src/Locations/ui/RamButton.tsx | 14 +- src/Locations/ui/Root.tsx | 4 +- src/Locations/ui/SlumsLocation.tsx | 48 +- src/Locations/ui/SpecialLocation.tsx | 55 +- src/Locations/ui/TechVendorLocation.tsx | 11 +- src/Locations/ui/TorButton.tsx | 7 +- src/Locations/ui/TravelAgencyLocation.tsx | 9 +- src/Locations/ui/UniversityLocation.tsx | 3 +- src/Message/Message.ts | 6 +- src/Message/MessageHelpers.js | 30 +- src/Milestones/Milestones.ts | 4 +- src/Milestones/ui/Root.tsx | 4 +- src/Missions.jsx | 184 +- src/Netscript/WorkerScript.ts | 19 +- src/Netscript/killWorkerScript.ts | 35 +- src/NetscriptBladeburner.js | 6 +- src/NetscriptEvaluator.js | 10 +- src/NetscriptFunctions.js | 1940 ++++------------ src/NetscriptJSEvaluator.js | 13 +- src/NetscriptWorker.js | 112 +- src/PersonObjects/IPlayer.ts | 5 +- src/PersonObjects/Person.ts | 44 +- src/PersonObjects/Player/PlayerObject.js | 6 +- .../Player/PlayerObjectAugmentationMethods.ts | 5 +- .../Player/PlayerObjectBladeburnerMethods.js | 7 +- .../Player/PlayerObjectGangMethods.js | 4 +- .../Player/PlayerObjectGeneralMethods.jsx | 766 ++----- .../Player/PlayerObjectServerMethods.ts | 12 +- src/PersonObjects/Resleeving/Resleeve.ts | 19 +- src/PersonObjects/Resleeving/Resleeving.ts | 14 +- src/PersonObjects/Resleeving/ResleevingUI.tsx | 224 +- src/PersonObjects/Sleeve/Sleeve.ts | 225 +- .../Sleeve/SleeveAugmentationsUI.tsx | 14 +- src/PersonObjects/Sleeve/SleeveHelpers.ts | 5 +- src/PersonObjects/Sleeve/SleeveUI.tsx | 244 +- src/PersonObjects/Sleeve/data/SleeveFaq.tsx | 80 +- .../Sleeve/ui/CovenantPurchasesRoot.tsx | 39 +- .../Sleeve/ui/CovenantSleeveMemoryUpgrade.tsx | 21 +- .../Sleeve/ui/EarningsTableElement.tsx | 5 +- .../Sleeve/ui/MoreEarningsContent.tsx | 90 +- .../Sleeve/ui/MoreStatsContent.tsx | 121 +- src/PersonObjects/Sleeve/ui/StatsElement.tsx | 3 +- src/PersonObjects/formulas/intelligence.ts | 5 +- src/Prestige.js | 59 +- src/Programs/Program.ts | 4 +- src/Programs/ProgramHelpers.js | 6 +- src/Programs/data/ProgramsMetadata.ts | 21 +- src/RedPill.js | 65 +- src/SaveObject.jsx | 71 +- src/Script/RamCalculations.d.ts | 5 +- src/Script/RamCalculations.js | 26 +- src/Script/RunningScript.ts | 21 +- src/Script/Script.ts | 6 +- src/Script/ScriptHelpers.js | 48 +- src/ScriptEditor/ui/OptionsPopup.tsx | 12 +- src/ScriptEditor/ui/Root.tsx | 71 +- src/Server/AllServers.ts | 20 +- src/Server/BaseServer.ts | 23 +- src/Server/Server.ts | 30 +- src/Server/ServerHelpers.ts | 41 +- src/Server/ServerPurchases.ts | 27 +- src/Server/SpecialServerIps.ts | 6 +- src/Server/data/servers.ts | 21 +- src/Server/formulas/grow.ts | 16 +- src/Settings/Settings.ts | 8 +- src/StockMarket/BuyingAndSelling.tsx | 104 +- src/StockMarket/Order.ts | 6 +- src/StockMarket/OrderProcessing.tsx | 33 +- src/StockMarket/PlayerInfluencing.ts | 18 +- src/StockMarket/Stock.ts | 18 +- src/StockMarket/StockMarket.tsx | 91 +- src/StockMarket/StockMarketCosts.ts | 9 +- src/StockMarket/StockMarketHelpers.ts | 39 +- .../data/TickerHeaderFormatData.ts | 10 +- src/StockMarket/ui/InfoAndPurchases.tsx | 73 +- src/StockMarket/ui/Root.tsx | 6 +- src/StockMarket/ui/StockTicker.tsx | 117 +- src/StockMarket/ui/StockTickerHeaderText.tsx | 18 +- src/StockMarket/ui/StockTickerOrder.tsx | 11 +- src/StockMarket/ui/StockTickerOrderList.tsx | 8 +- .../ui/StockTickerPositionText.tsx | 36 +- src/StockMarket/ui/StockTickerTxButton.tsx | 4 +- src/StockMarket/ui/StockTickers.tsx | 11 +- src/StockMarket/ui/StockTickersConfig.tsx | 18 +- src/Terminal.jsx | 563 +---- src/Terminal/DirectoryHelpers.ts | 10 +- src/Terminal/DirectoryServerHelpers.ts | 6 +- src/Terminal/HelpText.ts | 7 +- ...termineAllPossibilitiesForTabCompletion.ts | 26 +- src/Terminal/tabCompletion.ts | 29 +- src/TextFile.ts | 16 +- src/ThirdParty/raphael.min.js | 1993 ++++------------- src/data/codingcontracttypes.ts | 110 +- src/engine.jsx | 403 ++-- src/index.html | 417 +--- src/ui/ActiveScripts/Root.tsx | 7 +- src/ui/ActiveScripts/ScriptProduction.tsx | 6 +- src/ui/ActiveScripts/ServerAccordion.tsx | 11 +- .../ActiveScripts/ServerAccordionContent.tsx | 16 +- src/ui/ActiveScripts/ServerAccordions.tsx | 8 +- .../ActiveScripts/WorkerScriptAccordion.tsx | 57 +- src/ui/CharacterInfo.tsx | 108 +- src/ui/MainMenu/Headers.ts | 49 +- src/ui/MainMenu/Links.ts | 7 +- src/ui/React/Accordion.tsx | 4 +- src/ui/React/AccordionButton.tsx | 14 +- src/ui/React/AutoupdatingParagraph.tsx | 4 +- src/ui/React/AutoupdatingStdButton.tsx | 13 +- src/ui/React/CharacterOverview.jsx | 49 +- src/ui/React/CodingContractPopup.tsx | 35 +- src/ui/React/CorruptableText.tsx | 8 +- src/ui/React/ErrorBoundary.tsx | 8 +- src/ui/React/Hashes.tsx | 4 +- src/ui/React/Money.tsx | 15 +- src/ui/React/MuiTextField.tsx | 4 +- src/ui/React/ParagraphWithTooltip.tsx | 5 +- src/ui/React/PopupButton.tsx | 6 +- src/ui/React/PopupCloseButton.tsx | 6 +- src/ui/React/Reputation.tsx | 4 +- src/ui/React/ServerDropdown.jsx | 16 +- src/ui/React/StatsTable.tsx | 3 +- src/ui/React/StdButton.tsx | 14 +- src/ui/React/StdButtonPurchased.tsx | 18 +- src/ui/React/createPopup.tsx | 13 +- src/ui/numeralFormat.ts | 8 +- src/ui/postToTerminal.tsx | 9 +- src/ui/setSettingsLabels.js | 35 +- src/utils/MoneySourceTracker.ts | 10 +- src/utils/calculateEffectWithFactors.ts | 14 +- stylelint.config.js | 7 +- test/Netscript/DynamicRamCalculation.test.js | 5 +- test/Netscript/StaticRamCalculation.test.js | 10 +- test/StockMarket.test.ts | 413 +--- test/StringHelperFunctions.test.ts | 37 +- test/Terminal/Directory.test.js | 20 +- ...neAllPossibilitiesForTabCompletion.test.ts | 75 +- utils/DialogBox.tsx | 5 +- utils/FactionInvitationBox.js | 12 +- utils/GameOptions.js | 17 +- utils/IPAddress.ts | 9 +- utils/JSONReviver.d.ts | 6 +- utils/JSONReviver.js | 10 +- utils/LogBox.tsx | 14 +- utils/StringHelperFunctions.ts | 21 +- utils/YesNoBox.ts | 37 +- utils/helpers/createProgressBarText.ts | 18 +- utils/helpers/getTimestamp.ts | 4 +- utils/uiHelpers/clearEventListeners.ts | 4 +- utils/uiHelpers/createAccordionElement.ts | 8 +- utils/uiHelpers/createElement.ts | 35 +- utils/uiHelpers/createOptionElement.ts | 5 +- utils/uiHelpers/createPopup.ts | 6 +- utils/uiHelpers/removeChildrenFromElement.ts | 4 +- utils/uiHelpers/removeElement.ts | 4 +- webpack.config.js | 4 +- 360 files changed, 5424 insertions(+), 15764 deletions(-) diff --git a/.prettierrc b/.prettierrc index e391e9ad6..907d4d108 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,5 @@ { "trailingComma": "all", - "tabWidth": 2 + "tabWidth": 2, + "printWidth": 120 } diff --git a/babel.config.js b/babel.config.js index bcbc32950..458b4a687 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,7 +1,3 @@ module.exports = { - presets: [ - "@babel/preset-react", - "@babel/preset-env", - "@babel/preset-typescript", - ], + presets: ["@babel/preset-react", "@babel/preset-env", "@babel/preset-typescript"], }; diff --git a/css/_theme.scss b/css/_theme.scss index 9322ede9e..fc44765cd 100644 --- a/css/_theme.scss +++ b/css/_theme.scss @@ -1,5 +1,5 @@ -$fontFamily: "Lucida Console", "Lucida Sans Unicode", "Fira Mono", "Consolas", - "Courier New", Courier, monospace, "Times New Roman"; +$fontFamily: "Lucida Console", "Lucida Sans Unicode", "Fira Mono", "Consolas", "Courier New", Courier, monospace, + "Times New Roman"; $defaultFontSize: 16px; /* COLORS */ diff --git a/css/hacknetnodes.scss b/css/hacknetnodes.scss index f1cb5c941..9bb81a6be 100644 --- a/css/hacknetnodes.scss +++ b/css/hacknetnodes.scss @@ -21,8 +21,7 @@ white-space: nowrap; &.hacknet-node { - $boxShadowArgs: inset 0 0 8px rgba(0, 0, 0, 0.1), - 0 0 16px rgba(0, 0, 0, 0.1); + $boxShadowArgs: inset 0 0 8px rgba(0, 0, 0, 0.1), 0 0 16px rgba(0, 0, 0, 0.1); @include boxShadow($boxShadowArgs); margin: 6px; diff --git a/cypress/integration/netscript.spec.ts b/cypress/integration/netscript.spec.ts index b4afb03a8..a07421d54 100644 --- a/cypress/integration/netscript.spec.ts +++ b/cypress/integration/netscript.spec.ts @@ -17,8 +17,7 @@ describe("netscript", () => { cy.findByRole("textbox").type("nano script.js{enter}"); // monaco can take a bit - cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}") - .type(`export const main = async (ns) => {{} + cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type(`export const main = async (ns) => {{} while(true) {{} await ns.hack("n00dles");`); @@ -39,8 +38,7 @@ describe("netscript", () => { cy.findByRole("textbox").type("nano script.js{enter}"); // monaco can take a bit - cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}") - .type(`export const main = async (ns) => {{} + cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type(`export const main = async (ns) => {{} const command = "hack"; ns[command]("n00dles");`); @@ -48,8 +46,6 @@ ns[command]("n00dles");`); cy.findByRole("button", { name: /Save & Close/i }).click(); cy.findByRole("textbox").type("run script.js{enter}"); - cy.findByText( - /Dynamic RAM usage calculated to be greater than initial RAM usage on fn: hack./i, - ); + cy.findByText(/Dynamic RAM usage calculated to be greater than initial RAM usage on fn: hack./i); }); }); diff --git a/cypress/integration/tutorial.spec.ts b/cypress/integration/tutorial.spec.ts index d3de57489..f13eb7592 100644 --- a/cypress/integration/tutorial.spec.ts +++ b/cypress/integration/tutorial.spec.ts @@ -49,14 +49,10 @@ describe("tutorial", () => { cy.findByRole("button", { name: "Next" }).click(); cy.findByText(/hacking exp/i); - cy.findByRole("textbox", { timeout: 15_000 }) - .should("not.be.disabled") - .type("nano n00dles.script{enter}"); + cy.findByRole("textbox", { timeout: 15_000 }).should("not.be.disabled").type("nano n00dles.script{enter}"); // monaco can take a bit - cy.findByRole("code", { timeout: 15_000 }) - .type("{selectall}{del}") - .type("while(true) {{}{enter}hack('n00dles');"); + cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type("while(true) {{}{enter}hack('n00dles');"); cy.findByRole("button", { name: /Save & Close/i }).click(); diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 59b2bab6e..8229063ad 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -19,4 +19,4 @@ module.exports = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config -} +}; diff --git a/index.html b/index.html index c682d3b33..72b210dd0 100644 --- a/index.html +++ b/index.html @@ -1,18 +1,18 @@ - + Bitburner - - - - - - - - - - + + + + + + + + + + - + - - + + + + + @@ -376,15 +417,11 @@ @@ -395,9 +432,7 @@

- + @@ -428,12 +463,8 @@
- - + +
@@ -446,180 +477,251 @@ - - + + + + + diff --git a/scripts/.eslintrc.js b/scripts/.eslintrc.js index ac57cfcac..7c2723fff 100644 --- a/scripts/.eslintrc.js +++ b/scripts/.eslintrc.js @@ -2,433 +2,366 @@ const numSpaces = 4; const maxLineLength = 160; module.exports = { - "env": { - "es6": true, - "node": true + env: { + es6: true, + node: true, + }, + extends: "eslint:recommended", + parserOptions: { + ecmaFeatures: { + experimentalObjectRestSpread: true, }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaFeatures": { - "experimentalObjectRestSpread": true - }, - "ecmaVersion": 8, - "sourceType": "module" - }, - "rules": { - "accessor-pairs": [ - "error", - { - "getWithoutSet": false, - "setWithoutGet": true - } - ], - "array-bracket-newline": ["error"], - "array-bracket-spacing": ["error"], - "array-callback-return": ["error"], - "array-element-newline": ["error"], - "arrow-body-style": ["error"], - "arrow-parens": ["error"], - "arrow-spacing": ["error"], - "block-scoped-var": ["error"], - "block-spacing": ["error"], - "brace-style": ["error"], - "callback-return": ["error"], - "camelcase": ["error"], - "capitalized-comments": ["error"], - "class-methods-use-this": ["error"], - "comma-dangle": ["error"], - "comma-spacing": ["error"], - "comma-style": [ - "error", - "last" - ], - "complexity": ["error"], - "computed-property-spacing": [ - "error", - "never" - ], - "consistent-return": ["error"], - "consistent-this": ["error"], - "constructor-super": ["error"], - "curly": ["error"], - "default-case": ["error"], - "dot-location": [ - "error", - "property" - ], - "dot-notation": ["error"], - "eol-last": ["error"], - "eqeqeq": ["error"], - "for-direction": ["error"], - "func-call-spacing": ["error"], - "func-name-matching": ["error"], - "func-names": [ - "error", - "never" - ], - "func-style": ["error"], - "function-paren-newline": ["error"], - "generator-star-spacing": [ - "error", - "before" - ], - "getter-return": [ - "error", - { - "allowImplicit": false - } - ], - "global-require": ["error"], - "guard-for-in": ["error"], - "handle-callback-err": ["error"], - "id-blacklist": ["error"], - "id-length": ["error"], - "id-match": ["error"], - "implicit-arrow-linebreak": [ - "error", - "beside" - ], - "indent": [ - "error", - numSpaces, - { - "SwitchCase": 1 - } - ], - "init-declarations": ["error"], - "jsx-quotes": ["error"], - "key-spacing": ["error"], - "keyword-spacing": ["error"], - "line-comment-position": ["error"], - "linebreak-style": [ - "error", - "windows" - ], - "lines-around-comment": ["error"], - "lines-between-class-members": ["error"], - "max-depth": ["error"], - "max-len": [ - "error", - maxLineLength - ], - "max-lines": [ - "error", - { - "skipBlankLines": true, - "skipComments": true - } - ], - "max-nested-callbacks": ["error"], - "max-params": ["error"], - "max-statements": ["error"], - "max-statements-per-line": ["error"], - "multiline-comment-style": [ - "off", - "starred-block" - ], - "multiline-ternary": [ - "error", - "never" - ], - "new-cap": ["error"], - "new-parens": ["error"], - // TODO: configure this... - "newline-before-return": ["error"], - "newline-per-chained-call": ["error"], - "no-alert": ["error"], - "no-array-constructor": ["error"], - "no-await-in-loop": ["error"], - "no-bitwise": ["error"], - "no-buffer-constructor": ["error"], - "no-caller": ["error"], - "no-case-declarations": ["error"], - "no-catch-shadow": ["error"], - "no-class-assign": ["error"], - "no-compare-neg-zero": ["error"], - "no-cond-assign": [ - "error", - "except-parens" - ], - "no-confusing-arrow": ["error"], - "no-console": ["error"], - "no-const-assign": ["error"], - "no-constant-condition": [ - "error", - { - "checkLoops": false - } - ], - "no-continue": ["off"], - "no-control-regex": ["error"], - "no-debugger": ["error"], - "no-delete-var": ["error"], - "no-div-regex": ["error"], - "no-dupe-args": ["error"], - "no-dupe-class-members": ["error"], - "no-dupe-keys": ["error"], - "no-duplicate-case": ["error"], - "no-duplicate-imports": [ - "error", - { - "includeExports": true - } - ], - "no-else-return": ["error"], - "no-empty": [ - "error", - { - "allowEmptyCatch": false - } - ], - "no-empty-character-class": ["error"], - "no-empty-function": ["error"], - "no-empty-pattern": ["error"], - "no-eq-null": ["error"], - "no-eval": ["error"], - "no-ex-assign": ["error"], - "no-extend-native": ["error"], - "no-extra-bind": ["error"], - "no-extra-boolean-cast": ["error"], - "no-extra-label": ["error"], - "no-extra-parens": [ - "error", - "all", - { - "conditionalAssign": false - } - ], - "no-extra-semi": ["error"], - "no-fallthrough": ["error"], - "no-floating-decimal": ["error"], - "no-func-assign": ["error"], - "no-global-assign": ["error"], - "no-implicit-coercion": ["error"], - "no-implicit-globals": ["error"], - "no-implied-eval": ["error"], - "no-inline-comments": ["error"], - "no-inner-declarations": [ - "error", - "both" - ], - "no-invalid-regexp": ["error"], - "no-invalid-this": ["error"], - "no-irregular-whitespace": [ - "error", - { - "skipComments": false, - "skipRegExps": false, - "skipStrings": false, - "skipTemplates": false - } - ], - "no-iterator": ["error"], - "no-label-var": ["error"], - "no-labels": ["error"], - "no-lone-blocks": ["error"], - "no-lonely-if": ["error"], - "no-loop-func": ["error"], - "no-magic-numbers": [ - "error", - { - "ignore": [ - -1, - 0, - 1 - ], - "ignoreArrayIndexes": true - } - ], - "no-mixed-operators": ["error"], - "no-mixed-requires": ["error"], - "no-mixed-spaces-and-tabs": ["error"], - "no-multi-assign": ["error"], - "no-multi-spaces": ["error"], - "no-multi-str": ["error"], - "no-multiple-empty-lines": [ - "error", - { - "max": 1 - } - ], - "no-native-reassign": ["error"], - "no-negated-condition": ["error"], - "no-negated-in-lhs": ["error"], - "no-nested-ternary": ["error"], - "no-new": ["error"], - "no-new-func": ["error"], - "no-new-object": ["error"], - "no-new-require": ["error"], - "no-new-symbol": ["error"], - "no-new-wrappers": ["error"], - "no-obj-calls": ["error"], - "no-octal": ["error"], - "no-octal-escape": ["error"], - "no-param-reassign": ["error"], - "no-path-concat": ["error"], - "no-plusplus": [ - "error", - { - "allowForLoopAfterthoughts": true - } - ], - "no-process-env": ["error"], - "no-process-exit": ["error"], - "no-proto": ["error"], - "no-prototype-builtins": ["error"], - "no-redeclare": ["error"], - "no-regex-spaces": ["error"], - "no-restricted-globals": ["error"], - "no-restricted-imports": ["error"], - "no-restricted-modules": ["error"], - "no-restricted-properties": [ - "error", - { - "message": "'log' is too general, use an appropriate level when logging.", - "object": "console", - "property": "log" - } - ], - "no-restricted-syntax": ["error"], - "no-return-assign": ["error"], - "no-return-await": ["error"], - "no-script-url": ["error"], - "no-self-assign": [ - "error", - { - "props": false - } - ], - "no-self-compare": ["error"], - "no-sequences": ["error"], - "no-shadow": ["error"], - "no-shadow-restricted-names": ["error"], - "no-spaced-func": ["error"], - "no-sparse-arrays": ["error"], - "no-sync": ["error"], - "no-tabs": ["error"], - "no-template-curly-in-string": ["error"], - "no-ternary": ["off"], - "no-this-before-super": ["error"], - "no-throw-literal": ["error"], - "no-trailing-spaces": ["error"], - "no-undef": ["error"], - "no-undef-init": ["error"], - "no-undefined": ["error"], - "no-underscore-dangle": ["error"], - "no-unexpected-multiline": ["error"], - "no-unmodified-loop-condition": ["error"], - "no-unneeded-ternary": ["error"], - "no-unreachable": ["error"], - "no-unsafe-finally": ["error"], - "no-unsafe-negation": ["error"], - "no-unused-expressions": ["error"], - "no-unused-labels": ["error"], - "no-unused-vars": ["error"], - "no-use-before-define": ["error"], - "no-useless-call": ["error"], - "no-useless-computed-key": ["error"], - "no-useless-concat": ["error"], - "no-useless-constructor": ["error"], - "no-useless-escape": ["error"], - "no-useless-rename": [ - "error", - { - "ignoreDestructuring": false, - "ignoreExport": false, - "ignoreImport": false - } - ], - "no-useless-return": ["error"], - "no-var": ["error"], - "no-void": ["error"], - "no-warning-comments": ["error"], - "no-whitespace-before-property": ["error"], - "no-with": ["error"], - "nonblock-statement-body-position": [ - "error", - "below" - ], - "object-curly-newline": ["error"], - "object-curly-spacing": ["error"], - "object-property-newline": ["error"], - "object-shorthand": ["error"], - "one-var": ["off"], - "one-var-declaration-per-line": ["error"], - "operator-assignment": ["error"], - "operator-linebreak": [ - "error", - "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" - ] - } + ecmaVersion: 8, + sourceType: "module", + }, + rules: { + "accessor-pairs": [ + "error", + { + getWithoutSet: false, + setWithoutGet: true, + }, + ], + "array-bracket-newline": ["error"], + "array-bracket-spacing": ["error"], + "array-callback-return": ["error"], + "array-element-newline": ["error"], + "arrow-body-style": ["error"], + "arrow-parens": ["error"], + "arrow-spacing": ["error"], + "block-scoped-var": ["error"], + "block-spacing": ["error"], + "brace-style": ["error"], + "callback-return": ["error"], + camelcase: ["error"], + "capitalized-comments": ["error"], + "class-methods-use-this": ["error"], + "comma-dangle": ["error"], + "comma-spacing": ["error"], + "comma-style": ["error", "last"], + complexity: ["error"], + "computed-property-spacing": ["error", "never"], + "consistent-return": ["error"], + "consistent-this": ["error"], + "constructor-super": ["error"], + curly: ["error"], + "default-case": ["error"], + "dot-location": ["error", "property"], + "dot-notation": ["error"], + "eol-last": ["error"], + eqeqeq: ["error"], + "for-direction": ["error"], + "func-call-spacing": ["error"], + "func-name-matching": ["error"], + "func-names": ["error", "never"], + "func-style": ["error"], + "function-paren-newline": ["error"], + "generator-star-spacing": ["error", "before"], + "getter-return": [ + "error", + { + allowImplicit: false, + }, + ], + "global-require": ["error"], + "guard-for-in": ["error"], + "handle-callback-err": ["error"], + "id-blacklist": ["error"], + "id-length": ["error"], + "id-match": ["error"], + "implicit-arrow-linebreak": ["error", "beside"], + indent: [ + "error", + numSpaces, + { + SwitchCase: 1, + }, + ], + "init-declarations": ["error"], + "jsx-quotes": ["error"], + "key-spacing": ["error"], + "keyword-spacing": ["error"], + "line-comment-position": ["error"], + "linebreak-style": ["error", "windows"], + "lines-around-comment": ["error"], + "lines-between-class-members": ["error"], + "max-depth": ["error"], + "max-len": ["error", maxLineLength], + "max-lines": [ + "error", + { + skipBlankLines: true, + skipComments: true, + }, + ], + "max-nested-callbacks": ["error"], + "max-params": ["error"], + "max-statements": ["error"], + "max-statements-per-line": ["error"], + "multiline-comment-style": ["off", "starred-block"], + "multiline-ternary": ["error", "never"], + "new-cap": ["error"], + "new-parens": ["error"], + // TODO: configure this... + "newline-before-return": ["error"], + "newline-per-chained-call": ["error"], + "no-alert": ["error"], + "no-array-constructor": ["error"], + "no-await-in-loop": ["error"], + "no-bitwise": ["error"], + "no-buffer-constructor": ["error"], + "no-caller": ["error"], + "no-case-declarations": ["error"], + "no-catch-shadow": ["error"], + "no-class-assign": ["error"], + "no-compare-neg-zero": ["error"], + "no-cond-assign": ["error", "except-parens"], + "no-confusing-arrow": ["error"], + "no-console": ["error"], + "no-const-assign": ["error"], + "no-constant-condition": [ + "error", + { + checkLoops: false, + }, + ], + "no-continue": ["off"], + "no-control-regex": ["error"], + "no-debugger": ["error"], + "no-delete-var": ["error"], + "no-div-regex": ["error"], + "no-dupe-args": ["error"], + "no-dupe-class-members": ["error"], + "no-dupe-keys": ["error"], + "no-duplicate-case": ["error"], + "no-duplicate-imports": [ + "error", + { + includeExports: true, + }, + ], + "no-else-return": ["error"], + "no-empty": [ + "error", + { + allowEmptyCatch: false, + }, + ], + "no-empty-character-class": ["error"], + "no-empty-function": ["error"], + "no-empty-pattern": ["error"], + "no-eq-null": ["error"], + "no-eval": ["error"], + "no-ex-assign": ["error"], + "no-extend-native": ["error"], + "no-extra-bind": ["error"], + "no-extra-boolean-cast": ["error"], + "no-extra-label": ["error"], + "no-extra-parens": [ + "error", + "all", + { + conditionalAssign: false, + }, + ], + "no-extra-semi": ["error"], + "no-fallthrough": ["error"], + "no-floating-decimal": ["error"], + "no-func-assign": ["error"], + "no-global-assign": ["error"], + "no-implicit-coercion": ["error"], + "no-implicit-globals": ["error"], + "no-implied-eval": ["error"], + "no-inline-comments": ["error"], + "no-inner-declarations": ["error", "both"], + "no-invalid-regexp": ["error"], + "no-invalid-this": ["error"], + "no-irregular-whitespace": [ + "error", + { + skipComments: false, + skipRegExps: false, + skipStrings: false, + skipTemplates: false, + }, + ], + "no-iterator": ["error"], + "no-label-var": ["error"], + "no-labels": ["error"], + "no-lone-blocks": ["error"], + "no-lonely-if": ["error"], + "no-loop-func": ["error"], + "no-magic-numbers": [ + "error", + { + ignore: [-1, 0, 1], + ignoreArrayIndexes: true, + }, + ], + "no-mixed-operators": ["error"], + "no-mixed-requires": ["error"], + "no-mixed-spaces-and-tabs": ["error"], + "no-multi-assign": ["error"], + "no-multi-spaces": ["error"], + "no-multi-str": ["error"], + "no-multiple-empty-lines": [ + "error", + { + max: 1, + }, + ], + "no-native-reassign": ["error"], + "no-negated-condition": ["error"], + "no-negated-in-lhs": ["error"], + "no-nested-ternary": ["error"], + "no-new": ["error"], + "no-new-func": ["error"], + "no-new-object": ["error"], + "no-new-require": ["error"], + "no-new-symbol": ["error"], + "no-new-wrappers": ["error"], + "no-obj-calls": ["error"], + "no-octal": ["error"], + "no-octal-escape": ["error"], + "no-param-reassign": ["error"], + "no-path-concat": ["error"], + "no-plusplus": [ + "error", + { + allowForLoopAfterthoughts: true, + }, + ], + "no-process-env": ["error"], + "no-process-exit": ["error"], + "no-proto": ["error"], + "no-prototype-builtins": ["error"], + "no-redeclare": ["error"], + "no-regex-spaces": ["error"], + "no-restricted-globals": ["error"], + "no-restricted-imports": ["error"], + "no-restricted-modules": ["error"], + "no-restricted-properties": [ + "error", + { + message: "'log' is too general, use an appropriate level when logging.", + object: "console", + property: "log", + }, + ], + "no-restricted-syntax": ["error"], + "no-return-assign": ["error"], + "no-return-await": ["error"], + "no-script-url": ["error"], + "no-self-assign": [ + "error", + { + props: false, + }, + ], + "no-self-compare": ["error"], + "no-sequences": ["error"], + "no-shadow": ["error"], + "no-shadow-restricted-names": ["error"], + "no-spaced-func": ["error"], + "no-sparse-arrays": ["error"], + "no-sync": ["error"], + "no-tabs": ["error"], + "no-template-curly-in-string": ["error"], + "no-ternary": ["off"], + "no-this-before-super": ["error"], + "no-throw-literal": ["error"], + "no-trailing-spaces": ["error"], + "no-undef": ["error"], + "no-undef-init": ["error"], + "no-undefined": ["error"], + "no-underscore-dangle": ["error"], + "no-unexpected-multiline": ["error"], + "no-unmodified-loop-condition": ["error"], + "no-unneeded-ternary": ["error"], + "no-unreachable": ["error"], + "no-unsafe-finally": ["error"], + "no-unsafe-negation": ["error"], + "no-unused-expressions": ["error"], + "no-unused-labels": ["error"], + "no-unused-vars": ["error"], + "no-use-before-define": ["error"], + "no-useless-call": ["error"], + "no-useless-computed-key": ["error"], + "no-useless-concat": ["error"], + "no-useless-constructor": ["error"], + "no-useless-escape": ["error"], + "no-useless-rename": [ + "error", + { + ignoreDestructuring: false, + ignoreExport: false, + ignoreImport: false, + }, + ], + "no-useless-return": ["error"], + "no-var": ["error"], + "no-void": ["error"], + "no-warning-comments": ["error"], + "no-whitespace-before-property": ["error"], + "no-with": ["error"], + "nonblock-statement-body-position": ["error", "below"], + "object-curly-newline": ["error"], + "object-curly-spacing": ["error"], + "object-property-newline": ["error"], + "object-shorthand": ["error"], + "one-var": ["off"], + "one-var-declaration-per-line": ["error"], + "operator-assignment": ["error"], + "operator-linebreak": ["error", "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"], + }, }; diff --git a/scripts/engines-check.js b/scripts/engines-check.js index 5db6af9ac..c00ba229d 100644 --- a/scripts/engines-check.js +++ b/scripts/engines-check.js @@ -8,66 +8,74 @@ const path = require("path"); const exec = require("child_process").exec; const semver = require("./semver"); -const getPackageJson = () => new Promise((resolve, reject) => { +const getPackageJson = () => + new Promise((resolve, reject) => { try { - /* eslint-disable-next-line global-require */ - resolve(require(path.resolve(process.cwd(), "package.json"))); + /* eslint-disable-next-line global-require */ + resolve(require(path.resolve(process.cwd(), "package.json"))); } catch (error) { - reject(error); + reject(error); } -}); + }); -const getEngines = (data) => new Promise((resolve, reject) => { +const getEngines = (data) => + new Promise((resolve, reject) => { let versions = null; if (data.engines) { - versions = data.engines; + versions = data.engines; } if (versions) { - resolve(versions); + resolve(versions); } else { - reject("Missing or improper 'engines' property in 'package.json'"); + reject("Missing or improper 'engines' property in 'package.json'"); } -}); + }); -const checkNpmVersion = (engines) => new Promise((resolve, reject) => { +const checkNpmVersion = (engines) => + new Promise((resolve, reject) => { exec("npm -v", (error, stdout, stderr) => { - if (error) { - reject(`Unable to find NPM version\n${stderr}`); - } + if (error) { + reject(`Unable to find NPM version\n${stderr}`); + } - const npmVersion = stdout.trim(); - const engineVersion = engines.npm || ">=0"; + const npmVersion = stdout.trim(); + const engineVersion = engines.npm || ">=0"; - if (semver.satisfies(npmVersion, engineVersion)) { - resolve(); - } else { - reject(`Incorrect npm version\n'package.json' specifies "${engineVersion}", you are currently running "${npmVersion}".`); - } + if (semver.satisfies(npmVersion, engineVersion)) { + resolve(); + } else { + reject( + `Incorrect npm version\n'package.json' specifies "${engineVersion}", you are currently running "${npmVersion}".`, + ); + } }); -}); + }); -const checkNodeVersion = (engines) => new Promise((resolve, reject) => { +const checkNodeVersion = (engines) => + new Promise((resolve, reject) => { const nodeVersion = process.version.substring(1); if (semver.satisfies(nodeVersion, engines.node)) { - resolve(engines); + resolve(engines); } else { - reject(`Incorrect node version\n'package.json' specifies "${engines.node}", you are currently running "${process.version}".`); + reject( + `Incorrect node version\n'package.json' specifies "${engines.node}", you are currently running "${process.version}".`, + ); } -}); + }); getPackageJson() - .then(getEngines) - .then(checkNodeVersion) - .then(checkNpmVersion) - .then( - () => true, - (error) => { - // Specifically disable these as the error message gets lost in the normal unhandled output. - /* eslint-disable no-console, no-process-exit */ - console.error(error); - process.exit(1); - } - ); + .then(getEngines) + .then(checkNodeVersion) + .then(checkNpmVersion) + .then( + () => true, + (error) => { + // Specifically disable these as the error message gets lost in the normal unhandled output. + /* eslint-disable no-console, no-process-exit */ + console.error(error); + process.exit(1); + }, + ); diff --git a/scripts/semver.js b/scripts/semver.js index b5d015570..daf4a1882 100644 --- a/scripts/semver.js +++ b/scripts/semver.js @@ -81,30 +81,20 @@ src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-][a-zA-Z0-9-]*"; // ## Main Version // Three dot-separated numeric identifiers. +src[MAINVERSION] = `(${src[NUMERICIDENTIFIER]})\\.(${src[NUMERICIDENTIFIER]})\\.(${src[NUMERICIDENTIFIER]})`; src[ - MAINVERSION -] = `(${src[NUMERICIDENTIFIER]})\\.(${src[NUMERICIDENTIFIER]})\\.(${src[NUMERICIDENTIFIER]})`; -src[ - MAINVERSIONLOOSE + MAINVERSIONLOOSE ] = `(${src[NUMERICIDENTIFIERLOOSE]})\\.(${src[NUMERICIDENTIFIERLOOSE]})\\.(${src[NUMERICIDENTIFIERLOOSE]})`; // ## Pre-release Version Identifier // A numeric identifier, or a non-numeric identifier. -src[ - PRERELEASEIDENTIFIER -] = `(?:${src[NUMERICIDENTIFIER]}|${src[NONNUMERICIDENTIFIER]})`; -src[ - PRERELEASEIDENTIFIERLOOSE -] = `(?:${src[NUMERICIDENTIFIERLOOSE]}|${src[NONNUMERICIDENTIFIER]})`; +src[PRERELEASEIDENTIFIER] = `(?:${src[NUMERICIDENTIFIER]}|${src[NONNUMERICIDENTIFIER]})`; +src[PRERELEASEIDENTIFIERLOOSE] = `(?:${src[NUMERICIDENTIFIERLOOSE]}|${src[NONNUMERICIDENTIFIER]})`; // ## Pre-release Version // Hyphen, followed by one or more dot-separated pre-release version identifiers. -src[ - PRERELEASE -] = `(?:-(${src[PRERELEASEIDENTIFIER]}(?:\\.${src[PRERELEASEIDENTIFIER]})*))`; -src[ - PRERELEASELOOSE -] = `(?:-?(${src[PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[PRERELEASEIDENTIFIERLOOSE]})*))`; +src[PRERELEASE] = `(?:-(${src[PRERELEASEIDENTIFIER]}(?:\\.${src[PRERELEASEIDENTIFIER]})*))`; +src[PRERELEASELOOSE] = `(?:-?(${src[PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[PRERELEASEIDENTIFIERLOOSE]})*))`; // ## Build Metadata Identifier // Any combination of digits, letters, or hyphens. @@ -136,7 +126,7 @@ src[XRANGEIDENTIFIER] = `${src[NUMERICIDENTIFIER]}|x|X|\\*`; /* eslint-disable-next-line max-len */ src[ - XRANGEPLAIN + XRANGEPLAIN ] = `[v=\\s]*(${src[XRANGEIDENTIFIER]})(?:\\.(${src[XRANGEIDENTIFIER]})(?:\\.(${src[XRANGEIDENTIFIER]})(?:${src[PRERELEASE]})?${src[BUILD]}?)?)?`; /* eslint-disable-next-line max-len */ @@ -151,7 +141,7 @@ src[XRANGELOOSE] = `^${src[GTLT]}\\s*${src[XRANGEPLAINLOOSE]}$`; // Extract anything that could conceivably be a part of a valid semver /* eslint-disable-next-line max-len */ src[ - COERCE + COERCE ] = `(?:^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:$|[^\\d])`; // Tilde ranges. @@ -180,9 +170,7 @@ src[COMPARATORLOOSE] = `^${src[GTLT]}\\s*(${LOOSEPLAIN})$|^$`; src[COMPARATOR] = `^${src[GTLT]}\\s*(${FULLPLAIN})$|^$`; // An expression to strip any whitespace between the gtlt and the thing it modifies, so that `> 1.2.3` ==> `>1.2.3` -src[ - COMPARATORTRIM -] = `(\\s*)${src[GTLT]}\\s*(${LOOSEPLAIN}|${src[XRANGEPLAIN]})`; +src[COMPARATORTRIM] = `(\\s*)${src[GTLT]}\\s*(${LOOSEPLAIN}|${src[XRANGEPLAIN]})`; // This one has to use the /g flag re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g"); @@ -190,13 +178,9 @@ const comparatorTrimReplace = "$1$2$3"; // Something like `1.2.3 - 1.2.4` // Note that these all use the loose form, because they'll be checked against either the strict or loose comparator form later. -src[ - HYPHENRANGE -] = `^\\s*(${src[XRANGEPLAIN]})\\s+-\\s+(${src[XRANGEPLAIN]})\\s*$`; +src[HYPHENRANGE] = `^\\s*(${src[XRANGEPLAIN]})\\s+-\\s+(${src[XRANGEPLAIN]})\\s*$`; -src[ - HYPHENRANGELOOSE -] = `^\\s*(${src[XRANGEPLAINLOOSE]})\\s+-\\s+(${src[XRANGEPLAINLOOSE]})\\s*$`; +src[HYPHENRANGELOOSE] = `^\\s*(${src[XRANGEPLAINLOOSE]})\\s+-\\s+(${src[XRANGEPLAINLOOSE]})\\s*$`; // Star ranges basically just allow anything at all. src[STAR] = "(<|>)?=?\\s*\\*"; @@ -205,40 +189,40 @@ src[STAR] = "(<|>)?=?\\s*\\*"; // Compile to actual regexp objects. // All are flag-free, unless they were created above with a flag. for (let idx = 0; idx <= STAR; idx++) { - if (!re[idx]) { - re[idx] = new RegExp(src[idx]); - } + if (!re[idx]) { + re[idx] = new RegExp(src[idx]); + } } const ANY = {}; const isX = (id) => !id || id.toLowerCase() === "x" || id === "*"; function compareIdentifiers(left, right) { - const numeric = /^[0-9]+$/; - const leftIsNumeric = numeric.test(left); - const rightIsNumeric = numeric.test(right); - if (leftIsNumeric && !rightIsNumeric) { - return -1; - } + const numeric = /^[0-9]+$/; + const leftIsNumeric = numeric.test(left); + const rightIsNumeric = numeric.test(right); + if (leftIsNumeric && !rightIsNumeric) { + return -1; + } - if (rightIsNumeric && !leftIsNumeric) { - return 1; - } + if (rightIsNumeric && !leftIsNumeric) { + return 1; + } - if (leftIsNumeric && rightIsNumeric) { - left = Number(left); - right = Number(right); - } + if (leftIsNumeric && rightIsNumeric) { + left = Number(left); + right = Number(right); + } - if (left < right) { - return -1; - } + if (left < right) { + return -1; + } - if (left > right) { - return 1; - } + if (left > right) { + return 1; + } - return 0; + return 0; } // This function is passed to string.replace(re[HYPHENRANGE]) @@ -247,58 +231,56 @@ function compareIdentifiers(left, right) { // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do // 1.2 - 3.4 => >=1.2.0 <3.5.0 function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) { - if (isX(fM)) { - from = ""; - } else if (isX(fm)) { - from = `>=${fM}.0.0`; - } else if (isX(fp)) { - from = `>=${fM}.${fm}.0`; - } else { - from = `>=${from}`; - } + if (isX(fM)) { + from = ""; + } else if (isX(fm)) { + from = `>=${fM}.0.0`; + } else if (isX(fp)) { + from = `>=${fM}.${fm}.0`; + } else { + from = `>=${from}`; + } - if (isX(tM)) { - to = ""; - } else if (isX(tm)) { - to = `<${Number(tM) + 1}.0.0`; - } else if (isX(tp)) { - to = `<${tM}.${Number(tm) + 1}.0`; - } else if (tpr) { - to = `<=${tM}.${tm}.${tp}-${tpr}`; - } else { - to = `<=${to}`; - } + if (isX(tM)) { + to = ""; + } else if (isX(tm)) { + to = `<${Number(tM) + 1}.0.0`; + } else if (isX(tp)) { + to = `<${tM}.${Number(tm) + 1}.0`; + } else if (tpr) { + to = `<=${tM}.${tm}.${tp}-${tpr}`; + } else { + to = `<=${to}`; + } - return `${from} ${to}`.trim(); + return `${from} ${to}`.trim(); } function replaceTilde(comp, loose) { - const regex = loose ? re[TILDELOOSE] : re[TILDE]; + const regex = loose ? re[TILDELOOSE] : re[TILDE]; - return comp.replace(regex, function (match, major, minor, patch, prerelease) { - let ret; + return comp.replace(regex, function (match, major, minor, patch, prerelease) { + let ret; - if (isX(major)) { - ret = ""; - } else if (isX(minor)) { - ret = `>=${major}.0.0 <${Number(major) + 1}.0.0`; - } else if (isX(patch)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0`; - } else if (prerelease) { - if (prerelease.charAt(0) !== "-") { - prerelease = `-${prerelease}`; - } - ret = `>=${major}.${minor}.${patch}${prerelease} <${major}.${ - Number(minor) + 1 - }.0`; - } else { - // ~1.2.3 == >=1.2.3 <1.3.0 - ret = `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0`; - } + if (isX(major)) { + ret = ""; + } else if (isX(minor)) { + ret = `>=${major}.0.0 <${Number(major) + 1}.0.0`; + } else if (isX(patch)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0`; + } else if (prerelease) { + if (prerelease.charAt(0) !== "-") { + prerelease = `-${prerelease}`; + } + ret = `>=${major}.${minor}.${patch}${prerelease} <${major}.${Number(minor) + 1}.0`; + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0`; + } - return ret; - }); + return ret; + }); } // ~, ~> --> * (any, kinda silly) @@ -308,62 +290,54 @@ function replaceTilde(comp, loose) { // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 function replaceTildes(comp, loose) { - return comp - .trim() - .split(/\s+/) - .map((comp1) => replaceTilde(comp1, loose)) - .join(" "); + return comp + .trim() + .split(/\s+/) + .map((comp1) => replaceTilde(comp1, loose)) + .join(" "); } function replaceCaret(comp, loose) { - const regex = loose ? re[CARETLOOSE] : re[CARET]; + const regex = loose ? re[CARETLOOSE] : re[CARET]; - return comp.replace(regex, function (match, major, minor, patch, prerelease) { - let ret; + return comp.replace(regex, function (match, major, minor, patch, prerelease) { + let ret; - if (isX(major)) { - ret = ""; - } else if (isX(minor)) { - ret = `>=${major}.0.0 <${Number(major) + 1}.0.0`; - } else if (isX(patch)) { - if (major === "0") { - ret = `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0`; - } else { - ret = `>=${major}.${minor}.0 <${Number(major) + 1}.0.0`; - } - } else if (prerelease) { - if (prerelease.charAt(0) !== "-") { - prerelease = `-${prerelease}`; - } - if (major === "0") { - if (minor === "0") { - ret = `>=${major}.${minor}.${patch}${prerelease} <${major}.${minor}.${ - Number(patch) + 1 - }`; - } else { - ret = `>=${major}.${minor}.${patch}${prerelease} <${major}.${ - Number(minor) + 1 - }.0`; - } - } else { - ret = `>=${major}.${minor}.${patch}${prerelease} <${ - Number(major) + 1 - }.0.0`; - } - } else if (major === "0") { - if (minor === "0") { - ret = `>=${major}.${minor}.${patch} <${major}.${minor}.${ - Number(patch) + 1 - }`; - } else { - ret = `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0`; - } + if (isX(major)) { + ret = ""; + } else if (isX(minor)) { + ret = `>=${major}.0.0 <${Number(major) + 1}.0.0`; + } else if (isX(patch)) { + if (major === "0") { + ret = `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0`; + } else { + ret = `>=${major}.${minor}.0 <${Number(major) + 1}.0.0`; + } + } else if (prerelease) { + if (prerelease.charAt(0) !== "-") { + prerelease = `-${prerelease}`; + } + if (major === "0") { + if (minor === "0") { + ret = `>=${major}.${minor}.${patch}${prerelease} <${major}.${minor}.${Number(patch) + 1}`; } else { - ret = `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0`; + ret = `>=${major}.${minor}.${patch}${prerelease} <${major}.${Number(minor) + 1}.0`; } + } else { + ret = `>=${major}.${minor}.${patch}${prerelease} <${Number(major) + 1}.0.0`; + } + } else if (major === "0") { + if (minor === "0") { + ret = `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}`; + } else { + ret = `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0`; + } + } else { + ret = `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0`; + } - return ret; - }); + return ret; + }); } // ^ --> * (any, kinda silly) @@ -373,232 +347,234 @@ function replaceCaret(comp, loose) { // ^1.2.3 --> >=1.2.3 <2.0.0 // ^1.2.0 --> >=1.2.0 <2.0.0 function replaceCarets(comp, loose) { - return comp - .trim() - .split(/\s+/) - .map((comp1) => replaceCaret(comp1, loose)) - .join(" "); + return comp + .trim() + .split(/\s+/) + .map((comp1) => replaceCaret(comp1, loose)) + .join(" "); } function replaceXRange(comp, loose) { - comp = comp.trim(); - const regex = loose ? re[XRANGELOOSE] : re[XRANGE]; + comp = comp.trim(); + const regex = loose ? re[XRANGELOOSE] : re[XRANGE]; - return comp.replace(regex, function (ret, operator, major, minor, patch) { - const xM = isX(major); - const xm = xM || isX(minor); - const xp = xm || isX(patch); - const anyX = xp; + return comp.replace(regex, function (ret, operator, major, minor, patch) { + const xM = isX(major); + const xm = xM || isX(minor); + const xp = xm || isX(patch); + const anyX = xp; - if (operator === "=" && anyX) { - operator = ""; - } + if (operator === "=" && anyX) { + operator = ""; + } - if (xM) { - if (operator === ">" || operator === "<") { - // Nothing is allowed - ret = "<0.0.0"; - } else { - // Nothing is forbidden - ret = "*"; - } - } else if (operator && anyX) { - // Replace X with 0 - if (xm) { - minor = 0; - } - if (xp) { - patch = 0; - } + if (xM) { + if (operator === ">" || operator === "<") { + // Nothing is allowed + ret = "<0.0.0"; + } else { + // Nothing is forbidden + ret = "*"; + } + } else if (operator && anyX) { + // Replace X with 0 + if (xm) { + minor = 0; + } + if (xp) { + patch = 0; + } - if (operator === ">") { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 - operator = ">="; - if (xm) { - major = Number(major) + 1; - minor = 0; - patch = 0; - } else if (xp) { - minor = Number(minor) + 1; - patch = 0; - } - } else if (operator === "<=") { - // <=0.7.x is actually <0.8.0, since any 0.7.x should pass. Similarly, <=7.x is actually <8.0.0, etc. - operator = "<"; - if (xm) { - major = Number(major) + 1; - } else { - minor = Number(minor) + 1; - } - } - - ret = `${operator}${major}.${minor}.${patch}`; - } else if (xm) { - ret = `>=${major}.0.0 <${Number(major) + 1}.0.0`; + if (operator === ">") { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + operator = ">="; + if (xm) { + major = Number(major) + 1; + minor = 0; + patch = 0; } else if (xp) { - ret = `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0`; + minor = Number(minor) + 1; + patch = 0; } + } else if (operator === "<=") { + // <=0.7.x is actually <0.8.0, since any 0.7.x should pass. Similarly, <=7.x is actually <8.0.0, etc. + operator = "<"; + if (xm) { + major = Number(major) + 1; + } else { + minor = Number(minor) + 1; + } + } - return ret; - }); + ret = `${operator}${major}.${minor}.${patch}`; + } else if (xm) { + ret = `>=${major}.0.0 <${Number(major) + 1}.0.0`; + } else if (xp) { + ret = `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0`; + } + + return ret; + }); } function replaceXRanges(comp, loose) { - return comp - .split(/\s+/) - .map((comp1) => replaceXRange(comp1, loose)) - .join(" "); + return comp + .split(/\s+/) + .map((comp1) => replaceXRange(comp1, loose)) + .join(" "); } // Because * is AND-ed with everything else in the comparator, and '' means "any version", just remove the *s entirely. function replaceStars(comp) { - // Looseness is ignored here. star is always as loose as it gets! - return comp.trim().replace(re[STAR], ""); + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[STAR], ""); } // Comprised of xranges, tildes, stars, and gtlt's at this point. // Already replaced the hyphen ranges turn into a set of JUST comparators. function parseComparator(comp, loose) { - comp = replaceCarets(comp, loose); - comp = replaceTildes(comp, loose); - comp = replaceXRanges(comp, loose); - comp = replaceStars(comp, loose); + comp = replaceCarets(comp, loose); + comp = replaceTildes(comp, loose); + comp = replaceXRanges(comp, loose); + comp = replaceStars(comp, loose); - return comp; + return comp; } class SemVer { - - /** + /** * A semantic version. * @param {string} version The version. * @param {boolean} loose If this is a loose representation of a version. * @returns {SemVer} a new instance. */ - constructor(version, loose) { - if (version instanceof SemVer) { - if (version.loose === loose) { - return version; - } - version = version.version; - } else if (typeof version !== "string") { - throw new TypeError(`Invalid Version: ${version}`); + constructor(version, loose) { + if (version instanceof SemVer) { + if (version.loose === loose) { + return version; + } + version = version.version; + } else if (typeof version !== "string") { + throw new TypeError(`Invalid Version: ${version}`); + } + if (version.length > MAX_LENGTH) { + throw new TypeError(`version is longer than ${MAX_LENGTH} characters`); + } + if (!(this instanceof SemVer)) { + return new SemVer(version, loose); + } + this.loose = loose; + const matches = version.trim().match(loose ? re[LOOSE] : re[FULL]); + if (!matches) { + throw new TypeError(`Invalid Version: ${version}`); + } + this.raw = version; + // These are actually numbers + this.major = Number(matches[1]); + this.minor = Number(matches[2]); + this.patch = Number(matches[3]); + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError("Invalid major version"); + } + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError("Invalid minor version"); + } + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError("Invalid patch version"); + } + // Numberify any prerelease numeric ids + if (matches[4]) { + this.prerelease = matches[4].split(".").map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = Number(id); + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num; + } } - if (version.length > MAX_LENGTH) { - throw new TypeError(`version is longer than ${MAX_LENGTH} characters`); - } - if (!(this instanceof SemVer)) { - return new SemVer(version, loose); - } - this.loose = loose; - const matches = version.trim().match(loose ? re[LOOSE] : re[FULL]); - if (!matches) { - throw new TypeError(`Invalid Version: ${version}`); - } - this.raw = version; - // These are actually numbers - this.major = Number(matches[1]); - this.minor = Number(matches[2]); - this.patch = Number(matches[3]); - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); - } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); - } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); - } - // Numberify any prerelease numeric ids - if (matches[4]) { - this.prerelease = matches[4].split(".").map((id) => { - if ((/^[0-9]+$/).test(id)) { - const num = Number(id); - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num; - } - } - return id; - }); - } else { - this.prerelease = []; - } - this.build = matches[5] ? matches[5].split(".") : []; - this.format(); + return id; + }); + } else { + this.prerelease = []; + } + this.build = matches[5] ? matches[5].split(".") : []; + this.format(); + } + + format() { + this.version = `${this.major}.${this.minor}.${this.patch}`; + if (this.prerelease.length) { + this.version += `-${this.prerelease.join(".")}`; } - format() { - this.version = `${this.major}.${this.minor}.${this.patch}`; - if (this.prerelease.length) { - this.version += `-${this.prerelease.join(".")}`; - } + return this.version; + } - return this.version; - } + toString() { + return this.version; + } - toString() { - return this.version; - } - - /** + /** * Comares the current instance against another instance. * @param {SemVer} other The SemVer to comare to. * @returns {0|1|-1} A comparable value for sorting. */ - compare(other) { - return this.compareMain(other) || this.comparePre(other); + compare(other) { + return this.compareMain(other) || this.comparePre(other); + } + + compareMain(other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.loose); } - compareMain(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.loose); - } + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ); + } - return ( - compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch) - ); + comparePre(other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.loose); } - - comparePre(other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.loose); - } - // NOT having a prerelease is > having one - if (this.prerelease.length && !other.prerelease.length) { - return -1; - } else if (!this.prerelease.length && other.prerelease.length) { - return 1; - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0; - } - let idx = 0; - do { - const thisPrelease = this.prerelease[idx]; - const otherPrelease = other.prerelease[idx]; - const thisPreleaseIsUndefined = typeof thisPrelease === "undefined"; - const otherPreleaseIsUndefined = typeof otherPrelease === "undefined"; - if (thisPreleaseIsUndefined && otherPreleaseIsUndefined) { - return 0; - } else if (otherPreleaseIsUndefined) { - return 1; - } else if (thisPreleaseIsUndefined) { - return -1; - } else if (thisPrelease === otherPrelease) { - continue; - } else { - return compareIdentifiers(thisPrelease, otherPrelease); - } - } while ((idx += 1) > 0); - - // Should not hit this point, but assume equal ranking. + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1; + } else if (!this.prerelease.length && other.prerelease.length) { + return 1; + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0; + } + let idx = 0; + do { + const thisPrelease = this.prerelease[idx]; + const otherPrelease = other.prerelease[idx]; + const thisPreleaseIsUndefined = typeof thisPrelease === "undefined"; + const otherPreleaseIsUndefined = typeof otherPrelease === "undefined"; + if (thisPreleaseIsUndefined && otherPreleaseIsUndefined) { return 0; - } + } else if (otherPreleaseIsUndefined) { + return 1; + } else if (thisPreleaseIsUndefined) { + return -1; + } else if (thisPrelease === otherPrelease) { + continue; + } else { + return compareIdentifiers(thisPrelease, otherPrelease); + } + } while ((idx += 1) > 0); + + // Should not hit this point, but assume equal ranking. + return 0; + } } -const compare = (leftVersion, rightVersion, loose) => new SemVer(leftVersion, loose).compare(new SemVer(rightVersion, loose)); +const compare = (leftVersion, rightVersion, loose) => + new SemVer(leftVersion, loose).compare(new SemVer(rightVersion, loose)); const gt = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) > 0; const lt = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) < 0; const eq = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) === 0; @@ -607,136 +583,134 @@ const gte = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVers const lte = (leftVersion, rightVersion, loose) => compare(leftVersion, rightVersion, loose) <= 0; function cmp(left, op, right, loose) { - let ret; - switch (op) { - case "===": - if (typeof left === "object") { - left = left.version; - } - if (typeof right === "object") { - right = right.version; - } - ret = left === right; - break; - case "!==": - if (typeof left === "object") { - left = left.version; - } - if (typeof right === "object") { - right = right.version; - } - ret = left !== right; - break; - case "": - case "=": - case "==": - ret = eq(left, right, loose); - break; - case "!=": - ret = neq(left, right, loose); - break; - case ">": - ret = gt(left, right, loose); - break; - case ">=": - ret = gte(left, right, loose); - break; - case "<": - ret = lt(left, right, loose); - break; - case "<=": - ret = lte(left, right, loose); - break; - default: - throw new TypeError(`Invalid operator: ${op}`); - } + let ret; + switch (op) { + case "===": + if (typeof left === "object") { + left = left.version; + } + if (typeof right === "object") { + right = right.version; + } + ret = left === right; + break; + case "!==": + if (typeof left === "object") { + left = left.version; + } + if (typeof right === "object") { + right = right.version; + } + ret = left !== right; + break; + case "": + case "=": + case "==": + ret = eq(left, right, loose); + break; + case "!=": + ret = neq(left, right, loose); + break; + case ">": + ret = gt(left, right, loose); + break; + case ">=": + ret = gte(left, right, loose); + break; + case "<": + ret = lt(left, right, loose); + break; + case "<=": + ret = lte(left, right, loose); + break; + default: + throw new TypeError(`Invalid operator: ${op}`); + } - return ret; + return ret; } function testSet(set, version) { - for (let idx = 0; idx < set.length; idx++) { - if (!set[idx].test(version)) { - return false; - } + for (let idx = 0; idx < set.length; idx++) { + if (!set[idx].test(version)) { + return false; } + } - if (version.prerelease.length) { + if (version.prerelease.length) { // Find the set of versions that are allowed to have prereleases // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 // That should allow `1.2.3-pr.2` to pass. // However, `1.2.4-alpha.notready` should NOT be allowed, even though it's within the range set by the comparators. - for (let idx = 0; idx < set.length; idx++) { - if (set[idx].semver !== ANY) { - if (set[idx].semver.prerelease.length > 0) { - const allowed = set[idx].semver; - if ( - allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch - ) { - return true; - } - } - } + for (let idx = 0; idx < set.length; idx++) { + if (set[idx].semver !== ANY) { + if (set[idx].semver.prerelease.length > 0) { + const allowed = set[idx].semver; + if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) { + return true; + } } - - // Version has a -pre, but it's not one of the ones we like. - return false; + } } - return true; + // Version has a -pre, but it's not one of the ones we like. + return false; + } + + return true; } class Comparator { - constructor(comp, loose) { - if (comp instanceof Comparator) { - if (comp.loose === loose) { - return comp; - } - comp = comp.value; - } - if (!(this instanceof Comparator)) { - return new Comparator(comp, loose); - } - this.loose = loose; - this.parse(comp); - if (this.semver === ANY) { - this.value = ""; - } else { - this.value = this.operator + this.semver.version; - } + constructor(comp, loose) { + if (comp instanceof Comparator) { + if (comp.loose === loose) { + return comp; + } + comp = comp.value; + } + if (!(this instanceof Comparator)) { + return new Comparator(comp, loose); + } + this.loose = loose; + this.parse(comp); + if (this.semver === ANY) { + this.value = ""; + } else { + this.value = this.operator + this.semver.version; + } + } + + parse(comp) { + const regex = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + const matches = comp.match(regex); + if (!matches) { + throw new TypeError(`Invalid comparator: ${comp}`); + } + this.operator = matches[1]; + if (this.operator === "=") { + this.operator = ""; + } + // If it literally is just '>' or '' then allow anything. + if (matches[2]) { + this.semver = new SemVer(matches[2], this.loose); + } else { + this.semver = ANY; + } + } + + toString() { + return this.value; + } + + test(version) { + if (this.semver === ANY) { + return true; + } + if (typeof version === "string") { + version = new SemVer(version, this.loose); } - parse(comp) { - const regex = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; - const matches = comp.match(regex); - if (!matches) { - throw new TypeError(`Invalid comparator: ${comp}`); - } - this.operator = matches[1]; - if (this.operator === "=") { - this.operator = ""; - } - // If it literally is just '>' or '' then allow anything. - if (matches[2]) { - this.semver = new SemVer(matches[2], this.loose); - } else { - this.semver = ANY; - } - } - - toString() { - return this.value; - } - - test(version) { - if (this.semver === ANY) { - return true; - } - if (typeof version === "string") { - version = new SemVer(version, this.loose); - } - - return cmp(version, this.operator, this.semver, this.loose); - } + return cmp(version, this.operator, this.semver, this.loose); + } } /** @@ -746,99 +720,99 @@ class Comparator { * @returns {Range} the Range instace. */ class Range { - constructor(range, loose) { - if (range instanceof Range) { - if (range.loose === loose) { - return range; - } + constructor(range, loose) { + if (range instanceof Range) { + if (range.loose === loose) { + return range; + } - return new Range(range.raw, loose); - } - if (range instanceof Comparator) { - return new Range(range.value, loose); - } - if (!(this instanceof Range)) { - return new Range(range, loose); - } - this.loose = loose; - // First, split based on boolean or || - /** + return new Range(range.raw, loose); + } + if (range instanceof Comparator) { + return new Range(range.value, loose); + } + if (!(this instanceof Range)) { + return new Range(range, loose); + } + this.loose = loose; + // First, split based on boolean or || + /** * @type {string} */ - this.raw = range; - // Throw out any that are not relevant for whatever reason - const hasLength = (item) => item.length; - this.set = this.raw - .split(/\s*\|\|\s*/) - .map(function (range1) { - return this.parseRange(range1.trim()); - }, this) - .filter(hasLength); - if (!this.set.length) { - throw new TypeError(`Invalid SemVer Range: ${range}`); - } - this.format(); + this.raw = range; + // Throw out any that are not relevant for whatever reason + const hasLength = (item) => item.length; + this.set = this.raw + .split(/\s*\|\|\s*/) + .map(function (range1) { + return this.parseRange(range1.trim()); + }, this) + .filter(hasLength); + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${range}`); + } + this.format(); + } + + format() { + this.range = this.set + .map((comps) => comps.join(" ").trim()) + .join("||") + .trim(); + + return this.range; + } + + toString() { + return this.range; + } + + parseRange(range) { + const loose = this.loose; + range = range.trim(); + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]; + range = range.replace(hr, hyphenReplace); + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace); + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[TILDETRIM], tildeTrimReplace); + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[CARETTRIM], caretTrimReplace); + // Normalize spaces + range = range.split(/\s+/).join(" "); + // At this point, the range is completely trimmed and ready to be split into comparators. + const compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + let set = range + .split(" ") + .map((comp) => parseComparator(comp, loose)) + .join(" ") + .split(/\s+/); + if (loose) { + // In loose mode, throw out any that are not valid comparators + set = set.filter((comp) => Boolean(comp.match(compRe))); + } + set = set.map((comp) => new Comparator(comp, loose)); + + return set; + } + + // If ANY of the sets match ALL of its comparators, then pass + test(version) { + if (!version) { + return false; + } + if (typeof version === "string") { + version = new SemVer(version, this.loose); + } + for (let idx = 0; idx < this.set.length; idx++) { + if (testSet(this.set[idx], version)) { + return true; + } } - format() { - this.range = this.set - .map((comps) => comps.join(" ").trim()) - .join("||") - .trim(); - - return this.range; - } - - toString() { - return this.range; - } - - parseRange(range) { - const loose = this.loose; - range = range.trim(); - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - const hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]; - range = range.replace(hr, hyphenReplace); - // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` - range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace); - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[TILDETRIM], tildeTrimReplace); - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[CARETTRIM], caretTrimReplace); - // Normalize spaces - range = range.split(/\s+/).join(" "); - // At this point, the range is completely trimmed and ready to be split into comparators. - const compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; - let set = range - .split(" ") - .map((comp) => parseComparator(comp, loose)) - .join(" ") - .split(/\s+/); - if (loose) { - // In loose mode, throw out any that are not valid comparators - set = set.filter((comp) => Boolean(comp.match(compRe))); - } - set = set.map((comp) => new Comparator(comp, loose)); - - return set; - } - - // If ANY of the sets match ALL of its comparators, then pass - test(version) { - if (!version) { - return false; - } - if (typeof version === "string") { - version = new SemVer(version, this.loose); - } - for (let idx = 0; idx < this.set.length; idx++) { - if (testSet(this.set[idx], version)) { - return true; - } - } - - return false; - } + return false; + } } /** @@ -849,13 +823,13 @@ class Range { * @returns {boolean} Whether the versions successfully satisfies the range. */ function satisfies(version, range, loose) { - try { - const rangeObj = new Range(range, loose); + try { + const rangeObj = new Range(range, loose); - return rangeObj.test(version); - } catch (er) { - return false; - } + return rangeObj.test(version); + } catch (er) { + return false; + } } module.exports.satisfies = satisfies; diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index 795c16cdf..6a32d775d 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -8,11 +8,7 @@ import { Factions } from "../Faction/Factions"; import { numeralWrapper } from "../ui/numeralFormat"; import { Money } from "../ui/React/Money"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; interface IConstructorParams { info: string | JSX.Element; @@ -58,11 +54,7 @@ interface IConstructorParams { programs?: string[]; } -function generateStatsDescription( - mults: IMap, - programs?: string[], - startingMoney?: number, -): JSX.Element { +function generateStatsDescription(mults: IMap, programs?: string[], startingMoney?: number): JSX.Element { const f = (x: number, decimals = 0): string => { // look, I don't know how to make a "smart decimals" // todo, make it smarter @@ -224,8 +216,7 @@ function generateStatsDescription( desc = ( <> {desc} -
+{f(mults.hacking_speed_mult - 1)} faster hack(), grow(), and - weaken() +
+{f(mults.hacking_speed_mult - 1)} faster hack(), grow(), and weaken() ); if (mults.hacking_chance_mult) @@ -250,15 +241,11 @@ function generateStatsDescription( ); - if ( - mults.faction_rep_mult && - mults.faction_rep_mult === mults.company_rep_mult - ) { + if (mults.faction_rep_mult && mults.faction_rep_mult === mults.company_rep_mult) { desc = ( <> {desc} -
+{f(mults.faction_rep_mult - 1)} reputation from factions and - companies +
+{f(mults.faction_rep_mult - 1)} reputation from factions and companies ); } else { @@ -311,16 +298,14 @@ function generateStatsDescription( desc = ( <> {desc} -
-{f(-(mults.hacknet_node_purchase_cost_mult - 1))} hacknet nodes - cost +
-{f(-(mults.hacknet_node_purchase_cost_mult - 1))} hacknet nodes cost ); if (mults.hacknet_node_level_cost_mult) desc = ( <> {desc} -
-{f(-(mults.hacknet_node_level_cost_mult - 1))} hacknet nodes - upgrade cost +
-{f(-(mults.hacknet_node_level_cost_mult - 1))} hacknet nodes upgrade cost ); @@ -328,32 +313,28 @@ function generateStatsDescription( desc = ( <> {desc} -
+{f(mults.bladeburner_max_stamina_mult - 1)} Bladeburner Max - Stamina +
+{f(mults.bladeburner_max_stamina_mult - 1)} Bladeburner Max Stamina ); if (mults.bladeburner_stamina_gain_mult) desc = ( <> {desc} -
+{f(mults.bladeburner_stamina_gain_mult - 1)} Bladeburner Stamina - gain +
+{f(mults.bladeburner_stamina_gain_mult - 1)} Bladeburner Stamina gain ); if (mults.bladeburner_analysis_mult) desc = ( <> {desc} -
+{f(mults.bladeburner_analysis_mult - 1)} Bladeburner Field - Analysis effectiveness +
+{f(mults.bladeburner_analysis_mult - 1)} Bladeburner Field Analysis effectiveness ); if (mults.bladeburner_success_chance_mult) desc = ( <> {desc} -
+{f(mults.bladeburner_success_chance_mult - 1)} Bladeburner - Contracts and Operations success chance +
+{f(mults.bladeburner_success_chance_mult - 1)} Bladeburner Contracts and Operations success chance ); @@ -362,8 +343,7 @@ function generateStatsDescription( <> {desc}
- Start with after installing - Augmentations. + Start with after installing Augmentations. ); @@ -425,8 +405,7 @@ export class Augmentation { this.info = params.info; this.prereqs = params.prereqs ? params.prereqs : []; - this.baseRepRequirement = - params.repCost * BitNodeMultipliers.AugmentationRepCost; + this.baseRepRequirement = params.repCost * BitNodeMultipliers.AugmentationRepCost; this.baseCost = params.moneyCost * BitNodeMultipliers.AugmentationMoneyCost; this.startingCost = this.baseCost; @@ -504,43 +483,32 @@ export class Augmentation { this.mults.hacknet_node_money_mult = params.hacknet_node_money_mult; } if (params.hacknet_node_purchase_cost_mult) { - this.mults.hacknet_node_purchase_cost_mult = - params.hacknet_node_purchase_cost_mult; + this.mults.hacknet_node_purchase_cost_mult = params.hacknet_node_purchase_cost_mult; } if (params.hacknet_node_ram_cost_mult) { this.mults.hacknet_node_ram_cost_mult = params.hacknet_node_ram_cost_mult; } if (params.hacknet_node_core_cost_mult) { - this.mults.hacknet_node_core_cost_mult = - params.hacknet_node_core_cost_mult; + this.mults.hacknet_node_core_cost_mult = params.hacknet_node_core_cost_mult; } if (params.hacknet_node_level_cost_mult) { - this.mults.hacknet_node_level_cost_mult = - params.hacknet_node_level_cost_mult; + this.mults.hacknet_node_level_cost_mult = params.hacknet_node_level_cost_mult; } if (params.bladeburner_max_stamina_mult) { - this.mults.bladeburner_max_stamina_mult = - params.bladeburner_max_stamina_mult; + this.mults.bladeburner_max_stamina_mult = params.bladeburner_max_stamina_mult; } if (params.bladeburner_stamina_gain_mult) { - this.mults.bladeburner_stamina_gain_mult = - params.bladeburner_stamina_gain_mult; + this.mults.bladeburner_stamina_gain_mult = params.bladeburner_stamina_gain_mult; } if (params.bladeburner_analysis_mult) { this.mults.bladeburner_analysis_mult = params.bladeburner_analysis_mult; } if (params.bladeburner_success_chance_mult) { - this.mults.bladeburner_success_chance_mult = - params.bladeburner_success_chance_mult; + this.mults.bladeburner_success_chance_mult = params.bladeburner_success_chance_mult; } if (params.stats) this.stats = params.stats; - else - this.stats = generateStatsDescription( - this.mults, - params.programs, - params.startingMoney, - ); + else this.stats = generateStatsDescription(this.mults, params.programs, params.startingMoney); } // Adds this Augmentation to the specified Factions @@ -548,9 +516,7 @@ export class Augmentation { for (let i = 0; i < factionList.length; ++i) { const faction: Faction | null = Factions[factionList[i]]; if (faction == null) { - console.warn( - `In Augmentation.addToFactions(), could not find faction with this name: ${factionList[i]}`, - ); + console.warn(`In Augmentation.addToFactions(), could not find faction with this name: ${factionList[i]}`); continue; } faction.augmentations.push(this.name); @@ -563,9 +529,7 @@ export class Augmentation { if (Factions.hasOwnProperty(fac)) { const facObj: Faction | null = Factions[fac]; if (facObj == null) { - console.warn( - `Invalid Faction object in addToAllFactions(). Key value: ${fac}`, - ); + console.warn(`Invalid Faction object in addToAllFactions(). Key value: ${fac}`); continue; } facObj.augmentations.push(this.name); diff --git a/src/Augmentation/AugmentationHelpers.jsx b/src/Augmentation/AugmentationHelpers.jsx index 135f08773..e9da71d17 100644 --- a/src/Augmentation/AugmentationHelpers.jsx +++ b/src/Augmentation/AugmentationHelpers.jsx @@ -141,9 +141,7 @@ function initAugmentations() { Object.keys(randomBonuses.bonuses).forEach( (key) => (UnstableCircadianModulatorParams[key] = randomBonuses.bonuses[key]), ); - const UnstableCircadianModulator = new Augmentation( - UnstableCircadianModulatorParams, - ); + const UnstableCircadianModulator = new Augmentation(UnstableCircadianModulatorParams); UnstableCircadianModulator.addToFactions(["Speakers for the Dead"]); if (augmentationExists(AugmentationNames.UnstableCircadianModulator)) { @@ -156,9 +154,7 @@ function initAugmentations() { name: AugmentationNames.HemoRecirculator, moneyCost: 4.5e7, repCost: 1e4, - info: - "A heart implant that greatly increases the body's ability to effectively use and pump " + - "blood.", + info: "A heart implant that greatly increases the body's ability to effectively use and pump " + "blood.", strength_mult: 1.08, defense_mult: 1.08, agility_mult: 1.08, @@ -221,9 +217,7 @@ function initAugmentations() { name: AugmentationNames.Targeting3, moneyCost: 1.15e8, repCost: 2.75e4, - info: - "The latest version of the 'Augmented Targeting' implant adds the ability to " + - "lock-on and track threats.", + info: "The latest version of the 'Augmented Targeting' implant adds the ability to " + "lock-on and track threats.", prereqs: [AugmentationNames.Targeting2], dexterity_mult: 1.3, }); @@ -442,15 +436,11 @@ function initAugmentations() { repCost: 1.125e6, moneyCost: 4.25e9, info: - "Graphene is grafted and fused into the skeletal structure, " + - "enhancing bone density and tensile strength.", + "Graphene is grafted and fused into the skeletal structure, " + "enhancing bone density and tensile strength.", strength_mult: 1.7, defense_mult: 1.7, }); - GrapheneBoneLacings.addToFactions([ - "Fulcrum Secret Technologies", - "The Covenant", - ]); + GrapheneBoneLacings.addToFactions(["Fulcrum Secret Technologies", "The Covenant"]); if (augmentationExists(AugmentationNames.GrapheneBoneLacings)) { delete Augmentations[AugmentationNames.GrapheneBoneLacings]; } @@ -530,11 +520,7 @@ function initAugmentations() { prereqs: [AugmentationNames.BionicLegs], agility_mult: 2.5, }); - GrapheneBionicLegs.addToFactions([ - "MegaCorp", - "ECorp", - "Fulcrum Secret Technologies", - ]); + GrapheneBionicLegs.addToFactions(["MegaCorp", "ECorp", "Fulcrum Secret Technologies"]); if (augmentationExists(AugmentationNames.GrapheneBionicLegs)) { delete Augmentations[AugmentationNames.GrapheneBionicLegs]; } @@ -638,10 +624,7 @@ function initAugmentations() { hacking_money_mult: 1.15, hacking_mult: 1.12, }); - ArtificialBioNeuralNetwork.addToFactions([ - "BitRunners", - "Fulcrum Secret Technologies", - ]); + ArtificialBioNeuralNetwork.addToFactions(["BitRunners", "Fulcrum Secret Technologies"]); if (augmentationExists(AugmentationNames.ArtificialBioNeuralNetwork)) { delete Augmentations[AugmentationNames.ArtificialBioNeuralNetwork]; } @@ -677,11 +660,7 @@ function initAugmentations() { hacking_exp_mult: 1.1, hacking_mult: 1.08, }); - EnhancedMyelinSheathing.addToFactions([ - "Fulcrum Secret Technologies", - "BitRunners", - "The Black Hand", - ]); + EnhancedMyelinSheathing.addToFactions(["Fulcrum Secret Technologies", "BitRunners", "The Black Hand"]); if (augmentationExists(AugmentationNames.EnhancedMyelinSheathing)) { delete Augmentations[AugmentationNames.EnhancedMyelinSheathing]; } @@ -727,13 +706,7 @@ function initAugmentations() { "and delete it.", hacking_money_mult: 1.25, }); - DataJack.addToFactions([ - "BitRunners", - "The Black Hand", - "NiteSec", - "Chongqing", - "New Tokyo", - ]); + DataJack.addToFactions(["BitRunners", "The Black Hand", "NiteSec", "Chongqing", "New Tokyo"]); if (augmentationExists(AugmentationNames.DataJack)) { delete Augmentations[AugmentationNames.DataJack]; } @@ -1001,11 +974,7 @@ function initAugmentations() { hacking_money_mult: 1.15, hacking_mult: 1.09, }); - CranialSignalProcessorsG3.addToFactions([ - "NiteSec", - "The Black Hand", - "BitRunners", - ]); + CranialSignalProcessorsG3.addToFactions(["NiteSec", "The Black Hand", "BitRunners"]); if (augmentationExists(AugmentationNames.CranialSignalProcessorsG3)) { delete Augmentations[AugmentationNames.CranialSignalProcessorsG3]; } @@ -1122,9 +1091,7 @@ function initAugmentations() { name: AugmentationNames.FocusWire, repCost: 7.5e4, moneyCost: 9e8, - info: - "A cranial implant that stops procrastination by blocking specific neural pathways " + - "in the brain.", + info: "A cranial implant that stops procrastination by blocking specific neural pathways " + "in the brain.", hacking_exp_mult: 1.05, strength_exp_mult: 1.05, defense_exp_mult: 1.05, @@ -1134,12 +1101,7 @@ function initAugmentations() { company_rep_mult: 1.1, work_money_mult: 1.2, }); - FocusWire.addToFactions([ - "Bachman & Associates", - "Clarke Incorporated", - "Four Sigma", - "KuaiGong International", - ]); + FocusWire.addToFactions(["Bachman & Associates", "Clarke Incorporated", "Four Sigma", "KuaiGong International"]); if (augmentationExists(AugmentationNames.FocusWire)) { delete Augmentations[AugmentationNames.FocusWire]; } @@ -1156,12 +1118,7 @@ function initAugmentations() { company_rep_mult: 1.3, hacking_mult: 1.08, }); - PCDNI.addToFactions([ - "Four Sigma", - "OmniTek Incorporated", - "ECorp", - "Blade Industries", - ]); + PCDNI.addToFactions(["Four Sigma", "OmniTek Incorporated", "ECorp", "Blade Industries"]); if (augmentationExists(AugmentationNames.PCDNI)) { delete Augmentations[AugmentationNames.PCDNI]; } @@ -1179,11 +1136,7 @@ function initAugmentations() { company_rep_mult: 1.75, hacking_mult: 1.1, }); - PCDNIOptimizer.addToFactions([ - "Fulcrum Secret Technologies", - "ECorp", - "Blade Industries", - ]); + PCDNIOptimizer.addToFactions(["Fulcrum Secret Technologies", "ECorp", "Blade Industries"]); if (augmentationExists(AugmentationNames.PCDNIOptimizer)) { delete Augmentations[AugmentationNames.PCDNIOptimizer]; } @@ -1220,13 +1173,7 @@ function initAugmentations() { company_rep_mult: 1.1, faction_rep_mult: 1.1, }); - ADRPheromone1.addToFactions([ - "Tian Di Hui", - "The Syndicate", - "NWO", - "MegaCorp", - "Four Sigma", - ]); + ADRPheromone1.addToFactions(["Tian Di Hui", "The Syndicate", "NWO", "MegaCorp", "Four Sigma"]); if (augmentationExists(AugmentationNames.ADRPheromone1)) { delete Augmentations[AugmentationNames.ADRPheromone1]; } @@ -1243,12 +1190,7 @@ function initAugmentations() { company_rep_mult: 1.2, faction_rep_mult: 1.2, }); - ADRPheromone2.addToFactions([ - "Silhouette", - "Four Sigma", - "Bachman & Associates", - "Clarke Incorporated", - ]); + ADRPheromone2.addToFactions(["Silhouette", "Four Sigma", "Bachman & Associates", "Clarke Incorporated"]); if (augmentationExists(AugmentationNames.ADRPheromone2)) { delete Augmentations[AugmentationNames.ADRPheromone2]; } @@ -1267,11 +1209,7 @@ function initAugmentations() { company_rep_mult: 1.15, faction_rep_mult: 1.15, }); - ShadowsSimulacrum.addToFactions([ - "The Syndicate", - "The Dark Army", - "Speakers for the Dead", - ]); + ShadowsSimulacrum.addToFactions(["The Syndicate", "The Dark Army", "Speakers for the Dead"]); if (augmentationExists(AugmentationNames.ShadowsSimulacrum)) { delete Augmentations[AugmentationNames.ShadowsSimulacrum]; } @@ -1373,9 +1311,8 @@ function initAugmentations() { "body's nervous system.", stats: ( <> - This special augmentation can be leveled up infinitely. Each level of - this augmentation increases ALL multipliers by 1%, stacking - multiplicatively. + This special augmentation can be leveled up infinitely. Each level of this augmentation increases ALL + multipliers by 1%, stacking multiplicatively. ), hacking_chance_mult: 1.01, @@ -1419,17 +1356,13 @@ function initAugmentations() { // levels that are purchased but not yet installed let nextLevel = currLevel; for (let i = 0; i < Player.queuedAugmentations.length; ++i) { - if ( - Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor - ) { + if (Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor) { ++nextLevel; } } let mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); - NeuroFluxGovernor.baseRepRequirement = - 500 * mult * BitNodeMultipliers.AugmentationRepCost; - NeuroFluxGovernor.baseCost = - 750e3 * mult * BitNodeMultipliers.AugmentationMoneyCost; + NeuroFluxGovernor.baseRepRequirement = 500 * mult * BitNodeMultipliers.AugmentationRepCost; + NeuroFluxGovernor.baseCost = 750e3 * mult * BitNodeMultipliers.AugmentationMoneyCost; if (augmentationExists(AugmentationNames.NeuroFluxGovernor)) { delete Augmentations[AugmentationNames.NeuroFluxGovernor]; } @@ -1559,9 +1492,7 @@ function initAugmentations() { name: AugmentationNames.SmartSonar, repCost: 2.25e4, moneyCost: 7.5e7, - info: - "A cochlear implant that helps the player detect and locate enemies " + - "using sound propagation.", + info: "A cochlear implant that helps the player detect and locate enemies " + "using sound propagation.", dexterity_mult: 1.1, dexterity_exp_mult: 1.15, crime_money_mult: 1.25, @@ -1593,12 +1524,7 @@ function initAugmentations() { agility_exp_mult: 1.1, charisma_exp_mult: 1.1, }); - PowerRecirculator.addToFactions([ - "Tetrads", - "The Dark Army", - "The Syndicate", - "NWO", - ]); + PowerRecirculator.addToFactions(["Tetrads", "The Dark Army", "The Syndicate", "NWO"]); if (augmentationExists(AugmentationNames.PowerRecirculator)) { delete Augmentations[AugmentationNames.PowerRecirculator]; } @@ -1941,9 +1867,8 @@ function initAugmentations() { moneyCost: 1.25e8, info: ( <> - A collection of digital assets saved on a small chip. The chip is - implanted into your wrist. A small jack in the chip allows you to - connect it to a computer and upload the assets. + A collection of digital assets saved on a small chip. The chip is implanted into your wrist. A small jack in the + chip allows you to connect it to a computer and upload the assets. ), startingMoney: 1e6, @@ -2006,8 +1931,7 @@ function initAugmentations() { repCost: 7.5e3, moneyCost: 3e7, info: - "A tiny chip that sits behind the retinae. This implant lets the" + - "user visually detect infrared radiation.", + "A tiny chip that sits behind the retinae. This implant lets the" + "user visually detect infrared radiation.", crime_success_mult: 1.25, crime_money_mult: 1.1, dexterity_mult: 1.1, @@ -2098,8 +2022,7 @@ function initAugmentations() { repCost: 6.25e4, moneyCost: 2.75e8, info: - "Cybernetic arms created from plasteel and carbon fibers that completely replace " + - "the user's organic arms.", + "Cybernetic arms created from plasteel and carbon fibers that completely replace " + "the user's organic arms.", strength_mult: 1.3, dexterity_mult: 1.3, }); @@ -2417,8 +2340,8 @@ function initAugmentations() { "weaponized by Bladeburner units to be used against Synthoids.", stats: ( <> - This augmentation allows you to perform Bladeburner actions and other - actions (such as working, commiting crimes, etc.) at the same time. + This augmentation allows you to perform Bladeburner actions and other actions (such as working, commiting + crimes, etc.) at the same time. ), isSpecial: true, @@ -2429,8 +2352,7 @@ function initAugmentations() { // Update costs based on how many have been purchased mult = Math.pow( - CONSTANTS.MultipleAugMultiplier * - [1, 0.96, 0.94, 0.93][SourceFileFlags[11]], + CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]], Player.queuedAugmentations.length, ); for (var name in Augmentations) { @@ -2445,9 +2367,7 @@ function initAugmentations() { //Resets an Augmentation during (re-initizliation) function resetAugmentation(newAugObject) { if (!(newAugObject instanceof Augmentation)) { - throw new Error( - "Invalid argument 'newAugObject' passed into resetAugmentation", - ); + throw new Error("Invalid argument 'newAugObject' passed into resetAugmentation"); } var name = newAugObject.name; if (augmentationExists(name)) { @@ -2464,9 +2384,7 @@ function applyAugmentation(aug, reapply = false) { // Apply multipliers for (const mult in augObj.mults) { if (Player[mult] == null) { - console.warn( - `Augmentation has unrecognized multiplier property: ${mult}`, - ); + console.warn(`Augmentation has unrecognized multiplier property: ${mult}`); } else { Player[mult] *= augObj.mults[mult]; } @@ -2477,9 +2395,7 @@ function applyAugmentation(aug, reapply = false) { if (!reapply) { Augmentations[aug.name].level = aug.level; for (let i = 0; i < Player.augmentations.length; ++i) { - if ( - Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor - ) { + if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { Player.augmentations[i].level = aug.level; return; // break; @@ -2503,9 +2419,7 @@ function installAugmentations() { let augmentationList = ""; let nfgIndex = -1; for (let i = Player.queuedAugmentations.length - 1; i >= 0; i--) { - if ( - Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor - ) { + if (Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor) { nfgIndex = i; break; } @@ -2519,8 +2433,7 @@ function installAugmentations() { } applyAugmentation(Player.queuedAugmentations[i]); - if (ownedAug.name === AugmentationNames.NeuroFluxGovernor && i !== nfgIndex) - continue; + if (ownedAug.name === AugmentationNames.NeuroFluxGovernor && i !== nfgIndex) continue; let level = ""; if (ownedAug.name === AugmentationNames.NeuroFluxGovernor) { @@ -2555,13 +2468,7 @@ export function displayAugmentationsContent(contentEl) { onExport(Player); } - ReactDOM.render( - , - contentEl, - ); + ReactDOM.render(, contentEl); } export function isRepeatableAug(aug) { @@ -2574,9 +2481,4 @@ export function isRepeatableAug(aug) { return false; } -export { - installAugmentations, - initAugmentations, - applyAugmentation, - augmentationExists, -}; +export { installAugmentations, initAugmentations, applyAugmentation, augmentationExists }; diff --git a/src/Augmentation/ui/InstalledAugmentations.tsx b/src/Augmentation/ui/InstalledAugmentations.tsx index a073efc46..58be31f73 100644 --- a/src/Augmentation/ui/InstalledAugmentations.tsx +++ b/src/Augmentation/ui/InstalledAugmentations.tsx @@ -15,10 +15,7 @@ import { AugmentationAccordion } from "../../ui/React/AugmentationAccordion"; export function InstalledAugmentations(): React.ReactElement { const sourceAugs = Player.augmentations.slice(); - if ( - Settings.OwnedAugmentationsOrder === - OwnedAugmentationsOrderSetting.Alphabetically - ) { + if (Settings.OwnedAugmentationsOrder === OwnedAugmentationsOrderSetting.Alphabetically) { sourceAugs.sort((aug1, aug2) => { return aug1.name <= aug2.name ? -1 : 1; }); diff --git a/src/Augmentation/ui/InstalledAugmentationsAndSourceFiles.tsx b/src/Augmentation/ui/InstalledAugmentationsAndSourceFiles.tsx index 0d3741487..f275e71ba 100644 --- a/src/Augmentation/ui/InstalledAugmentationsAndSourceFiles.tsx +++ b/src/Augmentation/ui/InstalledAugmentationsAndSourceFiles.tsx @@ -23,10 +23,7 @@ type IState = { rerenderFlag: boolean; }; -export class InstalledAugmentationsAndSourceFiles extends React.Component< - IProps, - IState -> { +export class InstalledAugmentationsAndSourceFiles extends React.Component { listRef: React.RefObject; constructor(props: IProps) { @@ -89,14 +86,12 @@ export class InstalledAugmentationsAndSourceFiles extends React.Component< } sortByAcquirementTime(): void { - Settings.OwnedAugmentationsOrder = - OwnedAugmentationsOrderSetting.AcquirementTime; + Settings.OwnedAugmentationsOrder = OwnedAugmentationsOrderSetting.AcquirementTime; this.rerender(); } sortInOrder(): void { - Settings.OwnedAugmentationsOrder = - OwnedAugmentationsOrderSetting.Alphabetically; + Settings.OwnedAugmentationsOrder = OwnedAugmentationsOrderSetting.Alphabetically; this.rerender(); } diff --git a/src/Augmentation/ui/OwnedSourceFiles.tsx b/src/Augmentation/ui/OwnedSourceFiles.tsx index 42fe88c09..db777bdce 100644 --- a/src/Augmentation/ui/OwnedSourceFiles.tsx +++ b/src/Augmentation/ui/OwnedSourceFiles.tsx @@ -14,10 +14,7 @@ import { SourceFileAccordion } from "../../ui/React/SourceFileAccordion"; export function OwnedSourceFiles(): React.ReactElement { const sourceSfs = Player.sourceFiles.slice(); - if ( - Settings.OwnedAugmentationsOrder === - OwnedAugmentationsOrderSetting.Alphabetically - ) { + if (Settings.OwnedAugmentationsOrder === OwnedAugmentationsOrderSetting.Alphabetically) { sourceSfs.sort((sf1, sf2) => { return sf1.n - sf2.n; }); diff --git a/src/Augmentation/ui/PlayerMultipliers.tsx b/src/Augmentation/ui/PlayerMultipliers.tsx index 9bf2be557..f5572710c 100644 --- a/src/Augmentation/ui/PlayerMultipliers.tsx +++ b/src/Augmentation/ui/PlayerMultipliers.tsx @@ -25,10 +25,7 @@ export function PlayerMultipliers(): React.ReactElement { function improvements(r: number): JSX.Element[] { let elems: JSX.Element[] = []; if (r) { - elems = [ -  {"=>"} , - {numeralWrapper.formatPercentage(r)}, - ]; + elems = [ {"=>"} , {numeralWrapper.formatPercentage(r)}]; } return elems; } @@ -60,20 +57,17 @@ export function PlayerMultipliers(): React.ReactElement { [ "Bladeburner Success Chance", Player.bladeburner_success_chance_mult, - Player.bladeburner_success_chance_mult * - mults.bladeburner_success_chance_mult, + Player.bladeburner_success_chance_mult * mults.bladeburner_success_chance_mult, ], [ "Bladeburner Max Stamina", Player.bladeburner_max_stamina_mult, - Player.bladeburner_max_stamina_mult * - mults.bladeburner_max_stamina_mult, + Player.bladeburner_max_stamina_mult * mults.bladeburner_max_stamina_mult, ], [ "Bladeburner Stamina Gain", Player.bladeburner_stamina_gain_mult, - Player.bladeburner_stamina_gain_mult * - mults.bladeburner_stamina_gain_mult, + Player.bladeburner_stamina_gain_mult * mults.bladeburner_stamina_gain_mult, ], [ "Bladeburner Field Analysis", @@ -95,110 +89,46 @@ export function PlayerMultipliers(): React.ReactElement {


{MultiplierTable([ - [ - "Hacking Chance ", - Player.hacking_chance_mult, - Player.hacking_chance_mult * mults.hacking_chance_mult, - ], - [ - "Hacking Speed ", - Player.hacking_speed_mult, - Player.hacking_speed_mult * mults.hacking_speed_mult, - ], - [ - "Hacking Money ", - Player.hacking_money_mult, - Player.hacking_money_mult * mults.hacking_money_mult, - ], - [ - "Hacking Growth ", - Player.hacking_grow_mult, - Player.hacking_grow_mult * mults.hacking_grow_mult, - ], + ["Hacking Chance ", Player.hacking_chance_mult, Player.hacking_chance_mult * mults.hacking_chance_mult], + ["Hacking Speed ", Player.hacking_speed_mult, Player.hacking_speed_mult * mults.hacking_speed_mult], + ["Hacking Money ", Player.hacking_money_mult, Player.hacking_money_mult * mults.hacking_money_mult], + ["Hacking Growth ", Player.hacking_grow_mult, Player.hacking_grow_mult * mults.hacking_grow_mult], ])}
{MultiplierTable([ - [ - "Hacking Level ", - Player.hacking_mult, - Player.hacking_mult * mults.hacking_mult, - ], - [ - "Hacking Experience ", - Player.hacking_exp_mult, - Player.hacking_exp_mult * mults.hacking_exp_mult, - ], + ["Hacking Level ", Player.hacking_mult, Player.hacking_mult * mults.hacking_mult], + ["Hacking Experience ", Player.hacking_exp_mult, Player.hacking_exp_mult * mults.hacking_exp_mult], ])}
{MultiplierTable([ - [ - "Strength Level ", - Player.strength_mult, - Player.strength_mult * mults.strength_mult, - ], - [ - "Strength Experience ", - Player.strength_exp_mult, - Player.strength_exp_mult * mults.strength_exp_mult, - ], + ["Strength Level ", Player.strength_mult, Player.strength_mult * mults.strength_mult], + ["Strength Experience ", Player.strength_exp_mult, Player.strength_exp_mult * mults.strength_exp_mult], ])}
{MultiplierTable([ - [ - "Defense Level ", - Player.defense_mult, - Player.defense_mult * mults.defense_mult, - ], - [ - "Defense Experience ", - Player.defense_exp_mult, - Player.defense_exp_mult * mults.defense_exp_mult, - ], + ["Defense Level ", Player.defense_mult, Player.defense_mult * mults.defense_mult], + ["Defense Experience ", Player.defense_exp_mult, Player.defense_exp_mult * mults.defense_exp_mult], ])}
{MultiplierTable([ - [ - "Dexterity Level ", - Player.dexterity_mult, - Player.dexterity_mult * mults.dexterity_mult, - ], - [ - "Dexterity Experience ", - Player.dexterity_exp_mult, - Player.dexterity_exp_mult * mults.dexterity_exp_mult, - ], + ["Dexterity Level ", Player.dexterity_mult, Player.dexterity_mult * mults.dexterity_mult], + ["Dexterity Experience ", Player.dexterity_exp_mult, Player.dexterity_exp_mult * mults.dexterity_exp_mult], ])}
{MultiplierTable([ - [ - "Agility Level ", - Player.agility_mult, - Player.agility_mult * mults.agility_mult, - ], - [ - "Agility Experience ", - Player.agility_exp_mult, - Player.agility_exp_mult * mults.agility_exp_mult, - ], + ["Agility Level ", Player.agility_mult, Player.agility_mult * mults.agility_mult], + ["Agility Experience ", Player.agility_exp_mult, Player.agility_exp_mult * mults.agility_exp_mult], ])}
{MultiplierTable([ - [ - "Charisma Level ", - Player.charisma_mult, - Player.charisma_mult * mults.charisma_mult, - ], - [ - "Charisma Experience ", - Player.charisma_exp_mult, - Player.charisma_exp_mult * mults.charisma_exp_mult, - ], + ["Charisma Level ", Player.charisma_mult, Player.charisma_mult * mults.charisma_mult], + ["Charisma Experience ", Player.charisma_exp_mult, Player.charisma_exp_mult * mults.charisma_exp_mult], ])}
@@ -211,8 +141,7 @@ export function PlayerMultipliers(): React.ReactElement { [ "Hacknet Node purchase cost ", Player.hacknet_node_purchase_cost_mult, - Player.hacknet_node_purchase_cost_mult * - mults.hacknet_node_purchase_cost_mult, + Player.hacknet_node_purchase_cost_mult * mults.hacknet_node_purchase_cost_mult, ], [ "Hacknet Node RAM upgrade cost ", @@ -222,48 +151,26 @@ export function PlayerMultipliers(): React.ReactElement { [ "Hacknet Node Core purchase cost ", Player.hacknet_node_core_cost_mult, - Player.hacknet_node_core_cost_mult * - mults.hacknet_node_core_cost_mult, + Player.hacknet_node_core_cost_mult * mults.hacknet_node_core_cost_mult, ], [ "Hacknet Node level upgrade cost ", Player.hacknet_node_level_cost_mult, - Player.hacknet_node_level_cost_mult * - mults.hacknet_node_level_cost_mult, + Player.hacknet_node_level_cost_mult * mults.hacknet_node_level_cost_mult, ], ])}
{MultiplierTable([ - [ - "Company reputation gain ", - Player.company_rep_mult, - Player.company_rep_mult * mults.company_rep_mult, - ], - [ - "Faction reputation gain ", - Player.faction_rep_mult, - Player.faction_rep_mult * mults.faction_rep_mult, - ], - [ - "Salary ", - Player.work_money_mult, - Player.work_money_mult * mults.work_money_mult, - ], + ["Company reputation gain ", Player.company_rep_mult, Player.company_rep_mult * mults.company_rep_mult], + ["Faction reputation gain ", Player.faction_rep_mult, Player.faction_rep_mult * mults.faction_rep_mult], + ["Salary ", Player.work_money_mult, Player.work_money_mult * mults.work_money_mult], ])}
{MultiplierTable([ - [ - "Crime success ", - Player.crime_success_mult, - Player.crime_success_mult * mults.crime_success_mult, - ], - [ - "Crime money ", - Player.crime_money_mult, - Player.crime_money_mult * mults.crime_money_mult, - ], + ["Crime success ", Player.crime_success_mult, Player.crime_success_mult * mults.crime_success_mult], + ["Crime money ", Player.crime_money_mult, Player.crime_money_mult * mults.crime_money_mult], ])}
diff --git a/src/Augmentation/ui/PurchasedAugmentations.tsx b/src/Augmentation/ui/PurchasedAugmentations.tsx index 99193cd9c..7ffc8ff4e 100644 --- a/src/Augmentation/ui/PurchasedAugmentations.tsx +++ b/src/Augmentation/ui/PurchasedAugmentations.tsx @@ -15,17 +15,14 @@ export function PurchasedAugmentations(): React.ReactElement { // Only render the last NeuroFlux (there are no findLastIndex btw) let nfgIndex = -1; for (let i = Player.queuedAugmentations.length - 1; i >= 0; i--) { - if ( - Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor - ) { + if (Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor) { nfgIndex = i; break; } } for (let i = 0; i < Player.queuedAugmentations.length; i++) { const ownedAug = Player.queuedAugmentations[i]; - if (ownedAug.name === AugmentationNames.NeuroFluxGovernor && i !== nfgIndex) - continue; + if (ownedAug.name === AugmentationNames.NeuroFluxGovernor && i !== nfgIndex) continue; const aug = Augmentations[ownedAug.name]; let level = null; if (ownedAug.name === AugmentationNames.NeuroFluxGovernor) { diff --git a/src/Augmentation/ui/Root.tsx b/src/Augmentation/ui/Root.tsx index 5cf97c0e7..b363e4763 100644 --- a/src/Augmentation/ui/Root.tsx +++ b/src/Augmentation/ui/Root.tsx @@ -47,13 +47,10 @@ export class AugmentationsRoot extends React.Component {

Purchased Augmentations

- Below is a list of all Augmentations you have purchased but not yet - installed. Click the button below to install them. -

-

- WARNING: Installing your Augmentations resets most of your progress, - including: + Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to + install them.

+

WARNING: Installing your Augmentations resets most of your progress, including:


- Stats/Skill levels and Experience

- Money

@@ -64,10 +61,9 @@ export class AugmentationsRoot extends React.Component {

- Stocks


- Installing Augmentations lets you start over with the perks and - benefits granted by all of the Augmentations you have ever installed. - Also, you will keep any scripts and RAM/Core upgrades on your home - computer (but you will lose all programs besides NUKE.exe) + Installing Augmentations lets you start over with the perks and benefits granted by all of the Augmentations + you have ever installed. Also, you will keep any scripts and RAM/Core upgrades on your home computer (but you + will lose all programs besides NUKE.exe)

{

Installed Augmentations

- {`List of all Augmentations ${ - Player.sourceFiles.length > 0 ? "and Source Files " : "" - } ` + + {`List of all Augmentations ${Player.sourceFiles.length > 0 ? "and Source Files " : ""} ` + `that have been installed. You have gained the effects of these.`}

diff --git a/src/Augmentation/ui/SourceFileMinus1.tsx b/src/Augmentation/ui/SourceFileMinus1.tsx index 25637c337..95725f157 100644 --- a/src/Augmentation/ui/SourceFileMinus1.tsx +++ b/src/Augmentation/ui/SourceFileMinus1.tsx @@ -29,8 +29,8 @@ export function SourceFileMinus1(): React.ReactElement { panelContent={ <>

- This Source-File can only be acquired with obscure knowledge of - the game, javascript, and the web ecosystem. + This Source-File can only be acquired with obscure knowledge of the game, javascript, and the web + ecosystem.

It increases all of the player's multipliers by 0.1%


diff --git a/src/Bladeburner/Action.ts b/src/Bladeburner/Action.ts index c106a2b17..70218e882 100644 --- a/src/Bladeburner/Action.ts +++ b/src/Bladeburner/Action.ts @@ -1,11 +1,7 @@ import { Player } from "../Player"; import { getRandomInt } from "../../utils/helpers/getRandomInt"; import { addOffset } from "../../utils/helpers/addOffset"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; import { BladeburnerConstants } from "./data/Constants"; import { IBladeburner } from "./IBladeburner"; import { IAction, ISuccessChanceParams } from "./IAction"; @@ -106,10 +102,8 @@ export class Action implements IAction { if (params && params.name) this.name = params.name; if (params && params.desc) this.desc = params.desc; - if (params && params.baseDifficulty) - this.baseDifficulty = addOffset(params.baseDifficulty, 10); - if (params && params.difficultyFac) - this.difficultyFac = params.difficultyFac; + if (params && params.baseDifficulty) this.baseDifficulty = addOffset(params.baseDifficulty, 10); + if (params && params.difficultyFac) this.difficultyFac = params.difficultyFac; if (params && params.rewardFac) this.rewardFac = params.rewardFac; if (params && params.rankGain) this.rankGain = params.rankGain; @@ -144,11 +138,7 @@ export class Action implements IAction { if (this.decays.hasOwnProperty(decay)) { if (this.decays[decay] > 1) { throw new Error( - "Invalid decays when constructing " + - "Action " + - this.name + - ". " + - "Decay value cannot be greater than 1", + "Invalid decays when constructing " + "Action " + this.name + ". " + "Decay value cannot be greater than 1", ); } } @@ -156,8 +146,7 @@ export class Action implements IAction { } getDifficulty(): number { - const difficulty = - this.baseDifficulty * Math.pow(this.difficultyFac, this.level - 1); + const difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level - 1); if (isNaN(difficulty)) { throw new Error("Calculated NaN in Action.getDifficulty()"); } @@ -207,27 +196,16 @@ export class Action implements IAction { return 1; } - getChaosCompetencePenalty( - inst: IBladeburner, - params: ISuccessChanceParams, - ): number { + getChaosCompetencePenalty(inst: IBladeburner, params: ISuccessChanceParams): number { const city = inst.getCurrentCity(); if (params.est) { - return Math.pow( - city.popEst / BladeburnerConstants.PopulationThreshold, - BladeburnerConstants.PopulationExponent, - ); + return Math.pow(city.popEst / BladeburnerConstants.PopulationThreshold, BladeburnerConstants.PopulationExponent); } else { - return Math.pow( - city.pop / BladeburnerConstants.PopulationThreshold, - BladeburnerConstants.PopulationExponent, - ); + return Math.pow(city.pop / BladeburnerConstants.PopulationThreshold, BladeburnerConstants.PopulationExponent); } } - getChaosDifficultyBonus( - inst: IBladeburner /*, params: ISuccessChanceParams*/, - ): number { + getChaosDifficultyBonus(inst: IBladeburner /*, params: ISuccessChanceParams*/): number { const city = inst.getCurrentCity(); if (city.chaos > BladeburnerConstants.ChaosThreshold) { const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold); @@ -260,14 +238,9 @@ export class Action implements IAction { * @params - options: * est (bool): Get success chance estimate instead of real success chance */ - getSuccessChance( - inst: IBladeburner, - params: ISuccessChanceParams = { est: false }, - ): number { + getSuccessChance(inst: IBladeburner, params: ISuccessChanceParams = { est: false }): number { if (inst == null) { - throw new Error( - "Invalid Bladeburner instance passed into Action.getSuccessChance", - ); + throw new Error("Invalid Bladeburner instance passed into Action.getSuccessChance"); } let difficulty = this.getDifficulty(); let competence = 0; @@ -277,14 +250,10 @@ export class Action implements IAction { const key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1); let effMultiplier = inst.skillMultipliers[key]; if (effMultiplier == null) { - console.error( - `Failed to find Bladeburner Skill multiplier for: ${stat}`, - ); + console.error(`Failed to find Bladeburner Skill multiplier for: ${stat}`); effMultiplier = 1; } - competence += - this.weights[stat] * - Math.pow(effMultiplier * playerStatLvl, this.decays[stat]); + competence += this.weights[stat] * Math.pow(effMultiplier * playerStatLvl, this.decays[stat]); } } competence *= Player.getIntelligenceBonus(0.75); @@ -313,24 +282,17 @@ export class Action implements IAction { competence *= Player.bladeburner_success_chance_mult; if (isNaN(competence)) { - throw new Error( - "Competence calculated as NaN in Action.getSuccessChance()", - ); + throw new Error("Competence calculated as NaN in Action.getSuccessChance()"); } return Math.min(1, competence / difficulty); } getSuccessesNeededForNextLevel(baseSuccessesPerLevel: number): number { - return Math.ceil( - 0.5 * this.maxLevel * (2 * baseSuccessesPerLevel + (this.maxLevel - 1)), - ); + return Math.ceil(0.5 * this.maxLevel * (2 * baseSuccessesPerLevel + (this.maxLevel - 1))); } setMaxLevel(baseSuccessesPerLevel: number): void { - if ( - this.successes >= - this.getSuccessesNeededForNextLevel(baseSuccessesPerLevel) - ) { + if (this.successes >= this.getSuccessesNeededForNextLevel(baseSuccessesPerLevel)) { ++this.maxLevel; } } diff --git a/src/Bladeburner/ActionIdentifier.ts b/src/Bladeburner/ActionIdentifier.ts index 801a85de5..efbb01202 100644 --- a/src/Bladeburner/ActionIdentifier.ts +++ b/src/Bladeburner/ActionIdentifier.ts @@ -1,9 +1,5 @@ import { IActionIdentifier } from "./IActionIdentifier"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; interface IParams { name?: string; diff --git a/src/Bladeburner/BlackOperation.ts b/src/Bladeburner/BlackOperation.ts index 2f57adf28..86da39929 100644 --- a/src/Bladeburner/BlackOperation.ts +++ b/src/Bladeburner/BlackOperation.ts @@ -1,9 +1,5 @@ import { Operation, IOperationParams } from "./Operation"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; export class BlackOperation extends Operation { constructor(params: IOperationParams | null = null) { diff --git a/src/Bladeburner/BlackOperations.ts b/src/Bladeburner/BlackOperations.ts index c6fb88366..ab3175a1a 100644 --- a/src/Bladeburner/BlackOperations.ts +++ b/src/Bladeburner/BlackOperations.ts @@ -735,9 +735,7 @@ export const BlackOperations: IMap = {}; }); BlackOperations["Operation Daedalus"] = new BlackOperation({ name: "Operation Daedalus", - desc: - "Yesterday we obeyed kings and bent our neck to emperors. " + - "Today we kneel only to truth.", + desc: "Yesterday we obeyed kings and bent our neck to emperors. " + "Today we kneel only to truth.", baseDifficulty: 80e3, reqdRank: 400e3, rankGain: 40e3, diff --git a/src/Bladeburner/Bladeburner.ts b/src/Bladeburner/Bladeburner.ts index 33f2fa241..f0ccde9b2 100644 --- a/src/Bladeburner/Bladeburner.ts +++ b/src/Bladeburner/Bladeburner.ts @@ -1,8 +1,4 @@ -import { - Reviver, - Generic_toJSON, - Generic_fromJSON, -} from "../../utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON } from "../../utils/JSONReviver"; import { IBladeburner } from "./IBladeburner"; import { IActionIdentifier } from "./IActionIdentifier"; import { ActionIdentifier } from "./ActionIdentifier"; @@ -90,16 +86,11 @@ export class Bladeburner implements IBladeburner { }); automateThreshLow = 0; consoleHistory: string[] = []; - consoleLogs: string[] = [ - "Bladeburner Console", - "Type 'help' to see console commands", - ]; + consoleLogs: string[] = ["Bladeburner Console", "Type 'help' to see console commands"]; constructor(player?: IPlayer) { for (let i = 0; i < BladeburnerConstants.CityNames.length; ++i) { - this.cities[BladeburnerConstants.CityNames[i]] = new City( - BladeburnerConstants.CityNames[i], - ); + this.cities[BladeburnerConstants.CityNames[i]] = new City(BladeburnerConstants.CityNames[i]); } this.updateSkillMultipliers(); // Calls resetSkillMultipliers() @@ -113,9 +104,7 @@ export class Bladeburner implements IBladeburner { getCurrentCity(): City { const city = this.cities[this.city]; if (!(city instanceof City)) { - throw new Error( - "Bladeburner.getCurrentCity() did not properly return a City object", - ); + throw new Error("Bladeburner.getCurrentCity() did not properly return a City object"); } return city; } @@ -136,9 +125,7 @@ export class Bladeburner implements IBladeburner { try { const action = this.getActionObject(actionId); if (action == null) { - throw new Error( - "Failed to get Contract Object for: " + actionId.name, - ); + throw new Error("Failed to get Contract Object for: " + actionId.name); } if (action.count < 1) { return this.resetAction(); @@ -152,17 +139,12 @@ export class Bladeburner implements IBladeburner { try { const action = this.getActionObject(actionId); if (action == null) { - throw new Error( - "Failed to get Operation Object for: " + actionId.name, - ); + throw new Error("Failed to get Operation Object for: " + actionId.name); } if (action.count < 1) { return this.resetAction(); } - if ( - actionId.name === "Raid" && - this.getCurrentCity().commsEst === 0 - ) { + if (actionId.name === "Raid" && this.getCurrentCity().commsEst === 0) { return this.resetAction(); } this.actionTimeToComplete = action.getActionTime(this); @@ -177,17 +159,13 @@ export class Bladeburner implements IBladeburner { // Safety measure - don't repeat BlackOps that are already done if (this.blackops[actionId.name] != null) { this.resetAction(); - this.log( - "Error: Tried to start a Black Operation that had already been completed", - ); + this.log("Error: Tried to start a Black Operation that had already been completed"); break; } const action = this.getActionObject(actionId); if (action == null) { - throw new Error( - "Failed to get BlackOperation object for: " + actionId.name, - ); + throw new Error("Failed to get BlackOperation object for: " + actionId.name); } this.actionTimeToComplete = action.getActionTime(this); } catch (e) { @@ -208,10 +186,7 @@ export class Bladeburner implements IBladeburner { this.actionTimeToComplete = 60; break; default: - throw new Error( - "Invalid Action Type in startAction(Bladeburner,player, ): " + - actionId.type, - ); + throw new Error("Invalid Action Type in startAction(Bladeburner,player, ): " + actionId.type); break; } } @@ -225,12 +200,7 @@ export class Bladeburner implements IBladeburner { this.skills[skillName] = 1; } if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) { - throw new Error( - "Level of Skill " + - skillName + - " is invalid: " + - this.skills[skillName], - ); + throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]); } this.updateSkillMultipliers(); } @@ -379,9 +349,7 @@ export class Bladeburner implements IBladeburner { executeStartConsoleCommand(player: IPlayer, args: string[]): void { if (args.length !== 3) { - this.postToConsole( - "Invalid usage of 'start' console command: start [type] [name]", - ); + this.postToConsole("Invalid usage of 'start' console command: start [type] [name]"); this.postToConsole("Use 'help start' for more info"); return; } @@ -433,9 +401,7 @@ export class Bladeburner implements IBladeburner { break; default: this.postToConsole("Invalid action/event type specified: " + args[1]); - this.postToConsole( - "Examples of valid action/event identifiers are: [general, contract, op, blackop]", - ); + this.postToConsole("Examples of valid action/event identifiers are: [general, contract, op, blackop]"); break; } } @@ -444,9 +410,7 @@ export class Bladeburner implements IBladeburner { switch (args.length) { case 1: { // Display Skill Help Command - this.postToConsole( - "Invalid usage of 'skill' console command: skill [action] [name]", - ); + this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]"); this.postToConsole("Use 'help skill' for more info"); break; } @@ -461,9 +425,7 @@ export class Bladeburner implements IBladeburner { if (this.skills[skill.name] != null) { level = this.skills[skill.name]; } - this.postToConsole( - skill.name + ": Level " + formatNumber(level, 0), - ); + this.postToConsole(skill.name + ": Level " + formatNumber(level, 0)); } this.postToConsole(" "); this.postToConsole("Effects: "); @@ -525,9 +487,7 @@ export class Bladeburner implements IBladeburner { } } } else { - this.postToConsole( - "Invalid usage of 'skill' console command: skill [action] [name]", - ); + this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]"); this.postToConsole("Use 'help skill' for more info"); } break; @@ -536,9 +496,7 @@ export class Bladeburner implements IBladeburner { const skillName = args[2]; const skill = Skills[skillName]; if (skill == null || !(skill instanceof Skill)) { - this.postToConsole( - "Invalid skill name (Note that it is case-sensitive): " + skillName, - ); + this.postToConsole("Invalid skill name (Note that it is case-sensitive): " + skillName); } if (args[1].toLowerCase() === "list") { let level = 0; @@ -555,27 +513,20 @@ export class Bladeburner implements IBladeburner { if (this.skillPoints >= pointCost) { this.skillPoints -= pointCost; this.upgradeSkill(skill); - this.log( - skill.name + " upgraded to Level " + this.skills[skillName], - ); + this.log(skill.name + " upgraded to Level " + this.skills[skillName]); } else { this.postToConsole( - "You do not have enough Skill Points to upgrade this. You need " + - formatNumber(pointCost, 0), + "You do not have enough Skill Points to upgrade this. You need " + formatNumber(pointCost, 0), ); } } else { - this.postToConsole( - "Invalid usage of 'skill' console command: skill [action] [name]", - ); + this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]"); this.postToConsole("Use 'help skill' for more info"); } break; } default: { - this.postToConsole( - "Invalid usage of 'skill' console command: skill [action] [name]", - ); + this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]"); this.postToConsole("Use 'help skill' for more info"); break; } @@ -584,9 +535,7 @@ export class Bladeburner implements IBladeburner { executeLogConsoleCommand(args: string[]): void { if (args.length < 3) { - this.postToConsole( - "Invalid usage of log command: log [enable/disable] [action/event]", - ); + this.postToConsole("Invalid usage of log command: log [enable/disable] [action/event]"); this.postToConsole("Use 'help log' for more details and examples"); return; } @@ -600,34 +549,26 @@ export class Bladeburner implements IBladeburner { case "general": case "gen": this.logging.general = flag; - this.log( - "Logging " + (flag ? "enabled" : "disabled") + " for general actions", - ); + this.log("Logging " + (flag ? "enabled" : "disabled") + " for general actions"); break; case "contract": case "contracts": this.logging.contracts = flag; - this.log( - "Logging " + (flag ? "enabled" : "disabled") + " for Contracts", - ); + this.log("Logging " + (flag ? "enabled" : "disabled") + " for Contracts"); break; case "ops": case "op": case "operations": case "operation": this.logging.ops = flag; - this.log( - "Logging " + (flag ? "enabled" : "disabled") + " for Operations", - ); + this.log("Logging " + (flag ? "enabled" : "disabled") + " for Operations"); break; case "blackops": case "blackop": case "black operations": case "black operation": this.logging.blackops = flag; - this.log( - "Logging " + (flag ? "enabled" : "disabled") + " for BlackOps", - ); + this.log("Logging " + (flag ? "enabled" : "disabled") + " for BlackOps"); break; case "event": case "events": @@ -640,9 +581,7 @@ export class Bladeburner implements IBladeburner { this.logging.ops = flag; this.logging.blackops = flag; this.logging.events = flag; - this.log( - "Logging " + (flag ? "enabled" : "disabled") + " for everything", - ); + this.log("Logging " + (flag ? "enabled" : "disabled") + " for everything"); break; default: this.postToConsole("Invalid action/event type specified: " + args[2]); @@ -681,9 +620,7 @@ export class Bladeburner implements IBladeburner { if (args.length === 2) { const flag = args[1]; if (flag.toLowerCase() === "status") { - this.postToConsole( - "Automation: " + (this.automateEnabled ? "enabled" : "disabled"), - ); + this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled")); this.postToConsole( "When your stamina drops to " + formatNumber(this.automateThreshLow, 0) + @@ -737,12 +674,7 @@ export class Bladeburner implements IBladeburner { } else { this.automateActionLow = action; } - this.log( - "Automate (" + - (highLow ? "HIGH" : "LOW") + - ") action set to " + - val, - ); + this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val); } else { this.postToConsole("Invalid action name specified: " + val); } @@ -759,12 +691,7 @@ export class Bladeburner implements IBladeburner { } else { this.automateActionLow = action; } - this.log( - "Automate (" + - (highLow ? "HIGH" : "LOW") + - ") action set to " + - val, - ); + this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val); } else { this.postToConsole("Invalid contract name specified: " + val); } @@ -783,34 +710,21 @@ export class Bladeburner implements IBladeburner { } else { this.automateActionLow = action; } - this.log( - "Automate (" + - (highLow ? "HIGH" : "LOW") + - ") action set to " + - val, - ); + this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val); } else { this.postToConsole("Invalid Operation name specified: " + val); } break; case "stamina": if (isNaN(parseFloat(val))) { - this.postToConsole( - "Invalid value specified for stamina threshold (must be numeric): " + - val, - ); + this.postToConsole("Invalid value specified for stamina threshold (must be numeric): " + val); } else { if (highLow) { this.automateThreshHigh = Number(val); } else { this.automateThreshLow = Number(val); } - this.log( - "Automate (" + - (highLow ? "HIGH" : "LOW") + - ") stamina threshold set to " + - val, - ); + this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") stamina threshold set to " + val); } break; default: @@ -835,11 +749,7 @@ export class Bladeburner implements IBladeburner { if (c === '"') { // Double quotes const endQuote = command.indexOf('"', i + 1); - if ( - endQuote !== -1 && - (endQuote === command.length - 1 || - command.charAt(endQuote + 1) === " ") - ) { + if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === " ")) { args.push(command.substr(i + 1, endQuote - i - 1)); if (endQuote === command.length - 1) { start = i = endQuote + 1; @@ -851,11 +761,7 @@ export class Bladeburner implements IBladeburner { } else if (c === "'") { // Single quotes, same thing as above const endQuote = command.indexOf("'", i + 1); - if ( - endQuote !== -1 && - (endQuote === command.length - 1 || - command.charAt(endQuote + 1) === " ") - ) { + if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === " ")) { args.push(command.substr(i + 1, endQuote - i - 1)); if (endQuote === command.length - 1) { start = i = endQuote + 1; @@ -938,9 +844,7 @@ export class Bladeburner implements IBladeburner { triggerPotentialMigration(sourceCityName: string, chance: number): void { if (chance == null || isNaN(chance)) { - console.error( - "Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()", - ); + console.error("Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()"); } if (chance > 1) { chance /= 100; @@ -957,9 +861,7 @@ export class Bladeburner implements IBladeburner { const sourceCityName = BladeburnerConstants.CityNames[getRandomInt(0, 5)]; const sourceCity = this.cities[sourceCityName]; if (!(sourceCity instanceof City)) { - throw new Error( - "sourceCity was not a City object in Bladeburner.randomEvent()", - ); + throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()"); } let destCityName = BladeburnerConstants.CityNames[getRandomInt(0, 5)]; @@ -969,9 +871,7 @@ export class Bladeburner implements IBladeburner { const destCity = this.cities[destCityName]; if (!(sourceCity instanceof City) || !(destCity instanceof City)) { - throw new Error( - "sourceCity/destCity was not a City object in Bladeburner.randomEvent()", - ); + throw new Error("sourceCity/destCity was not a City object in Bladeburner.randomEvent()"); } if (chance <= 0.05) { @@ -981,9 +881,7 @@ export class Bladeburner implements IBladeburner { const count = Math.round(sourceCity.pop * percentage); sourceCity.pop += count; if (this.logging.events) { - this.log( - "Intelligence indicates that a new Synthoid community was formed in a city", - ); + this.log("Intelligence indicates that a new Synthoid community was formed in a city"); } } else if (chance <= 0.1) { // Synthoid Community Migration, 5% @@ -994,9 +892,7 @@ export class Bladeburner implements IBladeburner { const count = Math.round(sourceCity.pop * percentage); sourceCity.pop += count; if (this.logging.events) { - this.log( - "Intelligence indicates that a new Synthoid community was formed in a city", - ); + this.log("Intelligence indicates that a new Synthoid community was formed in a city"); } } else { --sourceCity.comms; @@ -1010,9 +906,7 @@ export class Bladeburner implements IBladeburner { if (this.logging.events) { this.log( - "Intelligence indicates that a Synthoid community migrated from " + - sourceCityName + - " to some other city", + "Intelligence indicates that a Synthoid community migrated from " + sourceCityName + " to some other city", ); } } @@ -1023,9 +917,7 @@ export class Bladeburner implements IBladeburner { sourceCity.pop += count; if (this.logging.events) { this.log( - "Intelligence indicates that the Synthoid population of " + - sourceCityName + - " just changed significantly", + "Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly", ); } } else if (chance <= 0.5) { @@ -1043,11 +935,7 @@ export class Bladeburner implements IBladeburner { sourceCity.chaos += 1; sourceCity.chaos *= 1 + getRandomInt(5, 20) / 100; if (this.logging.events) { - this.log( - "Tensions between Synthoids and humans lead to riots in " + - sourceCityName + - "! Chaos increased", - ); + this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased"); } } else if (chance <= 0.9) { // Less Synthoids, 20% @@ -1056,9 +944,7 @@ export class Bladeburner implements IBladeburner { sourceCity.pop -= count; if (this.logging.events) { this.log( - "Intelligence indicates that the Synthoid population of " + - sourceCityName + - " just changed significantly", + "Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly", ); } } @@ -1084,41 +970,15 @@ export class Bladeburner implements IBladeburner { const time = this.actionTimeToComplete; const successMult = success ? 1 : 0.5; - const unweightedGain = - time * BladeburnerConstants.BaseStatGain * successMult * difficultyMult; - const unweightedIntGain = - time * BladeburnerConstants.BaseIntGain * successMult * difficultyMult; + const unweightedGain = time * BladeburnerConstants.BaseStatGain * successMult * difficultyMult; + const unweightedIntGain = time * BladeburnerConstants.BaseIntGain * successMult * difficultyMult; const skillMult = this.skillMultipliers.expGain; - player.gainHackingExp( - unweightedGain * - action.weights.hack * - player.hacking_exp_mult * - skillMult, - ); - player.gainStrengthExp( - unweightedGain * - action.weights.str * - player.strength_exp_mult * - skillMult, - ); - player.gainDefenseExp( - unweightedGain * action.weights.def * player.defense_exp_mult * skillMult, - ); - player.gainDexterityExp( - unweightedGain * - action.weights.dex * - player.dexterity_exp_mult * - skillMult, - ); - player.gainAgilityExp( - unweightedGain * action.weights.agi * player.agility_exp_mult * skillMult, - ); - player.gainCharismaExp( - unweightedGain * - action.weights.cha * - player.charisma_exp_mult * - skillMult, - ); + player.gainHackingExp(unweightedGain * action.weights.hack * player.hacking_exp_mult * skillMult); + player.gainStrengthExp(unweightedGain * action.weights.str * player.strength_exp_mult * skillMult); + player.gainDefenseExp(unweightedGain * action.weights.def * player.defense_exp_mult * skillMult); + player.gainDexterityExp(unweightedGain * action.weights.dex * player.dexterity_exp_mult * skillMult); + player.gainAgilityExp(unweightedGain * action.weights.agi * player.agility_exp_mult * skillMult); + player.gainCharismaExp(unweightedGain * action.weights.cha * player.charisma_exp_mult * skillMult); let intExp = unweightedIntGain * action.weights.int * skillMult; if (intExp > 1) { intExp = Math.pow(intExp, 0.8); @@ -1131,9 +991,7 @@ export class Bladeburner implements IBladeburner { const CharismaLinearFactor = 1e3; const CharismaExponentialFactor = 0.045; - const charismaEff = - Math.pow(player.charisma, CharismaExponentialFactor) + - player.charisma / CharismaLinearFactor; + const charismaEff = Math.pow(player.charisma, CharismaExponentialFactor) + player.charisma / CharismaLinearFactor; return (100 - charismaEff) / 100; } @@ -1144,12 +1002,7 @@ export class Bladeburner implements IBladeburner { getRecruitmentTime(player: IPlayer): number { const effCharisma = player.charisma * this.skillMultipliers.effCha; const charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90; - return Math.max( - 10, - Math.round( - BladeburnerConstants.BaseRecruitmentTimeNeeded - charismaFactor, - ), - ); + return Math.max(10, Math.round(BladeburnerConstants.BaseRecruitmentTimeNeeded - charismaFactor)); } resetSkillMultipliers(): void { @@ -1190,10 +1043,7 @@ export class Bladeburner implements IBladeburner { const multiplierNames = Object.keys(this.skillMultipliers); for (let i = 0; i < multiplierNames.length; ++i) { const multiplierName = multiplierNames[i]; - if ( - skill.getMultiplier(multiplierName) != null && - !isNaN(skill.getMultiplier(multiplierName)) - ) { + if (skill.getMultiplier(multiplierName) != null && !isNaN(skill.getMultiplier(multiplierName))) { const value = skill.getMultiplier(multiplierName) * level; let multiplierValue = 1 + value / 100; if (multiplierName === "actionTime") { @@ -1208,15 +1058,11 @@ export class Bladeburner implements IBladeburner { completeOperation(success: boolean): void { if (this.action.type !== ActionTypes.Operation) { - throw new Error( - "completeOperation() called even though current action is not an Operation", - ); + throw new Error("completeOperation() called even though current action is not an Operation"); } const action = this.getActionObject(this.action); if (action == null) { - throw new Error( - "Failed to get Contract/Operation Object for: " + this.action.name, - ); + throw new Error("Failed to get Contract/Operation Object for: " + this.action.name); } // Calculate team losses @@ -1232,12 +1078,7 @@ export class Bladeburner implements IBladeburner { this.teamSize -= losses; this.teamLost += losses; if (this.logging.ops && losses > 0) { - this.log( - "Lost " + - formatNumber(losses, 0) + - " team members during this " + - action.name, - ); + this.log("Lost " + formatNumber(losses, 0) + " team members during this " + action.name); } } @@ -1245,13 +1086,8 @@ export class Bladeburner implements IBladeburner { switch (action.name) { case "Investigation": if (success) { - city.improvePopulationEstimateByPercentage( - 0.4 * this.skillMultipliers.successChanceEstimate, - ); - if ( - Math.random() < - 0.02 * this.skillMultipliers.successChanceEstimate - ) { + city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate); + if (Math.random() < 0.02 * this.skillMultipliers.successChanceEstimate) { city.improveCommunityEstimate(1); } } else { @@ -1260,13 +1096,8 @@ export class Bladeburner implements IBladeburner { break; case "Undercover Operation": if (success) { - city.improvePopulationEstimateByPercentage( - 0.8 * this.skillMultipliers.successChanceEstimate, - ); - if ( - Math.random() < - 0.02 * this.skillMultipliers.successChanceEstimate - ) { + city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate); + if (Math.random() < 0.02 * this.skillMultipliers.successChanceEstimate) { city.improveCommunityEstimate(1); } } else { @@ -1315,9 +1146,7 @@ export class Bladeburner implements IBladeburner { city.changeChaosByPercentage(getRandomInt(-5, 5)); break; default: - throw new Error( - "Invalid Action name in completeOperation: " + this.action.name, - ); + throw new Error("Invalid Action name in completeOperation: " + this.action.name); } } @@ -1351,9 +1180,7 @@ export class Bladeburner implements IBladeburner { completeContract(success: boolean): void { if (this.action.type !== ActionTypes.Contract) { - throw new Error( - "completeContract() called even though current action is not a Contract", - ); + throw new Error("completeContract() called even though current action is not a Contract"); } const city = this.getCurrentCity(); if (success) { @@ -1371,9 +1198,7 @@ export class Bladeburner implements IBladeburner { city.changeChaosByCount(0.04); break; default: - throw new Error( - "Invalid Action name in completeContract: " + this.action.name, - ); + throw new Error("Invalid Action name in completeContract: " + this.action.name); } } } @@ -1386,23 +1211,16 @@ export class Bladeburner implements IBladeburner { const isOperation = this.action.type === ActionTypes["Operation"]; const action = this.getActionObject(this.action); if (action == null) { - throw new Error( - "Failed to get Contract/Operation Object for: " + - this.action.name, - ); + throw new Error("Failed to get Contract/Operation Object for: " + this.action.name); } const difficulty = action.getDifficulty(); const difficultyMultiplier = - Math.pow( - difficulty, - BladeburnerConstants.DiffMultExponentialFactor, - ) + + Math.pow(difficulty, BladeburnerConstants.DiffMultExponentialFactor) + difficulty / BladeburnerConstants.DiffMultLinearFactor; const rewardMultiplier = Math.pow(action.rewardFac, action.level - 1); // Stamina loss is based on difficulty - this.stamina -= - BladeburnerConstants.BaseStaminaLoss * difficultyMultiplier; + this.stamina -= BladeburnerConstants.BaseStaminaLoss * difficultyMultiplier; if (this.stamina < 0) { this.stamina = 0; } @@ -1416,38 +1234,21 @@ export class Bladeburner implements IBladeburner { // Earn money for contracts let moneyGain = 0; if (!isOperation) { - moneyGain = - BladeburnerConstants.ContractBaseMoneyGain * - rewardMultiplier * - this.skillMultipliers.money; + moneyGain = BladeburnerConstants.ContractBaseMoneyGain * rewardMultiplier * this.skillMultipliers.money; player.gainMoney(moneyGain); player.recordMoneySource(moneyGain, "bladeburner"); } if (isOperation) { - action.setMaxLevel( - BladeburnerConstants.OperationSuccessesPerLevel, - ); + action.setMaxLevel(BladeburnerConstants.OperationSuccessesPerLevel); } else { - action.setMaxLevel( - BladeburnerConstants.ContractSuccessesPerLevel, - ); + action.setMaxLevel(BladeburnerConstants.ContractSuccessesPerLevel); } if (action.rankGain) { - const gain = addOffset( - action.rankGain * - rewardMultiplier * - BitNodeMultipliers.BladeburnerRank, - 10, - ); + const gain = addOffset(action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank, 10); this.changeRank(player, gain); if (isOperation && this.logging.ops) { - this.log( - action.name + - " successfully completed! Gained " + - formatNumber(gain, 3) + - " rank", - ); + this.log(action.name + " successfully completed! Gained " + formatNumber(gain, 3) + " rank"); } else if (!isOperation && this.logging.contracts) { this.log( action.name + @@ -1458,9 +1259,7 @@ export class Bladeburner implements IBladeburner { ); } } - isOperation - ? this.completeOperation(true) - : this.completeContract(true); + isOperation ? this.completeOperation(true) : this.completeContract(true); } else { this.gainActionStats(player, action, false); ++action.failures; @@ -1492,9 +1291,7 @@ export class Bladeburner implements IBladeburner { } else if (!isOperation && this.logging.contracts) { this.log(action.name + " contract failed! " + logLossText); } - isOperation - ? this.completeOperation(false) - : this.completeContract(false); + isOperation ? this.completeOperation(false) : this.completeContract(false); } if (action.autoLevel) { action.level = action.maxLevel; @@ -1510,21 +1307,15 @@ export class Bladeburner implements IBladeburner { try { const action = this.getActionObject(this.action); if (action == null || !(action instanceof BlackOperation)) { - throw new Error( - "Failed to get BlackOperation Object for: " + this.action.name, - ); + throw new Error("Failed to get BlackOperation Object for: " + this.action.name); } const difficulty = action.getDifficulty(); const difficultyMultiplier = - Math.pow( - difficulty, - BladeburnerConstants.DiffMultExponentialFactor, - ) + + Math.pow(difficulty, BladeburnerConstants.DiffMultExponentialFactor) + difficulty / BladeburnerConstants.DiffMultLinearFactor; // Stamina loss is based on difficulty - this.stamina -= - BladeburnerConstants.BaseStaminaLoss * difficultyMultiplier; + this.stamina -= BladeburnerConstants.BaseStaminaLoss * difficultyMultiplier; if (this.stamina < 0) { this.stamina = 0; } @@ -1539,10 +1330,7 @@ export class Bladeburner implements IBladeburner { this.blackops[action.name] = true; let rankGain = 0; if (action.rankGain) { - rankGain = addOffset( - action.rankGain * BitNodeMultipliers.BladeburnerRank, - 10, - ); + rankGain = addOffset(action.rankGain * BitNodeMultipliers.BladeburnerRank, 10); this.changeRank(player, rankGain); } teamLossMax = Math.ceil(teamCount / 2); @@ -1554,12 +1342,7 @@ export class Bladeburner implements IBladeburner { } if (this.logging.blackops) { - this.log( - action.name + - " successful! Gained " + - formatNumber(rankGain, 1) + - " rank", - ); + this.log(action.name + " successful! Gained " + formatNumber(rankGain, 1) + " rank"); } } else { this.gainActionStats(player, action, false); @@ -1600,12 +1383,7 @@ export class Bladeburner implements IBladeburner { this.teamSize -= losses; this.teamLost += losses; if (this.logging.blackops) { - this.log( - "You lost " + - formatNumber(losses, 0) + - " team members during " + - action.name, - ); + this.log("You lost " + formatNumber(losses, 0) + " team members during " + action.name); } } } catch (e) { @@ -1652,9 +1430,7 @@ export class Bladeburner implements IBladeburner { 0.02 * Math.pow(player.charisma, 0.3); eff *= player.bladeburner_analysis_mult; if (isNaN(eff) || eff < 0) { - throw new Error( - "Field Analysis Effectiveness calculated to be NaN or negative", - ); + throw new Error("Field Analysis Effectiveness calculated to be NaN or negative"); } const hackingExpGain = 20 * player.hacking_exp_mult, charismaExpGain = 20 * player.charisma_exp_mult; @@ -1662,9 +1438,7 @@ export class Bladeburner implements IBladeburner { player.gainIntelligenceExp(BladeburnerConstants.BaseIntGain); player.gainCharismaExp(charismaExpGain); this.changeRank(player, 0.1 * BitNodeMultipliers.BladeburnerRank); - this.getCurrentCity().improvePopulationEstimateByPercentage( - eff * this.skillMultipliers.successChanceEstimate, - ); + this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate); if (this.logging.general) { this.log( "Field analysis completed. Gained 0.1 rank, " + @@ -1680,27 +1454,17 @@ export class Bladeburner implements IBladeburner { case ActionTypes["Recruitment"]: { const successChance = this.getRecruitmentSuccessChance(player); if (Math.random() < successChance) { - const expGain = - 2 * BladeburnerConstants.BaseStatGain * this.actionTimeToComplete; + const expGain = 2 * BladeburnerConstants.BaseStatGain * this.actionTimeToComplete; player.gainCharismaExp(expGain); ++this.teamSize; if (this.logging.general) { - this.log( - "Successfully recruited a team member! Gained " + - formatNumber(expGain, 1) + - " charisma exp", - ); + this.log("Successfully recruited a team member! Gained " + formatNumber(expGain, 1) + " charisma exp"); } } else { - const expGain = - BladeburnerConstants.BaseStatGain * this.actionTimeToComplete; + const expGain = BladeburnerConstants.BaseStatGain * this.actionTimeToComplete; player.gainCharismaExp(expGain); if (this.logging.general) { - this.log( - "Failed to recruit a team member. Gained " + - formatNumber(expGain, 1) + - " charisma exp", - ); + this.log("Failed to recruit a team member. Gained " + formatNumber(expGain, 1) + " charisma exp"); } } this.startAction(player, this.action); // Repeat action @@ -1714,9 +1478,7 @@ export class Bladeburner implements IBladeburner { } if (this.logging.general) { this.log( - `Diplomacy completed. Chaos levels in the current city fell by ${numeralWrapper.formatPercentage( - 1 - eff, - )}`, + `Diplomacy completed. Chaos levels in the current city fell by ${numeralWrapper.formatPercentage(1 - eff)}`, ); } this.startAction(player, this.action); // Repeat Action @@ -1725,25 +1487,20 @@ export class Bladeburner implements IBladeburner { case ActionTypes["Hyperbolic Regeneration Chamber"]: { player.regenerateHp(BladeburnerConstants.HrcHpGain); - const staminaGain = - this.maxStamina * (BladeburnerConstants.HrcStaminaGain / 100); + const staminaGain = this.maxStamina * (BladeburnerConstants.HrcStaminaGain / 100); this.stamina = Math.min(this.maxStamina, this.stamina + staminaGain); this.startAction(player, this.action); if (this.logging.general) { this.log( `Rested in Hyperbolic Regeneration Chamber. Restored ${ BladeburnerConstants.HrcHpGain - } HP and gained ${numeralWrapper.formatStamina( - staminaGain, - )} stamina`, + } HP and gained ${numeralWrapper.formatStamina(staminaGain)} stamina`, ); } break; } default: - console.error( - `Bladeburner.completeAction() called for invalid action: ${this.action.type}`, - ); + console.error(`Bladeburner.completeAction() called for invalid action: ${this.action.type}`); break; } } @@ -1762,29 +1519,21 @@ export class Bladeburner implements IBladeburner { if (factionExists(bladeburnersFactionName)) { const bladeburnerFac = Factions[bladeburnersFactionName]; if (!(bladeburnerFac instanceof Faction)) { - throw new Error( - "Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button", - ); + throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button"); } if (bladeburnerFac.isMember) { const favorBonus = 1 + bladeburnerFac.favor / 100; bladeburnerFac.playerReputation += - BladeburnerConstants.RankToFactionRepFactor * - change * - player.faction_rep_mult * - favorBonus; + BladeburnerConstants.RankToFactionRepFactor * change * player.faction_rep_mult * favorBonus; } } // Gain skill points - const rankNeededForSp = - (this.totalSkillPoints + 1) * BladeburnerConstants.RanksPerSkillPoint; + const rankNeededForSp = (this.totalSkillPoints + 1) * BladeburnerConstants.RanksPerSkillPoint; if (this.maxRank >= rankNeededForSp) { // Calculate how many skill points to gain const gainedSkillPoints = Math.floor( - (this.maxRank - rankNeededForSp) / - BladeburnerConstants.RanksPerSkillPoint + - 1, + (this.maxRank - rankNeededForSp) / BladeburnerConstants.RanksPerSkillPoint + 1, ); this.skillPoints += gainedSkillPoints; this.totalSkillPoints += gainedSkillPoints; @@ -1794,9 +1543,7 @@ export class Bladeburner implements IBladeburner { processAction(player: IPlayer, seconds: number): void { if (this.action.type === ActionTypes["Idle"]) return; if (this.actionTimeToComplete <= 0) { - throw new Error( - `Invalid actionTimeToComplete value: ${this.actionTimeToComplete}, type; ${this.action.type}`, - ); + throw new Error(`Invalid actionTimeToComplete value: ${this.actionTimeToComplete}, type; ${this.action.type}`); } if (!(this.action instanceof ActionIdentifier)) { throw new Error("Bladeburner.action is not an ActionIdentifier Object"); @@ -1807,23 +1554,16 @@ export class Bladeburner implements IBladeburner { this.actionTimeCurrent += seconds + this.actionTimeOverflow; this.actionTimeOverflow = 0; if (this.actionTimeCurrent >= this.actionTimeToComplete) { - this.actionTimeOverflow = - this.actionTimeCurrent - this.actionTimeToComplete; + this.actionTimeOverflow = this.actionTimeCurrent - this.actionTimeToComplete; return this.completeAction(player); } } calculateStaminaGainPerSecond(player: IPlayer): number { const effAgility = player.agility * this.skillMultipliers.effAgi; - const maxStaminaBonus = - this.maxStamina / BladeburnerConstants.MaxStaminaToGainFactor; - const gain = - (BladeburnerConstants.StaminaGainPerSecond + maxStaminaBonus) * - Math.pow(effAgility, 0.17); - return ( - gain * - (this.skillMultipliers.stamina * player.bladeburner_stamina_gain_mult) - ); + const maxStaminaBonus = this.maxStamina / BladeburnerConstants.MaxStaminaToGainFactor; + const gain = (BladeburnerConstants.StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17); + return gain * (this.skillMultipliers.stamina * player.bladeburner_stamina_gain_mult); } calculateMaxStamina(player: IPlayer): void { @@ -1838,9 +1578,7 @@ export class Bladeburner implements IBladeburner { this.stamina = (this.maxStamina * this.stamina) / oldMax; } if (isNaN(maxStamina)) { - throw new Error( - "Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()", - ); + throw new Error("Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()"); } } @@ -2015,9 +1753,7 @@ export class Bladeburner implements IBladeburner { }); this.operations["Sting Operation"] = new Operation({ name: "Sting Operation", - desc: - "Conduct a sting operation to bait and capture particularly " + - "notorious Synthoid criminals.", + desc: "Conduct a sting operation to bait and capture particularly " + "notorious Synthoid criminals.", baseDifficulty: 650, difficultyFac: 1.04, rewardFac: 1.095, @@ -2154,21 +1890,14 @@ export class Bladeburner implements IBladeburner { process(player: IPlayer): void { // Edge case condition...if Operation Daedalus is complete trigger the BitNode - if ( - redPillFlag === false && - this.blackops.hasOwnProperty("Operation Daedalus") - ) { + if (redPillFlag === false && this.blackops.hasOwnProperty("Operation Daedalus")) { return hackWorldDaemon(player.bitNodeN); } // If the Player starts doing some other actions, set action to idle and alert - if ( - Augmentations[AugmentationNames.BladesSimulacrum].owned === false && - player.isWorking - ) { + if (Augmentations[AugmentationNames.BladesSimulacrum].owned === false && player.isWorking) { if (this.action.type !== ActionTypes["Idle"]) { - let msg = - "Your Bladeburner action was cancelled because you started doing something else."; + let msg = "Your Bladeburner action was cancelled because you started doing something else."; if (this.automateEnabled) { msg += `

Your automation was disabled as well. You will have to re-enable it through the Bladeburner console`; this.automateEnabled = false; @@ -2182,17 +1911,13 @@ export class Bladeburner implements IBladeburner { // If the Player has no Stamina, set action to idle if (this.stamina <= 0) { - this.log( - "Your Bladeburner action was cancelled because your stamina hit 0", - ); + this.log("Your Bladeburner action was cancelled because your stamina hit 0"); this.resetAction(); } // A 'tick' for this mechanic is one second (= 5 game cycles) if (this.storedCycles >= BladeburnerConstants.CyclesPerSecond) { - let seconds = Math.floor( - this.storedCycles / BladeburnerConstants.CyclesPerSecond, - ); + let seconds = Math.floor(this.storedCycles / BladeburnerConstants.CyclesPerSecond); seconds = Math.min(seconds, 5); // Max of 5 'ticks' this.storedCycles -= seconds * BladeburnerConstants.CyclesPerSecond; @@ -2204,23 +1929,14 @@ export class Bladeburner implements IBladeburner { // Count increase for contracts/operations for (const contract of Object.values(this.contracts) as Contract[]) { let growthF = Growths[contract.name]; - if (growthF === undefined) - throw new Error( - `growth formula for action '${contract.name}' is undefined`, - ); - contract.count += - (seconds * growthF()) / BladeburnerConstants.ActionCountGrowthPeriod; + if (growthF === undefined) throw new Error(`growth formula for action '${contract.name}' is undefined`); + contract.count += (seconds * growthF()) / BladeburnerConstants.ActionCountGrowthPeriod; } for (const op of Object.values(this.operations) as Operation[]) { const growthF = Growths[op.name]; - if (growthF === undefined) - throw new Error( - `growth formula for action '${op.name}' is undefined`, - ); + if (growthF === undefined) throw new Error(`growth formula for action '${op.name}' is undefined`); if (growthF !== undefined) { - op.count += - (seconds * growthF()) / - BladeburnerConstants.ActionCountGrowthPeriod; + op.count += (seconds * growthF()) / BladeburnerConstants.ActionCountGrowthPeriod; } } @@ -2228,9 +1944,7 @@ export class Bladeburner implements IBladeburner { for (const cityName of BladeburnerConstants.CityNames) { const city = this.cities[cityName]; if (!(city instanceof City)) { - throw new Error( - "Invalid City object when processing passive chaos reduction in Bladeburner.process", - ); + throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process"); } city.chaos -= 0.0001 * seconds; city.chaos = Math.max(0, city.chaos); @@ -2250,10 +1964,7 @@ export class Bladeburner implements IBladeburner { if (this.automateEnabled) { // Note: Do NOT set this.action = this.automateActionHigh/Low since it creates a reference if (this.stamina <= this.automateThreshLow) { - if ( - this.action.name !== this.automateActionLow.name || - this.action.type !== this.automateActionLow.type - ) { + if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) { this.action = new ActionIdentifier({ type: this.automateActionLow.type, name: this.automateActionLow.name, @@ -2261,10 +1972,7 @@ export class Bladeburner implements IBladeburner { this.startAction(player, this.action); } } else if (this.stamina >= this.automateThreshHigh) { - if ( - this.action.name !== this.automateActionHigh.name || - this.action.type !== this.automateActionHigh.type - ) { + if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) { this.action = new ActionIdentifier({ type: this.automateActionHigh.type, name: this.automateActionHigh.name, @@ -2316,12 +2024,7 @@ export class Bladeburner implements IBladeburner { return Object.keys(Skills); } - startActionNetscriptFn( - player: IPlayer, - type: string, - name: string, - workerScript: WorkerScript, - ): boolean { + startActionNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): boolean { const errorLogText = `Invalid action: type='${type}' name='${name}'`; const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { @@ -2333,25 +2036,17 @@ export class Bladeburner implements IBladeburner { if (actionId.type === ActionTypes["BlackOp"]) { // Can't start a BlackOp if you don't have the required rank const action = this.getActionObject(actionId); - if (action == null) - throw new Error(`Action not found ${actionId.type}, ${actionId.name}`); - if (!(action instanceof BlackOperation)) - throw new Error(`Action should be BlackOperation but isn't`); + if (action == null) throw new Error(`Action not found ${actionId.type}, ${actionId.name}`); + if (!(action instanceof BlackOperation)) throw new Error(`Action should be BlackOperation but isn't`); //const blackOp = (action as BlackOperation); if (action.reqdRank > this.rank) { - workerScript.log( - "bladeburner.startAction", - `Insufficient rank to start Black Op '${actionId.name}'.`, - ); + workerScript.log("bladeburner.startAction", `Insufficient rank to start Black Op '${actionId.name}'.`); return false; } // Can't start a BlackOp if its already been done if (this.blackops[actionId.name] != null) { - workerScript.log( - "bladeburner.startAction", - `Black Op ${actionId.name} has already been completed.`, - ); + workerScript.log("bladeburner.startAction", `Black Op ${actionId.name} has already been completed.`); return false; } @@ -2368,10 +2063,7 @@ export class Bladeburner implements IBladeburner { const i = blackops.indexOf(actionId.name); if (i === -1) { - workerScript.log( - "bladeburner.startAction", - `Invalid Black Op: '${name}'`, - ); + workerScript.log("bladeburner.startAction", `Invalid Black Op: '${name}'`); return false; } @@ -2386,10 +2078,7 @@ export class Bladeburner implements IBladeburner { try { this.startAction(player, actionId); - workerScript.log( - "bladeburner.startAction", - `Starting bladeburner action with type '${type}' and name ${name}"`, - ); + workerScript.log("bladeburner.startAction", `Starting bladeburner action with type '${type}' and name ${name}"`); return true; } catch (e) { this.resetAction(); @@ -2398,12 +2087,7 @@ export class Bladeburner implements IBladeburner { } } - getActionTimeNetscriptFn( - player: IPlayer, - type: string, - name: string, - workerScript: WorkerScript, - ): number { + getActionTimeNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): number { const errorLogText = `Invalid action: type='${type}' name='${name}'`; const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { @@ -2447,19 +2131,13 @@ export class Bladeburner implements IBladeburner { const errorLogText = `Invalid action: type='${type}' name='${name}'`; const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { - workerScript.log( - "bladeburner.getActionEstimatedSuccessChance", - errorLogText, - ); + workerScript.log("bladeburner.getActionEstimatedSuccessChance", errorLogText); return [-1, -1]; } const actionObj = this.getActionObject(actionId); if (actionObj == null) { - workerScript.log( - "bladeburner.getActionEstimatedSuccessChance", - errorLogText, - ); + workerScript.log("bladeburner.getActionEstimatedSuccessChance", errorLogText); return [-1, -1]; } @@ -2480,19 +2158,12 @@ export class Bladeburner implements IBladeburner { return [recChance, recChance]; } default: - workerScript.log( - "bladeburner.getActionEstimatedSuccessChance", - errorLogText, - ); + workerScript.log("bladeburner.getActionEstimatedSuccessChance", errorLogText); return [-1, -1]; } } - getActionCountRemainingNetscriptFn( - type: string, - name: string, - workerScript: WorkerScript, - ): number { + getActionCountRemainingNetscriptFn(type: string, name: string, workerScript: WorkerScript): number { const errorLogText = `Invalid action: type='${type}' name='${name}'`; const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { @@ -2530,15 +2201,9 @@ export class Bladeburner implements IBladeburner { } } - getSkillLevelNetscriptFn( - skillName: string, - workerScript: WorkerScript, - ): number { + getSkillLevelNetscriptFn(skillName: string, workerScript: WorkerScript): number { if (skillName === "" || !Skills.hasOwnProperty(skillName)) { - workerScript.log( - "bladeburner.getSkillLevel", - `Invalid skill: '${skillName}'`, - ); + workerScript.log("bladeburner.getSkillLevel", `Invalid skill: '${skillName}'`); return -1; } @@ -2549,15 +2214,9 @@ export class Bladeburner implements IBladeburner { } } - getSkillUpgradeCostNetscriptFn( - skillName: string, - workerScript: WorkerScript, - ): number { + getSkillUpgradeCostNetscriptFn(skillName: string, workerScript: WorkerScript): number { if (skillName === "" || !Skills.hasOwnProperty(skillName)) { - workerScript.log( - "bladeburner.getSkillUpgradeCost", - `Invalid skill: '${skillName}'`, - ); + workerScript.log("bladeburner.getSkillUpgradeCost", `Invalid skill: '${skillName}'`); return -1; } @@ -2569,10 +2228,7 @@ export class Bladeburner implements IBladeburner { } } - upgradeSkillNetscriptFn( - skillName: string, - workerScript: WorkerScript, - ): boolean { + upgradeSkillNetscriptFn(skillName: string, workerScript: WorkerScript): boolean { const errorLogText = `Invalid skill: '${skillName}'`; if (!Skills.hasOwnProperty(skillName)) { workerScript.log("bladeburner.upgradeSkill", errorLogText); @@ -2587,10 +2243,7 @@ export class Bladeburner implements IBladeburner { const cost = skill.calculateCost(currentLevel); if (skill.maxLvl && currentLevel >= skill.maxLvl) { - workerScript.log( - "bladeburner.upgradeSkill", - `Skill '${skillName}' is already maxed.`, - ); + workerScript.log("bladeburner.upgradeSkill", `Skill '${skillName}' is already maxed.`); return false; } @@ -2604,18 +2257,11 @@ export class Bladeburner implements IBladeburner { this.skillPoints -= cost; this.upgradeSkill(skill); - workerScript.log( - "bladeburner.upgradeSkill", - `'${skillName}' upgraded to level ${this.skills[skillName]}`, - ); + workerScript.log("bladeburner.upgradeSkill", `'${skillName}' upgraded to level ${this.skills[skillName]}`); return true; } - getTeamSizeNetscriptFn( - type: string, - name: string, - workerScript: WorkerScript, - ): number { + getTeamSizeNetscriptFn(type: string, name: string, workerScript: WorkerScript): number { if (type === "" && name === "") { return this.teamSize; } @@ -2644,12 +2290,7 @@ export class Bladeburner implements IBladeburner { } } - setTeamSizeNetscriptFn( - type: string, - name: string, - size: number, - workerScript: WorkerScript, - ): number { + setTeamSizeNetscriptFn(type: string, name: string, size: number, workerScript: WorkerScript): number { const errorLogText = `Invalid action: type='${type}' name='${name}'`; const actionId = this.getActionIdFromTypeAndName(type, name); if (actionId == null) { @@ -2662,10 +2303,7 @@ export class Bladeburner implements IBladeburner { actionId.type !== ActionTypes["BlackOp"] && actionId.type !== ActionTypes["BlackOperation"] ) { - workerScript.log( - "bladeburner.setTeamSize", - "Only valid for 'Operations' and 'BlackOps'", - ); + workerScript.log("bladeburner.setTeamSize", "Only valid for 'Operations' and 'BlackOps'"); return -1; } @@ -2684,10 +2322,7 @@ export class Bladeburner implements IBladeburner { sanitizedSize = this.teamSize; } actionObj.teamCount = sanitizedSize; - workerScript.log( - "bladeburner.setTeamSize", - `Team size for '${name}' set to ${sanitizedSize}.`, - ); + workerScript.log("bladeburner.setTeamSize", `Team size for '${name}' set to ${sanitizedSize}.`); return sanitizedSize; } @@ -2697,10 +2332,7 @@ export class Bladeburner implements IBladeburner { return true; } else if (this.rank >= BladeburnerConstants.RankNeededForFaction) { joinFaction(bladeburnerFac); - workerScript.log( - "bladeburner.joinBladeburnerFaction", - "Joined Bladeburners faction.", - ); + workerScript.log("bladeburner.joinBladeburnerFaction", "Joined Bladeburners faction."); return true; } else { workerScript.log( diff --git a/src/Bladeburner/City.ts b/src/Bladeburner/City.ts index c36673c78..029a0fd7f 100644 --- a/src/Bladeburner/City.ts +++ b/src/Bladeburner/City.ts @@ -1,10 +1,6 @@ import { BladeburnerConstants } from "./data/Constants"; import { getRandomInt } from "../../utils/helpers/getRandomInt"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; import { addOffset } from "../../utils/helpers/addOffset"; interface IChangePopulationByCountParams { @@ -52,10 +48,7 @@ export class City { this.name = name; // Synthoid population and estimate - this.pop = getRandomInt( - BladeburnerConstants.PopulationThreshold, - 1.5 * BladeburnerConstants.PopulationThreshold, - ); + this.pop = getRandomInt(BladeburnerConstants.PopulationThreshold, 1.5 * BladeburnerConstants.PopulationThreshold); this.popEst = this.pop * (Math.random() + 0.5); // Number of Synthoid communities population and estimate @@ -83,9 +76,7 @@ export class City { improvePopulationEstimateByCount(n: number): void { if (isNaN(n)) { - throw new Error( - "NaN passeed into City.improvePopulationEstimateByCount()", - ); + throw new Error("NaN passeed into City.improvePopulationEstimateByCount()"); } if (this.popEst < this.pop) { this.popEst += n; @@ -106,9 +97,7 @@ export class City { improvePopulationEstimateByPercentage(p: number, skillMult = 1): void { p = p * skillMult; if (isNaN(p)) { - throw new Error( - "NaN passed into City.improvePopulationEstimateByPercentage()", - ); + throw new Error("NaN passed into City.improvePopulationEstimateByPercentage()"); } if (this.popEst < this.pop) { ++this.popEst; // In case estimate is 0 @@ -146,10 +135,7 @@ export class City { * estChange(int): How much the estimate should change by * estOffset(int): Add offset to estimate (offset by percentage) */ - changePopulationByCount( - n: number, - params: IChangePopulationByCountParams = { estChange: 0, estOffset: 0 }, - ): void { + changePopulationByCount(n: number, params: IChangePopulationByCountParams = { estChange: 0, estOffset: 0 }): void { if (isNaN(n)) { throw new Error("NaN passed into City.changePopulationByCount()"); } diff --git a/src/Bladeburner/Contract.ts b/src/Bladeburner/Contract.ts index f9613e560..c1e68b81d 100644 --- a/src/Bladeburner/Contract.ts +++ b/src/Bladeburner/Contract.ts @@ -1,10 +1,6 @@ import { IBladeburner } from "./IBladeburner"; import { Action, IActionParams } from "./Action"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; export class Contract extends Action { constructor(params: IActionParams | null = null) { diff --git a/src/Bladeburner/IAction.ts b/src/Bladeburner/IAction.ts index 3c0c7a6c9..4fb4a2495 100644 --- a/src/Bladeburner/IAction.ts +++ b/src/Bladeburner/IAction.ts @@ -61,10 +61,7 @@ export interface IAction { getActionTime(inst: IBladeburner): number; getTeamSuccessBonus(inst: IBladeburner): number; getActionTypeSkillSuccessBonus(inst: IBladeburner): number; - getChaosCompetencePenalty( - inst: IBladeburner, - params: ISuccessChanceParams, - ): number; + getChaosCompetencePenalty(inst: IBladeburner, params: ISuccessChanceParams): number; getChaosDifficultyBonus(inst: IBladeburner): number; getEstSuccessChance(inst: IBladeburner): number[]; getSuccessChance(inst: IBladeburner, params: ISuccessChanceParams): number; diff --git a/src/Bladeburner/IBladeburner.ts b/src/Bladeburner/IBladeburner.ts index 05e70416a..8b2ed88c2 100644 --- a/src/Bladeburner/IBladeburner.ts +++ b/src/Bladeburner/IBladeburner.ts @@ -68,57 +68,22 @@ export interface IBladeburner { getBlackOpNamesNetscriptFn(): string[]; getGeneralActionNamesNetscriptFn(): string[]; getSkillNamesNetscriptFn(): string[]; - startActionNetscriptFn( - player: IPlayer, - type: string, - name: string, - workerScript: WorkerScript, - ): boolean; - getActionTimeNetscriptFn( - player: IPlayer, - type: string, - name: string, - workerScript: WorkerScript, - ): number; + startActionNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): boolean; + getActionTimeNetscriptFn(player: IPlayer, type: string, name: string, workerScript: WorkerScript): number; getActionEstimatedSuccessChanceNetscriptFn( player: IPlayer, type: string, name: string, workerScript: WorkerScript, ): number[]; - getActionCountRemainingNetscriptFn( - type: string, - name: string, - workerScript: WorkerScript, - ): number; - getSkillLevelNetscriptFn( - skillName: string, - workerScript: WorkerScript, - ): number; - getSkillUpgradeCostNetscriptFn( - skillName: string, - workerScript: WorkerScript, - ): number; - upgradeSkillNetscriptFn( - skillName: string, - workerScript: WorkerScript, - ): boolean; - getTeamSizeNetscriptFn( - type: string, - name: string, - workerScript: WorkerScript, - ): number; - setTeamSizeNetscriptFn( - type: string, - name: string, - size: number, - workerScript: WorkerScript, - ): number; + getActionCountRemainingNetscriptFn(type: string, name: string, workerScript: WorkerScript): number; + getSkillLevelNetscriptFn(skillName: string, workerScript: WorkerScript): number; + getSkillUpgradeCostNetscriptFn(skillName: string, workerScript: WorkerScript): number; + upgradeSkillNetscriptFn(skillName: string, workerScript: WorkerScript): boolean; + getTeamSizeNetscriptFn(type: string, name: string, workerScript: WorkerScript): number; + setTeamSizeNetscriptFn(type: string, name: string, size: number, workerScript: WorkerScript): number; joinBladeburnerFactionNetscriptFn(workerScript: WorkerScript): boolean; - getActionIdFromTypeAndName( - type: string, - name: string, - ): IActionIdentifier | null; + getActionIdFromTypeAndName(type: string, name: string): IActionIdentifier | null; executeStartConsoleCommand(player: IPlayer, args: string[]): void; executeSkillConsoleCommand(args: string[]): void; executeLogConsoleCommand(args: string[]): void; diff --git a/src/Bladeburner/Operation.ts b/src/Bladeburner/Operation.ts index ae572ef64..fe2052f4a 100644 --- a/src/Bladeburner/Operation.ts +++ b/src/Bladeburner/Operation.ts @@ -1,11 +1,7 @@ import { IBladeburner } from "./IBladeburner"; import { BladeburnerConstants } from "./data/Constants"; import { Action, IActionParams } from "./Action"; -import { - Generic_fromJSON, - Generic_toJSON, - Reviver, -} from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; export interface IOperationParams extends IActionParams { reqdRank?: number; @@ -37,9 +33,7 @@ export class Operation extends Action { return inst.skillMultipliers.successChanceOperation; } - getChaosDifficultyBonus( - inst: IBladeburner /*, params: ISuccessChanceParams*/, - ): number { + getChaosDifficultyBonus(inst: IBladeburner /*, params: ISuccessChanceParams*/): number { const city = inst.getCurrentCity(); if (city.chaos > BladeburnerConstants.ChaosThreshold) { const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold); diff --git a/src/Bladeburner/Skill.ts b/src/Bladeburner/Skill.ts index 95d26dcce..160429ed5 100644 --- a/src/Bladeburner/Skill.ts +++ b/src/Bladeburner/Skill.ts @@ -66,14 +66,10 @@ export class Skill { constructor(params: ISkillParams = { name: "foo", desc: "foo" }) { if (!params.name) { - throw new Error( - "Failed to initialize Bladeburner Skill. No name was specified in ctor", - ); + throw new Error("Failed to initialize Bladeburner Skill. No name was specified in ctor"); } if (!params.desc) { - throw new Error( - "Failed to initialize Bladeburner Skills. No desc was specified in ctor", - ); + throw new Error("Failed to initialize Bladeburner Skills. No desc was specified in ctor"); } this.name = params.name; this.desc = params.desc; @@ -138,10 +134,7 @@ export class Skill { } calculateCost(currentLevel: number): number { - return Math.floor( - (this.baseCost + currentLevel * this.costInc) * - BitNodeMultipliers.BladeburnerSkillCost, - ); + return Math.floor((this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost); } getMultiplier(name: string): number { diff --git a/src/Bladeburner/Skills.ts b/src/Bladeburner/Skills.ts index c242b7929..6067b4f71 100644 --- a/src/Bladeburner/Skills.ts +++ b/src/Bladeburner/Skills.ts @@ -8,8 +8,7 @@ export const Skills: IMap = {}; Skills[SkillNames.BladesIntuition] = new Skill({ name: SkillNames.BladesIntuition, desc: - "Each level of this skill increases your success chance " + - "for all Contracts, Operations, and BlackOps by 3%", + "Each level of this skill increases your success chance " + "for all Contracts, Operations, and BlackOps by 3%", baseCost: 3, costInc: 2.1, successChanceAll: 3, @@ -34,18 +33,14 @@ export const Skills: IMap = {}; }); Skills[SkillNames.DigitalObserver] = new Skill({ name: SkillNames.DigitalObserver, - desc: - "Each level of this skill increases your success chance in " + - "all Operations and BlackOps by 4%", + desc: "Each level of this skill increases your success chance in " + "all Operations and BlackOps by 4%", baseCost: 2, costInc: 2.1, successChanceOperation: 4, }); Skills[SkillNames.Tracer] = new Skill({ name: SkillNames.Tracer, - desc: - "Each level of this skill increases your success chance in " + - "all Contracts by 4%", + desc: "Each level of this skill increases your success chance in " + "all Contracts by 4%", baseCost: 2, costInc: 2.1, successChanceContract: 4, @@ -72,9 +67,7 @@ export const Skills: IMap = {}; }); Skills[SkillNames.EvasiveSystem] = new Skill({ name: SkillNames.EvasiveSystem, - desc: - "Each level of this skill increases your effective " + - "dexterity and agility for Bladeburner actions by 4%", + desc: "Each level of this skill increases your effective " + "dexterity and agility for Bladeburner actions by 4%", baseCost: 2, costInc: 2.1, effDex: 4, diff --git a/src/Bladeburner/data/Constants.ts b/src/Bladeburner/data/Constants.ts index 4672f803c..6fbd2b38f 100644 --- a/src/Bladeburner/data/Constants.ts +++ b/src/Bladeburner/data/Constants.ts @@ -27,14 +27,7 @@ export const BladeburnerConstants: { HrcHpGain: number; HrcStaminaGain: number; } = { - CityNames: [ - "Aevum", - "Chongqing", - "Sector-12", - "New Tokyo", - "Ishima", - "Volhaven", - ], + CityNames: ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"], CyclesPerSecond: 5, // Game cycle is 200 ms StaminaGainPerSecond: 0.0085, diff --git a/src/Bladeburner/data/Icons.tsx b/src/Bladeburner/data/Icons.tsx index b17211ca4..e156a6a51 100644 --- a/src/Bladeburner/data/Icons.tsx +++ b/src/Bladeburner/data/Icons.tsx @@ -1,13 +1,7 @@ import * as React from "react"; export const stealthIcon = ( - + diff --git a/src/Bladeburner/ui/AllPages.tsx b/src/Bladeburner/ui/AllPages.tsx index 479d2d841..8c773bcd5 100644 --- a/src/Bladeburner/ui/AllPages.tsx +++ b/src/Bladeburner/ui/AllPages.tsx @@ -26,11 +26,7 @@ export function AllPages(props: IProps): React.ReactElement { return ( setPage(props.name)} - className={ - page !== props.name - ? "bladeburner-nav-button noselect" - : "bladeburner-nav-button-inactive noselect" - } + className={page !== props.name ? "bladeburner-nav-button noselect" : "bladeburner-nav-button-inactive noselect"} > {props.name} @@ -44,29 +40,14 @@ export function AllPages(props: IProps): React.ReactElement {
- {page === "General" && ( - - )} - {page === "Contracts" && ( - - )} - {page === "Operations" && ( - - )} - {page === "BlackOps" && ( - - )} + {page === "General" && } + {page === "Contracts" && } + {page === "Operations" && } + {page === "BlackOps" && } {page === "Skills" && }
- {stealthIcon} = This action requires stealth, {killIcon} = This action - involves retirement + {stealthIcon} = This action requires stealth, {killIcon} = This action involves retirement ); diff --git a/src/Bladeburner/ui/BlackOpElem.tsx b/src/Bladeburner/ui/BlackOpElem.tsx index 7d5fba339..760508af0 100644 --- a/src/Bladeburner/ui/BlackOpElem.tsx +++ b/src/Bladeburner/ui/BlackOpElem.tsx @@ -1,8 +1,5 @@ import React, { useState } from "react"; -import { - formatNumber, - convertTimeMsToTimeElapsedString, -} from "../../../utils/StringHelperFunctions"; +import { formatNumber, convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions"; import { ActionTypes } from "../data/ActionTypes"; import { createProgressBarText } from "../../../utils/helpers/createProgressBarText"; import { stealthIcon, killIcon } from "../data/Icons"; @@ -23,17 +20,13 @@ export function BlackOpElem(props: IProps): React.ReactElement { const setRerender = useState(false)[1]; const isCompleted = props.bladeburner.blackops[props.action.name] != null; if (isCompleted) { - return ( -

{props.action.name} (COMPLETED)

- ); + return

{props.action.name} (COMPLETED)

; } const isActive = props.bladeburner.action.type === ActionTypes["BlackOperation"] && props.action.name === props.bladeburner.action.name; - const estimatedSuccessChance = props.action.getEstSuccessChance( - props.bladeburner, - ); + const estimatedSuccessChance = props.action.getEstSuccessChance(props.bladeburner); const actionTime = props.action.getActionTime(props.bladeburner); const hasReqdRank = props.bladeburner.rank >= props.action.reqdRank; const computedActionTimeCurrent = Math.min( @@ -62,8 +55,7 @@ export function BlackOpElem(props: IProps): React.ReactElement {

{isActive ? ( <> - (IN PROGRESS -{" "} - {formatNumber(computedActionTimeCurrent, 0)} /{" "} + (IN PROGRESS - {formatNumber(computedActionTimeCurrent, 0)} /{" "} {formatNumber(props.bladeburner.actionTimeToComplete, 0)}) ) : ( @@ -73,9 +65,7 @@ export function BlackOpElem(props: IProps): React.ReactElement { {isActive ? (

{createProgressBarText({ - progress: - computedActionTimeCurrent / - props.bladeburner.actionTimeToComplete, + progress: computedActionTimeCurrent / props.bladeburner.actionTimeToComplete, })}

) : ( @@ -87,21 +77,14 @@ export function BlackOpElem(props: IProps): React.ReactElement { > Start - + Set Team Size (Curr Size: {formatNumber(props.action.teamCount, 0)}) )}

-

+



@@ -109,8 +92,7 @@ export function BlackOpElem(props: IProps): React.ReactElement {


-        Estimated Success Chance:{" "}
-        {" "}
+        Estimated Success Chance: {" "}
         {props.action.isStealth ? stealthIcon : <>}
         {props.action.isKill ? killIcon : <>}
         
diff --git a/src/Bladeburner/ui/BlackOpList.tsx b/src/Bladeburner/ui/BlackOpList.tsx index a001578d0..02dc5470a 100644 --- a/src/Bladeburner/ui/BlackOpList.tsx +++ b/src/Bladeburner/ui/BlackOpList.tsx @@ -22,7 +22,8 @@ export function BlackOpList(props: IProps): React.ReactElement { }); blackops = blackops.filter( - (blackop: BlackOperation, i: number) => !( + (blackop: BlackOperation, i: number) => + !( props.bladeburner.blackops[blackops[i].name] == null && i !== 0 && props.bladeburner.blackops[blackops[i - 1].name] == null @@ -35,11 +36,7 @@ export function BlackOpList(props: IProps): React.ReactElement { <> {blackops.map((blackop: BlackOperation) => (
  • - +
  • ))} diff --git a/src/Bladeburner/ui/BlackOpPage.tsx b/src/Bladeburner/ui/BlackOpPage.tsx index 0c158eec5..006228546 100644 --- a/src/Bladeburner/ui/BlackOpPage.tsx +++ b/src/Bladeburner/ui/BlackOpPage.tsx @@ -12,19 +12,15 @@ export function BlackOpPage(props: IProps): React.ReactElement { return ( <>

    - Black Operations (Black Ops) are special, one-time covert operations. - Each Black Op must be unlocked successively by completing the one before - it. + Black Operations (Black Ops) are special, one-time covert operations. Each Black Op must be unlocked + successively by completing the one before it.

    - - Your ultimate goal to climb through the ranks of Bladeburners is to - complete all of the Black Ops. - + Your ultimate goal to climb through the ranks of Bladeburners is to complete all of the Black Ops.

    - Like normal operations, you may use a team for Black Ops. Failing a - black op will incur heavy HP and rank losses. + Like normal operations, you may use a team for Black Ops. Failing a black op will incur heavy HP and rank + losses.

    diff --git a/src/Bladeburner/ui/Console.tsx b/src/Bladeburner/ui/Console.tsx index 027feac3c..1dce0224e 100644 --- a/src/Bladeburner/ui/Console.tsx +++ b/src/Bladeburner/ui/Console.tsx @@ -10,10 +10,7 @@ interface ILineProps { function Line(props: ILineProps): React.ReactElement { return ( - + {props.content} @@ -29,9 +26,7 @@ export function Console(props: IProps): React.ReactElement { const lastRef = useRef(null); const setRerender = useState(false)[1]; - const [consoleHistoryIndex, setConsoleHistoryIndex] = useState( - props.bladeburner.consoleHistory.length, - ); + const [consoleHistoryIndex, setConsoleHistoryIndex] = useState(props.bladeburner.consoleHistory.length); // TODO: Figure out how to actually make the scrolling work correctly. function scrollToBottom(): void { @@ -121,11 +116,7 @@ export function Console(props: IProps): React.ReactElement { {props.bladeburner.consoleLogs.map((log: any, i: number) => ( ))} - +
    {"> "}
    !old); } function decreaseLevel(): void { --props.action.level; - if (isActive) - props.bladeburner.startAction(props.player, props.bladeburner.action); + if (isActive) props.bladeburner.startAction(props.player, props.bladeburner.action); setRerender((old) => !old); } @@ -65,8 +57,7 @@ export function ContractElem(props: IProps): React.ReactElement {

    {isActive ? ( <> - (IN PROGRESS -{" "} - {formatNumber(computedActionTimeCurrent, 0)} /{" "} + (IN PROGRESS - {formatNumber(computedActionTimeCurrent, 0)} /{" "} {formatNumber(props.bladeburner.actionTimeToComplete, 0)}) ) : ( @@ -76,18 +67,12 @@ export function ContractElem(props: IProps): React.ReactElement { {isActive ? (

    {createProgressBarText({ - progress: - computedActionTimeCurrent / - props.bladeburner.actionTimeToComplete, + progress: computedActionTimeCurrent / props.bladeburner.actionTimeToComplete, })}

    ) : ( <> - + Start @@ -96,40 +81,24 @@ export function ContractElem(props: IProps): React.ReactElement {
             
    -          {props.action.getSuccessesNeededForNextLevel(
    -            BladeburnerConstants.ContractSuccessesPerLevel,
    -          )}{" "}
    -          successes needed for next level
    +          {props.action.getSuccessesNeededForNextLevel(BladeburnerConstants.ContractSuccessesPerLevel)} successes needed
    +          for next level
             
             Level: {props.action.level} / {props.action.maxLevel}
           
    - {isActive && ( - - WARNING: changing the level will restart the Operation - - )} - ↑ + {isActive && WARNING: changing the level will restart the Operation}↑ - {isActive && ( - - WARNING: changing the level will restart the Operation - - )} - ↓ + {isActive && WARNING: changing the level will restart the Operation}↓

    @@ -137,8 +106,7 @@ export function ContractElem(props: IProps): React.ReactElement {

    - Estimated success chance:{" "} - {" "} + Estimated success chance: {" "} {props.action.isStealth ? stealthIcon : <>} {props.action.isKill ? killIcon : <>}
    @@ -151,22 +119,11 @@ export function ContractElem(props: IProps): React.ReactElement { Failures: {props.action.failures}


    -

    diff --git a/src/Bladeburner/ui/SkillElem.tsx b/src/Bladeburner/ui/SkillElem.tsx index 85f563881..b362f1408 100644 --- a/src/Bladeburner/ui/SkillElem.tsx +++ b/src/Bladeburner/ui/SkillElem.tsx @@ -12,18 +12,13 @@ interface IProps { export function SkillElem(props: IProps): React.ReactElement { const skillName = props.skill.name; let currentLevel = 0; - if ( - props.bladeburner.skills[skillName] && - !isNaN(props.bladeburner.skills[skillName]) - ) { + if (props.bladeburner.skills[skillName] && !isNaN(props.bladeburner.skills[skillName])) { currentLevel = props.bladeburner.skills[skillName]; } const pointCost = props.skill.calculateCost(currentLevel); const canLevel = props.bladeburner.skillPoints >= pointCost; - const maxLvl = props.skill.maxLvl - ? currentLevel >= props.skill.maxLvl - : false; + const maxLvl = props.skill.maxLvl ? currentLevel >= props.skill.maxLvl : false; function onClick(): void { if (props.bladeburner.skillPoints < pointCost) return; @@ -40,9 +35,7 @@ export function SkillElem(props: IProps): React.ReactElement { Level @@ -52,14 +45,9 @@ export function SkillElem(props: IProps): React.ReactElement { {maxLvl ? (

    MAX LEVEL

    ) : ( -

    - Skill Points required: {formatNumber(pointCost, 0)} -

    +

    Skill Points required: {formatNumber(pointCost, 0)}

    )} -

    +

    ); } diff --git a/src/Bladeburner/ui/SkillList.tsx b/src/Bladeburner/ui/SkillList.tsx index 6e2a21f6b..9ee24a2e6 100644 --- a/src/Bladeburner/ui/SkillList.tsx +++ b/src/Bladeburner/ui/SkillList.tsx @@ -13,11 +13,7 @@ export function SkillList(props: IProps): React.ReactElement { <> {Object.keys(Skills).map((skill: string) => (

  • - +
  • ))} diff --git a/src/Bladeburner/ui/SkillPage.tsx b/src/Bladeburner/ui/SkillPage.tsx index 259e1b3ff..fd36e8f5a 100644 --- a/src/Bladeburner/ui/SkillPage.tsx +++ b/src/Bladeburner/ui/SkillPage.tsx @@ -19,94 +19,46 @@ export function SkillPage(props: IProps): React.ReactElement { return ( <>

    - - Skill Points: {formatNumber(props.bladeburner.skillPoints, 0)} - + Skill Points: {formatNumber(props.bladeburner.skillPoints, 0)}

    - You will gain one skill point every{" "} - {BladeburnerConstants.RanksPerSkillPoint} ranks. + You will gain one skill point every {BladeburnerConstants.RanksPerSkillPoint} ranks.

    - Note that when upgrading a skill, the benefit for that skill is - additive. However, the effects of different skills with each other is - multiplicative. + Note that when upgrading a skill, the benefit for that skill is additive. However, the effects of different + skills with each other is multiplicative.


    - {valid(mults["successChanceAll"]) && ( -

    - Total Success Chance: x{formatNumber(mults["successChanceAll"], 3)} -

    - )} + {valid(mults["successChanceAll"]) &&

    Total Success Chance: x{formatNumber(mults["successChanceAll"], 3)}

    } {valid(mults["successChanceStealth"]) && ( -

    - Stealth Success Chance: x - {formatNumber(mults["successChanceStealth"], 3)} -

    +

    Stealth Success Chance: x{formatNumber(mults["successChanceStealth"], 3)}

    )} {valid(mults["successChanceKill"]) && ( -

    - Retirement Success Chance: x - {formatNumber(mults["successChanceKill"], 3)} -

    +

    Retirement Success Chance: x{formatNumber(mults["successChanceKill"], 3)}

    )} {valid(mults["successChanceContract"]) && ( -

    - Contract Success Chance: x - {formatNumber(mults["successChanceContract"], 3)} -

    +

    Contract Success Chance: x{formatNumber(mults["successChanceContract"], 3)}

    )} {valid(mults["successChanceOperation"]) && ( -

    - Operation Success Chance: x - {formatNumber(mults["successChanceOperation"], 3)} -

    +

    Operation Success Chance: x{formatNumber(mults["successChanceOperation"], 3)}

    )} {valid(mults["successChanceEstimate"]) && ( -

    - Synthoid Data Estimate: x - {formatNumber(mults["successChanceEstimate"], 3)} -

    - )} - {valid(mults["actionTime"]) && ( -

    Action Time: x{formatNumber(mults["actionTime"], 3)}

    - )} - {valid(mults["effHack"]) && ( -

    Hacking Skill: x{formatNumber(mults["effHack"], 3)}

    - )} - {valid(mults["effStr"]) && ( -

    Strength: x{formatNumber(mults["effStr"], 3)}

    - )} - {valid(mults["effDef"]) && ( -

    Defense: x{formatNumber(mults["effDef"], 3)}

    - )} - {valid(mults["effDex"]) && ( -

    Dexterity: x{formatNumber(mults["effDex"], 3)}

    - )} - {valid(mults["effAgi"]) && ( -

    Agility: x{formatNumber(mults["effAgi"], 3)}

    - )} - {valid(mults["effCha"]) && ( -

    Charisma: x{formatNumber(mults["effCha"], 3)}

    - )} - {valid(mults["effInt"]) && ( -

    Intelligence: x{formatNumber(mults["effInt"], 3)}

    - )} - {valid(mults["stamina"]) && ( -

    Stamina: x{formatNumber(mults["stamina"], 3)}

    - )} - {valid(mults["money"]) && ( -

    Contract Money: x{formatNumber(mults["money"], 3)}

    - )} - {valid(mults["expGain"]) && ( -

    Exp Gain: x{formatNumber(mults["expGain"], 3)}

    +

    Synthoid Data Estimate: x{formatNumber(mults["successChanceEstimate"], 3)}

    )} + {valid(mults["actionTime"]) &&

    Action Time: x{formatNumber(mults["actionTime"], 3)}

    } + {valid(mults["effHack"]) &&

    Hacking Skill: x{formatNumber(mults["effHack"], 3)}

    } + {valid(mults["effStr"]) &&

    Strength: x{formatNumber(mults["effStr"], 3)}

    } + {valid(mults["effDef"]) &&

    Defense: x{formatNumber(mults["effDef"], 3)}

    } + {valid(mults["effDex"]) &&

    Dexterity: x{formatNumber(mults["effDex"], 3)}

    } + {valid(mults["effAgi"]) &&

    Agility: x{formatNumber(mults["effAgi"], 3)}

    } + {valid(mults["effCha"]) &&

    Charisma: x{formatNumber(mults["effCha"], 3)}

    } + {valid(mults["effInt"]) &&

    Intelligence: x{formatNumber(mults["effInt"], 3)}

    } + {valid(mults["stamina"]) &&

    Stamina: x{formatNumber(mults["stamina"], 3)}

    } + {valid(mults["money"]) &&

    Contract Money: x{formatNumber(mults["money"], 3)}

    } + {valid(mults["expGain"]) &&

    Exp Gain: x{formatNumber(mults["expGain"], 3)}

    }
    - setRerender((old) => !old)} - /> + setRerender((old) => !old)} /> ); } diff --git a/src/Bladeburner/ui/Stats.tsx b/src/Bladeburner/ui/Stats.tsx index bbda4238a..aba9e2fed 100644 --- a/src/Bladeburner/ui/Stats.tsx +++ b/src/Bladeburner/ui/Stats.tsx @@ -1,8 +1,5 @@ import React, { useState, useEffect } from "react"; -import { - formatNumber, - convertTimeMsToTimeElapsedString, -} from "../../../utils/StringHelperFunctions"; +import { formatNumber, convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions"; import { BladeburnerConstants } from "../data/Constants"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { IEngine } from "../../IEngine"; @@ -12,10 +9,7 @@ import { numeralWrapper } from "../../ui/numeralFormat"; import { dialogBoxCreate } from "../../../utils/DialogBox"; import { createPopup } from "../../ui/React/createPopup"; import { Factions } from "../../Faction/Factions"; -import { - joinFaction, - displayFactionContent, -} from "../../Faction/FactionHelpers"; +import { joinFaction, displayFactionContent } from "../../Faction/FactionHelpers"; import { IBladeburner } from "../IBladeburner"; import { TravelPopup } from "./TravelPopup"; @@ -83,13 +77,9 @@ export function Stats(props: IProps): React.ReactElement { } else { if (props.bladeburner.rank >= BladeburnerConstants.RankNeededForFaction) { joinFaction(faction); - dialogBoxCreate( - "Congratulations! You were accepted into the Bladeburners faction", - ); + dialogBoxCreate("Congratulations! You were accepted into the Bladeburners faction"); } else { - dialogBoxCreate( - "You need a rank of 25 to join the Bladeburners Faction!", - ); + dialogBoxCreate("You need a rank of 25 to join the Bladeburners Faction!"); } } } @@ -98,46 +88,31 @@ export function Stats(props: IProps): React.ReactElement { <>

    Rank: {formatNumber(props.bladeburner.rank, 2)} - - Your rank within the Bladeburner division. - + Your rank within the Bladeburner division.


    - Stamina: {formatNumber(props.bladeburner.stamina, 3)} /{" "} - {formatNumber(props.bladeburner.maxStamina, 3)} + Stamina: {formatNumber(props.bladeburner.stamina, 3)} / {formatNumber(props.bladeburner.maxStamina, 3)}

    ?

    -

    - Stamina Penalty:{" "} - {formatNumber( - (1 - props.bladeburner.calculateStaminaPenalty()) * 100, - 1, - )} - % -

    +

    Stamina Penalty: {formatNumber((1 - props.bladeburner.calculateStaminaPenalty()) * 100, 1)}%


    Team Size: {formatNumber(props.bladeburner.teamSize, 0)}

    Team Members Lost: {formatNumber(props.bladeburner.teamLost, 0)}


    Num Times Hospitalized: {props.bladeburner.numHosp}

    - Money Lost From Hospitalizations:{" "} - + Money Lost From Hospitalizations:


    Current City: {props.bladeburner.city}

    - Est. Synthoid Population:{" "} - {numeralWrapper.formatPopulation( - props.bladeburner.getCurrentCity().popEst, - )} + Est. Synthoid Population: {numeralWrapper.formatPopulation(props.bladeburner.getCurrentCity().popEst)} - This is your Bladeburner division's estimate of how many Synthoids - exist in your current city. + This is your Bladeburner division's estimate of how many Synthoids exist in your current city.

    @@ -145,20 +120,17 @@ export function Stats(props: IProps): React.ReactElement {

    - Est. Synthoid Communities:{" "} - {formatNumber(props.bladeburner.getCurrentCity().comms, 0)} + Est. Synthoid Communities: {formatNumber(props.bladeburner.getCurrentCity().comms, 0)} - This is your Bladeburner divison's estimate of how many Synthoid - communities exist in your current city. + This is your Bladeburner divison's estimate of how many Synthoid communities exist in your current city.


    City Chaos: {formatNumber(props.bladeburner.getCurrentCity().chaos)} - The city's chaos level due to tensions and conflicts between humans - and Synthoids. Having too high of a chaos level can make contracts and - operations harder. + The city's chaos level due to tensions and conflicts between humans and Synthoids. Having too high of a chaos + level can make contracts and operations harder.


    @@ -166,56 +138,29 @@ export function Stats(props: IProps): React.ReactElement {

    Bonus time:{" "} {convertTimeMsToTimeElapsedString( - (props.bladeburner.storedCycles / - BladeburnerConstants.CyclesPerSecond) * - 1000, + (props.bladeburner.storedCycles / BladeburnerConstants.CyclesPerSecond) * 1000, )}
    - You gain bonus time while offline or when the game is inactive (e.g. - when the tab is throttled by browser). Bonus time makes the - Bladeburner mechanic progress faster, up to 5x the normal speed. + You gain bonus time while offline or when the game is inactive (e.g. when the tab is throttled by browser). + Bonus time makes the Bladeburner mechanic progress faster, up to 5x the normal speed.

    Skill Points: {formatNumber(props.bladeburner.skillPoints, 0)}


    {StatsTable([ - [ - "Aug. Success Chance mult: ", - formatNumber(props.player.bladeburner_success_chance_mult * 100, 1) + - "%", - ], - [ - "Aug. Max Stamina mult: ", - formatNumber(props.player.bladeburner_max_stamina_mult * 100, 1) + - "%", - ], - [ - "Aug. Stamina Gain mult: ", - formatNumber(props.player.bladeburner_stamina_gain_mult * 100, 1) + - "%", - ], - [ - "Aug. Field Analysis mult: ", - formatNumber(props.player.bladeburner_analysis_mult * 100, 1) + "%", - ], + ["Aug. Success Chance mult: ", formatNumber(props.player.bladeburner_success_chance_mult * 100, 1) + "%"], + ["Aug. Max Stamina mult: ", formatNumber(props.player.bladeburner_max_stamina_mult * 100, 1) + "%"], + ["Aug. Stamina Gain mult: ", formatNumber(props.player.bladeburner_stamina_gain_mult * 100, 1) + "%"], + ["Aug. Field Analysis mult: ", formatNumber(props.player.bladeburner_analysis_mult * 100, 1) + "%"], ])}
    - + Travel - + - Apply to the Bladeburner Faction, or go to the faction page if you are - already a member + Apply to the Bladeburner Faction, or go to the faction page if you are already a member Faction diff --git a/src/Bladeburner/ui/SuccessChance.tsx b/src/Bladeburner/ui/SuccessChance.tsx index 510c729f3..31273541d 100644 --- a/src/Bladeburner/ui/SuccessChance.tsx +++ b/src/Bladeburner/ui/SuccessChance.tsx @@ -12,8 +12,7 @@ export function SuccessChance(props: IProps): React.ReactElement { return ( <> - {formatNumber(props.chance[0] * 100, 1)}% ~{" "} - {formatNumber(props.chance[1] * 100, 1)}% + {formatNumber(props.chance[0] * 100, 1)}% ~ {formatNumber(props.chance[1] * 100, 1)}% ); } diff --git a/src/Bladeburner/ui/TeamSizePopup.tsx b/src/Bladeburner/ui/TeamSizePopup.tsx index d03e4753f..d58a2ec22 100644 --- a/src/Bladeburner/ui/TeamSizePopup.tsx +++ b/src/Bladeburner/ui/TeamSizePopup.tsx @@ -17,9 +17,7 @@ export function TeamSizePopup(props: IProps): React.ReactElement { if (teamSize === undefined) return; const num = Math.round(teamSize); if (isNaN(num) || num < 0) { - dialogBoxCreate( - "Invalid value entered for number of Team Members (must be numeric, positive)", - ); + dialogBoxCreate("Invalid value entered for number of Team Members (must be numeric, positive)"); } else { props.action.teamCount = num; } @@ -29,10 +27,8 @@ export function TeamSizePopup(props: IProps): React.ReactElement { return ( <>

    - Enter the amount of team members you would like to take on this Op. If - you do not have the specified number of team members, then as many as - possible will be used. Note that team members may be lost during - operations. + Enter the amount of team members you would like to take on this Op. If you do not have the specified number of + team members, then as many as possible will be used. Note that team members may be lost during operations.

    - Travel to a different city for your Bladeburner activities. This does - not cost any money. The city you are in for your Bladeburner duties does - not affect your location in the game otherwise. + Travel to a different city for your Bladeburner activities. This does not cost any money. The city you are in + for your Bladeburner duties does not affect your location in the game otherwise.

    {BladeburnerConstants.CityNames.map((city) => { // Reusing this css class...it adds a border and makes it // so that background color changes when you hover return ( -
    travel(city)} - > +
    travel(city)}> {city}
    ); diff --git a/src/Casino/Blackjack.tsx b/src/Casino/Blackjack.tsx index c9792769c..c89cfab5e 100644 --- a/src/Casino/Blackjack.tsx +++ b/src/Casino/Blackjack.tsx @@ -76,14 +76,8 @@ export class Blackjack extends Game { // always reload without saving but w.e) this.props.p.loseMoney(this.state.bet); - const playerHand = new Hand([ - this.deck.safeDrawCard(), - this.deck.safeDrawCard(), - ]); - const dealerHand = new Hand([ - this.deck.safeDrawCard(), - this.deck.safeDrawCard(), - ]); + const playerHand = new Hand([this.deck.safeDrawCard(), this.deck.safeDrawCard()]); + const dealerHand = new Hand([this.deck.safeDrawCard(), this.deck.safeDrawCard()]); this.setState({ playerHand, @@ -242,9 +236,7 @@ export class Blackjack extends Game { }; isPlayerWinResult = (result: Result): boolean => { - return ( - result === Result.PlayerWon || result === Result.PlayerWonByBlackjack - ); + return result === Result.PlayerWon || result === Result.PlayerWonByBlackjack; }; wagerOnChange = (event: React.ChangeEvent): void => { @@ -304,16 +296,8 @@ export class Blackjack extends Game { }; render(): React.ReactNode { - const { - betInput, - playerHand, - dealerHand, - gameInProgress, - result, - wagerInvalid, - wagerInvalidHelperText, - gains, - } = this.state; + const { betInput, playerHand, dealerHand, gameInProgress, result, wagerInvalid, wagerInvalidHelperText, gains } = + this.state; // Get the player totals to display. const playerHandValues = this.getHandDisplayValues(playerHand); @@ -342,9 +326,7 @@ export class Blackjack extends Game { width: "200px", }} InputProps={{ - startAdornment: ( - $ - ), + startAdornment: $, }} /> @@ -357,11 +339,7 @@ export class Blackjack extends Game { {/* Buttons */} {!gameInProgress ? (
    - + Start
    @@ -398,11 +376,7 @@ export class Blackjack extends Game {
    Dealer
    {dealerHand.cards.map((card, i) => ( // Hide every card except the first while game is in progress -