comparison gamelib/equipment.py @ 161:9b4213f6ea7f

improved equipment layers; unequip method on animal
author Adrianna Pińska <adrianna.pinska@gmail.com>
date Thu, 03 Sep 2009 22:16:09 +0000
parents baf857805867
children 1d4d2202ef9f
comparison
equal deleted inserted replaced
160:8a11bbafa07f 161:9b4213f6ea7f
3 import random 3 import random
4 import sound 4 import sound
5 5
6 class Equipment(object): 6 class Equipment(object):
7 IS_EQUIPMENT = True 7 IS_EQUIPMENT = True
8 DRAW_LAYER = 0
8 9
9 def __init__(self): 10 def __init__(self):
10 self._buy_price = self.BUY_PRICE 11 self._buy_price = self.BUY_PRICE
11 self._sell_price = self.SELL_PRICE 12 self._sell_price = self.SELL_PRICE
12 self._name = self.NAME 13 self._name = self.NAME
20 def name(self): 21 def name(self):
21 return self._name 22 return self._name
22 23
23 class Weapon(Equipment): 24 class Weapon(Equipment):
24 IS_WEAPON = True 25 IS_WEAPON = True
26 DRAW_LAYER = 10
25 27
26 def in_range(self, gameboard, wielder, target): 28 def in_range(self, gameboard, wielder, target):
27 """Can the lucky wielder hit the potentially unlucky target with this?""" 29 """Can the lucky wielder hit the potentially unlucky target with this?"""
28 return wielder.pos.dist(target.pos) <= self.RANGE 30 return wielder.pos.dist(target.pos) <= self.RANGE
29 31
62 RANGE_MODIFIER = 0 64 RANGE_MODIFIER = 0
63 65
64 CHICKEN_IMAGE_FILE = 'sprites/equip_knife.png' 66 CHICKEN_IMAGE_FILE = 'sprites/equip_knife.png'
65 67
66 class Armour(Equipment): 68 class Armour(Equipment):
69 DRAW_LAYER = 5
67 70
68 def place(self, animal): 71 def place(self, animal):
69 """Give additional lives""" 72 """Give additional lives"""
70 animal.lives += self.PROTECTION 73 animal.lives += self.PROTECTION
71 return True 74 return True