Effect()

See the Effect guide for usage.

new Effect()

Listens to Events:
Properties:
Name Type Description
config object

Effect configuration (name/desc/duration/etc.)

Properties
Name Type Description
autoActivate boolean

If this effect immediately activates itself when added to the target

hidden boolean

If this effect is shown in the character's effect list

refreshes boolean

If an effect with the same type is applied it will trigger an effectRefresh event instead of applying the additional effect.

unique boolean

If multiple effects with the same config.type can be applied at once

maxStacks number

When adding an effect of the same type it adds a stack to the current effect up to maxStacks instead of adding the effect. Implies config.unique

persists boolean

If false the effect will not save to the player

type string

The effect category, mainly used when disallowing stacking

tickInterval boolean | number

Number of seconds between calls to the updateTick listener

description string
duration number

Total duration of effect in milliseconds

elapsed number

Get elapsed time in milliseconds

id string

filename minus .js

modifiers EffectModifiers

Attribute modifier functions

name string
remaining number

Number of seconds remaining

startedAt number

Date.now() time this effect became active

state object

Configuration of this type of effect (magnitude, element, stat, etc.)

target Character

Character this effect is... effecting

Extends

  • EventEmitter

Members

description :string

duration :number

elapsed :number

Elapsed time in milliseconds since event was activated

name :string

remaining :number

Remaining time in seconds

Methods

activate()

Set this effect active

Fires:

deactivate()

Set this effect active

Fires:

hydrate(state, data)

Reinitialize from persisted data

Parameters:
Name Type Description
state GameState
data Object

isCurrent() → {boolean}

Whether this effect has lapsed

Returns:
boolean

modifyAttribute(attrName, currentValue) → {number}

Parameters:
Name Type Description
attrName string
currentValue number
Returns:
number -

attribute modified by effect

modifyIncomingDamage(damage, currentAmount) → {Damage}

Parameters:
Name Type Description
damage Damage
currentAmount number
Returns:
Damage

modifyOutgoingDamage(damage, currentAmount) → {Damage}

Parameters:
Name Type Description
damage Damage
currentAmount number
Returns:
Damage

pause()

Stop this effect from having any effect temporarily

remove()

Remove this effect from its target

Fires:

resume()

Resume a paused effect

serialize() → {Object}

Gather data to persist

Returns:
Object

Events

effectActivated

effectAdded

Listeners of This Event:

effectDeactivated

effectRefreshed

Parameters:
Name Type Description
effect Effect

The new effect that is trying to be added

effectStackAdded

Parameters:
Name Type Description
effect Effect

The new effect that is trying to be added

remove