System template.json Changes and Improvements
I am planning some changes to the template.json
file which ships with game systems. There are a few things I want to address with these changes:
Identified Problems
- Informal use of lower case "actor" and "item" instead of upper-case "Actor" and "Item" entity names.
- Lack of explicitness around which sub-types of Entity are defined within the template.
- Difficulty in sharing common data structure across a subset (but not all) types.
Propsed Changes
- Add a
"templateVersion"
key to thesystem.json
file. If"templateVersion": 2
is set, the system will treat thetemplate.json
file as a "new style" template. - For new style templates, the entity names
"actor"
and"item"
(or other future entities which are supported in this way) must be capitalized as"Actor"
and"Item"
- For new style templates, each Entity declares the explicit named types which are supported by defining
"types": []
within the entity block. - For new style templates, within each Entity block you may define a set of named
"templates": {}
which can be included within the data model for each type as"templates": []
.
Example of New Style template.json File
{
"Actor": {
"types": ["hero", "pawn", "villain"],
"templates": {
"background": {
"biography": "",
"hairColor": "blue"
},
"resources": {
"health": {
"value": 10,
"max": 10
},
"power": {
"value": 1,
"max": 3
}
}
},
"hero": {
"templates": ["background", "resources"],
"goodness": {
"value": 5,
"max": 10
}
},
"pawn": {
"templates": ["resources"]
},
"villain": {
"templates": ["background", "resources"],
"wickedness": {
"value": 5,
"max": 100
}
}
},
"Item": {
"types": ["weapon", "spell"],
"templates": {
"rarity": {
"rarity": "Common",
"price": 20
}
},
"weapon": {
"templates": ["rarity"],
"damage": 5
},
"spell": {
"templates": ["rarity"],
"cost": 2
}
}
}
In the example, the Actor
entity has 3 sub-types: ["hero", "pawn", "villain"]
. All 3 types include the common set of "resources", while heroes and villains also include a "background".
When the data model is prepared, any templates applied to the entity sub-type are applied in order of their declaration, and lastly any additional data defined at the type level is applied to augment or overwrite the templates. For example, a "hero"
type Actor
would have the following data structure:
data = {
"background": "",
"hairColor": "blue",
"health": {
"value": 10,
"max": 10
},
"power": {
"value": 1,
"max": 3
},
"goodness": {
"value": 5,
"max": 10
}
}
Roll-Out Timeline
For 0.4.x
versions, both old templates and new templates will be supported. Once we reach 0.5.x
only new style templates can be used. Starting with 0.4.0
to opt-in to the new template.json format you will just put "templateVersion": 2
in your system.json
file.