comparison src/parpg/components/equip.py @ 147:3aff9dee1b4f

Added belt and neck as equipment slots.
author KarstenBock@gmx.net
date Wed, 05 Oct 2011 10:54:56 +0200
parents 90b49fda0340
children fadc02e77ae1
comparison
equal deleted inserted replaced
146:6e1eb964a6e5 147:3aff9dee1b4f
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"""