From ceac0090cfe933e40adc45e54461d043272705db Mon Sep 17 00:00:00 2001 From: borisflagell Date: Thu, 21 Apr 2022 18:19:04 +0200 Subject: [PATCH 1/7] 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. + + } + > + + () + +
From 4fa65322fe770dc3d79cd0301521d230694a1fc7 Mon Sep 17 00:00:00 2001 From: borisflagell Date: Thu, 21 Apr 2022 18:37:47 +0200 Subject: [PATCH 2/7] Update HacknetServerElem.tsx Run prettier. Run lint : no error. One warning about typescript versionning. --- src/Hacknet/ui/HacknetServerElem.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index 935b5dc35..c029959aa 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -60,9 +60,9 @@ export function HacknetServerElem(props: IProps): React.ReactElement { multiplier = Math.min(levelsToMax, purchaseMult as number); } - const base_increase = calculateHashGainRate(node.level + multiplier, 0, node.maxRam, node.cores, props.player.hacknet_node_money_mult) + 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 modded_increase = base_increase * (node.maxRam - node.ramUsed) / node.maxRam; const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, props.player.hacknet_node_level_cost_mult); upgradeLevelButton = ( @@ -125,8 +125,8 @@ export function HacknetServerElem(props: IProps): React.ReactElement { node.cores, props.player.hacknet_node_money_mult, ); - - let modded_increase = + + const modded_increase = calculateHashGainRate( node.level, node.ramUsed, @@ -182,7 +182,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement { 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 modded_increase = base_increase * (node.maxRam - node.ramUsed) / node.maxRam; const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult); upgradeCoresButton = ( @@ -270,11 +270,11 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
{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. + {numeralWrapper.formatRAM(node.maxRam - node.ramUsed)} / {numeralWrapper.formatRAM(node.maxRam)} ({Math.round(100 * (node.maxRam - node.ramUsed) / node.maxRam)}%) Ram allocated to hash production. } > - + ()
From a7045a234353de795494c0b3f378808b4a6d32aa Mon Sep 17 00:00:00 2001 From: borisflagell Date: Thu, 21 Apr 2022 19:20:16 +0200 Subject: [PATCH 3/7] Update HacknetServerElem.tsx Actually ran prettier this time. Apparently fixed my lint install : no error, no warning. --- src/Hacknet/ui/HacknetServerElem.tsx | 49 +++++++++++++--------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index c029959aa..14abbeca4 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -60,17 +60,18 @@ export function HacknetServerElem(props: IProps): React.ReactElement { multiplier = Math.min(levelsToMax, purchaseMult as number); } - 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); - const modded_increase = base_increase * (node.maxRam - node.ramUsed) / node.maxRam; + 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); + const 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) + + (base increase, attained when no script is running)
+ + (effective increase, taking current RAM usage into account) } > @@ -118,28 +119,17 @@ export function HacknetServerElem(props: IProps): React.ReactElement { node.maxRam * Math.pow(2, multiplier), node.cores, props.player.hacknet_node_money_mult, - ) - calculateHashGainRate( - node.level, - 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); - const modded_increase = + const 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, - ); + ) - + 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 = ( @@ -180,9 +170,10 @@ export function HacknetServerElem(props: IProps): React.ReactElement { multiplier = Math.min(levelsToMax, purchaseMult as number); } - 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); - const modded_increase = base_increase * (node.maxRam - node.ramUsed) / node.maxRam; + 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); + const modded_increase = (base_increase * (node.maxRam - node.ramUsed)) / node.maxRam; const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, props.player.hacknet_node_core_cost_mult); upgradeCoresButton = ( @@ -262,15 +253,19 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - hashes producted by this server since last augment installation. + hashes producted by this server since last augment + installation.
current production rate.
- max production rate. (achieved when 100% Ram is allocated to it) + 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.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. + {numeralWrapper.formatRAM(node.maxRam - node.ramUsed)} / {numeralWrapper.formatRAM(node.maxRam)} ( + {Math.round((100 * (node.maxRam - node.ramUsed)) / node.maxRam)}%) Ram allocated to hash production. } > From 08a7f82e73580220c23f16ab574b88180146583e Mon Sep 17 00:00:00 2001 From: borisflagell Date: Sat, 23 Apr 2022 14:59:46 +0200 Subject: [PATCH 4/7] Update HacknetServerElem.tsx Added some contrast between real and theoric displayed hashrate. As suggested by phyzical & nickofolas. --- src/Hacknet/ui/HacknetServerElem.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index 14abbeca4..0d31db5ab 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -70,7 +70,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (base increase, attained when no script is running)
+ + (base increase, attained when no script is running)
+ (effective increase, taking current RAM usage into account) } @@ -136,7 +136,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (base increase, attained when no script is running)
+ + (base increase, attained when no script is running)
+ (effective increase, taking current RAM usage into account) } @@ -180,7 +180,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (base increase, attained when no script is running)
+ + (base increase, attained when no script is running)
+ (effective increase, taking current RAM usage into account) } @@ -253,19 +253,21 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - hashes producted by this server since last augment + hashes produced by this server since last augment installation.
current production rate.
- max production - rate. (achieved when 100% Ram is allocated to it) + + + + {" "}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. + {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. + {Math.round((100 * (node.maxRam - node.ramUsed)) / node.maxRam)}%) RAM allocated to hash production. } > From d4f8f2d0354832101f48d60f0b3445cc1f43dd23 Mon Sep 17 00:00:00 2001 From: borisflagell Date: Sat, 23 Apr 2022 15:01:24 +0200 Subject: [PATCH 5/7] Update HacknetServerElem.tsx Prettier pass. Lint test : no warning, no error. --- src/Hacknet/ui/HacknetServerElem.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index 0d31db5ab..b5ff51258 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -70,7 +70,11 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (base increase, attained when no script is running)
+ + {" "} + +{" "} + {" "} + (base increase, attained when no script is running)
+ (effective increase, taking current RAM usage into account) } @@ -136,7 +140,11 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (base increase, attained when no script is running)
+ + {" "} + +{" "} + {" "} + (base increase, attained when no script is running)
+ (effective increase, taking current RAM usage into account) } @@ -180,7 +188,11 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (base increase, attained when no script is running)
+ + {" "} + +{" "} + {" "} + (base increase, attained when no script is running)
+ (effective increase, taking current RAM usage into account) } @@ -258,10 +270,10 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
current production rate.
- - - - {" "}max production rate. (achieved when 100% RAM is allocated to it) + + + {" "} + 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. From 1d3483c8c10b2eecc37a22ede408bd03c9a0ef0b Mon Sep 17 00:00:00 2001 From: borisflagell Date: Sat, 23 Apr 2022 15:17:24 +0200 Subject: [PATCH 6/7] Update HacknetServerElem.tsx OCD at work : putting the undimmed value above dimmed one for constency sake. --- src/Hacknet/ui/HacknetServerElem.tsx | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index b5ff51258..b40caf09e 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -70,12 +70,8 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - - {" "} - +{" "} - {" "} - (base increase, attained when no script is running)
- + (effective increase, taking current RAM usage into account) + + (effective increase, taking current RAM usage into account)
+ + (base increase, attained when no script is running) } > @@ -140,12 +136,8 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - - {" "} - +{" "} - {" "} - (base increase, attained when no script is running)
- + (effective increase, taking current RAM usage into account) + + (effective increase, taking current RAM usage into account)
+ + (base increase, attained when no script is running) } > @@ -188,12 +180,8 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - - {" "} - +{" "} - {" "} - (base increase, attained when no script is running)
- + (effective increase, taking current RAM usage into account) + + (effective increase, taking current RAM usage into account)
+ + (base increase, attained when no script is running) } > From ad4c84be937224297f6745b6df3d433466b047c1 Mon Sep 17 00:00:00 2001 From: borisflagell Date: Sat, 23 Apr 2022 15:18:43 +0200 Subject: [PATCH 7/7] Update HacknetServerElem.tsx Prettier pass --- src/Hacknet/ui/HacknetServerElem.tsx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Hacknet/ui/HacknetServerElem.tsx b/src/Hacknet/ui/HacknetServerElem.tsx index b40caf09e..ee1986599 100644 --- a/src/Hacknet/ui/HacknetServerElem.tsx +++ b/src/Hacknet/ui/HacknetServerElem.tsx @@ -70,8 +70,12 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (effective increase, taking current RAM usage into account)
- + (base increase, attained when no script is running) + + (effective increase, taking current RAM usage into account) +
+ + + + {" "} + (base increase, attained when no script is running) } > @@ -136,8 +140,12 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (effective increase, taking current RAM usage into account)
- + (base increase, attained when no script is running) + + (effective increase, taking current RAM usage into account) +
+ + + + {" "} + (base increase, attained when no script is running) } > @@ -180,8 +188,12 @@ export function HacknetServerElem(props: IProps): React.ReactElement { - + (effective increase, taking current RAM usage into account)
- + (base increase, attained when no script is running) + + (effective increase, taking current RAM usage into account) +
+ + + + {" "} + (base increase, attained when no script is running) } >