diff components/equip.py @ 69:c1959525efda

Added get_equipable and take_equipable functions.
author KarstenBock@gmx.net
date Wed, 21 Sep 2011 17:32:36 +0200
parents e856b604b650
children 8f1edcab5602
line wrap: on
line diff
--- a/components/equip.py	Wed Sep 21 16:48:01 2011 +0200
+++ b/components/equip.py	Wed Sep 21 17:32:36 2011 +0200
@@ -41,4 +41,19 @@
         except AttributeError:
             raise SlotInvalidError(slot)
     return None
+
+def get_equipable(wearer, slot):
+    """Return the equipable in the given slot"""
+    try:
+        item = getattr(wearer, slot)
+        return item
+    except AttributeError:
+        raise SlotInvalidError(slot)
+    
+def take_equipable(wearer, slot):
+    """Remove equipable from the given slot and return it"""
+    item = get_equipable(wearer, slot)
+    setattr(wearer, slot, None)    
+    return item
+    
     
\ No newline at end of file