Mercurial > rinkhals
changeset 307:bf1df0902883
three game modes: fortnight, quarter, fox extinction
author | Adrianna Pińska <adrianna.pinska@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 18:01:37 +0000 |
parents | c8267f62fbe8 |
children | 2688ce607d65 |
files | gamelib/gameboard.py gamelib/mainmenu.py |
diffstat | 2 files changed, 32 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gameboard.py Sat Sep 05 17:36:53 2009 +0000 +++ b/gamelib/gameboard.py Sat Sep 05 18:01:37 2009 +0000 @@ -1030,9 +1030,15 @@ building.place(self.tv) self.add_building(building) + def trees_left(self): + width, height = self.tv.size + return len([(x,y) for x in range(width) for y in range(height) if self.tv.get((x,y)) == self.WOODLAND]) + def is_game_over(self): """Return true if we're complete""" - if self.days > constants.TURN_LIMIT: + if self.trees_left() == 0: + return True + if constants.TURN_LIMIT > 0 and self.days > constants.TURN_LIMIT: return True if len(self.chickens) == 0: return True
--- a/gamelib/mainmenu.py Sat Sep 05 17:36:53 2009 +0000 +++ b/gamelib/mainmenu.py Sat Sep 05 18:01:37 2009 +0000 @@ -32,14 +32,29 @@ def quit_pressed(): pygame.event.post(engine.QUIT) - def start_pressed(): + def fortnight_pressed(): + constants.TURN_LIMIT = 14 + pygame.event.post(engine.START_DAY) + + def quarter_pressed(): + constants.TURN_LIMIT = 90 + pygame.event.post(engine.START_DAY) + + def unlimited_pressed(): + constants.TURN_LIMIT = 0 pygame.event.post(engine.START_DAY) def help_pressed(): pygame.event.post(engine.GO_HELP_SCREEN) - start_button = gui.Button("Start") - start_button.connect(gui.CLICK, start_pressed) + fortnight_button = gui.Button("Fortnight") + fortnight_button.connect(gui.CLICK, fortnight_pressed) + + quarter_button = gui.Button("Quarter") + quarter_button.connect(gui.CLICK, quarter_pressed) + + unlim_button = gui.Button("Unlimited") + unlim_button.connect(gui.CLICK, unlimited_pressed) quit_button = gui.Button("Quit") quit_button.connect(gui.CLICK, quit_pressed) @@ -59,7 +74,13 @@ } self.tr() - self.td(start_button, **td_kwargs) + self.td(fortnight_button, **td_kwargs) + + self.tr() + self.td(quarter_button, **td_kwargs) + + self.tr() + self.td(unlim_button, **td_kwargs) self.tr() self.td(help_button, **td_kwargs)