Mercurial > rinkhals
comparison gamelib/gameboard.py @ 346:6baf8b5beb5c
Remove the "constant" constant
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 23:11:16 +0000 |
parents | 279974cc0698 |
children | e61f95503461 |
comparison
equal
deleted
inserted
replaced
345:279974cc0698 | 346:6baf8b5beb5c |
---|---|
315 (animal.NinjaFox, 5), | 315 (animal.NinjaFox, 5), |
316 (animal.DemoFox, 5), | 316 (animal.DemoFox, 5), |
317 (animal.Rinkhals, 1), | 317 (animal.Rinkhals, 1), |
318 ) | 318 ) |
319 | 319 |
320 def __init__(self, main_app): | 320 def __init__(self, main_app, max_turns): |
321 self.disp = main_app | 321 self.disp = main_app |
322 self.tv = tiles.FarmVid() | 322 self.tv = tiles.FarmVid() |
323 self.tv.png_folder_load_tiles('tiles') | 323 self.tv.png_folder_load_tiles('tiles') |
324 self.tv.tga_load_level(data.filepath('levels/farm.tga')) | 324 self.tv.tga_load_level(data.filepath('levels/farm.tga')) |
325 height, width = self.tv.size | 325 height, width = self.tv.size |
326 # Ensure we don't every try to create more foxes then is sane | 326 # Ensure we don't every try to create more foxes then is sane |
327 self.max_foxes = min(height+width-15, constants.ABS_MAX_NUM_FOXES) | 327 self.max_foxes = min(height+width-15, constants.ABS_MAX_NUM_FOXES) |
328 self.max_turns = max_turns | |
328 self.create_display() | 329 self.create_display() |
329 | 330 |
330 self.selected_tool = None | 331 self.selected_tool = None |
331 self.animal_to_place = None | 332 self.animal_to_place = None |
332 self.sprite_cursor = None | 333 self.sprite_cursor = None |
824 return True | 825 return True |
825 return False | 826 return False |
826 | 827 |
827 def advance_day(self): | 828 def advance_day(self): |
828 self.days += 1 | 829 self.days += 1 |
829 if self.days == constants.TURN_LIMIT: | 830 if self.days == self.max_turns: |
830 self.toolbar.day_counter.style.color = (255, 0, 0) | 831 self.toolbar.day_counter.style.color = (255, 0, 0) |
831 self.toolbar.update_day_counter("%s/%s" % (self.days, constants.TURN_LIMIT if constants.TURN_LIMIT > 0 else "-")) | 832 self.toolbar.update_day_counter("%s/%s" % (self.days, |
833 self.max_turns if self.max_turns > 0 else "-")) | |
832 | 834 |
833 def clear_foxes(self): | 835 def clear_foxes(self): |
834 for fox in self.foxes.copy(): | 836 for fox in self.foxes.copy(): |
835 # Any foxes that didn't make it to the woods are automatically | 837 # Any foxes that didn't make it to the woods are automatically |
836 # killed | 838 # killed |
1058 | 1060 |
1059 def is_game_over(self): | 1061 def is_game_over(self): |
1060 """Return true if we're complete""" | 1062 """Return true if we're complete""" |
1061 if self.trees_left() == 0: | 1063 if self.trees_left() == 0: |
1062 return True | 1064 return True |
1063 if constants.TURN_LIMIT > 0 and self.days >= constants.TURN_LIMIT: | 1065 if self.max_turns > 0 and self.days >= self.max_turns: |
1064 return True | 1066 return True |
1065 if len(self.chickens) == 0: | 1067 if len(self.chickens) == 0: |
1066 return True | 1068 return True |
1067 | 1069 |
1068 | 1070 |