comparison gamelib/gameboard.py @ 223:527a5d4e3fa3

Disable tools at night.
author Simon Cross <hodgestar@gmail.com>
date Fri, 04 Sep 2009 22:39:19 +0000
parents d46ae64240a1
children c279ad59b8e2
comparison
equal deleted inserted replaced
222:322e6d3a46e4 223:527a5d4e3fa3
221 self.cash = 0 221 self.cash = 0
222 self.eggs = 0 222 self.eggs = 0
223 self.days = 0 223 self.days = 0
224 self.killed_foxes = 0 224 self.killed_foxes = 0
225 self.add_cash(constants.STARTING_CASH) 225 self.add_cash(constants.STARTING_CASH)
226 self.day, self.night = True, False
226 227
227 self.fix_buildings() 228 self.fix_buildings()
228 229
229 self.add_some_chickens() 230 self.add_some_chickens()
230 231
246 247
247 def loop(self): 248 def loop(self):
248 self.tv.loop() 249 self.tv.loop()
249 250
250 def set_selected_tool(self, tool, cursor): 251 def set_selected_tool(self, tool, cursor):
252 if not self.day:
253 return
251 self.selected_tool = tool 254 self.selected_tool = tool
252 if self.animal_to_place: 255 if self.animal_to_place:
253 # Clear any highlights 256 # Clear any highlights
254 self.animal_to_place.unequip_by_name("spotlight") 257 self.animal_to_place.unequip_by_name("spotlight")
255 self.select_animal_to_place(None) 258 self.select_animal_to_place(None)
274 277
275 def update_sprite_cursor(self, e): 278 def update_sprite_cursor(self, e):
276 tile_pos = self.tv.screen_to_tile(e.pos) 279 tile_pos = self.tv.screen_to_tile(e.pos)
277 self.sprite_cursor.set_pos(tile_pos) 280 self.sprite_cursor.set_pos(tile_pos)
278 281
282 def start_night(self):
283 self.day, self.night = False, True
284 self.tv.sun(False)
285 self.reset_states()
286
287 def start_day(self):
288 self.day, self.night = True, False
289 self.tv.sun(True)
290 self.reset_states()
291
279 def in_bounds(self, pos): 292 def in_bounds(self, pos):
280 """Check if a position is within the game boundaries""" 293 """Check if a position is within the game boundaries"""
281 if pos.x < 0 or pos.y < 0: 294 if pos.x < 0 or pos.y < 0:
282 return False 295 return False
283 width, height = self.tv.size 296 width, height = self.tv.size
284 if pos.x >= width or pos.y >= height: 297 if pos.x >= width or pos.y >= height:
285 return False 298 return False
286 return True 299 return True
287 300
288 def use_tool(self, e): 301 def use_tool(self, e):
302 if not self.day:
303 return
289 if e.button == 3: # Right button 304 if e.button == 3: # Right button
290 self.selected_tool = None 305 self.selected_tool = None
291 self.set_cursor() 306 self.set_cursor()
292 elif e.button != 1: # Left button 307 elif e.button != 1: # Left button
293 return 308 return