Mercurial > rinkhals
comparison gamelib/gameboard.py @ 131:4527e09dc620
Add lumberjacks.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 21:52:52 +0000 |
parents | c5f07479592e |
children | 149822fbebeb |
comparison
equal
deleted
inserted
replaced
130:96c5ef7613b5 | 131:4527e09dc620 |
---|---|
49 | 49 |
50 self.add_tool_button("Move Animals", constants.TOOL_PLACE_ANIMALS) | 50 self.add_tool_button("Move Animals", constants.TOOL_PLACE_ANIMALS) |
51 self.add_tool_button("Sell chicken", constants.TOOL_SELL_CHICKEN) | 51 self.add_tool_button("Sell chicken", constants.TOOL_SELL_CHICKEN) |
52 self.add_tool_button("Sell egg", constants.TOOL_SELL_EGG) | 52 self.add_tool_button("Sell egg", constants.TOOL_SELL_EGG) |
53 self.add_tool_button("Sell building", constants.TOOL_SELL_BUILDING) | 53 self.add_tool_button("Sell building", constants.TOOL_SELL_BUILDING) |
54 self.add_tool_button("Lumberjack", constants.TOOL_LOGGING) | |
54 self.add_tool_button("Buy fence", constants.TOOL_BUY_FENCE) | 55 self.add_tool_button("Buy fence", constants.TOOL_BUY_FENCE) |
55 for building_cls in buildings.BUILDINGS: | 56 for building_cls in buildings.BUILDINGS: |
56 self.add_tool_button("Buy %s" % (building_cls.NAME,), building_cls) | 57 self.add_tool_button("Buy %s" % (building_cls.NAME,), building_cls) |
57 for equipment_cls in equipment.EQUIPMENT: | 58 for equipment_cls in equipment.EQUIPMENT: |
58 self.add_tool_button("Buy %s" % (equipment_cls.NAME,), equipment_cls) | 59 self.add_tool_button("Buy %s" % (equipment_cls.NAME,), equipment_cls) |
191 self.place_animal(self.tv.screen_to_tile(e.pos)) | 192 self.place_animal(self.tv.screen_to_tile(e.pos)) |
192 elif self.selected_tool == constants.TOOL_BUY_FENCE: | 193 elif self.selected_tool == constants.TOOL_BUY_FENCE: |
193 self.buy_fence(self.tv.screen_to_tile(e.pos)) | 194 self.buy_fence(self.tv.screen_to_tile(e.pos)) |
194 elif self.selected_tool == constants.TOOL_SELL_BUILDING: | 195 elif self.selected_tool == constants.TOOL_SELL_BUILDING: |
195 self.sell_building(self.tv.screen_to_tile(e.pos)) | 196 self.sell_building(self.tv.screen_to_tile(e.pos)) |
197 elif self.selected_tool == constants.TOOL_LOGGING: | |
198 self.logging_forest(self.tv.screen_to_tile(e.pos)) | |
196 elif buildings.is_building(self.selected_tool): | 199 elif buildings.is_building(self.selected_tool): |
197 self.buy_building(self.tv.screen_to_tile(e.pos), self.selected_tool) | 200 self.buy_building(self.tv.screen_to_tile(e.pos), self.selected_tool) |
198 elif equipment.is_equipment(self.selected_tool): | 201 elif equipment.is_equipment(self.selected_tool): |
199 self.buy_equipment(self.tv.screen_to_tile(e.pos), self.selected_tool) | 202 self.buy_equipment(self.tv.screen_to_tile(e.pos), self.selected_tool) |
200 | 203 |
340 | 343 |
341 def sell_fence(self, tile_pos): | 344 def sell_fence(self, tile_pos): |
342 if self.tv.get(tile_pos) != self.FENCE: | 345 if self.tv.get(tile_pos) != self.FENCE: |
343 return | 346 return |
344 self.add_cash(constants.SELL_PRICE_FENCE) | 347 self.add_cash(constants.SELL_PRICE_FENCE) |
348 self.tv.set(tile_pos, self.GRASSLAND) | |
349 | |
350 def logging_forest(self, tile_pos): | |
351 if self.tv.get(tile_pos) != self.WOODLAND: | |
352 return | |
353 self.add_cash(-constants.LOGGING_PRICE) | |
345 self.tv.set(tile_pos, self.GRASSLAND) | 354 self.tv.set(tile_pos, self.GRASSLAND) |
346 | 355 |
347 def buy_building(self, tile_pos, building_cls): | 356 def buy_building(self, tile_pos, building_cls): |
348 building = building_cls(tile_pos) | 357 building = building_cls(tile_pos) |
349 if self.cash < building.buy_price(): | 358 if self.cash < building.buy_price(): |