mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 06:48:42 +02:00
PoC for save validation on load via hooking the Reviver function and
static property validationData on classes PoC/example implemented with HacknetNode: validates cores is a number in the range between 1 and HacknetNodeConstants.MaxCores validates level is a number in range between 1 and HacknetNodeConstants.MaxLevel validates ram is a number in range between 1 and HacknetNodeConstants.MaxRam validates onlineTimeSeconds in non negative number validates totalMoneyGenerated is a non negative number
This commit is contained in:
@@ -18,8 +18,36 @@ import { HacknetNodeConstants } from "./data/Constants";
|
||||
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
||||
import { ObjectValidator } from "src/utils/Validator";
|
||||
|
||||
export class HacknetNode implements IHacknetNode {
|
||||
|
||||
static validationData: ObjectValidator<HacknetNode> = {
|
||||
cores: {
|
||||
default: 1,
|
||||
min: 1,
|
||||
max: HacknetNodeConstants.MaxCores
|
||||
},
|
||||
level: {
|
||||
default: 1,
|
||||
min: 1,
|
||||
max: HacknetNodeConstants.MaxLevel
|
||||
},
|
||||
ram: {
|
||||
default: 1,
|
||||
min: 1,
|
||||
max: HacknetNodeConstants.MaxRam
|
||||
},
|
||||
onlineTimeSeconds: {
|
||||
default: 0,
|
||||
min: 0
|
||||
},
|
||||
totalMoneyGenerated: {
|
||||
default: 0,
|
||||
min: 0
|
||||
}
|
||||
}
|
||||
|
||||
// Node's number of cores
|
||||
cores = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user