Mercurial > rinkhals
comparison gamelib/gameboard.py @ 392:bb75979b58e6
Move game_over logic from gameboard to level, for later reworking
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sun, 01 Nov 2009 21:08:43 +0000 |
parents | 463802281182 |
children | 2d0ff46118e2 |
comparison
equal
deleted
inserted
replaced
391:fd8da9241381 | 392:bb75979b58e6 |
---|---|
765 return True | 765 return True |
766 return False | 766 return False |
767 | 767 |
768 def advance_day(self): | 768 def advance_day(self): |
769 self.days += 1 | 769 self.days += 1 |
770 if self.days == self.level.turn_limit: | 770 if self.level.is_last_day(self.days): |
771 self.toolbar.day_counter.style.color = (255, 0, 0) | 771 self.toolbar.day_counter.style.color = (255, 0, 0) |
772 self.toolbar.update_day_counter("%s/%s" % (self.days, | 772 self.toolbar.update_day_counter("%s/%s" % (self.days, |
773 self.level.turn_limit if self.level.turn_limit > 0 else "-")) | 773 self.level.get_max_turns())) |
774 | 774 |
775 def clear_foxes(self): | 775 def clear_foxes(self): |
776 for fox in self.foxes.copy(): | 776 for fox in self.foxes.copy(): |
777 # Any foxes that didn't make it to the woods are automatically | 777 # Any foxes that didn't make it to the woods are automatically |
778 # killed | 778 # killed |
961 | 961 |
962 def trees_left(self): | 962 def trees_left(self): |
963 width, height = self.tv.size | 963 width, height = self.tv.size |
964 return len([(x,y) for x in range(width) for y in range(height) if self.tv.get((x,y)) == self.WOODLAND]) | 964 return len([(x,y) for x in range(width) for y in range(height) if self.tv.get((x,y)) == self.WOODLAND]) |
965 | 965 |
966 def is_game_over(self): | |
967 """Return true if we're complete""" | |
968 if self.trees_left() == 0: | |
969 return True | |
970 if self.level.turn_limit > 0 and self.days >= self.level.turn_limit: | |
971 return True | |
972 if len(self.chickens) == 0: | |
973 return True | |
974 | |
975 | 966 |
976 class TextDialog(gui.Dialog): | 967 class TextDialog(gui.Dialog): |
977 def __init__(self, title, text, **params): | 968 def __init__(self, title, text, **params): |
978 title_label = gui.Label(title) | 969 title_label = gui.Label(title) |
979 | 970 |