changeset 108:2f928c913c78

Fixed item_type not being set when creating items.
author KarstenBock@gmx.net
date Fri, 23 Sep 2011 13:30:41 +0200
parents d456334d09c0
children bb0e09112a1f
files src/parpg/gamemodel.py
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 """