Mercurial > touhou
diff pytouhou/game/player.py @ 444:f26c8ab57257
Use a simple for loop to determine the power level of the player; fixes a traceback when the SHT has no shot at all.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 30 Aug 2013 14:16:08 +0200 |
parents | b9d2db93972f |
children |
line wrap: on
line diff
--- a/pytouhou/game/player.py +++ b/pytouhou/game/player.py @@ -114,7 +114,12 @@ class Player(Element): def fire(self): sht = self.focused_sht if self.state.focused else self.sht - power = min(power for power in sht.shots if self.state.power < power) + + # Don’t use min() since sht.shots could be an empty dict. + power = 999 + for shot_power in sht.shots: + if self.state.power < shot_power: + power = power if power < shot_power else shot_power bullets = self._game.players_bullets lasers = self._game.players_lasers