Mercurial > rinkhals
comparison gamelib/equipment.py @ 413:bdc4757e0497
Add Sniper Rifle and give guns limited ammunition.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 21 Nov 2009 12:07:01 +0000 |
parents | 02a6de5629d6 |
children | 8f012ef1f64f |
comparison
equal
deleted
inserted
replaced
412:1e24eedbf40f | 413:bdc4757e0497 |
---|---|
62 """Can the lucky wielder hit the potentially unlucky target with this?""" | 62 """Can the lucky wielder hit the potentially unlucky target with this?""" |
63 return wielder.pos.dist(target.pos) <= self._get_parameter('RANGE', wielder) | 63 return wielder.pos.dist(target.pos) <= self._get_parameter('RANGE', wielder) |
64 | 64 |
65 def hit(self, gameboard, wielder, target): | 65 def hit(self, gameboard, wielder, target): |
66 """Is the potentially unlucky target actually unlucky?""" | 66 """Is the potentially unlucky target actually unlucky?""" |
67 if hasattr(self, 'AMMUNITION'): | |
68 if self.ammunition <= 0: | |
69 # Out of ammunition, so we don't get to shoot. | |
70 return | |
71 else: | |
72 self.ammunition -= 1 | |
67 if hasattr(self, 'HIT_SOUND'): | 73 if hasattr(self, 'HIT_SOUND'): |
68 sound.play_sound(self.HIT_SOUND) | 74 sound.play_sound(self.HIT_SOUND) |
69 if hasattr(self, 'ANIMATION'): | 75 if hasattr(self, 'ANIMATION'): |
70 self.ANIMATION(gameboard.tv, wielder) | 76 self.ANIMATION(gameboard.tv, wielder) |
71 roll = random.randint(1, 100) | 77 roll = random.randint(1, 100) |
82 class Rifle(Weapon): | 88 class Rifle(Weapon): |
83 TYPE = "GUN" | 89 TYPE = "GUN" |
84 NAME = "Rifle" | 90 NAME = "Rifle" |
85 BUY_PRICE = 100 | 91 BUY_PRICE = 100 |
86 SELL_PRICE = 75 | 92 SELL_PRICE = 75 |
93 AMMUNITION = 30 | |
87 | 94 |
88 RANGE = 3 | 95 RANGE = 3 |
89 BASE_HIT = 55 | 96 BASE_HIT = 55 |
90 RANGE_PENALTY = 15 | 97 RANGE_PENALTY = 15 |
98 HIT_SOUND = "fire-rifle.ogg" | |
99 | |
100 CHICKEN_IMAGE_FILE = 'sprites/equip_rifle.png' | |
101 | |
102 ANIMATION = animations.MuzzleFlash | |
103 | |
104 class SniperRifle(Weapon): | |
105 TYPE = "GUN" | |
106 NAME = "Sniper Rifle" | |
107 BUY_PRICE = 150 | |
108 SELL_PRICE = 100 | |
109 AMMUNITION = 3 | |
110 | |
111 RANGE = 5 | |
112 BASE_HIT = 80 | |
113 RANGE_PENALTY = 10 | |
91 HIT_SOUND = "fire-rifle.ogg" | 114 HIT_SOUND = "fire-rifle.ogg" |
92 | 115 |
93 CHICKEN_IMAGE_FILE = 'sprites/equip_rifle.png' | 116 CHICKEN_IMAGE_FILE = 'sprites/equip_rifle.png' |
94 | 117 |
95 ANIMATION = animations.MuzzleFlash | 118 ANIMATION = animations.MuzzleFlash |