Mercurial > rinkhals
comparison gamelib/gameboard.py @ 397:532f1ea476ff
Make foxes enter buildings, with a seperate count for them
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Fri, 13 Nov 2009 14:14:57 +0000 |
parents | 19e583e5cdc0 |
children | 3294929223bd |
comparison
equal
deleted
inserted
replaced
396:19e583e5cdc0 | 397:532f1ea476ff |
---|---|
525 else: | 525 else: |
526 place.set_occupant(chicken) | 526 place.set_occupant(chicken) |
527 chicken.set_pos(place.get_pos()) | 527 chicken.set_pos(place.get_pos()) |
528 self.set_visibility(chicken) | 528 self.set_visibility(chicken) |
529 | 529 |
530 def set_visibility(self, chicken): | 530 def set_visibility(self, animal): |
531 if chicken.outside(): | 531 if animal.outside(): |
532 if chicken not in self.tv.sprites: | 532 if animal not in self.tv.sprites: |
533 self.tv.sprites.append(chicken) | 533 self.tv.sprites.append(animal) |
534 else: | 534 else: |
535 if chicken in self.tv.sprites: | 535 if animal in self.tv.sprites: |
536 self.tv.sprites.remove(chicken) | 536 self.tv.sprites.remove(animal) |
537 | 537 |
538 def open_dialog(self, widget, x=None, y=None, close_callback=None): | 538 def open_dialog(self, widget, x=None, y=None, close_callback=None): |
539 """Open a dialog for the given widget. Add close button.""" | 539 """Open a dialog for the given widget. Add close button.""" |
540 tbl = gui.Table() | 540 tbl = gui.Table() |
541 | 541 |
778 # killed | 778 # killed |
779 if self.in_bounds(fox.pos) and \ | 779 if self.in_bounds(fox.pos) and \ |
780 self.tv.get(fox.pos.to_tile_tuple()) != self.WOODLAND: | 780 self.tv.get(fox.pos.to_tile_tuple()) != self.WOODLAND: |
781 self.kill_fox(fox) | 781 self.kill_fox(fox) |
782 else: | 782 else: |
783 self.tv.sprites.remove(fox) | 783 self.remove_fox(fox) |
784 self.foxes = set() # Remove all the foxes | 784 self.foxes = set() # Remove all the foxes |
785 | 785 |
786 def run_animations(self): | 786 def run_animations(self): |
787 # For legacy. | 787 # For legacy. |
788 if self.toolbar.anim_clear_tool: | 788 if self.toolbar.anim_clear_tool: |
871 self.add_cash(self.level.sell_price_dead_fox) | 871 self.add_cash(self.level.sell_price_dead_fox) |
872 self.remove_fox(fox) | 872 self.remove_fox(fox) |
873 | 873 |
874 def remove_fox(self, fox): | 874 def remove_fox(self, fox): |
875 self.foxes.discard(fox) | 875 self.foxes.discard(fox) |
876 if fox.building: | |
877 fox.building.remove_predator(fox) | |
876 if fox in self.tv.sprites: | 878 if fox in self.tv.sprites: |
877 self.tv.sprites.remove(fox) | 879 self.tv.sprites.remove(fox) |
878 | 880 |
879 def remove_chicken(self, chick): | 881 def remove_chicken(self, chick): |
880 if chick is self.animal_to_place: | 882 if chick is self.animal_to_place: |