diff --git a/Taskfile.yml b/Taskfile.yml index 31ba9b7..f30744a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,6 +21,7 @@ tasks: - transerialize {{.SCHEMA}} {{.TRANSFORM}} {{.DEST}} validate: + deps: [ schemas ] silent: true cmds: - | @@ -28,6 +29,7 @@ tasks: --all-errors \ --errors=json \ --verbose \ + --data \ -c ajv-keywords \ -r schemas-json/classes.json \ -s schemas-json/character.json \ diff --git a/samples/verg.yml b/samples/verg.yml index 1000903..2277afd 100644 --- a/samples/verg.yml +++ b/samples/verg.yml @@ -1,8 +1,12 @@ name: Verg-La player: Yanick +level: 4 class: generic: magician subclass: cryomancer +health: + max: 13 + log: [ 4, 3, 2, 4 ] statistics: strength: 11 dexterity: 13 diff --git a/schemas-json/character.json b/schemas-json/character.json index f4d0d1a..704ef04 100644 --- a/schemas-json/character.json +++ b/schemas-json/character.json @@ -1,5 +1,32 @@ { "$defs" : { + "health" : { + "properties" : { + "current" : { + "type" : "number" + }, + "log" : { + "description" : "history of health rolls", + "items" : { + "type" : "number" + }, + "maxItems" : { + "$data" : "/level" + }, + "minItems" : { + "$data" : "/level" + }, + "type" : "array" + }, + "max" : { + "type" : "number" + } + }, + "required" : [ + "max" + ], + "type" : "object" + }, "statistic" : { "maximum" : 20, "minimum" : 1, @@ -12,6 +39,13 @@ "class" : { "$ref" : "/classes.json" }, + "health" : { + "$ref" : "#/$defs/health" + }, + "level" : { + "minimum" : 1, + "type" : "number" + }, "name" : { "type" : "string" }, @@ -47,7 +81,9 @@ "name", "player", "statistics", - "class" + "class", + "level", + "health" ], "title" : "Hyperboria character sheet", "type" : "object" diff --git a/schemas-yaml/character.yml b/schemas-yaml/character.yml index e0b0957..3abe8ed 100644 --- a/schemas-yaml/character.yml +++ b/schemas-yaml/character.yml @@ -7,6 +7,8 @@ required: - player - statistics - class + - level + - health properties: name: &string type: string @@ -23,9 +25,23 @@ properties: intelligence: *stat wisdom: *stat charisma: *stat + level: { type: number, minimum: 1 } + health: { $ref: '#/$defs/health' } $defs: statistic: type: number minimum: 1 maximum: 20 + health: + type: object + required: [ max ] + properties: + max: { type: number } + current: { type: number } + log: + type: array + description: history of health rolls + items: { type: number } + minItems: { $data: /level } + maxItems: { $data: /level }