Attributes

Container for a list of attributes for a Character

Note: this currently defines the default list of attributes for Characters and should probably be refactored to allow for bundles to define this list instead

Constructor

new Attributes(baseStats)

baseStats argument should adhere to the following format:

{
  statName: 10, // where 10 is your preferred base value
  ...
}

When stats are loaded from disk, however, they will follow this format:

{
  statName: {
    base: 10,
    delta: 0
  }
}

So technically either format is valid but the former is easier when setting initial defaults

Parameters:
Name Type Description
baseStats Object

Override for default attribute set

Extends

  • Map

Methods

add(name, base, delta)

Creates and adds an attribute of a given name to the list

Parameters:
Name Type Default Description
name string
base number
delta number 0

clearDeltas()

Clear all deltas for all attributes in the list

getAttributes() → {Array}

Returns:
Array -

see Map#entries

serialize() → {Object}

Gather data that will be persisted

Returns:
Object