changeset 173:fadc02e77ae1

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 2d671e57badb
children ee4c1fe78be1
files src/parpg/components/equip.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/parpg/components/equip.py	Sun Oct 09 18:22:48 2011 +0200
+++ b/src/parpg/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