Mercurial > rinkhals
diff 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 |
line wrap: on
line diff
--- a/gamelib/gameboard.py Wed Sep 02 20:54:45 2009 +0000 +++ b/gamelib/gameboard.py Wed Sep 02 20:54:47 2009 +0000 @@ -354,10 +354,20 @@ self.foxes = set() # Remove all the foxes def move_foxes(self): + """Move the foxes. + + We return True if there are no more foxes to move or all the + foxes are safely back. This end's the night""" + if not self.foxes: + return True + over = True for fox in self.foxes: fox.move(self) + if not fox.safe: + over = False for chicken in self.chickens: chicken.attack(self) + return over def add_chicken(self, chicken): self.chickens.add(chicken)