Persona Stat Definitions#

The PersonaStatDefinition is a definition of a given statistic that can be associated with any given Persona object. It has a set of properties that clearly define the boundaries of a statistic in order to simply code when performing comparison and computation against other statistics of like values.

Each statistic must define one or all of the following properties:

  • type - The data type of the statistic’s value. Must be a valid JavaScript data type. Possible values are:

    • boolean

    • number

    • bigint

    • string

    • object

  • min - The minimum value that is possible to assign to an associated Persona, describing a range of values.

  • max - The maximum value that is possible to assign to an associated Persona, describing a range of values.

  • values - A list of pre-defined values that the statistic can have. Useful when describing an enumerator.

  • default - The initial value that will be given to all Persona objects that have a stat associated with them.

When defining a definition the types of min , max , values and default must all be the same and must be of the same type as described by the type property. If the types are different the definition will be rejected upon creation. In the case of the object type no validation is performed other than to verify than a given value is a valid JavaScript object (e.g. {} ).

Using this definition it is possible to define many different types of statistic values.

Example Number#

The following example illustrates how to define a statistic with numerical values that range from 0 to 100 with a default value of 0:

1{
2    "name": "MyNumericalStat",
3    "type": "number",
4    "min": 0,
5    "max": 100,
6    "default": 0,
7}

Example String Enumerator#

The following example illustrates how to define an enumerated value of strings:

 1{
 2    "name": "MyEnumeratedStringStat",
 3    "type": "string",
 4    "values": [
 5        "A",
 6        "B",
 7        "C",
 8        "D"
 9    ],
10    "default": "A",
11}

Example Number Enumerator#

The following example illustrates how to define an enumerated value of numbers:

 1{
 2    "name": "MyEnumeratedNumberStat",
 3    "type": "number",
 4    "values": [
 5        0,
 6        1,
 7        2,
 8        3,
 9    ],
10    "default": 0,
11}

Example Object#

The following example illustrates how to define an statistic with an object value:

 1{
 2    "name": "MyObjectStat",
 3    "type": "object",
 4    "values": [
 5        { prop: 0 },
 6        { prop: 1 },
 7        { prop: 2 },
 8        { prop: 3 },
 9    ],
10    "default": { prop: 0 },
11}