NETSCRIPT: add formulas.hacking.growAmount() (#1090)

Also, improve docs.
This commit is contained in:
David Walker
2024-03-26 03:26:50 -07:00
committed by GitHub
parent d8de22a273
commit 75dabd10be
10 changed files with 132 additions and 32 deletions
+11 -1
View File
@@ -1,5 +1,5 @@
import { Player as player } from "../Player";
import { calculateServerGrowth } from "../Server/formulas/grow";
import { calculateServerGrowth, calculateGrowMoney } from "../Server/formulas/grow";
import { numCycleForGrowthCorrected } from "../Server/ServerHelpers";
import {
calculateMoneyGainRate,
@@ -196,6 +196,16 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
checkFormulasAccess(ctx);
return numCycleForGrowthCorrected(server, targetMoney, startMoney, cores, player);
},
growAmount:
(ctx) =>
(_server, _player, _threads, _cores = 1) => {
const server = helpers.server(ctx, _server);
const person = helpers.person(ctx, _player);
const threads = helpers.number(ctx, "threads", _threads);
const cores = helpers.number(ctx, "cores", _cores);
checkFormulasAccess(ctx);
return calculateGrowMoney(server, threads, person, cores);
},
hackTime: (ctx) => (_server, _player) => {
const server = helpers.server(ctx, _server);
const person = helpers.person(ctx, _player);