diff gamelib/animal.py @ 414:9096c237928c

Dear most illustrious brother, I seek your cooperation with the refactoring of egg layerings and the reloading of guns. Please to provide bank details.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 21 Nov 2009 12:48:12 +0000
parents bdc4757e0497
children 8f012ef1f64f
line wrap: on
line diff
--- a/gamelib/animal.py	Sat Nov 21 12:07:01 2009 +0000
+++ b/gamelib/animal.py	Sat Nov 21 12:48:12 2009 +0000
@@ -155,6 +155,10 @@
         Animal.__init__(self, image_left, image_right, pos)
         self.eggs = []
 
+    def start_night(self, gameboard):
+        self.lay(gameboard)
+        self.reload_weapon()
+
     def _game_death(self, gameboard):
         gameboard.remove_chicken(self)
 
@@ -162,12 +166,14 @@
         """A free chicken will move away from other free chickens"""
         pass
 
-    def lay(self):
+    def lay(self, gameboard):
         """See if the chicken lays an egg"""
-        if not self.eggs:
-            for x in range(random.randint(1, 4)):
-                self.eggs.append(Egg(self.pos))
-            self.equip(equipment.NestEgg())
+        if self.abode and self.abode.building.HENHOUSE:
+            if not self.eggs:
+                for x in range(random.randint(1, 4)):
+                    self.eggs.append(Egg(self.pos))
+                self.equip(equipment.NestEgg())
+            gameboard.eggs += self.get_num_eggs()
 
     def remove_eggs(self):
         """Clean up the egg state"""