mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-09 09:13:24 +08:00
Exceptions typing in bastd module
This commit is contained in:
parent
5b5aee6faf
commit
9143415308
@ -149,7 +149,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
||||
self._score_order: str
|
||||
if 'score_order' in settings:
|
||||
if not settings['score_order'] in ['increasing', 'decreasing']:
|
||||
raise Exception('Invalid score order: ' +
|
||||
raise ValueError('Invalid score order: ' +
|
||||
settings['score_order'])
|
||||
self._score_order = settings['score_order']
|
||||
else:
|
||||
@ -159,7 +159,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
||||
self._score_type: str
|
||||
if 'score_type' in settings:
|
||||
if not settings['score_type'] in ['points', 'time']:
|
||||
raise Exception('Invalid score type: ' +
|
||||
raise ValueError('Invalid score type: ' +
|
||||
settings['score_type'])
|
||||
self._score_type = settings['score_type']
|
||||
else:
|
||||
@ -387,7 +387,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
||||
label=ba.Lstr(resource='tournamentStandingsText')
|
||||
if self.session.tournament_id is not None else ba.Lstr(
|
||||
resource='worldsBestScoresText') if self._score_type
|
||||
== 'points' else ba.Lstr(resource='worldsBestTimesText'),
|
||||
== 'points' else ba.Lstr(
|
||||
resource='worldsBestTimesText'),
|
||||
autoselect=True,
|
||||
on_activate_call=ba.WeakCall(self._ui_worlds_best),
|
||||
transition_delay=delay + 1.9,
|
||||
@ -728,7 +729,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
||||
txt = Text(ba.Lstr(resource='tournamentStandingsText')
|
||||
if self.session.tournament_id is not None else ba.Lstr(
|
||||
resource='worldsBestScoresText') if self._score_type
|
||||
== 'points' else ba.Lstr(resource='worldsBestTimesText'),
|
||||
== 'points' else ba.Lstr(
|
||||
resource='worldsBestTimesText'),
|
||||
maxwidth=210,
|
||||
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
|
||||
transition=Text.Transition.IN_LEFT,
|
||||
@ -764,7 +766,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
||||
ts_h_offs = -480
|
||||
v_offs = 40
|
||||
Text(ba.Lstr(resource='yourBestScoresText') if self._score_type
|
||||
== 'points' else ba.Lstr(resource='yourBestTimesText'),
|
||||
== 'points' else ba.Lstr(
|
||||
resource='yourBestTimesText'),
|
||||
maxwidth=210,
|
||||
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
|
||||
transition=Text.Transition.IN_RIGHT,
|
||||
|
||||
@ -665,7 +665,7 @@ class Bomb(ba.Actor):
|
||||
|
||||
if bomb_type not in ('ice', 'impact', 'land_mine', 'normal', 'sticky',
|
||||
'tnt'):
|
||||
raise Exception('invalid bomb type: ' + bomb_type)
|
||||
raise ValueError('invalid bomb type: ' + bomb_type)
|
||||
self.bomb_type = bomb_type
|
||||
|
||||
self._exploded = False
|
||||
|
||||
@ -95,7 +95,7 @@ class OnScreenTimer(ba.Actor):
|
||||
assert isinstance(endtime, int)
|
||||
endtime_ms = endtime
|
||||
else:
|
||||
raise Exception(f'invalid timeformat: {timeformat}')
|
||||
raise ValueError(f'invalid timeformat: {timeformat}')
|
||||
|
||||
self.inputnode.timemax = endtime_ms - self._starttime
|
||||
|
||||
@ -119,7 +119,7 @@ class OnScreenTimer(ba.Actor):
|
||||
return 0.001 * val_ms
|
||||
if timeformat is ba.TimeFormat.MILLISECONDS:
|
||||
return val_ms
|
||||
raise Exception(f'invalid timeformat: {timeformat}')
|
||||
raise ValueError(f'invalid timeformat: {timeformat}')
|
||||
|
||||
def handlemessage(self, msg: Any) -> Any:
|
||||
# if we're asked to die, just kill our node/timer
|
||||
|
||||
@ -187,7 +187,7 @@ def get_factory() -> PowerupBoxFactory:
|
||||
"""Return a shared ba.PowerupBoxFactory object, creating if necessary."""
|
||||
activity = ba.getactivity()
|
||||
if activity is None:
|
||||
raise Exception('no current activity')
|
||||
raise RuntimeError('no current activity')
|
||||
try:
|
||||
# FIXME: et better way to store stuff with activity
|
||||
# pylint: disable=protected-access
|
||||
@ -252,10 +252,10 @@ class PowerupBox(ba.Actor):
|
||||
elif poweruptype == 'curse':
|
||||
tex = factory.tex_curse
|
||||
else:
|
||||
raise Exception('invalid poweruptype: ' + str(poweruptype))
|
||||
raise ValueError('invalid poweruptype: ' + str(poweruptype))
|
||||
|
||||
if len(position) != 3:
|
||||
raise Exception('expected 3 floats for position')
|
||||
raise ValueError('expected 3 floats for position')
|
||||
|
||||
self.node = ba.newnode(
|
||||
'prop',
|
||||
|
||||
@ -1384,7 +1384,7 @@ class Spaz(ba.Actor):
|
||||
return bomb_factory.tex_ice_bombs
|
||||
if self.bomb_type == 'impact':
|
||||
return bomb_factory.tex_impact_bombs
|
||||
raise Exception()
|
||||
raise ValueError('invalid bomb type')
|
||||
|
||||
def _flash_billboard(self, tex: ba.Texture) -> None:
|
||||
assert self.node
|
||||
|
||||
@ -1110,7 +1110,6 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
||||
if ((ba.is_point_in_box(pos, boxes['b8'])
|
||||
and not ba.is_point_in_box(pos, boxes['b9']))
|
||||
or pos == (0.0, 0.0, 0.0)):
|
||||
|
||||
# Default to walking right if we're still in the walking area.
|
||||
bot.node.move_left_right = speed
|
||||
bot.node.move_up_down = 0
|
||||
@ -1177,7 +1176,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
||||
def _get_bot_speed(self, bot_type: Type[spazbot.SpazBot]) -> float:
|
||||
speed = self._bot_speed_map.get(bot_type)
|
||||
if speed is None:
|
||||
raise Exception('Invalid bot type to _get_bot_speed(): ' +
|
||||
raise TypeError('Invalid bot type to _get_bot_speed(): ' +
|
||||
str(bot_type))
|
||||
return speed
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user