Ignore:
Timestamp:
06/30/10 18:47:25 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Minor modifications to dialogue files that check for an active quest and the quest variable instead of only for the quest variable
  • Containers now have a "replaceItem" method that can be used to replace an item with another. The new item will be at the same item position the old one was
  • Added "UseAction?" class that can be used when you need to execute commands that need a carryable item
  • Added ReplaceItem? command to UseAction?. This replaces the item, that the command is called on, with a new item of the given object type
  • Changed Box to have a "Use" Action with the display text "Open" that replaces the Box with Boots and sets the "open_box" variable of the fedex quest to 1
  • Added replace_stuff command to dialogues, this replaces an item, in either the pc's or npc's inventory (who), of the given item_id (old_item) with an new object of the given object_type(new_item)
  • When the player has opened the box it is possible to tell Janie who rewraps the Boots (replaces the boots in the pc's inventory with the Box)
  • checkAttributes method in GameModel? now does a deep copy instead of a shallow one.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/gamemodel.py

    r570 r571  
    6565        self.object_db = {} 
    6666        self.active_map = None 
    67         self.maps = {} 
    6867        self.map_files = {} 
    6968        self.agents = {} 
     
    7170        self.engine = engine 
    7271        self.fife_model = engine.getModel() 
    73         self.maps_file = "maps/maps.yaml" 
     72        self.game_state.maps_file = "maps/maps.yaml" 
    7473        self.all_agents_file = "maps/all_agents.yaml" 
    7574        self.object_db_file = "objects/ObjectDatabase.yaml" 
     
    8584        @param attributes: attributes to check 
    8685        @type attributes: Dictionary 
    87         @return: The modified attributes"""         
     86        @return: The modified attributes"""  
     87        from copy import deepcopy        
    8888        if attributes.has_key("object_type"): 
    8989            class_name = attributes.pop("object_type") 
     
    9191            class_name = attributes["type"] 
    9292        if self.object_db.has_key(class_name): 
    93             db_attributes = self.object_db[class_name].copy() 
     93            db_attributes = deepcopy(self.object_db[class_name]) 
    9494            for key in db_attributes.keys(): 
    9595                if attributes.has_key(key): 
     
    146146        else: 
    147147            container.placeItem(obj, index) 
     148     
     149    def deleteObject(self, object_id): 
     150        """Removes an object from the game 
     151        @param object_id: ID of the object 
     152        @type object_id: str 
     153        """ 
     154        self.game_state.deleteObject(object_id) 
    148155         
    149156    def save(self, path, filename): 
     
    166173            for agent in self.agents[map_name]: 
    167174                agent_obj = self.game_state.getObjectById(agent, map_name) 
    168                 agent_inst = self.maps[map_name].agent_layer.getInstance(agent) 
     175                agent_inst = self.game_state.maps[map_name].agent_layer.getInstance(agent) 
    169176                agent_dict = self.agents[map_name][agent] 
    170177                agent_dict.update(agent_obj.getStateForSaving()) 
     
    182189                agent_obj = self.game_state.getObjectById(agent, map_name) 
    183190            if agent_obj: 
    184                 agent_inst = self.maps[map_name].agent_layer.getInstance(agent) 
     191                agent_inst = self.game_state.maps[map_name].agent_layer.getInstance(agent) 
    185192                agent_dict.update(agent_obj.getStateForSaving()) 
    186193                agent_dict["Rotation"] = agent_inst.getRotation() 
     
    296303    def readMapFiles(self): 
    297304        """Read all a available map-files and store them""" 
    298         maps_data = file(self.maps_file) 
     305        maps_data = file(self.game_state.maps_file) 
    299306        self.map_files = yaml.load(maps_data)["Maps"] 
    300307     
     
    372379           @param map_name: Name of the map to load 
    373380           @return: None""" 
    374         if not map_name in self.maps:   
     381        if not map_name in self.game_state.maps:   
    375382            map_file = self.map_files[map_name] 
    376383            new_map = GameMap(self.engine, self) 
    377             self.maps[map_name] = new_map 
     384            self.game_state.maps[map_name] = new_map 
    378385            new_map.load(map_file) 
    379386     
     
    517524        self.engine.getModel().deleteObjects() 
    518525        self.game_state.clearObjects() 
    519         self.maps = {} 
     526        self.game_state.maps = {} 
    520527         
    521528    def setActiveMap(self, map_name): 
     
    528535        self.active_map.cameras[self.active_map.my_cam_id].setEnabled(False) 
    529536        # Make the new map active. 
    530         self.active_map = self.maps[map_name] 
     537        self.active_map = self.game_state.maps[map_name] 
    531538        self.active_map.makeActive() 
    532539        self.game_state.current_map_name = map_name 
Note: See TracChangeset for help on using the changeset viewer.