adding the class
This commit is contained in:
parent
f8df69a011
commit
82ca516b93
17
Taskfile.yml
17
Taskfile.yml
@ -3,16 +3,22 @@
|
||||
version: "3"
|
||||
|
||||
tasks:
|
||||
schemas: fd -e yml -p ./schemas-yaml -x task schema SCHEMA='{}'
|
||||
schemas:
|
||||
sources: [ 'schemas-yaml/*' ]
|
||||
generates: [ 'schemas-json/*' ]
|
||||
cmds:
|
||||
- fd -e yml -p ./schemas-yaml -x task schema SCHEMA='{}'
|
||||
|
||||
schema:
|
||||
vars:
|
||||
TRANSFORM:
|
||||
sh: |
|
||||
echo {{.SCHEMA}} | \
|
||||
perl -lnE's/yml$/pl/; s/^/.\//; say if -f $_'
|
||||
DEST:
|
||||
sh: echo {{.SCHEMA}} | perl -pe's/ya?ml/json/g'
|
||||
sources: ["{{.SCHEMA}}"]
|
||||
generates: ["{{.DEST}}"]
|
||||
cmds:
|
||||
- transerialize {{.SCHEMA}} {{.DEST}}
|
||||
- transerialize {{.SCHEMA}} {{.TRANSFORM}} {{.DEST}}
|
||||
|
||||
validate:
|
||||
silent: true
|
||||
@ -23,7 +29,8 @@ tasks:
|
||||
--errors=json \
|
||||
--verbose \
|
||||
-c ajv-keywords \
|
||||
-s schemas-yaml/character.yml \
|
||||
-r schemas-json/classes.json \
|
||||
-s schemas-json/character.json \
|
||||
-d {{.CLI_ARGS}}
|
||||
test:
|
||||
deps: [ schemas ]
|
||||
|
@ -1,5 +1,8 @@
|
||||
name: Verg-La
|
||||
player: Yanick
|
||||
class:
|
||||
generic: magician
|
||||
subclass: cryomancer
|
||||
statistics:
|
||||
strength: 11
|
||||
dexterity: 13
|
||||
|
@ -9,6 +9,9 @@
|
||||
"$id" : "https://hyperboria.babyl.ca/character.json",
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
"class" : {
|
||||
"$ref" : "/classes.json"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
},
|
||||
@ -43,7 +46,8 @@
|
||||
"required" : [
|
||||
"name",
|
||||
"player",
|
||||
"statistics"
|
||||
"statistics",
|
||||
"class"
|
||||
],
|
||||
"title" : "Hyperboria character sheet",
|
||||
"type" : "object"
|
||||
|
66
schemas-json/classes.json
Normal file
66
schemas-json/classes.json
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"$defs" : {
|
||||
"fighter" : [
|
||||
"barbarian",
|
||||
"berserker",
|
||||
"cataphract",
|
||||
"hunstman",
|
||||
"paladin",
|
||||
"ranger",
|
||||
"warlock"
|
||||
],
|
||||
"magician" : [
|
||||
"cryomancer",
|
||||
"illusionist",
|
||||
"necromancer",
|
||||
"pyromancer",
|
||||
"witch"
|
||||
]
|
||||
},
|
||||
"$id" : "https://hyperboria.babyl.ca/classes.json",
|
||||
"oneOf" : [
|
||||
{
|
||||
"enum" : [
|
||||
"fighter",
|
||||
"magician"
|
||||
]
|
||||
},
|
||||
{
|
||||
"properties" : {
|
||||
"generic" : {
|
||||
"const" : "fighter"
|
||||
},
|
||||
"subclass" : {
|
||||
"enum" : [
|
||||
"barbarian",
|
||||
"berserker",
|
||||
"cataphract",
|
||||
"hunstman",
|
||||
"paladin",
|
||||
"ranger",
|
||||
"warlock"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type" : "object"
|
||||
},
|
||||
{
|
||||
"properties" : {
|
||||
"generic" : {
|
||||
"const" : "magician"
|
||||
},
|
||||
"subclass" : {
|
||||
"enum" : [
|
||||
"cryomancer",
|
||||
"illusionist",
|
||||
"necromancer",
|
||||
"pyromancer",
|
||||
"witch"
|
||||
]
|
||||
}
|
||||
},
|
||||
"type" : "object"
|
||||
}
|
||||
],
|
||||
"title" : "Classes of characters for Hyperborea"
|
||||
}
|
@ -6,10 +6,12 @@ required:
|
||||
- name
|
||||
- player
|
||||
- statistics
|
||||
- class
|
||||
properties:
|
||||
name: &string
|
||||
type: string
|
||||
player: *string
|
||||
class: { $ref: '/classes.json' }
|
||||
statistics:
|
||||
type: object
|
||||
allRequired: true
|
||||
|
17
schemas-yaml/classes.pl
Normal file
17
schemas-yaml/classes.pl
Normal file
@ -0,0 +1,17 @@
|
||||
sub {
|
||||
my $schema = $_->{oneOf} = [];
|
||||
|
||||
push @$schema, { enum => [ keys $_->{'$defs'}->%* ] };
|
||||
|
||||
for my $generic ( keys $_->{'$defs'}->%* ) {
|
||||
push @$schema, {
|
||||
type => 'object',
|
||||
properties => {
|
||||
generic => { const => $generic },
|
||||
subclass => { enum => $_->{'$defs'}{$generic} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $_;
|
||||
}
|
12
schemas-yaml/classes.yml
Normal file
12
schemas-yaml/classes.yml
Normal file
@ -0,0 +1,12 @@
|
||||
$id: https://hyperboria.babyl.ca/classes.json
|
||||
title: Classes of characters for Hyperborea
|
||||
$defs:
|
||||
fighter:
|
||||
- barbarian
|
||||
- berserker
|
||||
- cataphract
|
||||
- hunstman
|
||||
- paladin
|
||||
- ranger
|
||||
- warlock
|
||||
magician: [cryomancer, illusionist, necromancer, pyromancer, witch]
|
Loading…
Reference in New Issue
Block a user