CORPORATION: Added check to buy amount (#149)

This commit is contained in:
G4mingJon4s
2022-10-24 22:09:53 +02:00
committed by GitHub
parent d22d0a25ef
commit 6dc5990b63
2 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -457,7 +457,8 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
const cityName = helpers.city(ctx, "cityName", _cityName);
const materialName = helpers.string(ctx, "materialName", _materialName);
const amt = helpers.number(ctx, "amt", _amt);
if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
if (amt < 0 || !Number.isFinite(amt))
throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
const material = getMaterial(divisionName, cityName, materialName);
BuyMaterial(material, amt);
},