Mercurial > rinkhals
comparison gamelib/gameboard.py @ 552:11c4cebfe4c5
Preparatory work for woodland biodiversity.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 28 Nov 2009 17:37:13 +0000 |
parents | 27c09c58d89d |
children | 7963fc09fac2 |
comparison
equal
deleted
inserted
replaced
551:dc8ff47371f2 | 552:11c4cebfe4c5 |
---|---|
73 | 73 |
74 class GameBoard(serializer.Simplifiable): | 74 class GameBoard(serializer.Simplifiable): |
75 | 75 |
76 GRASSLAND = tiles.REVERSE_TILE_MAP['grassland'] | 76 GRASSLAND = tiles.REVERSE_TILE_MAP['grassland'] |
77 FENCE = tiles.REVERSE_TILE_MAP['fence'] | 77 FENCE = tiles.REVERSE_TILE_MAP['fence'] |
78 WOODLAND = tiles.REVERSE_TILE_MAP['woodland'] | |
79 BROKEN_FENCE = tiles.REVERSE_TILE_MAP['broken fence'] | 78 BROKEN_FENCE = tiles.REVERSE_TILE_MAP['broken fence'] |
80 | 79 |
81 SIMPLIFY = [ | 80 SIMPLIFY = [ |
82 'level', | 81 'level', |
83 'tv', | 82 'tv', |
885 selection.remove(chick) | 884 selection.remove(chick) |
886 | 885 |
887 def advance_day(self): | 886 def advance_day(self): |
888 self.days += 1 | 887 self.days += 1 |
889 | 888 |
889 def is_woodland_tile(self, pos): | |
890 return tiles.TILE_MAP[self.tv.get(pos.to_tile_tuple())] == 'woodland' | |
891 | |
890 def clear_foxes(self): | 892 def clear_foxes(self): |
891 for fox in self.foxes.copy(): | 893 for fox in self.foxes.copy(): |
892 # Any foxes that didn't make it to the woods are automatically | 894 # Any foxes that didn't make it to the woods are automatically |
893 # killed | 895 # killed |
894 if self.in_bounds(fox.pos) and \ | 896 if self.in_bounds(fox.pos) and not self.is_woodland_tile(fox.pos): |
895 self.tv.get(fox.pos.to_tile_tuple()) != self.WOODLAND: | |
896 self.kill_fox(fox) | 897 self.kill_fox(fox) |
897 else: | 898 else: |
898 self.remove_fox(fox) | 899 self.remove_fox(fox) |
899 self.foxes = set() # Remove all the foxes | 900 self.foxes = set() # Remove all the foxes |
900 | 901 |
1112 building.place(self.tv) | 1113 building.place(self.tv) |
1113 self.add_building(building) | 1114 self.add_building(building) |
1114 | 1115 |
1115 def trees_left(self): | 1116 def trees_left(self): |
1116 width, height = self.tv.size | 1117 width, height = self.tv.size |
1117 return len([(x,y) for x in range(width) for y in range(height) if self.tv.get((x,y)) == self.WOODLAND]) | 1118 return len([(x,y) for x in range(width) for y in range(height) if self.is_woodland_tile(misc.Position(x,y))]) |
1118 | 1119 |
1119 def calculate_wood_groat_exchange_rate(self): | 1120 def calculate_wood_groat_exchange_rate(self): |
1120 # per five planks | 1121 # per five planks |
1121 width, height = self.tv.size | 1122 width, height = self.tv.size |
1122 treesleft = max(1, self.trees_left()) | 1123 treesleft = max(1, self.trees_left()) |