Merge pull request #2550 from TheMas3212/feature-save-validator

Feature save validator
This commit is contained in:
hydroflame
2022-01-15 17:52:17 -05:00
committed by GitHub
3 changed files with 95 additions and 1 deletions
+10
View File
@@ -18,8 +18,18 @@ import { HacknetNodeConstants } from "./data/Constants";
import { dialogBoxCreate } from "../ui/React/DialogBox";
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
import { ObjectValidator, minMax } from "../utils/Validator";
export class HacknetNode implements IHacknetNode {
static validationData: ObjectValidator<HacknetNode> = {
cores: minMax(1, 1, HacknetNodeConstants.MaxCores),
level: minMax(1, 1, HacknetNodeConstants.MaxLevel),
ram: minMax(1, 1, HacknetNodeConstants.MaxRam),
onlineTimeSeconds: minMax(0, 0, Infinity),
totalMoneyGenerated: minMax(0, 0, Infinity)
}
// Node's number of cores
cores = 1;