# HG changeset patch # User Adrianna PiƄska # Date 1252014649 0 # Node ID baf857805867e38db66f4271f3f377128083a609 # Parent e3572b907028e79b70f1e13dd1cf85320a797e8b armour works now diff -r e3572b907028 -r baf857805867 gamelib/animal.py --- a/gamelib/animal.py Thu Sep 03 21:45:57 2009 +0000 +++ b/gamelib/animal.py Thu Sep 03 21:50:49 2009 +0000 @@ -27,6 +27,7 @@ self.equipment = [] self.abode = None self.facing = 'left' + self.lives = 1 def loop(self, tv, _sprite): ppos = tv.tile_to_view(self.pos.to_tuple()) @@ -60,6 +61,13 @@ def equip(self, item): self.equipment.append(item) + self.draw_equipment(item) + if not equipment.is_weapon(item): + # redraw weapons on top + for weapon in self.weapons(): + self.draw_equipment(weapon) + + def draw_equipment(self, item): if not hasattr(self, 'EQUIPMENT_IMAGE_ATTRIBUTE'): return eq_image_attr = getattr(item, self.EQUIPMENT_IMAGE_ATTRIBUTE, 'None') @@ -271,9 +279,11 @@ def _catch_chicken(self, chicken, gameboard): """Catch a chicken""" - sound.play_sound("kill-chicken.ogg") + chicken.lives -= 1 + if not chicken.lives > 0: + sound.play_sound("kill-chicken.ogg") + gameboard.remove_chicken(chicken) self.closest = None - gameboard.remove_chicken(chicken) self.hunting = False self.last_steps = [] # Forget history here diff -r e3572b907028 -r baf857805867 gamelib/constants.py --- a/gamelib/constants.py Thu Sep 03 21:45:57 2009 +0000 +++ b/gamelib/constants.py Thu Sep 03 21:50:49 2009 +0000 @@ -29,7 +29,7 @@ STARTING_CASH = 1000 SELL_PRICE_CHICKEN = 10 SELL_PRICE_EGG = 5 -SELL_PRICE_DEAD_FOX = 5 +SELL_PRICE_DEAD_FOX = 15 LOGGING_PRICE = 50 BUY_PRICE_FENCE = 50 SELL_PRICE_FENCE = 25 diff -r e3572b907028 -r baf857805867 gamelib/equipment.py --- a/gamelib/equipment.py Thu Sep 03 21:45:57 2009 +0000 +++ b/gamelib/equipment.py Thu Sep 03 21:50:49 2009 +0000 @@ -54,7 +54,7 @@ class Knife(Weapon): NAME = "knife" - BUY_PRICE = 20 + BUY_PRICE = 25 SELL_PRICE = 15 RANGE = 1 @@ -63,6 +63,31 @@ CHICKEN_IMAGE_FILE = 'sprites/equip_knife.png' +class Armour(Equipment): + + def place(self, animal): + """Give additional lives""" + animal.lives += self.PROTECTION + return True + +class Helmet(Armour): + NAME = "helmet" + BUY_PRICE = 25 + SELL_PRICE = 15 + + PROTECTION = 1 + + CHICKEN_IMAGE_FILE = 'sprites/helmet.png' + +class Kevlar(Armour): + NAME = "kevlar" + BUY_PRICE = 100 + SELL_PRICE = 75 + + PROTECTION = 2 + + CHICKEN_IMAGE_FILE = 'sprites/kevlar.png' + def is_equipment(obj): """Return true if obj is a build class.""" return getattr(obj, "IS_EQUIPMENT", False) and hasattr(obj, "NAME") diff -r e3572b907028 -r baf857805867 gamelib/gameboard.py --- a/gamelib/gameboard.py Thu Sep 03 21:45:57 2009 +0000 +++ b/gamelib/gameboard.py Thu Sep 03 21:50:49 2009 +0000 @@ -476,10 +476,12 @@ def kill_fox(self, fox): if fox in self.foxes: - self.killed_foxes += 1 - self.toolbar.update_fox_counter(self.killed_foxes) - self.add_cash(constants.SELL_PRICE_DEAD_FOX) - self.remove_fox(fox) + fox.lives -= 1 + if not fox.lives > 0: + self.killed_foxes += 1 + self.toolbar.update_fox_counter(self.killed_foxes) + self.add_cash(constants.SELL_PRICE_DEAD_FOX) + self.remove_fox(fox) def remove_fox(self, fox): self.foxes.discard(fox)