changeset 98:c4c940fcbc83

Added get_equipable and take_equipable functions.
author KarstenBock@gmx.net
date Wed, 21 Sep 2011 17:32:36 +0200
parents 915190c0cbc8
children c045f97b7dbc
files src/parpg/components/equip.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/parpg/components/equip.py	Wed Sep 21 16:48:01 2011 +0200
+++ b/src/parpg/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