Mercurial > rinkhals
annotate gamelib/equipment.py @ 100:e90068d1f374
Re-indent to four spaces.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Wed, 02 Sep 2009 17:24:58 +0000 |
parents | f5d56688943b |
children | 48019afde338 |
rev | line source |
---|---|
84 | 1 """Stuff for animals to use.""" |
2 | |
3 import random | |
99
f5d56688943b
Added background music support, and daytime and night time music (really animal sounds, not music)
David Fraser <davidf@sjsoft.com>
parents:
84
diff
changeset
|
4 import sound |
84 | 5 |
6 class Equipment(object): | |
7 is_weapon = False | |
8 | |
9 class Weapon(Equipment): | |
10 is_weapon = True | |
11 | |
12 def in_range(self, gameboard, wielder, target): | |
13 """Can the lucky wielder hit the potentially unlucky target with this?""" | |
14 return False | |
15 | |
16 def hit(self, gameboard, wielder, target): | |
17 """Is the potentially unlucky target actually unlucky?""" | |
18 return False | |
19 | |
20 class Rifle(Weapon): | |
21 def in_range(self, gameboard, wielder, target): | |
22 """For now, we ignore terrain and just assume we can hit | |
23 anything that isn't too far away.""" | |
24 return wielder.pos.dist(target.pos) <= 3 | |
25 | |
26 def hit(self, gameboard, wielder, target): | |
27 """Closer is more accurate.""" | |
99
f5d56688943b
Added background music support, and daytime and night time music (really animal sounds, not music)
David Fraser <davidf@sjsoft.com>
parents:
84
diff
changeset
|
28 sound.play_sound("fire-rifle.ogg") |
84 | 29 return random.randint(1, 100) > 60 + 10*wielder.pos.dist(target.pos) |
30 |