Mercurial > rinkhals
changeset 198:355eaae40b1f
Buildings now affect weapon range and accuracy.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 04 Sep 2009 19:34:01 +0000 |
parents | d74693555b86 |
children | 696936621a93 |
files | gamelib/buildings.py gamelib/equipment.py |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/buildings.py Fri Sep 04 19:32:30 2009 +0000 +++ b/gamelib/buildings.py Fri Sep 04 19:34:01 2009 +0000 @@ -51,6 +51,8 @@ IS_BUILDING = True GRASSLAND = tiles.REVERSE_TILE_MAP['grassland'] + MODIFY_KNIFE_RANGE = lambda s, x: 0 + MODIFY_GUN_RANGE = lambda s, x: -1 def __init__(self, pos): """Initial image, tile vid position, size and tile number for building.""" @@ -187,6 +189,7 @@ class DoubleStoryHenHouse(HenHouse): """A double story hen house.""" + TILE_NO = tiles.REVERSE_TILE_MAP['hendominium'] BUY_PRICE = 300 SELL_PRICE = 150 @@ -208,6 +211,10 @@ NAME = 'Watchtower' FLOORS = 1 + MODIFY_GUN_RANGE = lambda s, x: (3*x)/2 + MODIFY_GUN_BASE_HIT = lambda s, x: x-5 + MODIFY_GUN_RANGE_PENALTY = lambda s, x: x-1 + def is_building(obj): """Return true if obj is a build class.""" return getattr(obj, "IS_BUILDING", False) and hasattr(obj, "NAME")
--- a/gamelib/equipment.py Fri Sep 04 19:32:30 2009 +0000 +++ b/gamelib/equipment.py Fri Sep 04 19:34:01 2009 +0000 @@ -35,9 +35,12 @@ DRAW_LAYER = 10 def _get_parameter(self, parameter, wielder): - mod_attr = 'MODIFY_%s_%s' % (self.TYPE, parameter) param = getattr(self, parameter) - return getattr(wielder.abode, mod_attr, lambda r: r)(param) + if wielder.abode: + mod_attr = 'MODIFY_%s_%s' % (self.TYPE, parameter) + modifier = getattr(wielder.abode.building, mod_attr, lambda r: r) + param = modifier(param) + return param def in_range(self, gameboard, wielder, target): """Can the lucky wielder hit the potentially unlucky target with this?"""