Mercurial > rinkhals
comparison gamelib/gameboard.py @ 298:88a626202591
Buy equipment for chickens in buildings
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 16:42:32 +0000 |
parents | 29e9683055dc |
children | 01c1682dc250 |
comparison
equal
deleted
inserted
replaced
297:73b9a39e9473 | 298:88a626202591 |
---|---|
703 if building.place(self.tv): | 703 if building.place(self.tv): |
704 self.add_cash(-building.buy_price()) | 704 self.add_cash(-building.buy_price()) |
705 self.add_building(building) | 705 self.add_building(building) |
706 | 706 |
707 def buy_equipment(self, tile_pos, equipment_cls): | 707 def buy_equipment(self, tile_pos, equipment_cls): |
708 | |
709 equipment = equipment_cls() | |
710 | |
711 def do_equip(chicken): | |
712 # Try to equip the chicken | |
713 if equipment.place(chicken): | |
714 self.add_cash(-equipment.buy_price()) | |
715 chicken.equip(equipment) | |
716 return False | |
717 | |
708 chicken = self.get_outside_chicken(tile_pos) | 718 chicken = self.get_outside_chicken(tile_pos) |
709 equipment = equipment_cls() | 719 if self.cash < equipment.buy_price(): |
710 if chicken is None or self.cash < equipment.buy_price(): | 720 return |
711 return | 721 if chicken is None: |
712 if equipment.place(chicken): | 722 building = self.get_building(tile_pos) |
713 self.add_cash(-equipment.buy_price()) | 723 if building is None: |
714 chicken.equip(equipment) | 724 return |
725 # Bounce through open dialog once more | |
726 self.open_building_dialog(building, do_equip) | |
727 else: | |
728 do_equip(chicken) | |
715 | 729 |
716 def sell_building(self, tile_pos): | 730 def sell_building(self, tile_pos): |
717 if self.tv.get(tile_pos) in [self.FENCE, self.BROKEN_FENCE]: | 731 if self.tv.get(tile_pos) in [self.FENCE, self.BROKEN_FENCE]: |
718 return self.sell_fence(tile_pos) | 732 return self.sell_fence(tile_pos) |
719 building = self.get_building(tile_pos) | 733 building = self.get_building(tile_pos) |