Mercurial > rinkhals
changeset 457:fc648da2334c
Fix position cache removal, slightly optimise chicken range check.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 23 Nov 2009 16:12:37 +0000 |
parents | 96dbf2c8506e |
children | 7e4ea53d8b10 |
files | gamelib/animal.py gamelib/gameboard.py |
diffstat | 2 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/animal.py Mon Nov 23 10:30:22 2009 +0000 +++ b/gamelib/animal.py Mon Nov 23 16:12:37 2009 +0000 @@ -255,9 +255,9 @@ """Choose a random fox within range of this weapon.""" killable_foxes = [] for fox in gameboard.foxes: - if not visible(self, fox, gameboard): + if not weapon.in_range(gameboard, self, fox): continue - if weapon.in_range(gameboard, self, fox): + if visible(self, fox, gameboard): killable_foxes.append(fox) if not killable_foxes: return None
--- a/gamelib/gameboard.py Mon Nov 23 10:30:22 2009 +0000 +++ b/gamelib/gameboard.py Mon Nov 23 16:12:37 2009 +0000 @@ -57,7 +57,7 @@ self._cache[animal_type][animal.pos] = animal def remove(self, pos, animal_type): - if pos in self._cache: + if pos in self._cache[animal_type]: del self._cache[animal_type][pos] def update(self, old_pos, animal, animal_type):