diff 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
line wrap: on
line diff
--- a/gamelib/gameboard.py	Wed Sep 02 21:40:47 2009 +0000
+++ b/gamelib/gameboard.py	Wed Sep 02 21:52:52 2009 +0000
@@ -51,6 +51,7 @@
         self.add_tool_button("Sell chicken", constants.TOOL_SELL_CHICKEN)
         self.add_tool_button("Sell egg", constants.TOOL_SELL_EGG)
         self.add_tool_button("Sell building", constants.TOOL_SELL_BUILDING)
+        self.add_tool_button("Lumberjack", constants.TOOL_LOGGING)
         self.add_tool_button("Buy fence", constants.TOOL_BUY_FENCE)
         for building_cls in buildings.BUILDINGS:
             self.add_tool_button("Buy %s" % (building_cls.NAME,), building_cls)
@@ -193,6 +194,8 @@
             self.buy_fence(self.tv.screen_to_tile(e.pos))
         elif self.selected_tool == constants.TOOL_SELL_BUILDING:
             self.sell_building(self.tv.screen_to_tile(e.pos))
+        elif self.selected_tool == constants.TOOL_LOGGING:
+            self.logging_forest(self.tv.screen_to_tile(e.pos))
         elif buildings.is_building(self.selected_tool):
             self.buy_building(self.tv.screen_to_tile(e.pos), self.selected_tool)
         elif equipment.is_equipment(self.selected_tool):
@@ -344,6 +347,12 @@
         self.add_cash(constants.SELL_PRICE_FENCE)
         self.tv.set(tile_pos, self.GRASSLAND)
 
+    def logging_forest(self, tile_pos):
+        if self.tv.get(tile_pos) != self.WOODLAND:
+            return
+        self.add_cash(-constants.LOGGING_PRICE)
+        self.tv.set(tile_pos, self.GRASSLAND)
+
     def buy_building(self, tile_pos, building_cls):
         building = building_cls(tile_pos)
         if self.cash < building.buy_price():