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. |
Members
-
engine :Engine
-
The game engine associated with the action.
Type:
-
entity :Entity
-
The entity associated with the action.
Type:
-
options :Object
-
The arguments associated with the action.
Type:
- Object
-
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:
-
result :Object
-
The result of the action. It should be null if it hasn't run yet.
Type:
- Object
Methods
-
<static> deserialize(engine, object) → {Action}
-
Deserializes the action.
Parameters:
Name Type Description engine
Engine The game engine.
object
Object Serialized Action object.
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.
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.
Throws:
Will throw an error if action#run is not implemented.
-
serialize() → {Object}
-
Serializes the action.
Returns:
The serialized Action object
- Type
- Object