changeset 143:fa5c769468f0

get_equipable now checks if wearer is valid and returns None if it is not. This will fix a falsely raised SlotInvalidError.
author KarstenBock@gmx.net
date Sun, 09 Oct 2011 19:23:59 +0200
parents c28e29056218
children 86b9b181ad1c
files components/equip.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/components/equip.py	Sun Oct 09 18:22:48 2011 +0200
+++ b/components/equip.py	Sun Oct 09 19:23:59 2011 +0200
@@ -21,6 +21,14 @@
     def __init__(self):
         Base.__init__(self, head=object, neck=object, body=object, belt=object, 
                       leg=object, feet=object, l_arm=object, r_arm=object)
+        self.head = None
+        self.neck = None
+        self.body = None
+        self.belt = None
+        self.leg = None
+        self.feet = None
+        self.l_arm = None
+        self.r_arm = None
 
     @property
     def saveable_fields(self):
@@ -76,6 +84,8 @@
 
 def get_equipable(wearer, slot):
     """Return the equipable in the given slot"""
+    if not wearer:
+        return None
     try:
         item = getattr(wearer, slot)
         return item