diff --git a/src/BitNode/ui/BitnodeMultipliersDescription.tsx b/src/BitNode/ui/BitnodeMultipliersDescription.tsx index 384cd094f..d01f182f4 100644 --- a/src/BitNode/ui/BitnodeMultipliersDescription.tsx +++ b/src/BitNode/ui/BitnodeMultipliersDescription.tsx @@ -1,554 +1,326 @@ -import ExpandMore from "@mui/icons-material/ExpandMore"; import ExpandLess from "@mui/icons-material/ExpandLess"; -import { Box, Collapse, ListItemButton, ListItemText, Paper, Typography } from "@mui/material"; +import ExpandMore from "@mui/icons-material/ExpandMore"; +import { Box, Collapse, ListItemButton, ListItemText, Paper, Table, TableBody, Typography } from "@mui/material"; +import { uniqueId } from "lodash"; import React from "react"; +import { SpecialServers } from "../../Server/data/SpecialServers"; +import { Settings } from "../../Settings/Settings"; import { use } from "../../ui/Context"; +import { StatsRow } from "../../ui/React/StatsRow"; import { defaultMultipliers, getBitNodeMultipliers } from "../BitNode"; import { IBitNodeMultipliers } from "../BitNodeMultipliers"; -import { SpecialServers } from "../../Server/data/SpecialServers"; interface IProps { n: number; + showNext?: boolean; } -export function BitnodeMultiplierDescription({ n }: IProps): React.ReactElement { - const player = use.Player(); +export function BitnodeMultiplierDescription({ n, showNext = false }: IProps): React.ReactElement { const [open, setOpen] = React.useState(false); - const mults = getBitNodeMultipliers(n, player.sourceFileLvl(n)); if (n === 1) return <>; return ( - <> -
- - setOpen((old) => !old)}> - Bitnode multipliers:} /> - {open ? : } - - - - - - - - - - - - - - - - - -
-
-
-
- + + setOpen((old) => !old)}> + Bitnode Multipliers} /> + {open ? : } + + + + + ); } +export const BitNodeMultipliersDisplay = ({ n, showNext = false }: IProps): React.ReactElement => { + const player = use.Player(); + const mults = getBitNodeMultipliers(n, player.sourceFileLvl(n) + +!!showNext); + + return ( + + + + + + + + + + + + + + + + + ); +}; + +interface IBNMultRows { + [mult: string]: { + name: string; + content?: string; + color?: string; + }; +} + +interface IBNMultTableProps { + sectionName: string; + rowData: IBNMultRows; + mults: IBitNodeMultipliers; +} + +const BNMultTable = (props: IBNMultTableProps): React.ReactElement => { + const rowsArray = Object.entries(props.rowData) + .filter(([key, _value]) => props.mults[key] !== defaultMultipliers[key]) + .map(([key, value]) => ( + + )); + + return rowsArray.length > 0 ? ( + + {props.sectionName} + + {rowsArray} +
+
+ ) : ( + <> + ); +}; + interface IMultsProps { n: number; mults: IBitNodeMultipliers; } function GeneralMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.ClassGymExpGain === defaultMultipliers.ClassGymExpGain && - mults.CodingContractMoney === defaultMultipliers.CodingContractMoney && - mults.DaedalusAugsRequirement === defaultMultipliers.DaedalusAugsRequirement && - mults.WorldDaemonDifficulty === defaultMultipliers.WorldDaemonDifficulty && - mults.HacknetNodeMoney === defaultMultipliers.HacknetNodeMoney - ) - return <>; - return ( - <> -
- General: - - {mults.WorldDaemonDifficulty !== defaultMultipliers.WorldDaemonDifficulty ? ( - - {SpecialServers.WorldDaemon} difficulty: x{mults.WorldDaemonDifficulty.toFixed(3)} - - ) : ( - <> - )} - {mults.DaedalusAugsRequirement !== defaultMultipliers.DaedalusAugsRequirement ? ( - Daedalus aug req.: {mults.DaedalusAugsRequirement} - ) : ( - <> - )} - {mults.HacknetNodeMoney !== defaultMultipliers.HacknetNodeMoney ? ( - Hacknet production: x{mults.HacknetNodeMoney.toFixed(3)} - ) : ( - <> - )} - {mults.CodingContractMoney !== defaultMultipliers.CodingContractMoney ? ( - Coding contract reward: x{mults.CodingContractMoney.toFixed(3)} - ) : ( - <> - )} - {mults.ClassGymExpGain !== defaultMultipliers.ClassGymExpGain ? ( - Class/Gym exp: x{mults.ClassGymExpGain.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + WorldDaemonDifficulty: { name: `${SpecialServers.WorldDaemon} Difficulty` }, + DaedalusAugsRequirement: { + name: "Daedalus Augs Requirement", + content: String(mults.DaedalusAugsRequirement), + }, + HacknetNodeMoney: { name: "Hacknet Production" }, + CodingContractMoney: { name: "Coding Contract Reward" }, + ClassGymExpGain: { name: "Class/Gym Exp" }, + }; + + return ; } function AugmentationMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.AugmentationMoneyCost === defaultMultipliers.AugmentationMoneyCost && - mults.AugmentationRepCost === defaultMultipliers.AugmentationRepCost - ) - return <>; - return ( - <> -
- Augmentations: - - {mults.AugmentationMoneyCost !== defaultMultipliers.AugmentationMoneyCost ? ( - Cost: x{mults.AugmentationMoneyCost.toFixed(3)} - ) : ( - <> - )} - {mults.AugmentationRepCost !== defaultMultipliers.AugmentationRepCost ? ( - Reputation: x{mults.AugmentationRepCost.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + AugmentationMoneyCost: { name: "Money Cost" }, + AugmentationRepCost: { + name: "Reputation Cost", + color: Settings.theme.rep, + }, + }; + + return ; } function CompanyMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.CompanyWorkExpGain === defaultMultipliers.CompanyWorkExpGain && - mults.CompanyWorkMoney === defaultMultipliers.CompanyWorkMoney - ) - return <>; - return ( - <> -
- Company: - - {mults.CompanyWorkMoney !== defaultMultipliers.CompanyWorkMoney ? ( - Money: x{mults.CompanyWorkMoney.toFixed(3)} - ) : ( - <> - )} - {mults.CompanyWorkExpGain !== defaultMultipliers.CompanyWorkExpGain ? ( - Exp: x{mults.CompanyWorkExpGain.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + CompanyWorkMoney: { + name: "Work Money", + color: Settings.theme.money, + }, + CompanyWorkExpGain: { name: "Work Exp" }, + }; + + return ; } function StockMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.FourSigmaMarketDataApiCost === defaultMultipliers.FourSigmaMarketDataApiCost && - mults.FourSigmaMarketDataCost === defaultMultipliers.FourSigmaMarketDataCost - ) - return <>; - return ( - <> -
- Stock market: - - {mults.FourSigmaMarketDataCost !== defaultMultipliers.FourSigmaMarketDataCost ? ( - Market data cost: x{mults.FourSigmaMarketDataCost.toFixed(3)} - ) : ( - <> - )} - {mults.FourSigmaMarketDataApiCost !== defaultMultipliers.FourSigmaMarketDataApiCost ? ( - Market data API cost: x{mults.FourSigmaMarketDataApiCost.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + FourSigmaMarketDataCost: { name: "Market Data Cost" }, + FourSigmaMarketDataApiCost: { name: "Market Data API Cost" }, + }; + + return ; } function FactionMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.FactionPassiveRepGain === defaultMultipliers.FactionPassiveRepGain && - mults.FactionWorkExpGain === defaultMultipliers.FactionWorkExpGain && - mults.FactionWorkRepGain === defaultMultipliers.FactionWorkRepGain && - mults.RepToDonateToFaction === defaultMultipliers.RepToDonateToFaction - ) - return <>; - return ( - <> -
- Faction: - - {mults.RepToDonateToFaction !== defaultMultipliers.RepToDonateToFaction ? ( - Favor to donate: x{mults.RepToDonateToFaction.toFixed(3)} - ) : ( - <> - )} - {mults.FactionWorkRepGain !== defaultMultipliers.FactionWorkRepGain ? ( - Work rep: x{mults.FactionWorkRepGain.toFixed(3)} - ) : ( - <> - )} - {mults.FactionWorkExpGain !== defaultMultipliers.FactionWorkExpGain ? ( - Work exp: x{mults.FactionWorkExpGain.toFixed(3)} - ) : ( - <> - )} - {mults.FactionPassiveRepGain !== defaultMultipliers.FactionPassiveRepGain ? ( - Passive rep: x{mults.FactionPassiveRepGain.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + RepToDonateToFaction: { name: "Favor to Donate" }, + FactionWorkRepGain: { + name: "Work Reputation", + color: Settings.theme.rep, + }, + FactionWorkExpGain: { name: "Work Exp" }, + FactionPassiveRepGain: { + name: "Passive Rep", + color: Settings.theme.rep, + }, + }; + + return ; } function CrimeMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if (mults.CrimeExpGain === defaultMultipliers.CrimeExpGain && mults.CrimeMoney === defaultMultipliers.CrimeMoney) - return <>; - return ( - <> -
- Crime: - - {mults.CrimeExpGain !== defaultMultipliers.CrimeExpGain ? ( - Exp: x{mults.CrimeExpGain.toFixed(3)} - ) : ( - <> - )} - {mults.CrimeMoney !== defaultMultipliers.CrimeMoney ? ( - Money: x{mults.CrimeMoney.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + CrimeExpGain: { + name: "Crime Exp", + color: Settings.theme.combat, + }, + CrimeMoney: { + name: "Crime Money", + color: Settings.theme.combat, + }, + }; + + return ; } function SkillMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.HackingLevelMultiplier === defaultMultipliers.HackingLevelMultiplier && - mults.AgilityLevelMultiplier === defaultMultipliers.AgilityLevelMultiplier && - mults.DefenseLevelMultiplier === defaultMultipliers.DefenseLevelMultiplier && - mults.DexterityLevelMultiplier === defaultMultipliers.DexterityLevelMultiplier && - mults.StrengthLevelMultiplier === defaultMultipliers.StrengthLevelMultiplier && - mults.CharismaLevelMultiplier === defaultMultipliers.CharismaLevelMultiplier - ) - return <>; - return ( - <> -
- Skills: - - {mults.HackingLevelMultiplier !== defaultMultipliers.HackingLevelMultiplier ? ( - Hacking: x{mults.HackingLevelMultiplier.toFixed(3)} - ) : ( - <> - )} - {mults.AgilityLevelMultiplier !== defaultMultipliers.AgilityLevelMultiplier ? ( - Agility: x{mults.AgilityLevelMultiplier.toFixed(3)} - ) : ( - <> - )} - {mults.DefenseLevelMultiplier !== defaultMultipliers.DefenseLevelMultiplier ? ( - Defense: x{mults.DefenseLevelMultiplier.toFixed(3)} - ) : ( - <> - )} - {mults.DexterityLevelMultiplier !== defaultMultipliers.DexterityLevelMultiplier ? ( - Dexterity: x{mults.DexterityLevelMultiplier.toFixed(3)} - ) : ( - <> - )} - {mults.StrengthLevelMultiplier !== defaultMultipliers.StrengthLevelMultiplier ? ( - Strength: x{mults.StrengthLevelMultiplier.toFixed(3)} - ) : ( - <> - )} - {mults.CharismaLevelMultiplier !== defaultMultipliers.CharismaLevelMultiplier ? ( - Charisma: x{mults.CharismaLevelMultiplier.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + HackingLevelMultiplier: { + name: "Hacking Level", + color: Settings.theme.hack, + }, + StrengthLevelMultiplier: { + name: "Strength Level", + color: Settings.theme.combat, + }, + DefenseLevelMultiplier: { + name: "Defense Level", + color: Settings.theme.combat, + }, + DexterityLevelMultiplier: { + name: "Dexterity Level", + color: Settings.theme.combat, + }, + CharismaLevelMultiplier: { + name: "Charisma Level", + color: Settings.theme.cha, + }, + }; + + return ; } function HackingMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.ServerGrowthRate === defaultMultipliers.ServerGrowthRate && - mults.ServerMaxMoney === defaultMultipliers.ServerMaxMoney && - mults.ServerStartingMoney === defaultMultipliers.ServerStartingMoney && - mults.ServerStartingSecurity === defaultMultipliers.ServerStartingSecurity && - mults.ServerWeakenRate === defaultMultipliers.ServerWeakenRate && - mults.ManualHackMoney === defaultMultipliers.ManualHackMoney && - mults.ScriptHackMoney === defaultMultipliers.ScriptHackMoney && - mults.ScriptHackMoneyGain === defaultMultipliers.ScriptHackMoneyGain && - mults.HackExpGain === defaultMultipliers.HackExpGain - ) - return <>; + const rows: IBNMultRows = { + HackExpGain: { + name: "Hacking Exp", + color: Settings.theme.hack, + }, + ServerGrowthRate: { name: "Server Growth Rate" }, + ServerMaxMoney: { name: "Server Max Money" }, + ServerStartingMoney: { name: "Server Starting Money" }, + ServerStartingSecurity: { name: "Server Starting Security" }, + ServerWeakenRate: { name: "Server Weaken Rate" }, + ManualHackMoney: { + name: "Manual Hack Money", + color: Settings.theme.money, + }, + ScriptHackMoney: { + name: "Script Hack Money", + color: Settings.theme.money, + }, + ScriptHackMoneyGain: { + name: "Money Gained From Hack", + color: Settings.theme.money, + }, + }; - return ( - <> -
- Hacking: - - {mults.HackExpGain !== defaultMultipliers.HackExpGain ? ( - Exp: x{mults.HackExpGain.toFixed(3)} - ) : ( - <> - )} - {mults.ServerGrowthRate !== defaultMultipliers.ServerGrowthRate ? ( - Growth rate: x{mults.ServerGrowthRate.toFixed(3)} - ) : ( - <> - )} - {mults.ServerMaxMoney !== defaultMultipliers.ServerMaxMoney ? ( - Max money: x{mults.ServerMaxMoney.toFixed(3)} - ) : ( - <> - )} - {mults.ServerStartingMoney !== defaultMultipliers.ServerStartingMoney ? ( - Starting money: x{mults.ServerStartingMoney.toFixed(3)} - ) : ( - <> - )} - {mults.ServerStartingSecurity !== defaultMultipliers.ServerStartingSecurity ? ( - Starting security: x{mults.ServerStartingSecurity.toFixed(3)} - ) : ( - <> - )} - {mults.ServerWeakenRate !== defaultMultipliers.ServerWeakenRate ? ( - Weaken rate: x{mults.ServerWeakenRate.toFixed(3)} - ) : ( - <> - )} - {mults.ManualHackMoney !== defaultMultipliers.ManualHackMoney ? ( - Manual hack money: x{mults.ManualHackMoney.toFixed(3)} - ) : ( - <> - )} - {mults.ScriptHackMoney !== defaultMultipliers.ScriptHackMoney ? ( - Hack money stolen: x{mults.ScriptHackMoney.toFixed(3)} - ) : ( - <> - )} - {mults.ScriptHackMoneyGain !== defaultMultipliers.ScriptHackMoneyGain ? ( - Money gained from hack: x{mults.ScriptHackMoneyGain.toFixed(3)} - ) : ( - <> - )} - - - ); + return ; } function PurchasedServersMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.PurchasedServerCost === defaultMultipliers.PurchasedServerCost && - mults.PurchasedServerSoftcap === defaultMultipliers.PurchasedServerSoftcap && - mults.PurchasedServerLimit === defaultMultipliers.PurchasedServerLimit && - mults.PurchasedServerMaxRam === defaultMultipliers.PurchasedServerMaxRam && - mults.HomeComputerRamCost === defaultMultipliers.HomeComputerRamCost - ) - return <>; - return ( - <> -
- Purchased servers: - - {mults.PurchasedServerCost !== defaultMultipliers.PurchasedServerCost ? ( - Base cost: {mults.PurchasedServerCost.toFixed(3)} - ) : ( - <> - )} - {mults.PurchasedServerSoftcap !== defaultMultipliers.PurchasedServerSoftcap ? ( - Softcap cost: {mults.PurchasedServerSoftcap.toFixed(3)} - ) : ( - <> - )} - {mults.PurchasedServerLimit !== defaultMultipliers.PurchasedServerLimit ? ( - Limit: x{mults.PurchasedServerLimit.toFixed(3)} - ) : ( - <> - )} - {mults.PurchasedServerMaxRam !== defaultMultipliers.PurchasedServerMaxRam ? ( - Max ram: x{mults.PurchasedServerMaxRam.toFixed(3)} - ) : ( - <> - )} - {mults.HomeComputerRamCost !== defaultMultipliers.HomeComputerRamCost ? ( - Home ram cost: x{mults.HomeComputerRamCost.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + PurchasedServerCost: { + name: "Base Cost", + content: mults.PurchasedServerCost.toFixed(3), + }, + PurchasedServerSoftcap: { + name: "Softcap Cost", + content: mults.PurchasedServerSoftcap.toFixed(3), + }, + PurchasedServerLimit: { name: "Server Limit" }, + PurchasedServerMaxRam: { name: "Max RAM" }, + HomeComputerRamCost: { name: "Home RAM Cost" }, + }; + + return ; } function InfiltrationMults({ mults }: IMultsProps): React.ReactElement { - // is it empty check - if ( - mults.InfiltrationMoney === defaultMultipliers.InfiltrationMoney && - mults.InfiltrationRep === defaultMultipliers.InfiltrationRep - ) - return <>; - return ( - <> -
- Infiltration: - - {mults.InfiltrationMoney !== defaultMultipliers.InfiltrationMoney ? ( - Money: {mults.InfiltrationMoney.toFixed(3)} - ) : ( - <> - )} - {mults.InfiltrationRep !== defaultMultipliers.InfiltrationRep ? ( - Reputation: x{mults.InfiltrationRep.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + InfiltrationMoney: { + name: "Infiltration Money", + color: Settings.theme.money, + }, + InfiltrationRep: { + name: "Infiltration Reputation", + color: Settings.theme.rep, + }, + }; + + return ; } -function BladeburnerMults({ n, mults }: IMultsProps): React.ReactElement { +function BladeburnerMults({ mults }: IMultsProps): React.ReactElement { const player = use.Player(); - // access check - if (n !== 6 && n !== 7 && player.sourceFileLvl(6) === 0) return <>; - //default mults check - if (mults.BladeburnerRank === 1 && mults.BladeburnerSkillCost === 1) return <>; - return ( - <> -
- Bladeburner: - - {mults.BladeburnerRank !== 1 ? Rank gain: x{mults.BladeburnerRank.toFixed(3)} : <>} - {mults.BladeburnerSkillCost !== 1 ? ( - Skill cost: x{mults.BladeburnerSkillCost.toFixed(3)} - ) : ( - <> - )} - - - ); + if (!player.canAccessBladeburner()) return <>; + + const rows: IBNMultRows = { + BladeburnerRank: { name: "Rank Gain" }, + BladeburnerSkillCost: { name: "Skill Cost" }, + }; + + return ; } -function StanekMults({ n, mults }: IMultsProps): React.ReactElement { +function StanekMults({ mults }: IMultsProps): React.ReactElement { const player = use.Player(); - // access check - if (n !== 13 && player.sourceFileLvl(13) === 0) return <>; - //default mults check - if ( - mults.StaneksGiftExtraSize === defaultMultipliers.StaneksGiftExtraSize && - mults.StaneksGiftPowerMultiplier === defaultMultipliers.StaneksGiftPowerMultiplier - ) - return <>; + if (!player.canAccessCotMG()) return <>; - const s = mults.StaneksGiftExtraSize; - return ( - <> -
- Stanek's Gift: - - {mults.StaneksGiftPowerMultiplier !== defaultMultipliers.StaneksGiftPowerMultiplier ? ( - Gift power: x{mults.StaneksGiftPowerMultiplier.toFixed(3)} - ) : ( - <> - )} - {s !== defaultMultipliers.StaneksGiftExtraSize ? ( - Base size modifier: {s > defaultMultipliers.StaneksGiftExtraSize ? `+${s}` : s} - ) : ( - <> - )} - - - ); + const extraSize = mults.StaneksGiftExtraSize.toFixed(3); + const rows: IBNMultRows = { + StnakesGiftPowerMultiplier: { name: "Gift Power" }, + StaneksGiftExtraSize: { + name: "Base Size Modifier", + content: `${mults.StaneksGiftExtraSize > defaultMultipliers.StaneksGiftExtraSize ? `+${extraSize}` : extraSize}`, + }, + }; + + return ; } -function GangMults({ n, mults }: IMultsProps): React.ReactElement { +function GangMults({ mults }: IMultsProps): React.ReactElement { const player = use.Player(); - // access check - if (n !== 2 && player.sourceFileLvl(2) === 0) return <>; - // is it empty check - if ( - mults.GangSoftcap === defaultMultipliers.GangSoftcap && - mults.GangUniqueAugs === defaultMultipliers.GangUniqueAugs - ) - return <>; - return ( - <> -
- Gang: - - {mults.GangSoftcap !== defaultMultipliers.GangSoftcap ? ( - Softcap: {mults.GangSoftcap.toFixed(3)} - ) : ( - <> - )} - {mults.GangUniqueAugs !== defaultMultipliers.GangUniqueAugs ? ( - Unique augs: x{mults.GangUniqueAugs.toFixed(3)} - ) : ( - <> - )} - - - ); + if (!player.canAccessGang()) return <>; + + const rows: IBNMultRows = { + GangSoftcap: { + name: "Gang Softcap", + content: mults.GangSoftcap.toFixed(3), + }, + GangUniqueAugs: { name: "Unique Augmentations" }, + }; + + return ; } -function CorporationMults({ n, mults }: IMultsProps): React.ReactElement { +function CorporationMults({ mults }: IMultsProps): React.ReactElement { const player = use.Player(); - // access check - if (n !== 3 && player.sourceFileLvl(3) === 0) return <>; - // is it empty check - if ( - mults.CorporationSoftCap === defaultMultipliers.CorporationSoftCap && - mults.CorporationValuation === defaultMultipliers.CorporationValuation - ) - return <>; + if (!player.canAccessCorporation()) return <>; - return ( - <> -
- Corporation: - - {mults.CorporationSoftCap !== defaultMultipliers.CorporationSoftCap ? ( - Softcap: {mults.CorporationSoftCap.toFixed(3)} - ) : ( - <> - )} - {mults.CorporationValuation !== defaultMultipliers.CorporationValuation ? ( - Valuation: x{mults.CorporationValuation.toFixed(3)} - ) : ( - <> - )} - - - ); + const rows: IBNMultRows = { + CorporationSoftCap: { + name: "Corporation Softcap", + content: mults.CorporationSoftCap.toFixed(3), + }, + CorporationValuation: { name: "Valuation" }, + }; + + return ; } diff --git a/src/BitNode/ui/PortalModal.tsx b/src/BitNode/ui/PortalModal.tsx index b3791fe83..c81a6790d 100644 --- a/src/BitNode/ui/PortalModal.tsx +++ b/src/BitNode/ui/PortalModal.tsx @@ -41,7 +41,7 @@ export function PortalModal(props: IProps): React.ReactElement {

{bitNode.info} - +