Mercurial > rinkhals
diff gamelib/gameboard.py @ 84:5494af02a0e8
Chickens with rifles!
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 01 Sep 2009 21:31:08 +0000 |
parents | 9bd2c22e1746 |
children | bea1b9364583 |
line wrap: on
line diff
--- a/gamelib/gameboard.py Tue Sep 01 19:40:08 2009 +0000 +++ b/gamelib/gameboard.py Tue Sep 01 21:31:08 2009 +0000 @@ -10,6 +10,7 @@ import constants import buildings import animal +import equipment class OpaqueLabel(gui.Label): def paint(self, s): @@ -248,19 +249,20 @@ def clear_foxes(self): for fox in self.foxes: - self.tv.sprites.remove(fox) # Any foxes that didn't make it to the woods are automatically # killed if self.in_bounds(fox.pos) and self.tv.get(fox.pos.to_tuple()) \ != self.WOODLAND: - self.killed_foxes += 1 - self.toolbar.update_fox_counter(self.killed_foxes) - self.add_cash(constants.SELL_PRICE_DEAD_FOX) + self.kill_fox(fox) + else: + self.tv.sprites.remove(fox) self.foxes = [] # Remove all the foxes def move_foxes(self): for fox in self.foxes: fox.move(self) + for chicken in self.chickens: + chicken.attack(self) def add_chicken(self, chicken): self.chickens.append(chicken) @@ -275,6 +277,13 @@ self.buildings.append(building) self.tv.sprites.append(building) + 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) + def remove_fox(self, fox): if fox in self.foxes: self.foxes.remove(fox) @@ -331,6 +340,8 @@ if roll == 1: # Create a chicken chick = animal.Chicken((x, y)) + if random.randint(0, 1) == 0: + chick.equip(equipment.Rifle()) self.add_chicken(chick) x += 1