Changeset 579


Ignore:
Timestamp:
07/11/10 13:50:17 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Changes according to our coding standards
  • Updated pylintrc
Location:
trunk/game
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/pylintrc

    r575 r579  
    140140 
    141141# Good variable names which should always be accepted, separated by a comma 
    142 good-names=k,ex,Run,_,__init__,__getstate__,__setstate__,ID,__repr__,x,y,z,X,Y,Z 
     142good-names=k,ex,Run,_,__init__,__getstate__,__setstate__,ID,__repr__,x,y,z,X,Y,Z,__str__,__getitem__ 
    143143 
    144144# Bad variable names which should always be refused, separated by a comma 
  • trunk/game/run.py

    r563 r579  
    1 #!/usr/bin/env python 
     1#!/usr/bin/env python # pylint: disable-msg=C0111 
    22 
    33#   This program is free software: you can redistribute it and/or modify 
  • trunk/game/scripts/gamemap.py

    r563 r579  
    131131        """Add the player character to the map 
    132132           @return: None""" 
    133         # Update gamestate.PlayerCharacter 
    134         self.model.game_state.PlayerCharacter.behaviour.onNewMap(self.agent_layer) 
     133        # Update gamestate.player_character 
     134        self.model.game_state.player_character.behaviour.onNewMap(self.agent_layer) 
    135135        self.cameras[self.my_cam_id].attach(self.model.game_state. 
    136                                             PlayerCharacter.behaviour.agent) 
     136                                            player_character.behaviour.agent) 
    137137 
    138138    def toggleRenderer(self, r_name): 
  • trunk/game/scripts/gamemodel.py

    r578 r579  
    1 #!/usr/bin/python 
     1#!/usr/bin/python # pylint: disable-msg=C0111 
    22 
    33#   This file is part of PARPG. 
     
    102102        @param attributes: Dictionary of all object attributes 
    103103        @type attributes: Dictionary 
    104         @return: The created object 
    105         """ 
     104        @return: The created object """ 
    106105        # create the extra data 
    107106        extra = {} 
     
    146145        """Removes an object from the game 
    147146        @param object_id: ID of the object 
    148         @type object_id: str 
    149         """ 
     147        @type object_id: str """ 
    150148        self.game_state.deleteObject(object_id) 
    151149         
     
    169167            for agent in self.agents[map_name]: 
    170168                agent_obj = self.game_state.getObjectById(agent, map_name) 
    171                 agent_inst = self.game_state.maps[map_name].agent_layer.getInstance(agent) 
     169                agent_inst = self.game_state.maps[map_name].\ 
     170                                    agent_layer.getInstance(agent) 
    172171                agent_dict = self.agents[map_name][agent] 
    173172                agent_dict.update(agent_obj.getStateForSaving()) 
     
    181180            agent_obj = None 
    182181            if agent == "PlayerCharacter": 
    183                 agent_obj = self.game_state.PlayerCharacter 
     182                agent_obj = self.game_state.player_character 
    184183            else: 
    185184                agent_obj = self.game_state.getObjectById(agent, map_name) 
    186185            if agent_obj: 
    187                 agent_inst = self.game_state.maps[map_name].agent_layer.getInstance(agent) 
     186                agent_inst = self.game_state.maps[map_name].\ 
     187                                    agent_layer.getInstance(agent) 
    188188                agent_dict.update(agent_obj.getStateForSaving()) 
    189189                agent_dict["Rotation"] = agent_inst.getRotation() 
     
    307307        @type namespace: str 
    308308        @param agent: The agent to be added 
    309         @type agent: dict 
    310         """ 
     309        @type agent: dict """ 
    311310        from local_loaders.loaders import loadImportFile 
    312311        if not self.agents.has_key(namespace): 
     
    326325        """Read the agents of the map 
    327326        @param map_name: Name of the map 
    328         @type map_name: str 
    329         """ 
     327        @type map_name: str """ 
    330328        #Get the agents of the map         
    331329        map_agents_file = self.map_files[map_name].\ 
     
    349347        @param map_name: Name of the map 
    350348        @type map_name: str 
    351         @return: A dictionary with the agents of the map 
    352         """ 
     349        @return: A dictionary with the agents of the map""" 
    353350        if not self.agents.has_key(map_name): 
    354351            return {} 
    355352        ret_dict = self.agents[map_name].copy() 
    356         for agent_name, agent_value in self.agents[self.ALL_AGENTS_KEY].iteritems(): 
     353        for agent_name, agent_value in self.agents[self.ALL_AGENTS_KEY]\ 
     354                                                .iteritems(): 
    357355            if agent_value["Map"] == map_name: 
    358356                ret_dict[agent_name] = agent_value 
     
    361359    def getAgentsOfActiveMap(self): 
    362360        """Returns the agents that are on active map 
    363         @return: A dictionary with the agents of the map 
    364         """ 
     361        @return: A dictionary with the agents of the map """ 
    365362        return self.getAgentsOfMap(self.active_map.map.getId()) 
    366363 
     
    472469     
    473470    def placeAgents(self): 
    474         """Places the current maps agents 
    475         """ 
     471        """Places the current maps agents """ 
    476472        if not self.active_map: 
    477473            return 
     
    492488        # create the PlayerCharacter agent 
    493489        self.active_map.addPC() 
    494         self.game_state.PlayerCharacter.start() 
     490        self.game_state.player_character.start() 
    495491        if agent.has_key("PeopleKnown"): 
    496             self.game_state.PlayerCharacter.peopleIknow = agent["PeopleKnown"] 
     492            self.game_state.player_character.peopleIknow = agent["PeopleKnown"] 
    497493                       
    498494    def changeMap(self, map_name, target_position = None): 
     
    568564        # in the future we will need to copy 
    569565        # PlayerCharacter specifics between the different PlayerCharacter's 
    570         self.game_state.PlayerCharacter = player_char 
    571         self.game_state.PlayerCharacter.setup()         
     566        self.game_state.player_character = player_char 
     567        self.game_state.player_character.setup()         
    572568 
    573569    def addObject(self, layer, obj, instance): 
     
    607603           @rtype: boolean 
    608604           @return: Status of result (True/False)""" 
    609         for i in \ 
     605        for game_object in \ 
    610606           self.game_state.getObjectsFromMap(self.game_state.current_map_name): 
    611             if (i.ID == ident): 
     607            if (game_object.ID == ident): 
    612608                # we found a match 
    613                 return i 
     609                return game_object 
    614610        # no match 
    615611        return False     
     
    621617           @return: None""" 
    622618        if(self.pc_run == 1): 
    623             self.game_state.PlayerCharacter.run(position) 
     619            self.game_state.player_character.run(position) 
    624620        else: 
    625             self.game_state.PlayerCharacter.walk(position) 
     621            self.game_state.player_character.walk(position) 
    626622         
    627623    def teleportAgent(self, agent, position): 
     
    634630 
    635631    def readObjectDB(self): 
    636         """Reads the Object Information Database from a file. 
    637         """ 
     632        """Reads the Object Information Database from a file. """ 
    638633        database_file = file(self.object_db_file, "r") 
    639634        database = yaml.load_all(database_file) 
     
    642637 
    643638    def getAgentImportFiles(self): 
    644         """Searches the agents directory for import files 
    645         """ 
     639        """Searches the agents directory for import files """ 
    646640        files = locateFiles("*.xml", self.agents_directory) 
    647641        for xml_file in files: 
     
    652646     
    653647    def getDialogues(self): 
    654         """Searches the dialogue directory for dialogues 
    655         """ 
     648        """Searches the dialogue directory for dialogues """ 
    656649        files = locateFiles("*.yaml", self.dialogues_directory) 
    657650        for dialogue_file in files: 
  • trunk/game/scripts/gamescenecontroller.py

    r572 r579  
    176176                                    agent_layer.getInstance("PlayerCharacter") 
    177177                self.model.active_map.agent_layer.deleteInstance(player_agent) 
    178                 player_char = self.model.game_state.PlayerCharacter 
    179                 self.model.game_state.PlayerCharacter = None 
     178                player_char = self.model.game_state.player_character 
     179                self.model.game_state.player_character = None 
    180180                pc_agent = self.model.agents[self.model.ALL_AGENTS_KEY]\ 
    181181                                                ["PlayerCharacter"]  
     
    207207                                            self.model.game_state.\ 
    208208                                                current_map_name) 
    209         self.model.game_state.PlayerCharacter.approach([npc.getLocation().\ 
     209        self.model.game_state.player_character.approach([npc.getLocation().\ 
    210210                                     getLayerCoordinates().x, 
    211211                                     npc.getLocation().\ 
     
    232232            else: 
    233233                actions.append(["Examine", "Examine", 
    234                                 self.model.game_state.PlayerCharacter.approach,  
     234                                self.model.game_state.player_character.approach,  
    235235                                [obj.X, obj.Y], 
    236236                                ExamineAction(self, obj.name, obj.text)]) 
     
    238238                if obj.trueAttr("door"): 
    239239                    actions.append(["Change Map", "Change Map", 
    240                        self.model.game_state.PlayerCharacter.approach,  
     240                       self.model.game_state.player_character.approach,  
    241241                       [obj.X, obj.Y], 
    242242                       ChangeMapAction(self, obj.target_map_name, 
     
    246246                    actions.append(["Open", "Open",  
    247247                                    self.model.game_state.\ 
    248                                         PlayerCharacter.approach, 
     248                                        player_character.approach, 
    249249                                    [obj.X, obj.Y], 
    250250                                    OpenBoxAction(self, obj)]) 
    251251                    actions.append(["Unlock", "Unlock",  
    252252                                    self.model.game_state.\ 
    253                                         PlayerCharacter.approach, 
     253                                        player_character.approach, 
    254254                                    [obj.X, obj.Y], 
    255255                                    UnlockBoxAction(self, obj)]) 
    256256                    actions.append(["Lock", "Lock",  
    257257                                    self.model.game_state.\ 
    258                                         PlayerCharacter.approach, 
     258                                        player_character.approach, 
    259259                                    [obj.X, obj.Y], 
    260260                                    LockBoxAction(self, obj)]) 
  • trunk/game/scripts/gamesceneview.py

    r563 r579  
    5555        """Callback sample for the context menu.""" 
    5656        self.hud.hideContainer() 
    57         self.model.game_state.PlayerCharacter.run(click) 
     57        self.model.game_state.player_character.run(click) 
    5858 
    5959    def refreshTopLayerTransparencies(self): 
     
    6565        # get the PlayerCharacter's screen coordinates 
    6666        camera = self.model.active_map.cameras[self.model.active_map.my_cam_id] 
    67         point = self.model.game_state.PlayerCharacter.\ 
     67        point = self.model.game_state.player_character.\ 
    6868                                        behaviour.agent.getLocation() 
    6969        scr_coords = camera.toScreenCoordinates(point.getMapCoordinates()) 
  • trunk/game/scripts/gamestate.py

    r574 r579  
    1 #!/usr/bin/python 
     1#!/usr/bin/python # pylint: disable-msg=C0111 
    22 
    33#   This file is part of PARPG. 
     
    2020class GameState(object): 
    2121    """This class holds the current state of the game.""" 
    22     def __init__(self, QuestsDir = None): 
    23         self.PlayerCharacter = None 
    24         self.quest_engine = QuestEngine(QuestsDir) 
     22    def __init__(self, quests_dir = None): 
     23        self.player_character = None 
     24        self.quest_engine = QuestEngine(quests_dir) 
    2525        self.quest_engine.readQuests() 
    2626        self.objects = {} 
  • trunk/game/scripts/gui/dialoguegui.py

    r575 r579  
    1 #!python 
     1#!/usr/bin/python # pylint: disable-msg=C0111 
    22 
    33#   This file is part of PARPG. 
  • trunk/game/scripts/gui/hud.py

    r572 r579  
    144144            'toggleInventoryButton': self.toggleInventoryButton, 
    145145        } 
    146         self.inventory_storage = self.model.game_state.PlayerCharacter.inventory 
     146        self.inventory_storage = self.model.game_state.player_character.inventory 
    147147        if self.inventory == None: 
    148148            self.inventory = inventorygui.InventoryGUI(self.controller, 
     
    430430                    npc, 
    431431                    self.model.game_state.quest_engine, 
    432                     self.model.game_state.PlayerCharacter) 
     432                    self.model.game_state.player_character) 
    433433        dialogue.initiateDialogue() 
  • trunk/game/scripts/objects/action.py

    r572 r579  
    219219           @return: None""" 
    220220       
    221         player_char = self.model.game_state.PlayerCharacter 
     221        player_char = self.model.game_state.player_character 
    222222        npc_coordinates = self.npc.getLocation().getLayerCoordinates() 
    223223        pc_coordinates = player_char.behaviour.agent.\ 
     
    246246                self.npc.behaviour.agent.say("Leave me alone!", 1000) 
    247247                 
    248             self.model.game_state.PlayerCharacter.behaviour.idle() 
    249             self.model.game_state.PlayerCharacter.nextAction = None 
     248            self.model.game_state.player_character.behaviour.idle() 
     249            self.model.game_state.player_character.nextAction = None 
    250250            super(TalkAction, self).execute() 
    251251 
  • trunk/game/scripts/quest_engine.py

    r575 r579  
    1 #!/usr/bin/python 
     1#!/usr/bin/python # pylint: disable-msg=C0111 
    22 
    33#   This file is part of PARPG. 
     
    2121 
    2222class Quest(object): 
     23    """Class that holds the information for a quest""" 
    2324    def __init__(self, quest_id, quest_giver_id, quest_name, description, 
    2425                 variables): 
    25         """This holds all the quest information""" 
    2626        self.quest_id = quest_id 
    2727        self.quest_giver_id = quest_giver_id 
     
    100100           @param variable_name: the name of the variable to set 
    101101           @return: True when it has reached or exceeded the goal value 
    102            @return: False when it has not reached or exceeded the goal value 
    103            """ 
     102           @return: False when it has not reached or exceeded the goal value """ 
    104103        if variable_name in self.quest_variables: 
    105104            return self.quest_variables[variable_name]["value"] >= \ 
     
    110109    def restartQuest(self): 
    111110        """Restarts the quest. This sets all values to the reset values, 
    112         if there is a reset value present 
    113         """ 
     111        if there is a reset value present """ 
    114112        for variable in self.quest_variables.itervalues(): 
    115113            if variable.has_key("reset_value"): 
     
    241239        """Prepares state for saving 
    242240        @type state: dictionary 
    243         @param state: State of the object   
    244         """ 
     241        @param state: State of the object""" 
    245242        ret_dict = {} 
    246243        variables_dict = ret_dict["Variables"] = {} 
Note: See TracChangeset for help on using the changeset viewer.