Changeset 142

06/15/09 12:36:00 (10 years ago)

Fully epydocc'd

1 edited


  • trunk/PARPG/scripts/

    r138 r142  
    3636    """A MapDoor is an item that when clicked transports the player to 
    3737       another map""" 
    38     def __init__(self, name, new_map, targ_tup): 
     38    def __init__(self, name, new_map, location): 
     39        """@type name: string 
     40           @param name: name of fife object 
     41           @type new_map: string 
     42           @param new_map: name of new map 
     43           @type location: tuple 
     44           @param location: where to put the PC when map is loaded 
     45           @return: None""" 
    3946 = name 
    4047 = "maps/"+new_map+".xml" 
    41         # self.targ_coord: a (int, int) which stores the intended location  
     48        # location is an (int, int) which stores the intended location  
    4249        # of the PC on the new map 
    43         self.targ_coords = targ_tup 
     50        self.targ_coords = location 
    4552class Engine: 
    46     """Engine holds the logic for the game 
     53    """Engine holds the logic for the game. 
    4754       Since some data (object position and so forth) is held in the 
    4855       fife, and would be pointless to replicate, we hold a instance of 
    4956       the fife view here. This also prevents us from just having a 
    50        function heavy controller""" 
     57       function heavy controller.""" 
    5158    def __init__(self, view): 
     59        """Initialise the instance. 
     60           @type engine: world 
     61           @param engine: A world instance 
     62           @return: None""" 
    5263        # a World object 
    5364        self.view = view 
    6071    def reset(self): 
    6172        """Clears the data on a map reload so we don't have objects/npcs from 
    62            other maps hanging around.""" 
     73           other maps hanging around. 
     74           @return: None""" 
    6375        self.PC = None 
    6476        self.npcs = [] 
    6880    def loadObjects(self, filename): 
    6981        """Load objects from the XML file 
    70            Returns True if it worked, False otherwise""" 
     82           Returns True if it worked, False otherwise. 
     83           @type filename: string 
     84           @param filename: The XML file to read. 
     85           @rtype: boolean 
     86           @return: Status of result (True/False)""" 
    7187        try: 
    7288            objects_file = open(filename, 'rt') 
    94110    def addPC(self,pc): 
    95         """Add the PC to the world""" 
     111        """Add the PC to the world 
     112           @type pc: list 
     113           @param pc: List of data for PC attributes 
     114           @return: None""" 
    96115        if self.PC_targLoc: 
    97116            self.view.addObject(float(self.PC_targLoc[0]), \ 
    107126    def addObjects(self,objects): 
    108127        """Add all of the objects we found into the fife map 
    109            and into our class 
    110            An NPC is just an object to FIFE""" 
     128           and into our class. An NPC is just an object to FIFE 
     129           @type objects: list 
     130           @param objects: List of objects to add 
     131           @return: None""" 
    111132        for i in objects: 
    112133            # is it visible? 
    118139    def addNPCs(self,npcs): 
    119         """Add all of the NPCs we found into the fife map 
    120            and into this class""" 
     140        """Add all of the NPCs we found into the fife map to FIFE. 
     141           @type npcs: list 
     142           @param npcs: List of NPC's to add 
     143           @return: None""" 
    121144        for i in npcs: 
    122145            self.view.addObject(float(i[0]), float(i[1]), i[2], i[3]) 
    127150    def addDoors(self, doors): 
    128         """Add all the doors to the map as well 
    129            As an object they have already been added""" 
     151        """Add all the doors to the map as well. 
     152           As an object they will have already been added. 
     153           @type engine: list 
     154           @param engine: List of doors 
     155           @return: None""" 
    130156        for i in doors: 
    131157            self.doors.append(MapDoor(i[0], i[1], i[2])) 
    133159    def objectActive(self, ident): 
    134160        """Given the objects ID, pass back the object if it is active, 
    135            False if it doesn't exist or not displayed""" 
     161           False if it doesn't exist or not displayed 
     162           @type ident: string 
     163           @param ident: ID of object 
     164           @rtype: boolean 
     165           @return: Status of result (True/False)""" 
    136166        for i in self.objects: 
    137167            if((i.display == True)and( == ident)): 
    148178    def getItemActions(self, obj_id): 
    149         """Given the objects ID, return the text strings and callbacks""" 
     179        """Given the objects ID, return the text strings and callbacks. 
     180           @type obj_id: string 
     181           @param obj_id: ID of object 
     182           @rtype: list 
     183           @return: List of text and callbacks""" 
    150184        actions=[] 
    151185        # note: ALWAYS check NPC's first! 
    178212    def loadMap(self,map_file): 
    179         """Load a new map 
    180            TODO: needs some error checking""" 
     213        """Load a new map. TODO: needs some error checking 
     214           @type map_file: string 
     215           @param map_file: Name of map file to load 
     216           @return: None""" 
    181217        # first we let FIFE load the rest of the map 
    182218        self.view.load(map_file) 
    187223    def handleMouseClick(self,position): 
     224        """Code called when user left clicks the screen. 
     225           @type position: fife.ScreenPoint 
     226           @param position: Screen position of click 
     227           @return: None""" 
Note: See TracChangeset for help on using the changeset viewer.