comparison 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
comparison
equal deleted inserted replaced
443:cae83b963695 444:f26c8ab57257
112 self.state.focused = False 112 self.state.focused = False
113 113
114 114
115 def fire(self): 115 def fire(self):
116 sht = self.focused_sht if self.state.focused else self.sht 116 sht = self.focused_sht if self.state.focused else self.sht
117 power = min(power for power in sht.shots if self.state.power < power) 117
118 # Don’t use min() since sht.shots could be an empty dict.
119 power = 999
120 for shot_power in sht.shots:
121 if self.state.power < shot_power:
122 power = power if power < shot_power else shot_power
118 123
119 bullets = self._game.players_bullets 124 bullets = self._game.players_bullets
120 lasers = self._game.players_lasers 125 lasers = self._game.players_lasers
121 nb_bullets_max = self._game.nb_bullets_max 126 nb_bullets_max = self._game.nb_bullets_max
122 127