Mercurial > rinkhals
comparison gamelib/gameboard.py @ 166:4aa800354b7c
Rename get_chicken to get_outside_chicken.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Thu, 03 Sep 2009 22:38:18 +0000 |
parents | c7d496556475 |
children | 1014bfcddc4c |
comparison
equal
deleted
inserted
replaced
165:c7d496556475 | 166:4aa800354b7c |
---|---|
228 elif buildings.is_building(self.selected_tool): | 228 elif buildings.is_building(self.selected_tool): |
229 self.buy_building(self.tv.screen_to_tile(e.pos), self.selected_tool) | 229 self.buy_building(self.tv.screen_to_tile(e.pos), self.selected_tool) |
230 elif equipment.is_equipment(self.selected_tool): | 230 elif equipment.is_equipment(self.selected_tool): |
231 self.buy_equipment(self.tv.screen_to_tile(e.pos), self.selected_tool) | 231 self.buy_equipment(self.tv.screen_to_tile(e.pos), self.selected_tool) |
232 | 232 |
233 def get_chicken(self, tile_pos): | 233 def get_outside_chicken(self, tile_pos): |
234 for chick in self.chickens: | 234 for chick in self.chickens: |
235 if chick.covers(tile_pos) and chick.outside(): | 235 if chick.covers(tile_pos) and chick.outside(): |
236 return chick | 236 return chick |
237 return None | 237 return None |
238 | 238 |
241 if building.covers(tile_pos): | 241 if building.covers(tile_pos): |
242 return building | 242 return building |
243 return None | 243 return None |
244 | 244 |
245 def sell_chicken(self, tile_pos): | 245 def sell_chicken(self, tile_pos): |
246 chick = self.get_chicken(tile_pos) | 246 chick = self.get_outside_chicken(tile_pos) |
247 if chick is None: | 247 if chick is None: |
248 return | 248 return |
249 if len(self.chickens) == 1: | 249 if len(self.chickens) == 1: |
250 print "You can't sell your last chicken!" | 250 print "You can't sell your last chicken!" |
251 return | 251 return |
257 """Handle an TOOL_PLACE_ANIMALS click. | 257 """Handle an TOOL_PLACE_ANIMALS click. |
258 | 258 |
259 This will either select an animal or | 259 This will either select an animal or |
260 place a selected animal in a building. | 260 place a selected animal in a building. |
261 """ | 261 """ |
262 chicken = self.get_chicken(tile_pos) | 262 chicken = self.get_outside_chicken(tile_pos) |
263 if chicken: | 263 if chicken: |
264 if chicken is self.animal_to_place: | 264 if chicken is self.animal_to_place: |
265 self.animal_to_place = None | 265 self.animal_to_place = None |
266 pygame.mouse.set_cursor(*cursors.cursors['select']) | 266 pygame.mouse.set_cursor(*cursors.cursors['select']) |
267 else: | 267 else: |
393 if building.place(self.tv): | 393 if building.place(self.tv): |
394 self.add_cash(-building.buy_price()) | 394 self.add_cash(-building.buy_price()) |
395 self.add_building(building) | 395 self.add_building(building) |
396 | 396 |
397 def buy_equipment(self, tile_pos, equipment_cls): | 397 def buy_equipment(self, tile_pos, equipment_cls): |
398 chicken = self.get_chicken(tile_pos) | 398 chicken = self.get_outside_chicken(tile_pos) |
399 equipment = equipment_cls() | 399 equipment = equipment_cls() |
400 if chicken is None or self.cash < equipment.buy_price(): | 400 if chicken is None or self.cash < equipment.buy_price(): |
401 return | 401 return |
402 if equipment.place(chicken): | 402 if equipment.place(chicken): |
403 self.add_cash(-equipment.buy_price()) | 403 self.add_cash(-equipment.buy_price()) |
412 self.add_cash(building.sell_price()) | 412 self.add_cash(building.sell_price()) |
413 building.remove(self.tv) | 413 building.remove(self.tv) |
414 self.remove_building(building) | 414 self.remove_building(building) |
415 | 415 |
416 def sell_equipment(self, tile_pos): | 416 def sell_equipment(self, tile_pos): |
417 chicken = self.get_chicken(tile_pos) | 417 chicken = self.get_outside_chicken(tile_pos) |
418 if chicken is None or not chicken.equipment: | 418 if chicken is None or not chicken.equipment: |
419 return | 419 return |
420 if len(chicken.equipment) == 1: | 420 if len(chicken.equipment) == 1: |
421 item = chicken.equipment[0] | 421 item = chicken.equipment[0] |
422 self.add_cash(item.sell_price()) | 422 self.add_cash(item.sell_price()) |