Mercurial > parpg-source
comparison components/equip.py @ 71:8f1edcab5602
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 | c1959525efda |
children | 783dc57eca7c |
comparison
equal
deleted
inserted
replaced
70:1b1ab906e76e | 71:8f1edcab5602 |
---|---|
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 |