Mercurial > rinkhals
changeset 298:88a626202591
Buy equipment for chickens in buildings
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 16:42:32 +0000 |
parents | 73b9a39e9473 |
children | d7f5cd8007fb |
files | gamelib/gameboard.py |
diffstat | 1 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gameboard.py Sat Sep 05 16:27:55 2009 +0000 +++ b/gamelib/gameboard.py Sat Sep 05 16:42:32 2009 +0000 @@ -705,13 +705,27 @@ self.add_building(building) def buy_equipment(self, tile_pos, equipment_cls): - chicken = self.get_outside_chicken(tile_pos) + equipment = equipment_cls() - if chicken is None or self.cash < equipment.buy_price(): + + def do_equip(chicken): + # Try to equip the chicken + if equipment.place(chicken): + self.add_cash(-equipment.buy_price()) + chicken.equip(equipment) + return False + + chicken = self.get_outside_chicken(tile_pos) + if self.cash < equipment.buy_price(): return - if equipment.place(chicken): - self.add_cash(-equipment.buy_price()) - chicken.equip(equipment) + if chicken is None: + building = self.get_building(tile_pos) + if building is None: + return + # Bounce through open dialog once more + self.open_building_dialog(building, do_equip) + else: + do_equip(chicken) def sell_building(self, tile_pos): if self.tv.get(tile_pos) in [self.FENCE, self.BROKEN_FENCE]: