diff src/parpg/components/equip.py @ 100:853ec1b277c7

Functions in equip.py will now correctly set the equipable's attributes.
author KarstenBock@gmx.net
date Wed, 21 Sep 2011 17:39:07 +0200
parents c4c940fcbc83
children 3d9b6405bd86
line wrap: on
line diff
--- a/src/parpg/components/equip.py	Wed Sep 21 17:37:30 2011 +0200
+++ b/src/parpg/components/equip.py	Wed Sep 21 17:39:07 2011 +0200
@@ -37,6 +37,8 @@
         try:
             old_item = getattr(wearer, slot)
             setattr(wearer, slot, equipable)
+            equipable.in_slot = slot
+            equipable.wearer = wearer
             return old_item
         except AttributeError:
             raise SlotInvalidError(slot)
@@ -53,7 +55,10 @@
 def take_equipable(wearer, slot):
     """Remove equipable from the given slot and return it"""
     item = get_equipable(wearer, slot)
-    setattr(wearer, slot, None)    
+    setattr(wearer, slot, None)
+    if item:
+        item.in_slot = None
+        item.wearer = None
     return item
     
     
\ No newline at end of file