Mercurial > rinkhals
view gamelib/equipment.py @ 84:5494af02a0e8
Chickens with rifles!
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 01 Sep 2009 21:31:08 +0000 |
parents | |
children | f5d56688943b |
line wrap: on
line source
"""Stuff for animals to use.""" import random class Equipment(object): is_weapon = False class Weapon(Equipment): is_weapon = True def in_range(self, gameboard, wielder, target): """Can the lucky wielder hit the potentially unlucky target with this?""" return False def hit(self, gameboard, wielder, target): """Is the potentially unlucky target actually unlucky?""" return False class Rifle(Weapon): def in_range(self, gameboard, wielder, target): """For now, we ignore terrain and just assume we can hit anything that isn't too far away.""" return wielder.pos.dist(target.pos) <= 3 def hit(self, gameboard, wielder, target): """Closer is more accurate.""" return random.randint(1, 100) > 60 + 10*wielder.pos.dist(target.pos)