mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
UI: Consistently calculate BitNode "level" (#2645)
This commit is contained in:
@@ -93,3 +93,12 @@ export function finishBitNode() {
|
|||||||
}
|
}
|
||||||
wd.backdoorInstalled = true;
|
wd.backdoorInstalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BitNode level is not something that is stored, but rather calculated from the current BN and SF level. The concept
|
||||||
|
* appeared because saying "Enter BN1.2" is shorter than saying "Enter BN1 with SF1.1". This is how we display it in the
|
||||||
|
* BitVerse UI and other places. This function is used to consistently calculate this "level".
|
||||||
|
*/
|
||||||
|
export function getBitNodeLevel(bn = Player.bitNodeN, sfLevel = Player.activeSourceFileLvl(bn)): number {
|
||||||
|
return Math.min(sfLevel + 1, bn === 12 ? Number.MAX_VALUE : 3);
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { StatsRow } from "../../ui/React/StatsRow";
|
|||||||
import { defaultMultipliers, getBitNodeMultipliers } from "../BitNode";
|
import { defaultMultipliers, getBitNodeMultipliers } from "../BitNode";
|
||||||
import { BitNodeMultipliers } from "../BitNodeMultipliers";
|
import { BitNodeMultipliers } from "../BitNodeMultipliers";
|
||||||
import { PartialRecord, getRecordEntries } from "../../Types/Record";
|
import { PartialRecord, getRecordEntries } from "../../Types/Record";
|
||||||
import { canAccessBitNodeFeature } from "../BitNodeUtils";
|
import { canAccessBitNodeFeature, getBitNodeLevel } from "../BitNodeUtils";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
n: number;
|
n: number;
|
||||||
@@ -56,8 +56,7 @@ export const BitNodeMultipliersDisplay = ({ n, level, hideMultsIfCannotAccessFea
|
|||||||
// If not, then we have to assume that we want the next level up from the
|
// If not, then we have to assume that we want the next level up from the
|
||||||
// current node's source file, so we get the min of that, the SF's max level,
|
// current node's source file, so we get the min of that, the SF's max level,
|
||||||
// or if it's BN12, ∞
|
// or if it's BN12, ∞
|
||||||
const maxSfLevel = n === 12 ? Number.MAX_VALUE : 3;
|
const mults = getBitNodeMultipliers(n, level ?? getBitNodeLevel(n));
|
||||||
const mults = getBitNodeMultipliers(n, level ?? Math.min(Player.activeSourceFileLvl(n) + 1, maxSfLevel));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ columnCount: 2, columnGap: 1, mb: n === 1 ? 0 : -2 }}>
|
<Box sx={{ columnCount: 2, columnGap: 1, mb: n === 1 ? 0 : -2 }}>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Button from "@mui/material/Button";
|
|||||||
import { BitNodeMultiplierDescription } from "./BitnodeMultipliersDescription";
|
import { BitNodeMultiplierDescription } from "./BitnodeMultipliersDescription";
|
||||||
import { BitNodeAdvancedOptions } from "./BitNodeAdvancedOptions";
|
import { BitNodeAdvancedOptions } from "./BitNodeAdvancedOptions";
|
||||||
import { JSONMap } from "../../Types/Jsonable";
|
import { JSONMap } from "../../Types/Jsonable";
|
||||||
|
import { getBitNodeLevel } from "../BitNodeUtils";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -37,7 +38,7 @@ export function PortalModal(props: IProps): React.ReactElement {
|
|||||||
const bitNode = BitNodes[bitNodeKey];
|
const bitNode = BitNodes[bitNodeKey];
|
||||||
if (bitNode == null) throw new Error(`Could not find BitNode object for number: ${props.n}`);
|
if (bitNode == null) throw new Error(`Could not find BitNode object for number: ${props.n}`);
|
||||||
const maxSourceFileLevel = props.n === 12 ? "∞" : "3";
|
const maxSourceFileLevel = props.n === 12 ? "∞" : "3";
|
||||||
const newLevel = Math.min(props.level + 1, props.n === 12 ? Number.MAX_VALUE : 3);
|
const newLevel = getBitNodeLevel(props.n, props.level);
|
||||||
|
|
||||||
let currentSourceFiles = new Map(Player.sourceFiles);
|
let currentSourceFiles = new Map(Player.sourceFiles);
|
||||||
if (!props.flume) {
|
if (!props.flume) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import { loadInfiltrations } from "./Infiltration/SaveLoadInfiltration";
|
|||||||
import { InfiltrationState } from "./Infiltration/formulas/game";
|
import { InfiltrationState } from "./Infiltration/formulas/game";
|
||||||
import { hasDarknetAccess } from "./DarkNet/utils/darknetAuthUtils";
|
import { hasDarknetAccess } from "./DarkNet/utils/darknetAuthUtils";
|
||||||
import { loadSettings } from "./Settings/SettingsUtils";
|
import { loadSettings } from "./Settings/SettingsUtils";
|
||||||
|
import { getBitNodeLevel } from "./BitNode/BitNodeUtils";
|
||||||
|
|
||||||
/* SaveObject.js
|
/* SaveObject.js
|
||||||
* Defines the object used to save/load games
|
* Defines the object used to save/load games
|
||||||
@@ -270,7 +271,7 @@ class BitburnerSaveObject implements BitburnerSaveObjectType {
|
|||||||
* - Base64 format: save file uses .json extension. Save data is the base64-encoded json save string.
|
* - Base64 format: save file uses .json extension. Save data is the base64-encoded json save string.
|
||||||
*/
|
*/
|
||||||
const extension = canUseBinaryFormat() ? "json.gz" : "json";
|
const extension = canUseBinaryFormat() ? "json.gz" : "json";
|
||||||
return `bitburnerSave_${epochTime}_BN${bn}x${Player.sourceFileLvl(bn) + 1}.${extension}`;
|
return `bitburnerSave_${epochTime}_BN${bn}x${getBitNodeLevel()}.${extension}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async exportGame(): Promise<void> {
|
async exportGame(): Promise<void> {
|
||||||
@@ -430,7 +431,10 @@ class BitburnerSaveObject implements BitburnerSaveObjectType {
|
|||||||
achievements: importedPlayer.achievements?.length ?? 0,
|
achievements: importedPlayer.achievements?.length ?? 0,
|
||||||
|
|
||||||
bitNode: importedPlayer.bitNodeN,
|
bitNode: importedPlayer.bitNodeN,
|
||||||
bitNodeLevel: importedPlayer.sourceFileLvl(importedPlayer.bitNodeN) + 1,
|
bitNodeLevel: getBitNodeLevel(
|
||||||
|
importedPlayer.bitNodeN,
|
||||||
|
importedPlayer.activeSourceFileLvl(importedPlayer.bitNodeN),
|
||||||
|
),
|
||||||
sourceFiles: [...importedPlayer.sourceFiles].reduce<number>((total, [__bn, lvl]) => (total += lvl), 0),
|
sourceFiles: [...importedPlayer.sourceFiles].reduce<number>((total, [__bn, lvl]) => (total += lvl), 0),
|
||||||
exploits: importedPlayer.exploits.length,
|
exploits: importedPlayer.exploits.length,
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { StatsRow } from "./React/StatsRow";
|
|||||||
import { StatsTable } from "./React/StatsTable";
|
import { StatsTable } from "./React/StatsTable";
|
||||||
import { useCycleRerender } from "./React/hooks";
|
import { useCycleRerender } from "./React/hooks";
|
||||||
import { getMaxRep } from "../Go/effects/effect";
|
import { getMaxRep } from "../Go/effects/effect";
|
||||||
import { canAccessBitNodeFeature, knowAboutBitverse } from "../BitNode/BitNodeUtils";
|
import { canAccessBitNodeFeature, getBitNodeLevel, knowAboutBitverse } from "../BitNode/BitNodeUtils";
|
||||||
|
|
||||||
interface EmployersModalProps {
|
interface EmployersModalProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -103,11 +103,10 @@ function MultiplierTable(props: MultTableProps): React.ReactElement {
|
|||||||
function CurrentBitNode(): React.ReactElement {
|
function CurrentBitNode(): React.ReactElement {
|
||||||
if (knowAboutBitverse()) {
|
if (knowAboutBitverse()) {
|
||||||
const index = "BitNode" + Player.bitNodeN;
|
const index = "BitNode" + Player.bitNodeN;
|
||||||
const lvl = Math.min(Player.sourceFileLvl(Player.bitNodeN) + 1, Player.bitNodeN === 12 ? Number.MAX_VALUE : 3);
|
|
||||||
return (
|
return (
|
||||||
<Paper sx={{ mb: 1, p: 1 }}>
|
<Paper sx={{ mb: 1, p: 1 }}>
|
||||||
<Typography variant="h5">
|
<Typography variant="h5">
|
||||||
BitNode {Player.bitNodeN}: {BitNodes[index].name} (Level {lvl})
|
BitNode {Player.bitNodeN}: {BitNodes[index].name} (Level {getBitNodeLevel()})
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography component="div" sx={{ whiteSpace: "pre-wrap", overflowWrap: "break-word" }}>
|
<Typography component="div" sx={{ whiteSpace: "pre-wrap", overflowWrap: "break-word" }}>
|
||||||
{BitNodes[index].info}
|
{BitNodes[index].info}
|
||||||
|
|||||||
Reference in New Issue
Block a user