comparison src/parpg/components/equip.py @ 98:c4c940fcbc83

Added get_equipable and take_equipable functions.
author KarstenBock@gmx.net
date Wed, 21 Sep 2011 17:32:36 +0200
parents 0f659c7675f6
children 853ec1b277c7
comparison
equal deleted inserted replaced
97:915190c0cbc8 98:c4c940fcbc83
39 setattr(wearer, slot, equipable) 39 setattr(wearer, slot, equipable)
40 return old_item 40 return old_item
41 except AttributeError: 41 except AttributeError:
42 raise SlotInvalidError(slot) 42 raise SlotInvalidError(slot)
43 return None 43 return None
44
45 def get_equipable(wearer, slot):
46 """Return the equipable in the given slot"""
47 try:
48 item = getattr(wearer, slot)
49 return item
50 except AttributeError:
51 raise SlotInvalidError(slot)
44 52
53 def take_equipable(wearer, slot):
54 """Remove equipable from the given slot and return it"""
55 item = get_equipable(wearer, slot)
56 setattr(wearer, slot, None)
57 return item
58
59