#!/usr/bin/python3 """ This module implements the GameContext class """ class GameContext(GameObject): """ A GameContext corresponds to a geographic location and is a collection of GameObjects, GameActors and state attributes. They exist in higherarchical relationships (e.g. kingdom, village, buiding, room). """ def __init__(self, name="context", descr=None, parent=None): """ create a new GameObject @param name: display name of this object @param descr: human description of this object """ def get(self, attribute): """ return the value of an attribute Differs from base class because calls flow up the chain of parents if this instance does not have the requested attribute. @param attribute: name of attribute to be fetched @return: (string) value (or None) """ def possible_actions(self, actor, context): """ return a list of possible actions in this context This base class merely passes that list up to our parent. @param actor: GameActor initiating the action @param context: GameContext for this action (should be "self") @return: list of possible GameActions """ def accept_action(self, action, actor, context): """ receive and process the effects of an action The only verb supported by this base class is SEARCH, which it passes on to any hidden (RESISTANCE.SEARCH > 0) object in this context. @param action: GameAction being performed @param actor: GameActor initiating the action @param context: GameContext in which the action is happening @return: (boolean success, string description of the effect) """ def get_party(self): """ @return: list of player GameActors in this context """ def add_member(self, member): """ Add an player character to this context @param member: (GameActor) player to be added """ def remove_member(self, member): """ Remove a player character from this context @param member: (GameActor) player to be removed """ def get_npcs(self): """ return a list of the NPCs GameActors in this context """ def add_npc(self, npc): """ Add an NPC to this context @param npc: (GameActor) the NPC to be added """ def remove_npc(self, npc): """ Remove a non-player character from this context @param npc: (GameActor) NPC to be removed """