Mercurial > rinkhals
comparison gamelib/gameboard.py @ 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 | 37af9e5dd292 |
children | a490ee2ef446 |
comparison
equal
deleted
inserted
replaced
190:c5ec3ff32d11 | 191:3c80f49d7d74 |
---|---|
411 return | 411 return |
412 if this_tile == self.GRASSLAND: | 412 if this_tile == self.GRASSLAND: |
413 cost = constants.BUY_PRICE_FENCE | 413 cost = constants.BUY_PRICE_FENCE |
414 else: | 414 else: |
415 cost = constants.REPAIR_PRICE_FENCE | 415 cost = constants.REPAIR_PRICE_FENCE |
416 if any((chicken.pos.x, chicken.pos.y) == tile_pos for chicken in self.chickens): | |
417 return | |
418 | |
416 if self.cash < cost: | 419 if self.cash < cost: |
417 print "You can't afford a fence." | 420 print "You can't afford a fence." |
418 return | 421 return |
419 self.add_cash(-cost) | 422 self.add_cash(-cost) |
420 self.tv.set(tile_pos, self.FENCE) | 423 self.tv.set(tile_pos, self.FENCE) |
434 self.tv.set(tile_pos, self.GRASSLAND) | 437 self.tv.set(tile_pos, self.GRASSLAND) |
435 | 438 |
436 def buy_building(self, tile_pos, building_cls): | 439 def buy_building(self, tile_pos, building_cls): |
437 building = building_cls(tile_pos) | 440 building = building_cls(tile_pos) |
438 if self.cash < building.buy_price(): | 441 if self.cash < building.buy_price(): |
442 return | |
443 if any(building.covers((chicken.pos.x, chicken.pos.y)) for chicken in self.chickens): | |
439 return | 444 return |
440 if building.place(self.tv): | 445 if building.place(self.tv): |
441 self.add_cash(-building.buy_price()) | 446 self.add_cash(-building.buy_price()) |
442 self.add_building(building) | 447 self.add_building(building) |
443 | 448 |