Changeset 569


Ignore:
Timestamp:
06/28/10 17:09:02 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Added item_id property to the CarryableItem? class. This should be the basic ID without the added number.
  • Container now can search an item by item_id too
  • Changed get_stuff function of dialoguegui to search an item by item_id instead of ID
Location:
trunk/game/scripts
Files:
4 edited

Legend:

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

    r566 r569  
    112112        info.update(extra) 
    113113        ID = info.pop("id") if info.has_key("id") else info.pop("ID") 
     114        if not info.has_key("item_id"): 
     115            info['item_id'] = ID 
    114116        if self.game_state.hasObject(ID): 
    115117            id_number = 1 
  • trunk/game/scripts/gui/dialoguegui.py

    r568 r569  
    5656 
    5757        def get_stuff(state, thing): 
    58             if not state['pc'].inventory.findItem(name = thing): 
     58            if not state['pc'].inventory.findItem(item_id = thing): 
    5959                try : 
    60                     self.npc.give(self.npc.inventory.findItem(ID = thing), state['pc']) 
     60                    self.npc.give(self.npc.inventory.findItem(item_id = thing),  
     61                                  state['pc']) 
    6162                    print "You've now have the %s" % thing 
    6263                except ValueError : 
  • trunk/game/scripts/objects/base.py

    r568 r569  
    348348        return None 
    349349 
     350    def findItemByItemID(self, item_id): 
     351        """Returns the item with the passed item_id""" 
     352        for i in self.items : 
     353            if self.items[i].item_id == item_id: 
     354                return self.items[i] 
     355        return None 
     356 
    350357    def findItem(self, **kwargs): 
    351358        """Find an item in container by attributes. All params are optional. 
     
    362369            if "kind" in kwargs and not self.items[i].trueAttr(kwargs["kind"]): 
    363370                continue 
     371            if "item_id" in kwargs and self.items[i].item_id != kwargs["item_id"]: 
     372                continue 
    364373            return self.items[i] 
    365374        return None 
  • trunk/game/scripts/objects/composed.py

    r568 r569  
    8181class CarryableItem (GameObject, Carryable, Usable): 
    8282    """Composite class that will be used for all carryable items""" 
    83     def __init__(self, **kwargs): 
     83    def __init__(self, item_id, **kwargs): 
    8484        GameObject.__init__(self, **kwargs) 
    8585        Carryable.__init__(self, **kwargs) 
    8686        Usable.__init__(self, **kwargs) 
     87        self.item_id = item_id 
    8788 
    8889    def prepareStateForSaving(self, state): 
Note: See TracChangeset for help on using the changeset viewer.