Mercurial > rinkhals
comparison gamelib/animal.py @ 389:463802281182
Add basic level support (level choosing needs work)
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Thu, 29 Oct 2009 20:55:37 +0000 |
parents | 1586eccdefe4 |
children | ad77b3b71b08 |
comparison
equal
deleted
inserted
replaced
388:c6f0e3e72e86 | 389:463802281182 |
---|---|
241 | 241 |
242 STEALTH = 20 | 242 STEALTH = 20 |
243 IMAGE_FILE = 'sprites/fox.png' | 243 IMAGE_FILE = 'sprites/fox.png' |
244 DEATH_ANIMATION = animations.FoxDeath | 244 DEATH_ANIMATION = animations.FoxDeath |
245 DEATH_SOUND = 'kill-fox.ogg' | 245 DEATH_SOUND = 'kill-fox.ogg' |
246 CONFIG_NAME = 'fox' | |
246 | 247 |
247 costs = { | 248 costs = { |
248 # weighting for movement calculation | 249 # weighting for movement calculation |
249 'grassland' : 2, | 250 'grassland' : 2, |
250 'woodland' : 1, # Try to keep to the woods if possible | 251 'woodland' : 1, # Try to keep to the woods if possible |
457 class NinjaFox(Fox): | 458 class NinjaFox(Fox): |
458 """Ninja foxes are hard to see""" | 459 """Ninja foxes are hard to see""" |
459 | 460 |
460 STEALTH = 60 | 461 STEALTH = 60 |
461 IMAGE_FILE = 'sprites/ninja_fox.png' | 462 IMAGE_FILE = 'sprites/ninja_fox.png' |
463 CONFIG_NAME = 'ninja fox' | |
462 | 464 |
463 class DemoFox(Fox): | 465 class DemoFox(Fox): |
464 """Demolition Foxes destroy fences easily""" | 466 """Demolition Foxes destroy fences easily""" |
465 | 467 |
466 DIG_ANIMATION = animations.FenceExplosion | 468 DIG_ANIMATION = animations.FenceExplosion |
467 IMAGE_FILE = 'sprites/sapper_fox.png' | 469 IMAGE_FILE = 'sprites/sapper_fox.png' |
470 CONFIG_NAME = 'sapper fox' | |
468 | 471 |
469 def __init__(self, pos): | 472 def __init__(self, pos): |
470 Fox.__init__(self, pos) | 473 Fox.__init__(self, pos) |
471 self.costs['fence'] = 2 # We don't worry about fences | 474 self.costs['fence'] = 2 # We don't worry about fences |
472 | 475 |
477 self.DIG_ANIMATION(gameboard.tv, dig_pos.to_tuple()) | 480 self.DIG_ANIMATION(gameboard.tv, dig_pos.to_tuple()) |
478 self._make_hole(gameboard) | 481 self._make_hole(gameboard) |
479 | 482 |
480 class GreedyFox(Fox): | 483 class GreedyFox(Fox): |
481 """Greedy foxes eat more chickens""" | 484 """Greedy foxes eat more chickens""" |
485 CONFIG_NAME = 'greedy fox' | |
482 | 486 |
483 def __init__(self, pos): | 487 def __init__(self, pos): |
484 Fox.__init__(self, pos) | 488 Fox.__init__(self, pos) |
485 self.chickens_eaten = 0 | 489 self.chickens_eaten = 0 |
486 | 490 |
494 | 498 |
495 class Rinkhals(Fox): | 499 class Rinkhals(Fox): |
496 """The Rinkhals has eclectic tastes""" | 500 """The Rinkhals has eclectic tastes""" |
497 STEALTH = 80 | 501 STEALTH = 80 |
498 IMAGE_FILE = 'sprites/rinkhals.png' | 502 IMAGE_FILE = 'sprites/rinkhals.png' |
503 CONFIG_NAME = 'rinkhals' | |
499 | 504 |
500 def _catch_chicken(self, chicken, gameboard): | 505 def _catch_chicken(self, chicken, gameboard): |
501 """The Rinkhals hunts for sport, catch and release style""" | 506 """The Rinkhals hunts for sport, catch and release style""" |
502 self.closest = None | 507 self.closest = None |
503 self.hunting = False | 508 self.hunting = False |
525 vision_bonus = _get_vision_param('VISION_BONUS', watcher) | 530 vision_bonus = _get_vision_param('VISION_BONUS', watcher) |
526 range_penalty = _get_vision_param('VISION_RANGE_PENALTY', watcher) | 531 range_penalty = _get_vision_param('VISION_RANGE_PENALTY', watcher) |
527 distance = watcher.pos.dist(watchee.pos) - 1 | 532 distance = watcher.pos.dist(watchee.pos) - 1 |
528 roll = random.randint(1, 100) | 533 roll = random.randint(1, 100) |
529 return roll > watchee.STEALTH - vision_bonus + range_penalty*distance | 534 return roll > watchee.STEALTH - vision_bonus + range_penalty*distance |
535 | |
536 # These don't have to add up to 100, but it's easier to think | |
537 # about them if they do. | |
538 DEFAULT_FOX_WEIGHTINGS = ( | |
539 (Fox, 59), | |
540 (GreedyFox, 30), | |
541 (NinjaFox, 5), | |
542 (DemoFox, 5), | |
543 (Rinkhals, 1), | |
544 ) | |
545 |