comparison components/equip.py @ 117:f2ef124128db

Added belt and neck as equipment slots.
author KarstenBock@gmx.net
date Wed, 05 Oct 2011 10:54:56 +0200
parents f94d4577ca5e
children fa5c769468f0
comparison
equal deleted inserted replaced
116:7f7f54c4077b 117:f2ef124128db
13 13
14 from base import Base 14 from base import Base
15 15
16 class Equip(Base): 16 class Equip(Base):
17 """ 17 """
18 Component that stores the equipment (what is being worn/wieled). 18 Component that stores the equipment (what is being worn/wielded).
19 """ 19 """
20 20
21 def __init__(self): 21 def __init__(self):
22 Base.__init__(self, head=object, body=object, leg=object, feet=object, l_arm=object, r_arm=object) 22 Base.__init__(self, head=object, neck=object, body=object, belt=object,
23 leg=object, feet=object, l_arm=object, r_arm=object)
23 24
24 @property 25 @property
25 def saveable_fields(self): 26 def saveable_fields(self):
26 return [] 27 return []
27 28
39 40
40 def __str__(self): 41 def __str__(self):
41 return "The equipable is already weared." 42 return "The equipable is already weared."
42 43
43 class CannotBeEquippedInSlot(Exception): 44 class CannotBeEquippedInSlot(Exception):
44 """Error that gets raised when the equipable can't be equiped in that slot""" 45 """Error that gets raised when the equipable can't be equiped in that
46 slot"""
45 47
46 def __init__(self, slot, equipable): 48 def __init__(self, slot, equipable):
47 self.slot = slot 49 self.slot = slot
48 self.equipable = equipable 50 self.equipable = equipable
49 51
50 def __str__(self): 52 def __str__(self):
51 return "%s is not in the equipables slots. (%s)" % (self.slot, ', '.join(self.equipable.possible_slots)) 53 return ("%s is not in the equipables slots. (%s)" %
54 (self.slot, ', '.join(self.equipable.possible_slots))
55 )
52 56
53 57
54 def equip(wearer, equipable, slot): 58 def equip(wearer, equipable, slot):
55 """Equip the wearer with the given equipable. 59 """Equip the wearer with the given equipable.
56 @returns The equipable that was at the given slot, or None""" 60 @returns The equipable that was at the given slot, or None"""