# HG changeset patch # User Neil Muller # Date 1251989953 0 # Node ID a9b800b4175e93a758262bc3822aca24ed3c95e8 # Parent f174ef6b26bae00554b58e9e12d4f6c85e6eec40 Add define for henhouses & egg laying. diff -r f174ef6b26ba -r a9b800b4175e gamelib/buildings.py --- a/gamelib/buildings.py Thu Sep 03 10:56:38 2009 +0000 +++ b/gamelib/buildings.py Thu Sep 03 14:59:13 2009 +0000 @@ -200,6 +200,9 @@ """Return true if obj is a build class.""" return getattr(obj, "IS_BUILDING", False) and hasattr(obj, "NAME") +# Building hens can lay eggs in +HENHOUSES = [HenHouse.NAME, DoubleStoryHenHouse.NAME] + BUILDINGS = [] for name in dir(): obj = eval(name) diff -r f174ef6b26ba -r a9b800b4175e gamelib/gameboard.py --- a/gamelib/gameboard.py Thu Sep 03 10:56:38 2009 +0000 +++ b/gamelib/gameboard.py Thu Sep 03 14:59:13 2009 +0000 @@ -447,7 +447,7 @@ def lay_eggs(self): self.eggs = 0 for building in self.buildings: - if building.NAME in [buildings.HenHouse.NAME]: + if building.NAME in buildings.HENHOUSES: for chicken in building.occupants(): chicken.lay() if chicken.egg: @@ -456,7 +456,7 @@ def hatch_eggs(self): for building in self.buildings: - if building.NAME in [buildings.HenHouse.NAME]: + if building.NAME in buildings.HENHOUSES: for chicken in building.occupants(): new_chick = chicken.hatch() if new_chick: @@ -488,9 +488,8 @@ if chick.abode: chick.abode.clear_occupant() self.toolbar.update_chicken_counter(len(self.chickens)) - if chick in self.tv.sprites: - if chick.outside(): - self.tv.sprites.remove(chick) + if chick in self.tv.sprites and chick.outside(): + self.tv.sprites.remove(chick) def remove_building(self, building): if building in self.buildings: