Mercurial > rinkhals
comparison gamelib/animal.py @ 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 |
comparison
equal
deleted
inserted
replaced
427:e89a1afe4e84 | 428:a356e57529ea |
---|---|
201 def chop(self, gameboard): | 201 def chop(self, gameboard): |
202 pos_x, pos_y = self.pos.to_tile_tuple() | 202 pos_x, pos_y = self.pos.to_tile_tuple() |
203 surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]] | 203 surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]] |
204 tree_options = [pos for pos in surrounds if gameboard.in_bounds(pos) and gameboard.tv.get(pos.to_tile_tuple()) == gameboard.WOODLAND] | 204 tree_options = [pos for pos in surrounds if gameboard.in_bounds(pos) and gameboard.tv.get(pos.to_tile_tuple()) == gameboard.WOODLAND] |
205 if tree_options: | 205 if tree_options: |
206 num_trees_to_cut = random.randint(0, len(tree_options)-1) | 206 num_trees_to_cut = random.randint(1, len(tree_options)) |
207 trees_to_cut = random.sample(tree_options, num_trees_to_cut) | 207 trees_to_cut = random.sample(tree_options, num_trees_to_cut) |
208 for tree_pos in trees_to_cut: | 208 for tree_pos in trees_to_cut: |
209 gameboard.add_wood(5) | 209 gameboard.add_wood(5) |
210 gameboard.tv.set(tree_pos.to_tile_tuple(), gameboard.GRASSLAND) | 210 gameboard.tv.set(tree_pos.to_tile_tuple(), gameboard.GRASSLAND) |
211 | 211 |