Mercurial > rinkhals
comparison gamelib/gameboard.py @ 428:a356e57529ea
buildings cost wood
author | Adrianna Pińska <adrianna.pinska@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 16:21:38 +0000 |
parents | 1d0cc37b4e14 |
children | 8643893635e7 |
comparison
equal
deleted
inserted
replaced
427:e89a1afe4e84 | 428:a356e57529ea |
---|---|
299 self.day, self.night = True, False | 299 self.day, self.night = True, False |
300 # For the level loading case | 300 # For the level loading case |
301 if self.disp: | 301 if self.disp: |
302 self.create_display() | 302 self.create_display() |
303 self.add_cash(level.starting_cash) | 303 self.add_cash(level.starting_cash) |
304 self.add_wood(level.starting_wood) | |
304 | 305 |
305 self.fix_buildings() | 306 self.fix_buildings() |
306 | 307 |
307 cdata = {} | 308 cdata = {} |
308 for tn in equipment.EQUIP_MAP: | 309 for tn in equipment.EQUIP_MAP: |
654 | 655 |
655 self.open_dialog(tbl, close_callback=close_callback) | 656 self.open_dialog(tbl, close_callback=close_callback) |
656 | 657 |
657 def buy_building(self, tile_pos, building_cls): | 658 def buy_building(self, tile_pos, building_cls): |
658 building = building_cls(tile_pos) | 659 building = building_cls(tile_pos) |
659 if self.cash < building.buy_price(): | 660 if self.wood < building.buy_price(): |
660 return | 661 return |
661 if any(building.covers((chicken.pos.x, chicken.pos.y)) for chicken in self.chickens): | 662 if any(building.covers((chicken.pos.x, chicken.pos.y)) for chicken in self.chickens): |
662 return | 663 return |
663 if building.place(self.tv): | 664 if building.place(self.tv): |
664 self.add_cash(-building.buy_price()) | 665 self.add_wood(-building.buy_price()) |
665 self.add_building(building) | 666 self.add_building(building) |
666 | 667 |
667 def buy_equipment(self, tile_pos, equipment_cls): | 668 def buy_equipment(self, tile_pos, equipment_cls): |
668 | 669 |
669 equipment = equipment_cls() | 670 equipment = equipment_cls() |
695 return | 696 return |
696 if list(building.occupants()): | 697 if list(building.occupants()): |
697 warning = gui.Button("Occupied buildings may not be sold.") | 698 warning = gui.Button("Occupied buildings may not be sold.") |
698 self.open_dialog(warning) | 699 self.open_dialog(warning) |
699 return | 700 return |
700 self.add_cash(building.sell_price()) | 701 self.add_wood(building.sell_price()) |
701 building.remove(self.tv) | 702 building.remove(self.tv) |
702 self.remove_building(building) | 703 self.remove_building(building) |
703 | 704 |
704 def repair_building(self, tile_pos): | 705 def repair_building(self, tile_pos): |
705 building = self.get_building(tile_pos) | 706 building = self.get_building(tile_pos) |
706 if not (building and building.broken()): | 707 if not (building and building.broken()): |
707 return | 708 return |
708 self.add_cash(-building.repair_price()) | 709 if self.wood < building.repair_price(): |
710 return | |
711 self.add_wood(-building.repair_price()) | |
709 building.repair(self.tv) | 712 building.repair(self.tv) |
710 | 713 |
711 def sell_equipment(self, tile_pos): | 714 def sell_equipment(self, tile_pos): |
712 x, y = 0, 0 | 715 x, y = 0, 0 |
713 def do_sell(chicken, update_button=None): | 716 def do_sell(chicken, update_button=None): |