84
|
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
|