Package adventure :: Module action :: Class Action
[hide private]
[frames] | no frames]

Class Action

object --+
         |
        Action

The class Action represents actions that a player make take in a text adventure game. Action objects are constructed based on a textual commands and are, in effect, parsers for such commands. An action object is immutable after creation.

Instance Methods [hide private]
 
__init__(self, command)
Creates a new action object based on the given command.
string
execute(self, actor)
Causes the given player to take the action represented by this object.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, command)
(Constructor)

 

Creates a new action object based on the given command.

Parameters:
  • command (string) - a textual game command, e.g. "go east", "rest"
Overrides: object.__init__

execute(self, actor)

 

Causes the given player to take the action represented by this object.

Parameters:
  • actor (player object) - a player who is to take action
Returns: string
a description of the results of the action, or None if the command was not known