Mercurial > rinkhals
comparison gamelib/gameboard.py @ 470:fbbd39cfc975
Alter day counter logic a bit to cater for the case when it stops being the last day.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Tue, 24 Nov 2009 22:21:06 +0000 |
parents | d5e4959cfe7a |
children | 67574723427e |
comparison
equal
deleted
inserted
replaced
469:e0b11d684ee8 | 470:fbbd39cfc975 |
---|---|
152 self.redraw_counters() | 152 self.redraw_counters() |
153 td.repaint() | 153 td.repaint() |
154 | 154 |
155 def redraw_counters(self): | 155 def redraw_counters(self): |
156 self.toolbar.update_egg_counter(self.eggs) | 156 self.toolbar.update_egg_counter(self.eggs) |
157 if self.level.is_last_day(self.days): | |
158 self.toolbar.day_counter.style.color = (255, 0, 0) | |
159 else: | |
160 # can come back from last day when restoring a saved game | |
161 self.toolbar.day_counter.style.color = (255, 255, 255) | |
157 self.toolbar.update_day_counter("%s/%s" % (self.days, | 162 self.toolbar.update_day_counter("%s/%s" % (self.days, |
158 self.level.get_max_turns())) | 163 self.level.get_max_turns())) |
159 self.toolbar.update_chicken_counter(len(self.chickens)) | 164 self.toolbar.update_chicken_counter(len(self.chickens)) |
160 self.toolbar.update_cash_counter(self.cash) | 165 self.toolbar.update_cash_counter(self.cash) |
161 self.toolbar.update_wood_counter(self.wood) | 166 self.toolbar.update_wood_counter(self.wood) |
223 self._pos_cache.clear() | 228 self._pos_cache.clear() |
224 self.advance_day() | 229 self.advance_day() |
225 self.clear_foxes() | 230 self.clear_foxes() |
226 for chicken in self.chickens.copy(): | 231 for chicken in self.chickens.copy(): |
227 chicken.start_day(self) | 232 chicken.start_day(self) |
228 self.toolbar.update_egg_counter(self.eggs) | 233 self.redraw_counters() |
229 | 234 |
230 def in_bounds(self, pos): | 235 def in_bounds(self, pos): |
231 """Check if a position is within the game boundaries""" | 236 """Check if a position is within the game boundaries""" |
232 if pos.x < 0 or pos.y < 0: | 237 if pos.x < 0 or pos.y < 0: |
233 return False | 238 return False |
611 return True | 616 return True |
612 return False | 617 return False |
613 | 618 |
614 def advance_day(self): | 619 def advance_day(self): |
615 self.days += 1 | 620 self.days += 1 |
616 if self.level.is_last_day(self.days): | |
617 self.toolbar.day_counter.style.color = (255, 0, 0) | |
618 self.toolbar.update_day_counter("%s/%s" % (self.days, | |
619 self.level.get_max_turns())) | |
620 | 621 |
621 def clear_foxes(self): | 622 def clear_foxes(self): |
622 for fox in self.foxes.copy(): | 623 for fox in self.foxes.copy(): |
623 # Any foxes that didn't make it to the woods are automatically | 624 # Any foxes that didn't make it to the woods are automatically |
624 # killed | 625 # killed |