1   
 2  """ This module implements the GameActor class """ 
 3  from random import randint 
 4  from gameobject import GameObject 
 5  from gameaction import GameAction 
 6  from gamecontext import GameContext 
 7   
 8   
10      """ 
11      A GameActor (typically a PC or NPC) is an agent that has a 
12      context and is capable of initiating and receiving actions. 
13      """ 
14   
15 -    def __init__(self, name="actor", descr=None): 
 16          """ 
17          create a new GameActor 
18          @param name: display name of this actor 
19          @param descr: human description of this actor 
20          """ 
 21   
23          """ 
24          Accept an attack, figure out if it hits, and how bad 
25          @param action: (GameAction) being performed 
26          @param actor: (GameActor) initiating the action 
27          @param context: (GameContext) in which action is being taken 
28          @return:  (boolean, string) succewss and description of the effect 
29   
30          """ 
 31           
32           
33           
34           
35           
36           
37   
39          """ 
40          receive and process the effects of an ATTACK 
41          (other actions are passed to our super-class) 
42   
43          A standard attack comes with at-least two standard attributes: 
44             - TO_HIT ... the (pre defense) to-hit probability 
45             - HIT_POINTS ... the (pre-armor) damage being delivered 
46   
47             1. use D100+EVASION to determine if attack hits 
48             2. use PROTECTION to see how much damage gets through 
49             3. update LIFE_POINTS 
50   
51          @param action: (GameAction) being performed 
52          @param actor: (GameActor) initiating the action 
53          @param context: (GameContext) in which action is being taken 
54          @return:  (boolean, string) description of the effect 
55          """ 
 56           
57           
58           
59   
61          """ 
62          return a list of possible interactions (w/this GameActor) 
63   
64          @param actor: (GameActor) initiating the interactions 
65          @return: Interaction object 
66   
67          GameObjects have a (ACTIONS) list of verbs that can be turned into 
68          a list of the GameActions that they enable. 
69          GameActors have a (INTERACTIONS) list of verbs that a requesting 
70          GameActor can turn into interaction GameActions that can be 
71          exchanged with that character. 
72   
73          The interaction object will have an ACTIONS attribute, 
74          containing a comma-separated list of the supported interaction verbs 
75          (which can be used to instantiate and deliver GameActions). 
76          """ 
 77   
78 -    def set_context(self, context): 
 79          """ 
80          establish the local context 
81          """ 
 82   
84          """ 
85          Initiate an action against a target 
86          @param action: (GameAction) to be initiated 
87          @param target: (GameObject) target of the action 
88          @return: (boolean, string) result of the action 
89          """ 
 90           
91   
93          """ 
94          called once per round in initiative order 
95          (must be implemented in sub-classes) 
96          """ 
  97