diff gamelib/gameboard.py @ 561:7f037ee2a6c8

Show count of selected chickens in buildings
author Neil Muller <drnlmuller@gmail.com>
date Sat, 28 Nov 2009 18:40:04 +0000
parents 50d6c68ce267
children 32b6b66e114a
line wrap: on
line diff
--- a/gamelib/gameboard.py	Sat Nov 28 18:27:59 2009 +0000
+++ b/gamelib/gameboard.py	Sat Nov 28 18:40:04 2009 +0000
@@ -484,18 +484,25 @@
 
     def select_animal(self, animal):
         self.selected_chickens.append(animal)
+        if animal.abode:
+            animal.abode.building.update_occupant_count()
         animal.equip(equipment.Spotlight())
 
     def unselect_all(self):
         # Clear any highlights
-        for chick in self.selected_chickens:
+        old_sel = self.selected_chickens
+        self.selected_chickens = []
+        for chick in old_sel:
             chick.unequip_by_name("Spotlight")
-        self.selected_chickens = []
+            if chick.abode:
+                chick.abode.building.update_occupant_count()
 
     def unselect_animal(self, animal):
         if animal in self.selected_chickens:
             self.selected_chickens.remove(animal)
             animal.unequip_by_name("Spotlight")
+            if animal.abode:
+                animal.abode.building.update_occupant_count()
 
     def get_chicken_at_pos(self, tile_pos):
         chicken = self.get_outside_chicken(tile_pos)