Use wasted hashes on "Sell for Money"

This commit is contained in:
Martin Fournier
2022-01-08 06:30:22 -05:00
parent d2193e017d
commit 7ddb66c601
2 changed files with 24 additions and 2 deletions
+15 -1
View File
@@ -421,7 +421,21 @@ function processAllHacknetServerEarnings(player: IPlayer, numCycles: number): nu
hashes += h;
}
player.hashManager.storeHashes(hashes);
const wastedHashes = player.hashManager.storeHashes(hashes);
if (wastedHashes > 0) {
// Currently set to cap in at 1% of the capacity so it's probably still more efficient to run a script to use the hashes
const maxHashesToConvert = player.hashManager.capacity * 0.01;
const hashesToConvertToCash = Math.min(wastedHashes, maxHashesToConvert);
const upgrade = HashUpgrades["Sell for Money"];
if (upgrade === null) throw new Error("Could not get the hash upgrade");
if (!upgrade.cost) throw new Error("Upgrade is not properly configured");
const multiplier = Math.floor(hashesToConvertToCash / upgrade.cost);
if (multiplier > 0) {
player.gainMoney(upgrade.value * multiplier, "hacknet");
}
}
return hashes;
}