Mercurial > rinkhals
comparison gamelib/gameboard.py @ 122:d2b19131d537
Don't continue the night if we're not doing anything anymore
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 20:54:47 +0000 |
parents | eeb42296b523 |
children | 69fd96eafde8 |
comparison
equal
deleted
inserted
replaced
121:7b2660cc7861 | 122:d2b19131d537 |
---|---|
352 else: | 352 else: |
353 self.tv.sprites.remove(fox) | 353 self.tv.sprites.remove(fox) |
354 self.foxes = set() # Remove all the foxes | 354 self.foxes = set() # Remove all the foxes |
355 | 355 |
356 def move_foxes(self): | 356 def move_foxes(self): |
357 """Move the foxes. | |
358 | |
359 We return True if there are no more foxes to move or all the | |
360 foxes are safely back. This end's the night""" | |
361 if not self.foxes: | |
362 return True | |
363 over = True | |
357 for fox in self.foxes: | 364 for fox in self.foxes: |
358 fox.move(self) | 365 fox.move(self) |
366 if not fox.safe: | |
367 over = False | |
359 for chicken in self.chickens: | 368 for chicken in self.chickens: |
360 chicken.attack(self) | 369 chicken.attack(self) |
370 return over | |
361 | 371 |
362 def add_chicken(self, chicken): | 372 def add_chicken(self, chicken): |
363 self.chickens.add(chicken) | 373 self.chickens.add(chicken) |
364 if chicken.outside(): | 374 if chicken.outside(): |
365 self.tv.sprites.append(chicken) | 375 self.tv.sprites.append(chicken) |