Mercurial > parpg-core
comparison src/parpg/components/equip.py @ 100:853ec1b277c7
Functions in equip.py will now correctly set the equipable's attributes.
author | KarstenBock@gmx.net |
---|---|
date | Wed, 21 Sep 2011 17:39:07 +0200 |
parents | c4c940fcbc83 |
children | 3d9b6405bd86 |
comparison
equal
deleted
inserted
replaced
99:c045f97b7dbc | 100:853ec1b277c7 |
---|---|
35 @returns The equipable that was at the given slot, or None""" | 35 @returns The equipable that was at the given slot, or None""" |
36 if slot in equipable.possible_slots: | 36 if slot in equipable.possible_slots: |
37 try: | 37 try: |
38 old_item = getattr(wearer, slot) | 38 old_item = getattr(wearer, slot) |
39 setattr(wearer, slot, equipable) | 39 setattr(wearer, slot, equipable) |
40 equipable.in_slot = slot | |
41 equipable.wearer = wearer | |
40 return old_item | 42 return old_item |
41 except AttributeError: | 43 except AttributeError: |
42 raise SlotInvalidError(slot) | 44 raise SlotInvalidError(slot) |
43 return None | 45 return None |
44 | 46 |
51 raise SlotInvalidError(slot) | 53 raise SlotInvalidError(slot) |
52 | 54 |
53 def take_equipable(wearer, slot): | 55 def take_equipable(wearer, slot): |
54 """Remove equipable from the given slot and return it""" | 56 """Remove equipable from the given slot and return it""" |
55 item = get_equipable(wearer, slot) | 57 item = get_equipable(wearer, slot) |
56 setattr(wearer, slot, None) | 58 setattr(wearer, slot, None) |
59 if item: | |
60 item.in_slot = None | |
61 item.wearer = None | |
57 return item | 62 return item |
58 | 63 |
59 | 64 |