Mercurial > rinkhals
comparison gamelib/gameboard.py @ 139:1d73de63bd71
Add basic game over screen
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 22:48:39 +0000 |
parents | 149822fbebeb |
children | a9b800b4175e |
comparison
equal
deleted
inserted
replaced
138:7c88a12cb0b6 | 139:1d73de63bd71 |
---|---|
37 gui.Table.__init__(self, **params) | 37 gui.Table.__init__(self, **params) |
38 self.gameboard = gameboard | 38 self.gameboard = gameboard |
39 self.cash_counter = mklabel() | 39 self.cash_counter = mklabel() |
40 self.chicken_counter = mklabel() | 40 self.chicken_counter = mklabel() |
41 self.egg_counter = mklabel() | 41 self.egg_counter = mklabel() |
42 self.day_counter = mklabel() | |
42 self.killed_foxes = mklabel() | 43 self.killed_foxes = mklabel() |
43 self.rifle_counter = mklabel() | 44 self.rifle_counter = mklabel() |
44 | 45 |
46 self.add_counter(mklabel("Day:"), self.day_counter) | |
45 self.add_counter(mklabel("Groats:"), self.cash_counter) | 47 self.add_counter(mklabel("Groats:"), self.cash_counter) |
46 self.add_counter(mklabel("Eggs:"), self.egg_counter) | 48 self.add_counter(mklabel("Eggs:"), self.egg_counter) |
47 self.add_counter(icons.CHKN_ICON, self.chicken_counter) | 49 self.add_counter(icons.CHKN_ICON, self.chicken_counter) |
48 self.add_counter(icons.KILLED_FOX, self.killed_foxes) | 50 self.add_counter(icons.KILLED_FOX, self.killed_foxes) |
49 | 51 |
66 | 68 |
67 update_cash_counter = mkcountupdate('cash_counter') | 69 update_cash_counter = mkcountupdate('cash_counter') |
68 update_fox_counter = mkcountupdate('killed_foxes') | 70 update_fox_counter = mkcountupdate('killed_foxes') |
69 update_chicken_counter = mkcountupdate('chicken_counter') | 71 update_chicken_counter = mkcountupdate('chicken_counter') |
70 update_egg_counter = mkcountupdate('egg_counter') | 72 update_egg_counter = mkcountupdate('egg_counter') |
73 update_day_counter = mkcountupdate('day_counter') | |
71 | 74 |
72 def add_spacer(self, height=30): | 75 def add_spacer(self, height=30): |
73 self.tr() | 76 self.tr() |
74 self.add(gui.Spacer(0, height)) | 77 self.add(gui.Spacer(0, height)) |
75 | 78 |
139 self.chickens = set() | 142 self.chickens = set() |
140 self.foxes = set() | 143 self.foxes = set() |
141 self.buildings = [] | 144 self.buildings = [] |
142 self.cash = 0 | 145 self.cash = 0 |
143 self.eggs = 0 | 146 self.eggs = 0 |
147 self.days = 0 | |
144 self.killed_foxes = 0 | 148 self.killed_foxes = 0 |
145 self.add_cash(constants.STARTING_CASH) | 149 self.add_cash(constants.STARTING_CASH) |
146 | 150 |
147 self.fix_buildings() | 151 self.fix_buildings() |
148 | 152 |
392 self.tvw.move_view(-self.TILE_DIMENSIONS[0], 0) | 396 self.tvw.move_view(-self.TILE_DIMENSIONS[0], 0) |
393 if e.key == K_RIGHT: | 397 if e.key == K_RIGHT: |
394 self.tvw.move_view(self.TILE_DIMENSIONS[0], 0) | 398 self.tvw.move_view(self.TILE_DIMENSIONS[0], 0) |
395 else: | 399 else: |
396 self.disp.event(e) | 400 self.disp.event(e) |
401 | |
402 def advance_day(self): | |
403 self.days += 1 | |
404 self.toolbar.update_day_counter(self.days) | |
397 | 405 |
398 def clear_foxes(self): | 406 def clear_foxes(self): |
399 for fox in self.foxes.copy(): | 407 for fox in self.foxes.copy(): |
400 # Any foxes that didn't make it to the woods are automatically | 408 # Any foxes that didn't make it to the woods are automatically |
401 # killed | 409 # killed |
598 building_cls = tile_to_building[tile_no] | 606 building_cls = tile_to_building[tile_no] |
599 building = building_cls(tile_pos) | 607 building = building_cls(tile_pos) |
600 building.remove(self.tv) | 608 building.remove(self.tv) |
601 building.place(self.tv) | 609 building.place(self.tv) |
602 self.add_building(building) | 610 self.add_building(building) |
611 | |
612 def is_game_over(self): | |
613 """Return true if we're complete""" | |
614 if self.days > constants.TURN_LIMIT: | |
615 return True | |
616 if len(self.chickens) == 0: | |
617 return True |