Stats

new Stats()

Stats component for RPG character statistics. Includes health, stamina, and stat modifiers.

Extends

Members

health

Health reads the authoritative Combatant after binding and writes through its validated health path.

isAlive

Check if alive.

maxHealth

Maximum health mirrors Combatant while explicitly bound; standalone Stats retains legacy ownership.

(readonly) properties

The entity that this component is attached to.

Inherited From

Methods

applyEffect(name, duration, modifier)

Apply a status effect.

Parameters:
NameTypeDescription
namestring
durationnumber

Duration in seconds.

modifierObject

{ stat: multiplier }

bindCombatant()

Bind this legacy stat component to the authoritative Combatant health state.

deserialize(props)

Populates the component properties from a data object. Override this method for custom property handling.

Parameters:
NameTypeDescription
propsobject

The properties object (usually from JSON).

Inherited From

getModifiedStat(statName) → {number}

Get stat with modifiers applied.

Parameters:
NameTypeDescription
statNamestring
Returns:
Type: 
number

heal(amount)

Heal health.

Parameters:
NameTypeDescription
amountnumber

regenStamina(amount)

Regenerate stamina.

Parameters:
NameTypeDescription
amountnumber

takeDamage(amount) → {number}

Take damage (reduced by defense).

Parameters:
NameTypeDescription
amountnumber

Raw damage amount.

Returns:

Actual damage taken.

Type: 
number

unbindCombatant()

Stop mirroring a Combatant, retaining the last authoritative health value.

updateEffects(deltaTime)

Update status effects.

Parameters:
NameTypeDescription
deltaTimenumber

useStamina(amount) → {boolean}

Use stamina.

Parameters:
NameTypeDescription
amountnumber
Returns:

True if had enough stamina.

Type: 
boolean