# HG changeset patch # User Simon Cross # Date 1252103959 0 # Node ID 527a5d4e3fa3430f8c73f104b92fe0eea7cbf382 # Parent 322e6d3a46e44d6baa93bc16551ec6231704a738 Disable tools at night. diff -r 322e6d3a46e4 -r 527a5d4e3fa3 gamelib/engine.py --- a/gamelib/engine.py Fri Sep 04 22:38:48 2009 +0000 +++ b/gamelib/engine.py Fri Sep 04 22:39:19 2009 +0000 @@ -105,7 +105,7 @@ def init(self): """Add some chickens to the farm""" sound.stop_background_music() - self.game.gameboard.tv.sun(True) + self.game.gameboard.start_day() sound.play_sound("daybreak.ogg") # disable timer @@ -147,8 +147,7 @@ def init(self): """Add some foxes to the farm""" sound.stop_background_music() - self.game.gameboard.tv.sun(False) - self.game.gameboard.reset_states() + self.game.gameboard.start_night() sound.play_sound("nightfall.ogg") # Add a timer to the event queue diff -r 322e6d3a46e4 -r 527a5d4e3fa3 gamelib/gameboard.py --- a/gamelib/gameboard.py Fri Sep 04 22:38:48 2009 +0000 +++ b/gamelib/gameboard.py Fri Sep 04 22:39:19 2009 +0000 @@ -223,6 +223,7 @@ self.days = 0 self.killed_foxes = 0 self.add_cash(constants.STARTING_CASH) + self.day, self.night = True, False self.fix_buildings() @@ -248,6 +249,8 @@ self.tv.loop() def set_selected_tool(self, tool, cursor): + if not self.day: + return self.selected_tool = tool if self.animal_to_place: # Clear any highlights @@ -276,6 +279,16 @@ tile_pos = self.tv.screen_to_tile(e.pos) self.sprite_cursor.set_pos(tile_pos) + def start_night(self): + self.day, self.night = False, True + self.tv.sun(False) + self.reset_states() + + def start_day(self): + self.day, self.night = True, False + self.tv.sun(True) + self.reset_states() + def in_bounds(self, pos): """Check if a position is within the game boundaries""" if pos.x < 0 or pos.y < 0: @@ -286,6 +299,8 @@ return True def use_tool(self, e): + if not self.day: + return if e.button == 3: # Right button self.selected_tool = None self.set_cursor()