changeset 216:962934b8c7dc

Implement UI part of egg selling
author Neil Muller <drnlmuller@gmail.com>
date Fri, 04 Sep 2009 22:04:04 +0000
parents 85a5299caf4a
children 76faa0eb38f0
files gamelib/animal.py gamelib/gameboard.py
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/animal.py	Fri Sep 04 22:01:20 2009 +0000
+++ b/gamelib/animal.py	Fri Sep 04 22:04:04 2009 +0000
@@ -143,13 +143,19 @@
         """See if the chicken lays an egg"""
         if not self.egg:
             self.egg = Egg(self.pos)
+            self.equip(equipment.NestEgg())
+
+    def remove_egg(self):
+        """Clean up the egg state"""
+        self.egg = None
+        self.unequip_by_name("nestegg")
 
     def hatch(self):
         """See if we have an egg to hatch"""
         if self.egg:
             chick = self.egg.hatch()
             if chick:
-                self.egg = None
+                self.remove_egg()
             return chick
         return None
 
--- a/gamelib/gameboard.py	Fri Sep 04 22:01:20 2009 +0000
+++ b/gamelib/gameboard.py	Fri Sep 04 22:04:04 2009 +0000
@@ -354,7 +354,7 @@
                 # We sell the egg
                 self.add_cash(constants.SELL_PRICE_EGG)
                 sound.play_sound("sell-chicken.ogg")
-                chicken.egg = None
+                chicken.remove_egg()
                 self.eggs -= 1
                 self.toolbar.update_egg_counter(self.eggs)
                 # Force update
@@ -480,6 +480,9 @@
                     if sell_callback(place.occupant):
                         # empty the nest (on button)
                         update_button(place.occupant, empty=True)
+                    else:
+                        # Update for equipment changes, etc.
+                        update_button(place.occupant)
             else:
                 # there is no occupant, attempt to fill the space
                 if self.animal_to_place is not None: