Mercurial > rinkhals
comparison 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 |
comparison
equal
deleted
inserted
replaced
83:9bd2c22e1746 | 84:5494af02a0e8 |
---|---|
1 """Stuff for animals to use.""" | |
2 | |
3 import random | |
4 | |
5 class Equipment(object): | |
6 is_weapon = False | |
7 | |
8 class Weapon(Equipment): | |
9 is_weapon = True | |
10 | |
11 def in_range(self, gameboard, wielder, target): | |
12 """Can the lucky wielder hit the potentially unlucky target with this?""" | |
13 return False | |
14 | |
15 def hit(self, gameboard, wielder, target): | |
16 """Is the potentially unlucky target actually unlucky?""" | |
17 return False | |
18 | |
19 class Rifle(Weapon): | |
20 def in_range(self, gameboard, wielder, target): | |
21 """For now, we ignore terrain and just assume we can hit | |
22 anything that isn't too far away.""" | |
23 return wielder.pos.dist(target.pos) <= 3 | |
24 | |
25 def hit(self, gameboard, wielder, target): | |
26 """Closer is more accurate.""" | |
27 return random.randint(1, 100) > 60 + 10*wielder.pos.dist(target.pos) | |
28 |