mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 13:43:49 +01:00
Calculating max purchase takes into account max level for Hacknet Nodes
This commit is contained in:
parent
2569a4819d
commit
d5ad17c84b
@ -215,20 +215,21 @@ updateHacknetNodesMultiplierButtons = function() {
|
||||
getMaxNumberLevelUpgrades = function(nodeObj) {
|
||||
if (nodeObj.calculateLevelUpgradeCost(1) > Player.money) {return 0;}
|
||||
var min = 1;
|
||||
var max = 199;
|
||||
var max = CONSTANTS.HacknetNodeMaxLevel-1;
|
||||
var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level;
|
||||
|
||||
while (min <= max) {
|
||||
var curr = (min + max) / 2 | 0;
|
||||
if (curr != 200 &&
|
||||
if (curr != CONSTANTS.HacknetNodeMaxLevel &&
|
||||
nodeObj.calculateLevelUpgradeCost(curr) < Player.money &&
|
||||
nodeObj.calculateLevelUpgradeCost(curr+1) > Player.money) {
|
||||
return curr;
|
||||
return Math.min(levelsToMax, curr);
|
||||
} else if (nodeObj.calculateLevelUpgradeCost(curr) > Player.money) {
|
||||
max = curr - 1;
|
||||
} else if (nodeObj.calculateLevelUpgradeCost(curr) < Player.money) {
|
||||
min = curr + 1;
|
||||
} else {
|
||||
return curr;
|
||||
return Math.min(levelsToMax, curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user