mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-07 08:07:57 +02:00
UI: Consistently calculate BitNode "level" (#2645)
This commit is contained in:
@@ -93,3 +93,12 @@ export function finishBitNode() {
|
||||
}
|
||||
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 { BitNodeMultipliers } from "../BitNodeMultipliers";
|
||||
import { PartialRecord, getRecordEntries } from "../../Types/Record";
|
||||
import { canAccessBitNodeFeature } from "../BitNodeUtils";
|
||||
import { canAccessBitNodeFeature, getBitNodeLevel } from "../BitNodeUtils";
|
||||
|
||||
interface IProps {
|
||||
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
|
||||
// current node's source file, so we get the min of that, the SF's max level,
|
||||
// or if it's BN12, ∞
|
||||
const maxSfLevel = n === 12 ? Number.MAX_VALUE : 3;
|
||||
const mults = getBitNodeMultipliers(n, level ?? Math.min(Player.activeSourceFileLvl(n) + 1, maxSfLevel));
|
||||
const mults = getBitNodeMultipliers(n, level ?? getBitNodeLevel(n));
|
||||
|
||||
return (
|
||||
<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 { BitNodeAdvancedOptions } from "./BitNodeAdvancedOptions";
|
||||
import { JSONMap } from "../../Types/Jsonable";
|
||||
import { getBitNodeLevel } from "../BitNodeUtils";
|
||||
|
||||
interface IProps {
|
||||
open: boolean;
|
||||
@@ -37,7 +38,7 @@ export function PortalModal(props: IProps): React.ReactElement {
|
||||
const bitNode = BitNodes[bitNodeKey];
|
||||
if (bitNode == null) throw new Error(`Could not find BitNode object for number: ${props.n}`);
|
||||
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);
|
||||
if (!props.flume) {
|
||||
|
||||
Reference in New Issue
Block a user