From ceac0090cfe933e40adc45e54461d043272705db Mon Sep 17 00:00:00 2001 From: borisflagell Date: Thu, 21 Apr 2022 18:19:04 +0200 Subject: [PATCH] UI: FIX #2256 Hacknet server's upgrade tooltip were not handling RAM usage correctly. Fix #2256 by using the correct formula to calculate the hashrate increase. Slightly revamp tooltip to display both theoric and effective increase. Add a discreet tooltip to the Production line which display details about hashrate and ram usage. Tested by running two script by intermittence on a loop on the hacknet server. Value displayed stay coherent all along. --- src/Hacknet/ui/HacknetServerElem.tsx | 71 ++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index b9a9d8f97..935b5dc35 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -60,15 +60,17 @@ export function HacknetServerElem(props: IProps): React.ReactElement { multiplier = Math.min(levelsToMax, purchaseMult as number); } - const increase = - calculateHashGainRate(node.level + multiplier, 0, node.maxRam, node.cores, props.player.hacknet_node_money_mult) - - node.hashRate; + const base_increase = calculateHashGainRate(node.level + multiplier, 0, node.maxRam, node.cores, props.player.hacknet_node_money_mult) + - calculateHashGainRate(node.level, 0, node.maxRam, node.cores, props.player.hacknet_node_money_mult); + let modded_increase = base_increase * (node.maxRam - node.ramUsed) / node.maxRam; + const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, props.player.hacknet_node_level_cost_mult); upgradeLevelButton = ( - + + + (base increase, attained when no script is running)
+ + (effective increase, taking current RAM usage into account) } > @@ -109,20 +111,43 @@ export function HacknetServerElem(props: IProps): React.ReactElement { multiplier = Math.min(levelsToMax, purchaseMult as number); } - const increase = + const base_increase = calculateHashGainRate( node.level, 0, node.maxRam * Math.pow(2, multiplier), node.cores, props.player.hacknet_node_money_mult, - ) - node.hashRate; + ) - calculateHashGainRate( + node.level, + 0, + node.maxRam, + node.cores, + props.player.hacknet_node_money_mult, + ); + + let modded_increase = + calculateHashGainRate( + node.level, + node.ramUsed, + node.maxRam * Math.pow(2, multiplier), + node.cores, + props.player.hacknet_node_money_mult, + ) - calculateHashGainRate( + node.level, + node.ramUsed, + node.maxRam, + node.cores, + props.player.hacknet_node_money_mult, + ); + const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, props.player.hacknet_node_ram_cost_mult); upgradeRamButton = ( - + + + (base increase, attained when no script is running)
+ + (effective increase, taking current RAM usage into account) } > @@ -155,15 +180,17 @@ export function HacknetServerElem(props: IProps): React.ReactElement { multiplier = Math.min(levelsToMax, purchaseMult as number); } - const increase = - calculateHashGainRate(node.level, 0, node.maxRam, node.cores + multiplier, props.player.hacknet_node_money_mult) - - node.hashRate; + const base_increase = calculateHashGainRate(node.level, 0, node.maxRam, node.cores + multiplier, props.player.hacknet_node_money_mult) + - calculateHashGainRate(node.level, 0, node.maxRam, node.cores, props.player.hacknet_node_money_mult); + let modded_increase = base_increase * (node.maxRam - node.ramUsed) / node.maxRam; + const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult); upgradeCoresButton = ( - + + + (base increase, attained when no script is running)
+ + (effective increase, taking current RAM usage into account) } > @@ -232,9 +259,25 @@ export function HacknetServerElem(props: IProps): React.ReactElement { Production: - - () - + + hashes producted by this server since last augment installation. +
+ current production rate. +
+ max production rate. (achieved when 100% Ram is allocated to it) +
+ {numeralWrapper.formatRAM(node.ramUsed)} / {numeralWrapper.formatRAM(node.maxRam)} ({Math.round(100 * node.ramUsed / node.maxRam)}%) Ram allocated to script. +
+ {numeralWrapper.formatRAM(node.maxRam - node.ramUsed)} / {numeralWrapper.formatRAM(node.maxRam)} ({Math.round(100 * (node.maxRam - node.ramUsed) / node.maxRam)}%) Ram allocated to hash production. + + } + > + + () + +