Mercurial > rinkhals
comparison gamelib/gameboard.py @ 238:1a7097c0fc8f
Try harder to have 10 chickens at the start
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 05 Sep 2009 09:54:47 +0000 |
parents | ee1ac134022d |
children | 8224d1ac99c7 |
comparison
equal
deleted
inserted
replaced
237:4a87bfa5cc63 | 238:1a7097c0fc8f |
---|---|
776 | 776 |
777 def add_some_chickens(self): | 777 def add_some_chickens(self): |
778 """Add some random chickens to start the game""" | 778 """Add some random chickens to start the game""" |
779 x, y = 0, 0 | 779 x, y = 0, 0 |
780 width, height = self.tv.size | 780 width, height = self.tv.size |
781 tries = 0 | |
781 while len(self.chickens) < 10: | 782 while len(self.chickens) < 10: |
782 if x < width: | 783 if x < width: |
783 tile = self.tv.get((x, y)) | 784 tile = self.tv.get((x, y)) |
784 else: | 785 else: |
785 y += 1 | 786 y += 1 |
786 if y >= height: | 787 if y >= height: |
787 break | 788 y = 0 |
789 tries += 1 | |
790 if tries > 3: | |
791 break # Things have gone wierd | |
788 x = 0 | 792 x = 0 |
789 continue | 793 continue |
790 # See if we place a chicken | 794 # See if we place a chicken |
791 if 'grassland' == tiles.TILE_MAP[tile]: | 795 if 'grassland' == tiles.TILE_MAP[tile]: |
792 # Farmland | 796 # Farmland |