changeset 428:a356e57529ea

buildings cost wood
author Adrianna Pińska <adrianna.pinska@gmail.com>
date Sat, 21 Nov 2009 16:21:38 +0000
parents e89a1afe4e84
children 42777630956a
files gamelib/animal.py gamelib/buildings.py gamelib/constants.py gamelib/gameboard.py gamelib/level.py
diffstat 5 files changed, 21 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/animal.py	Sat Nov 21 16:17:48 2009 +0000
+++ b/gamelib/animal.py	Sat Nov 21 16:21:38 2009 +0000
@@ -203,7 +203,7 @@
         surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]]
         tree_options = [pos for pos in surrounds if gameboard.in_bounds(pos) and gameboard.tv.get(pos.to_tile_tuple()) == gameboard.WOODLAND]
         if tree_options:
-            num_trees_to_cut = random.randint(0, len(tree_options)-1)
+            num_trees_to_cut = random.randint(1, len(tree_options))
             trees_to_cut = random.sample(tree_options, num_trees_to_cut)
             for tree_pos in trees_to_cut:
                 gameboard.add_wood(5)
--- a/gamelib/buildings.py	Sat Nov 21 16:17:48 2009 +0000
+++ b/gamelib/buildings.py	Sat Nov 21 16:21:38 2009 +0000
@@ -327,8 +327,8 @@
     """A HenHouse."""
 
     TILE_NO = tiles.REVERSE_TILE_MAP['henhouse']
-    BUY_PRICE = 100
-    SELL_PRICE = 90
+    BUY_PRICE = 20
+    SELL_PRICE = 18
     SIZE = (3, 2)
     IMAGE = 'sprites/henhouse.png'
     SELECTED_IMAGE = 'sprites/select_henhouse.png'
@@ -341,8 +341,8 @@
     """A double story hen house."""
 
     TILE_NO = tiles.REVERSE_TILE_MAP['hendominium']
-    BUY_PRICE = 300
-    SELL_PRICE = 150
+    BUY_PRICE = 60
+    SELL_PRICE = 30
     SIZE = (2, 3)
     IMAGE = 'sprites/hendominium.png'
     SELECTED_IMAGE = 'sprites/select_hendominium.png'
@@ -353,8 +353,8 @@
     """A GuardTower."""
 
     TILE_NO = tiles.REVERSE_TILE_MAP['guardtower']
-    BUY_PRICE = 200
-    SELL_PRICE = 150
+    BUY_PRICE = 40
+    SELL_PRICE = 30
     SIZE = (2, 2)
     IMAGE = 'sprites/watchtower.png'
     SELECTED_IMAGE = 'sprites/select_watchtower.png'
@@ -373,10 +373,10 @@
     TILE_NO = tiles.REVERSE_TILE_MAP['fence']
     TILE_NO_BROKEN = tiles.REVERSE_TILE_MAP['broken fence']
     BREAKABLE = True
-    BUY_PRICE = 50
-    SELL_PRICE = 25
-    REPAIR_PRICE = 25
-    SELL_PRICE_BROKEN = 5
+    BUY_PRICE = 10
+    SELL_PRICE = 5
+    REPAIR_PRICE = 5
+    SELL_PRICE_BROKEN = 1
     SIZE = (1, 1)
     IMAGE = 'tiles/fence.png'
     SELECTED_IMAGE = 'tiles/fence.png'
--- a/gamelib/constants.py	Sat Nov 21 16:17:48 2009 +0000
+++ b/gamelib/constants.py	Sat Nov 21 16:21:38 2009 +0000
@@ -28,6 +28,7 @@
 # Default values that can be overridden by the levels
 
 DEFAULT_STARTING_CASH = 1000
+DEFAULT_STARTING_WOOD = 0
 DEFAULT_SELL_PRICE_CHICKEN = 10
 DEFAULT_SELL_PRICE_EGG = 5
 DEFAULT_SELL_PRICE_DEAD_FOX = 15
--- a/gamelib/gameboard.py	Sat Nov 21 16:17:48 2009 +0000
+++ b/gamelib/gameboard.py	Sat Nov 21 16:21:38 2009 +0000
@@ -301,6 +301,7 @@
         if self.disp:
             self.create_display()
             self.add_cash(level.starting_cash)
+            self.add_wood(level.starting_wood)
 
         self.fix_buildings()
 
@@ -656,12 +657,12 @@
 
     def buy_building(self, tile_pos, building_cls):
         building = building_cls(tile_pos)
-        if self.cash < building.buy_price():
+        if self.wood < building.buy_price():
             return
         if any(building.covers((chicken.pos.x, chicken.pos.y)) for chicken in self.chickens):
             return
         if building.place(self.tv):
-            self.add_cash(-building.buy_price())
+            self.add_wood(-building.buy_price())
             self.add_building(building)
 
     def buy_equipment(self, tile_pos, equipment_cls):
@@ -697,7 +698,7 @@
             warning = gui.Button("Occupied buildings may not be sold.")
             self.open_dialog(warning)
             return
-        self.add_cash(building.sell_price())
+        self.add_wood(building.sell_price())
         building.remove(self.tv)
         self.remove_building(building)
 
@@ -705,7 +706,9 @@
         building = self.get_building(tile_pos)
         if not (building and building.broken()):
             return
-        self.add_cash(-building.repair_price())
+        if self.wood < building.repair_price():
+            return
+        self.add_wood(-building.repair_price())
         building.repair(self.tv)
 
     def sell_equipment(self, tile_pos):
--- a/gamelib/level.py	Sat Nov 21 16:17:48 2009 +0000
+++ b/gamelib/level.py	Sat Nov 21 16:21:38 2009 +0000
@@ -33,6 +33,7 @@
                 'max foxes' : constants.DEFAULT_MAX_FOXES,
                 'min foxes' : 0,
                 'starting cash' : constants.DEFAULT_STARTING_CASH,
+                'starting wood' : constants.DEFAULT_STARTING_WOOD,
                 }
         # Add default fox weightings
         for animal, prob in DEFAULT_FOX_WEIGHTINGS:
@@ -54,6 +55,7 @@
         self.sell_price_dead_fox = config.getint('Game values',
                 'sell price dead fox')
         self.starting_cash = config.getint('Game values', 'starting cash')
+        self.starting_wood = config.getint('Game values', 'starting wood')
         self.fox_weightings = []
         for animal, _prob in DEFAULT_FOX_WEIGHTINGS:
             self.fox_weightings.append((animal, config.getint('Fox probablities',