comparison 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
comparison
equal deleted inserted replaced
68:8915ff6183b0 69:c1959525efda
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