changeset 131:4527e09dc620

Add lumberjacks.
author Simon Cross <hodgestar@gmail.com>
date Wed, 02 Sep 2009 21:52:52 +0000
parents 96c5ef7613b5
children 03293bd45930
files gamelib/constants.py gamelib/gameboard.py
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/constants.py	Wed Sep 02 21:40:47 2009 +0000
+++ b/gamelib/constants.py	Wed Sep 02 21:52:52 2009 +0000
@@ -29,6 +29,7 @@
 STARTING_CASH = 1000
 SELL_PRICE_CHICKEN = 10
 SELL_PRICE_DEAD_FOX = 5
+LOGGING_PRICE = 50
 BUY_PRICE_FENCE = 50
 SELL_PRICE_FENCE = 25
 REPAIR_PRICE_FENCE = 25
@@ -38,3 +39,4 @@
 TOOL_SELL_BUILDING = 3
 TOOL_BUY_FENCE = 4
 TOOL_PLACE_ANIMALS = 5
+TOOL_LOGGING = 6
--- 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():