Mercurial > rinkhals
comparison gamelib/gameboard.py @ 108:437cbd856a03
Add occupants and abodes. Allowing moving chickens around.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 18:42:00 +0000 |
parents | 7910b4e01dba |
children | 48019afde338 |
comparison
equal
deleted
inserted
replaced
107:672cc5598e77 | 108:437cbd856a03 |
---|---|
215 This will either select an animal or | 215 This will either select an animal or |
216 place a selected animal in a building. | 216 place a selected animal in a building. |
217 """ | 217 """ |
218 chicken = self.get_chicken(tile_pos) | 218 chicken = self.get_chicken(tile_pos) |
219 if chicken: | 219 if chicken: |
220 self.animal_to_place = chicken | 220 if chicken is self.animal_to_place: |
221 print "Selected animal %r" % (chicken,) | 221 self.animal_to_place = None |
222 else: | |
223 self.animal_to_place = chicken | |
224 print "Selected animal %r" % (self.animal_to_place,) | |
222 return | 225 return |
223 building = self.get_building(tile_pos) | 226 building = self.get_building(tile_pos) |
224 if building: | 227 if building: |
225 if self.animal_to_place is not None: | 228 if self.animal_to_place is not None: |
226 self.put_animal_in_building(self.animal_to_place, building) | 229 occupant = self.animal_to_place |
230 if occupant in self.tv.sprites: | |
231 self.tv.sprites.remove(occupant) | |
232 building.add_occupant(occupant) | |
233 print building, building.occupants() | |
227 else: | 234 else: |
228 self.select_animal_from_building(building) | 235 self.select_animal_from_building(building) |
229 | 236 return |
230 def put_animal_in_building(self, animal, building): | 237 if self.tv.get(tile_pos) == self.GRASSLAND: |
231 """Place animal in building.""" | 238 if self.animal_to_place is not None: |
232 # XXX: unimplemented | 239 occupant = self.animal_to_place |
233 print "Placing %r in %r" % (animal, building) | 240 if occupant.abode is not None: |
241 occupant.abode.remove_occupant(occupant) | |
242 occupant.set_pos(tile_pos) | |
234 | 243 |
235 def select_animal_from_building(self, building): | 244 def select_animal_from_building(self, building): |
236 """Create dialog for selecting an animal from a building.""" | 245 """Create dialog for selecting an animal from a building.""" |
237 # XXX: unimplemented | 246 # XXX: unimplemented |
238 print "Selecting animal from building %r" % (building,) | 247 print "Selecting animal from building %r" % (building,) |