mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 20:55:44 +01:00
HACKNET: Disallow negative count
argument for spendHashes (#1127)
* disallow buying a negative amount of an upgrade * allow 0 silently
This commit is contained in:
parent
3d6692b292
commit
6288eec6d7
@ -201,7 +201,11 @@ export function NetscriptHacknet(): InternalAPI<IHacknet> {
|
|||||||
(_upgName, _upgTarget = "", _count = 1) => {
|
(_upgName, _upgTarget = "", _count = 1) => {
|
||||||
const upgName = helpers.string(ctx, "upgName", _upgName);
|
const upgName = helpers.string(ctx, "upgName", _upgName);
|
||||||
const upgTarget = helpers.string(ctx, "upgTarget", _upgTarget);
|
const upgTarget = helpers.string(ctx, "upgTarget", _upgTarget);
|
||||||
const count = helpers.number(ctx, "count", _count);
|
const count = Math.floor(helpers.number(ctx, "count", _count));
|
||||||
|
// TODO (3.0.0): use helpers.positiveInteger
|
||||||
|
if (!(count >= 0)) {
|
||||||
|
throw helpers.errorMessage(ctx, "count may not be negative");
|
||||||
|
}
|
||||||
if (!hasHacknetServers()) {
|
if (!hasHacknetServers()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user