Mercurial > rinkhals
diff 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 |
line wrap: on
line diff
--- a/gamelib/equipment.py Sat Nov 21 11:34:12 2009 +0000 +++ b/gamelib/equipment.py Sat Nov 21 12:07:01 2009 +0000 @@ -64,6 +64,12 @@ def hit(self, gameboard, wielder, target): """Is the potentially unlucky target actually unlucky?""" + if hasattr(self, 'AMMUNITION'): + if self.ammunition <= 0: + # Out of ammunition, so we don't get to shoot. + return + else: + self.ammunition -= 1 if hasattr(self, 'HIT_SOUND'): sound.play_sound(self.HIT_SOUND) if hasattr(self, 'ANIMATION'): @@ -84,6 +90,7 @@ NAME = "Rifle" BUY_PRICE = 100 SELL_PRICE = 75 + AMMUNITION = 30 RANGE = 3 BASE_HIT = 55 @@ -94,6 +101,22 @@ ANIMATION = animations.MuzzleFlash +class SniperRifle(Weapon): + TYPE = "GUN" + NAME = "Sniper Rifle" + BUY_PRICE = 150 + SELL_PRICE = 100 + AMMUNITION = 3 + + RANGE = 5 + BASE_HIT = 80 + RANGE_PENALTY = 10 + HIT_SOUND = "fire-rifle.ogg" + + CHICKEN_IMAGE_FILE = 'sprites/equip_rifle.png' + + ANIMATION = animations.MuzzleFlash + class Knife(Weapon): TYPE = "KNIFE" NAME = "Knife"