Module gameactor :: Class GameActor
[hide private]
[frames] | no frames]

Class GameActor

source code


A GameActor (typically a PC or NPC) is an agent that has a context and is capable of initiating and receiving actions.

Instance Methods [hide private]
 
__init__(self, name='actor', descr=None)
create a new GameActor
source code
 
_accept_attack(self, action, actor, context)
Accept an attack, figure out if it hits, and how bad
source code
 
accept_action(self, action, actor, context)
receive and process the effects of an ATTACK (other actions are passed to our super-class)
source code
 
interact(self, actor)
return a list of possible interactions (w/this GameActor)
source code
 
set_context(self, context)
establish the local context
source code
 
take_action(self, action, target)
Initiate an action against a target
source code
 
take_turn(self)
called once per round in initiative order (must be implemented in sub-classes)
source code

Inherited from gameobject.GameObject: __str__, add_object, get_object, get_objects, load, possible_actions

Inherited from base.Base: get, set

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

Instance Variables [hide private]

Inherited from gameobject.GameObject: objects

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name='actor', descr=None)
(Constructor)

source code 

create a new GameActor

Parameters:
  • name - display name of this actor
  • descr - human description of this actor
Overrides: object.__init__

_accept_attack(self, action, actor, context)

source code 

Accept an attack, figure out if it hits, and how bad

Parameters:
  • action - (GameAction) being performed
  • actor - (GameActor) initiating the action
  • context - (GameContext) in which action is being taken
Returns:
(boolean, string) succewss and description of the effect

accept_action(self, action, actor, context)

source code 

receive and process the effects of an ATTACK (other actions are passed to our super-class)

A standard attack comes with at-least two standard attributes:

  • TO_HIT ... the (pre defense) to-hit probability
  • HIT_POINTS ... the (pre-armor) damage being delivered
  1. use D100+EVASION to determine if attack hits
  2. use PROTECTION to see how much damage gets through
  3. update LIFE_POINTS
Parameters:
  • action - (GameAction) being performed
  • actor - (GameActor) initiating the action
  • context - (GameContext) in which action is being taken
Returns:
(boolean, string) description of the effect
Overrides: gameobject.GameObject.accept_action

interact(self, actor)

source code 

return a list of possible interactions (w/this GameActor)

Parameters:
  • actor - (GameActor) initiating the interactions
Returns:
Interaction object

GameObjects have a (ACTIONS) list of verbs that can be turned into a list of the GameActions that they enable. GameActors have a (INTERACTIONS) list of verbs that a requesting GameActor can turn into interaction GameActions that can be exchanged with that character.

The interaction object will have an ACTIONS attribute, containing a comma-separated list of the supported interaction verbs (which can be used to instantiate and deliver GameActions).

take_action(self, action, target)

source code 

Initiate an action against a target

Parameters:
  • action - (GameAction) to be initiated
  • target - (GameObject) target of the action
Returns:
(boolean, string) result of the action