Class: Action

Class: Action

Action

new Action(engine, entity, player, options)

Represents each action taken by a player.

Parameters:
Name Type Description
engine Engine

The game engine associated with the action.

entity Entity

The entity associated with the action.

player Entity

The player who requested the action.

options Object

The arguments associated with the action.

Source:

Members

engine :Engine

The game engine associated with the action.

Type:
Source:

entity :Entity

The entity associated with the action.

Type:
Source:

options :Object

The arguments associated with the action.

Type:
  • Object
Source:

player :Entity

The player who requested the action. Note that a player is an entity with a player component. It defaults to PlayerComponent, but it can be changed by TurnEngine.

Type:
Source:

result :Object

The result of the action. It should be null if it hasn't run yet.

Type:
  • Object
Source:

Methods

<static> deserialize(engine, object) → {Action}

Deserializes the action.

Parameters:
Name Type Description
engine Engine

The game engine.

object Object

Serialized Action object.

Source:
Returns:

The deserialized Action object

Type
Action

<static> scaffold(func, constructor, classObj) → {Action}

Creates a new Action class that has given function as Action#run.

Parameters:
Name Type Argument Default Description
func function

The function to use as Action#run.

constructor function

The function to use as constructor.

classObj function <optional>
Action

The class to extend from.

Source:
Returns:

A new class that has specified function and class.

Type
Action

run(engine)

Runs the action and applies changes to the engine.

Parameters:
Name Type Description
engine Engine

The game engine to assign.

Source:
Throws:

Will throw an error if action#run is not implemented.

serialize() → {Object}

Serializes the action.

Source:
Returns:

The serialized Action object

Type
Object