Changeset 579 for trunk/game/scripts/gamemodel.py
- Timestamp:
- 07/11/10 13:50:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/game/scripts/gamemodel.py
r578 r579 1 #!/usr/bin/python 1 #!/usr/bin/python # pylint: disable-msg=C0111 2 2 3 3 # This file is part of PARPG. … … 102 102 @param attributes: Dictionary of all object attributes 103 103 @type attributes: Dictionary 104 @return: The created object 105 """ 104 @return: The created object """ 106 105 # create the extra data 107 106 extra = {} … … 146 145 """Removes an object from the game 147 146 @param object_id: ID of the object 148 @type object_id: str 149 """ 147 @type object_id: str """ 150 148 self.game_state.deleteObject(object_id) 151 149 … … 169 167 for agent in self.agents[map_name]: 170 168 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) 172 171 agent_dict = self.agents[map_name][agent] 173 172 agent_dict.update(agent_obj.getStateForSaving()) … … 181 180 agent_obj = None 182 181 if agent == "PlayerCharacter": 183 agent_obj = self.game_state. PlayerCharacter182 agent_obj = self.game_state.player_character 184 183 else: 185 184 agent_obj = self.game_state.getObjectById(agent, map_name) 186 185 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) 188 188 agent_dict.update(agent_obj.getStateForSaving()) 189 189 agent_dict["Rotation"] = agent_inst.getRotation() … … 307 307 @type namespace: str 308 308 @param agent: The agent to be added 309 @type agent: dict 310 """ 309 @type agent: dict """ 311 310 from local_loaders.loaders import loadImportFile 312 311 if not self.agents.has_key(namespace): … … 326 325 """Read the agents of the map 327 326 @param map_name: Name of the map 328 @type map_name: str 329 """ 327 @type map_name: str """ 330 328 #Get the agents of the map 331 329 map_agents_file = self.map_files[map_name].\ … … 349 347 @param map_name: Name of the map 350 348 @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""" 353 350 if not self.agents.has_key(map_name): 354 351 return {} 355 352 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(): 357 355 if agent_value["Map"] == map_name: 358 356 ret_dict[agent_name] = agent_value … … 361 359 def getAgentsOfActiveMap(self): 362 360 """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 """ 365 362 return self.getAgentsOfMap(self.active_map.map.getId()) 366 363 … … 472 469 473 470 def placeAgents(self): 474 """Places the current maps agents 475 """ 471 """Places the current maps agents """ 476 472 if not self.active_map: 477 473 return … … 492 488 # create the PlayerCharacter agent 493 489 self.active_map.addPC() 494 self.game_state. PlayerCharacter.start()490 self.game_state.player_character.start() 495 491 if agent.has_key("PeopleKnown"): 496 self.game_state. PlayerCharacter.peopleIknow = agent["PeopleKnown"]492 self.game_state.player_character.peopleIknow = agent["PeopleKnown"] 497 493 498 494 def changeMap(self, map_name, target_position = None): … … 568 564 # in the future we will need to copy 569 565 # PlayerCharacter specifics between the different PlayerCharacter's 570 self.game_state. PlayerCharacter = player_char571 self.game_state. PlayerCharacter.setup()566 self.game_state.player_character = player_char 567 self.game_state.player_character.setup() 572 568 573 569 def addObject(self, layer, obj, instance): … … 607 603 @rtype: boolean 608 604 @return: Status of result (True/False)""" 609 for iin \605 for game_object in \ 610 606 self.game_state.getObjectsFromMap(self.game_state.current_map_name): 611 if ( i.ID == ident):607 if (game_object.ID == ident): 612 608 # we found a match 613 return i609 return game_object 614 610 # no match 615 611 return False … … 621 617 @return: None""" 622 618 if(self.pc_run == 1): 623 self.game_state. PlayerCharacter.run(position)619 self.game_state.player_character.run(position) 624 620 else: 625 self.game_state. PlayerCharacter.walk(position)621 self.game_state.player_character.walk(position) 626 622 627 623 def teleportAgent(self, agent, position): … … 634 630 635 631 def readObjectDB(self): 636 """Reads the Object Information Database from a file. 637 """ 632 """Reads the Object Information Database from a file. """ 638 633 database_file = file(self.object_db_file, "r") 639 634 database = yaml.load_all(database_file) … … 642 637 643 638 def getAgentImportFiles(self): 644 """Searches the agents directory for import files 645 """ 639 """Searches the agents directory for import files """ 646 640 files = locateFiles("*.xml", self.agents_directory) 647 641 for xml_file in files: … … 652 646 653 647 def getDialogues(self): 654 """Searches the dialogue directory for dialogues 655 """ 648 """Searches the dialogue directory for dialogues """ 656 649 files = locateFiles("*.yaml", self.dialogues_directory) 657 650 for dialogue_file in files:
Note: See TracChangeset
for help on using the changeset viewer.