# HG changeset patch # User KarstenBock@gmx.net # Date 1316777441 -7200 # Node ID 2f928c913c78983466569e10a406fd702a0d814d # Parent d456334d09c0ac58385a7dbc890b032869416ffb Fixed item_type not being set when creating items. diff -r d456334d09c0 -r 2f928c913c78 src/parpg/gamemodel.py --- a/src/parpg/gamemodel.py Fri Sep 23 13:30:17 2011 +0200 +++ b/src/parpg/gamemodel.py Fri Sep 23 13:30:41 2011 +0200 @@ -444,25 +444,31 @@ obj.container.children.append(None) items = inv["Items"] if inv.has_key("Items") else list() for data in items: + item_type = data["type"] item_data = {} - item_data = self.checkAttributes(item_data, data["type"]) + item_data = self.checkAttributes(item_data, item_type) if item_data.has_key("containable"): - item = createEntity(item_data, world, None) - self.game_state.addObject(self.createUniqueID(data["ID"]), None, item) + item = self.create_item(item_data, world, item_type, data) container.put_item(obj.container, item.containable) else: - raise Exception("Item %s is not containable." % data["type"]) + raise Exception("Item %s is not containable." % item_type) if agent.has_key("Equipment"): for slot, data in agent["Equipment"].iteritems(): + item_type = data["type"] item_data = {} - item_data = self.checkAttributes(item_data, data["type"]) + item_data = self.checkAttributes(item_data, item_type) if item_data.has_key("containable") and item_data.has_key("equipable"): - item = createEntity(item_data, world, None) - self.game_state.addObject(self.createUniqueID(data["ID"]), None, item) + item = self.create_item(item_data, world, item_type, data) equip.equip(obj.equip, item.equipable, slot) else: - raise Exception("Item %s is not containable or equipable." % data["type"]) + raise Exception("Item %s is not containable or equipable." % item_type) + + def create_item(self, item_data, world, item_type, data): + item = createEntity(item_data, world, None) + item.containable.item_type = item_type + self.game_state.addObject(self.createUniqueID(data["ID"]), None, item) + return item def placeAgents(self, world): """Places the current maps agents """