Mercurial > rinkhals
comparison gamelib/gameboard.py @ 144:a9b800b4175e
Add define for henhouses & egg laying.
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 03 Sep 2009 14:59:13 +0000 |
parents | 1d73de63bd71 |
children | 225be1220053 |
comparison
equal
deleted
inserted
replaced
143:f174ef6b26ba | 144:a9b800b4175e |
---|---|
445 self.tv.sprites.append(building) | 445 self.tv.sprites.append(building) |
446 | 446 |
447 def lay_eggs(self): | 447 def lay_eggs(self): |
448 self.eggs = 0 | 448 self.eggs = 0 |
449 for building in self.buildings: | 449 for building in self.buildings: |
450 if building.NAME in [buildings.HenHouse.NAME]: | 450 if building.NAME in buildings.HENHOUSES: |
451 for chicken in building.occupants(): | 451 for chicken in building.occupants(): |
452 chicken.lay() | 452 chicken.lay() |
453 if chicken.egg: | 453 if chicken.egg: |
454 self.eggs += 1 | 454 self.eggs += 1 |
455 self.toolbar.update_egg_counter(self.eggs) | 455 self.toolbar.update_egg_counter(self.eggs) |
456 | 456 |
457 def hatch_eggs(self): | 457 def hatch_eggs(self): |
458 for building in self.buildings: | 458 for building in self.buildings: |
459 if building.NAME in [buildings.HenHouse.NAME]: | 459 if building.NAME in buildings.HENHOUSES: |
460 for chicken in building.occupants(): | 460 for chicken in building.occupants(): |
461 new_chick = chicken.hatch() | 461 new_chick = chicken.hatch() |
462 if new_chick: | 462 if new_chick: |
463 self.eggs -= 1 | 463 self.eggs -= 1 |
464 try: | 464 try: |
486 self.eggs -= 1 | 486 self.eggs -= 1 |
487 self.toolbar.update_egg_counter(self.eggs) | 487 self.toolbar.update_egg_counter(self.eggs) |
488 if chick.abode: | 488 if chick.abode: |
489 chick.abode.clear_occupant() | 489 chick.abode.clear_occupant() |
490 self.toolbar.update_chicken_counter(len(self.chickens)) | 490 self.toolbar.update_chicken_counter(len(self.chickens)) |
491 if chick in self.tv.sprites: | 491 if chick in self.tv.sprites and chick.outside(): |
492 if chick.outside(): | 492 self.tv.sprites.remove(chick) |
493 self.tv.sprites.remove(chick) | |
494 | 493 |
495 def remove_building(self, building): | 494 def remove_building(self, building): |
496 if building in self.buildings: | 495 if building in self.buildings: |
497 self.buildings.remove(building) | 496 self.buildings.remove(building) |
498 self.tv.sprites.remove(building) | 497 self.tv.sprites.remove(building) |