Mercurial > rinkhals
changeset 191:3c80f49d7d74
Don't allow buildings and fences to be built on top of chickens.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Fri, 04 Sep 2009 18:17:17 +0000 |
parents | c5ec3ff32d11 |
children | a490ee2ef446 |
files | gamelib/gameboard.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gameboard.py Fri Sep 04 18:09:37 2009 +0000 +++ b/gamelib/gameboard.py Fri Sep 04 18:17:17 2009 +0000 @@ -413,6 +413,9 @@ cost = constants.BUY_PRICE_FENCE else: cost = constants.REPAIR_PRICE_FENCE + if any((chicken.pos.x, chicken.pos.y) == tile_pos for chicken in self.chickens): + return + if self.cash < cost: print "You can't afford a fence." return @@ -437,6 +440,8 @@ building = building_cls(tile_pos) if self.cash < building.buy_price(): return + if any(building.covers((chicken.pos.x, chicken.pos.y)) for chicken in self.chickens): + return if building.place(self.tv): self.add_cash(-building.buy_price()) self.add_building(building)