comparison gamelib/animal.py @ 552:11c4cebfe4c5

Preparatory work for woodland biodiversity.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 28 Nov 2009 17:37:13 +0000
parents 7addf41b6abb
children 50d6c68ce267
comparison
equal deleted inserted replaced
551:dc8ff47371f2 552:11c4cebfe4c5
215 215
216 def chop(self): 216 def chop(self):
217 if self.has_axe(): 217 if self.has_axe():
218 pos_x, pos_y = self.pos.to_tile_tuple() 218 pos_x, pos_y = self.pos.to_tile_tuple()
219 surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]] 219 surrounds = [Position(pos_x + dx, pos_y + dy) for dx in [-1, 0, 1] for dy in [-1, 0, 1]]
220 tree_options = [pos for pos in surrounds if self.gameboard.in_bounds(pos) and self.gameboard.tv.get(pos.to_tile_tuple()) == self.gameboard.WOODLAND] 220 tree_options = [pos for pos in surrounds if self.gameboard.in_bounds(pos) and self.gameboard.is_woodland_tile(pos)]
221 if tree_options: 221 if tree_options:
222 num_trees_to_cut = random.randint(1, len(tree_options)) 222 num_trees_to_cut = random.randint(1, len(tree_options))
223 trees_to_cut = random.sample(tree_options, num_trees_to_cut) 223 trees_to_cut = random.sample(tree_options, num_trees_to_cut)
224 for tree_pos in trees_to_cut: 224 for tree_pos in trees_to_cut:
225 self.gameboard.add_wood(5) 225 self.gameboard.add_wood(5)
830 # This allows chickens to fire across GuardTowers and Fences. 830 # This allows chickens to fire across GuardTowers and Fences.
831 if building and building.BLOCKS_VISION and not (watcher in building.occupants()): 831 if building and building.BLOCKS_VISION and not (watcher in building.occupants()):
832 return False 832 return False
833 distance = watcher.pos.dist(watchee.pos) - 1 833 distance = watcher.pos.dist(watchee.pos) - 1
834 # Intervening forests get in the way a bit. 834 # Intervening forests get in the way a bit.
835 woods = len([pos for pos in positions if gameboard.tv.get(pos.to_tile_tuple()) == gameboard.WOODLAND]) 835 woods = len([pos for pos in positions if gameboard.is_woodland_tile(pos)])
836 roll = random.randint(1, 100) 836 roll = random.randint(1, 100)
837 return roll > watchee.STEALTH - vision_bonus + range_penalty*distance + constants.WOODLAND_CONCEALMENT*woods 837 return roll > watchee.STEALTH - vision_bonus + range_penalty*distance + constants.WOODLAND_CONCEALMENT*woods
838 838
839 # These don't have to add up to 100, but it's easier to think 839 # These don't have to add up to 100, but it's easier to think
840 # about them if they do. 840 # about them if they do.