1
2 """ This module implements the GameContext class """
3 from gameobject import GameObject
4
5
6 -class GameContext(GameObject):
7 """
8 A GameContext corresponds to a geographic location and is a collection
9 of GameObjects, GameActors and state attributes. They exist in
10 higherarchical relationships (e.g. kingdom, village, buiding, room).
11 """
12
13 - def __init__(self, name="context", descr=None, parent=None):
14 """
15 create a new GameObject
16 @param name: display name of this object
17 @param descr: human description of this object
18 """
19
20 - def get(self, attribute):
21 """
22 return the value of an attribute
23
24 Differs from base class because calls flow up the chain of
25 parents if this instance does not have the requested attribute.
26
27 @param attribute: name of attribute to be fetched
28 @return: (string) value (or None)
29 """
30
31 - def possible_actions(self, actor, context):
32 """
33 return a list of possible actions in this context
34
35 This base class merely passes that list up to our parent.
36
37 @param actor: GameActor initiating the action
38 @param context: GameContext for this action (should be "self")
39 @return: list of possible GameActions
40 """
41
42
43 - def accept_action(self, action, actor, context):
44 """
45 receive and process the effects of an action
46
47 The only verb supported by this base class is SEARCH, which it passes
48 on to any hidden (RESISTANCE.SEARCH > 0) object in this context.
49
50 @param action: GameAction being performed
51 @param actor: GameActor initiating the action
52 @param context: GameContext in which the action is happening
53
54 @return: (boolean success, string description of the effect)
55 """
56
57
58
59
60 - def get_party(self):
61 """
62 @return: list of player GameActors in this context
63 """
64
65 - def add_member(self, member):
66 """
67 Add an player character to this context
68 @param member: (GameActor) player to be added
69 """
70
71 - def remove_member(self, member):
72 """
73 Remove a player character from this context
74 @param member: (GameActor) player to be removed
75 """
76
78 """
79 return a list of the NPCs GameActors in this context
80 """
81
82 - def add_npc(self, npc):
83 """
84 Add an NPC to this context
85 @param npc: (GameActor) the NPC to be added
86 """
87
88 - def remove_npc(self, npc):
89 """
90 Remove a non-player character from this context
91 @param npc: (GameActor) NPC to be removed
92 """
93