Ignore:
Timestamp:
06/26/10 15:34:34 (10 years ago)
Author:
beliar
Message:

Ticket #260 Patch by Beliar

  • When creating inventory objects there will now e a consecutively numbered number added to the ID. The new ID will have the form <ID>_<number>

fixes[s:trac, t:260

File:
1 edited

Legend:

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

    r563 r565  
    2424        self.quest_engine = quest_engine.QuestEngine() 
    2525        self.objects = {} 
     26        self.object_ids = {} 
    2627        self.current_map_name = None 
     28         
     29         
     30    def addObject(self, map_id, game_object): 
     31        """Adds an object to the objects and object_ids 
     32        dictionaries. 
     33        @param map_id: ID of the map the object is on.  
     34        If the object is in a container this has to be None 
     35        @param object: object to be added 
     36        @type object: GameObject 
     37        @type map_id: str or None 
     38        """ 
     39        object_id = game_object.ID 
     40        if not self.object_ids.has_key(object_id): 
     41            if map_id: 
     42                self.objects[map_id][object_id] = game_object 
     43            self.object_ids[object_id] = map_id 
    2744         
    2845    def getObjectsFromMap(self, map_id): 
     
    3653         
    3754        return {} 
     55     
     56    def hasObject(self, object_id): 
     57        """Check if an object with the given id is present  
     58        @param object_id: ID of the object 
     59        @type object_id: str 
     60        @return: True if there is an object False if not 
     61        """ 
     62        return self.object_ids.has_key(object_id) 
     63     
     64    def getMapOfObject(self, object_id): 
     65        """Returns the map the object is on. 
     66        @param object_id: ID of the object 
     67        @type object_id: str 
     68        @return: Name of the map the object is on.  
     69        If there is no such object or the object is in a container None is returned 
     70        """ 
     71        if self.object_ids.has_key(object_id): 
     72            return self.object_ids[object_id] 
     73        return None 
    3874     
    3975    def getObjectById(self, obj_id, map_id): 
     
    5389        """ 
    5490        self.objects = {} 
     91        self.object_ids = {} 
    5592         
    5693    def getStateForSaving(self): 
Note: See TracChangeset for help on using the changeset viewer.