Skip to main content

Stat

Stat

Modifiable statistic. Allows non-destructive linear arithmetic. Useful when we wish to be able to reverse part or the whole of the computation

Main purpose of the class is to facilitate implementation of RPG-like stats, such as maximum health, or armor. These stats can then be modified by various skills, equipment and effects. Each such modification will be added as a separate LinearModifier and can be reversed by removing the modifier.

Kind: global class

new Stat([value])

ParamTypeDefault
[value]number0

stat.id : number

Unique identifier of a stat, such a health, armor etc.

Kind: instance property of Stat

stat.postprocess : function

Computed value will be pass through this function before being exposed. Useful for rounding and clamping. see Stat.Process for some options.

Kind: instance property of Stat

stat.base : Vector1

Base value that modifiers will affect

Kind: instance property of Stat

stat.value : Vector1

Final computed value. Do not modify this directly

Kind: instance property of Stat

stat.onModifierAdded ⇒ Signal.<LinearModifier>

Kind: instance property of Stat

stat.onModifierRemoved ⇒ Signal.<LinearModifier>

Kind: instance property of Stat

stat.onChanged ⇒ Signal

Kind: instance property of Stat

stat.isStat : boolean

Kind: instance property of Stat
Read only: true

stat.resetModifiers()

Remove all modifiers from the stat

Kind: instance method of Stat

stat.valueOf() ⇒ number

Kind: instance method of Stat

stat.toString() ⇒ string

Kind: instance method of Stat

stat.getValue() ⇒ number

Kind: instance method of Stat

stat.getBaseValue() ⇒ number

Kind: instance method of Stat

stat.setBaseValue(v)

Kind: instance method of Stat

ParamType
vnumber

stat.getModifiers() ⇒ Array.<LinearModifier>

NOTE: do not modify result

Kind: instance method of Stat

stat.addModifier(mod)

Kind: instance method of Stat

ParamType
modLinearModifier

stat.hasModifier(mod) ⇒ boolean

Kind: instance method of Stat

ParamType
modLinearModifier

stat.removeModifier(mod) ⇒ boolean

Kind: instance method of Stat

ParamType
modLinearModifier

stat.equals(other) ⇒ boolean

Kind: instance method of Stat

ParamType
otherStat

stat.copy(other)

Kind: instance method of Stat

ParamType
otherStat

stat.copyBase(other)

Copy base value from another stat

Kind: instance method of Stat

ParamType
otherStat

stat.setBaseFromParametricFunction(f, v)

Kind: instance method of Stat

ParamType
ffunction
vnumber

stat.addNonTransientModifiersFromStat(other)

Kind: instance method of Stat

ParamType
otherStat

Stat.applyModifiers(input, modifiers) ⇒ number

Kind: static method of Stat

ParamType
inputnumber
modifiersList.<LinearModifier>