Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
Foundry Virtual Tabletop
Foundry Virtual Tabletop
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 587
    • Issues 587
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 0
    • Merge Requests 0
  • Requirements
    • Requirements
    • List
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Foundry Network
  • Foundry Virtual TabletopFoundry Virtual Tabletop
  • Issues
  • #1614

Closed
Open
Opened Oct 27, 2019 by Andrew@aaclaytonOwner

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

  1. Informal use of lower case "actor" and "item" instead of upper-case "Actor" and "Item" entity names.
  2. Lack of explicitness around which sub-types of Entity are defined within the template.
  3. Difficulty in sharing common data structure across a subset (but not all) types.

Propsed Changes

  1. Add a "templateVersion" key to the system.json file. If "templateVersion": 2 is set, the system will treat the template.json file as a "new style" template.
  2. 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"
  3. For new style templates, each Entity declares the explicit named types which are supported by defining "types": [] within the entity block.
  4. 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.

Edited Oct 28, 2019 by Andrew
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Beta 0.4.0
Milestone
Beta 0.4.0 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: foundrynet/foundryvtt#1614