mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-07 08:03:30 +08:00
oops pycharm formatting differ
This commit is contained in:
parent
976cf18247
commit
19591e128b
@ -78,9 +78,9 @@ class Campaign:
|
|||||||
for level in self._levels:
|
for level in self._levels:
|
||||||
if level.name == name:
|
if level.name == name:
|
||||||
return level
|
return level
|
||||||
raise _error.NotFoundError(
|
raise _error.NotFoundError("Level '" + name +
|
||||||
"Level '" + name + "' not found in campaign '" +
|
"' not found in campaign '" + self.name +
|
||||||
self.name + "'")
|
"'")
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
"""Reset state for the Campaign."""
|
"""Reset state for the Campaign."""
|
||||||
@ -100,7 +100,7 @@ class Campaign:
|
|||||||
"""Return the live config dict for this campaign."""
|
"""Return the live config dict for this campaign."""
|
||||||
val: Dict[str, Any] = (_ba.app.config.setdefault('Campaigns',
|
val: Dict[str, Any] = (_ba.app.config.setdefault('Campaigns',
|
||||||
{}).setdefault(
|
{}).setdefault(
|
||||||
self._name, {}))
|
self._name, {}))
|
||||||
assert isinstance(val, dict)
|
assert isinstance(val, dict)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|||||||
@ -357,7 +357,7 @@ class Map(Actor):
|
|||||||
return pnt
|
return pnt
|
||||||
|
|
||||||
def get_ffa_start_position(
|
def get_ffa_start_position(
|
||||||
self, players: Sequence[ba.Player]) -> Sequence[float]:
|
self, players: Sequence[ba.Player]) -> Sequence[float]:
|
||||||
"""Return a random starting position in one of the FFA spawn areas.
|
"""Return a random starting position in one of the FFA spawn areas.
|
||||||
|
|
||||||
If a list of ba.Players is provided; the returned points will be
|
If a list of ba.Players is provided; the returned points will be
|
||||||
|
|||||||
@ -326,7 +326,8 @@ def get_scan_results() -> ScanResults:
|
|||||||
while app.metascan is None:
|
while app.metascan is None:
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
if time.time() - starttime > 10.0:
|
if time.time() - starttime > 10.0:
|
||||||
raise TimeoutError('timeout waiting for meta scan to complete.')
|
raise TimeoutError(
|
||||||
|
'timeout waiting for meta scan to complete.')
|
||||||
return app.metascan
|
return app.metascan
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
self._game_name_str = self._campaign.name + ':' + self._level_name
|
self._game_name_str = self._campaign.name + ':' + self._level_name
|
||||||
self._game_config_str = str(len(
|
self._game_config_str = str(len(
|
||||||
self._player_info)) + 'p' + self._campaign.get_level(
|
self._player_info)) + 'p' + self._campaign.get_level(
|
||||||
self._level_name).get_score_version_string().replace(' ', '_')
|
self._level_name).get_score_version_string().replace(' ', '_')
|
||||||
|
|
||||||
# If game-center/etc scores are available we show our friends'
|
# If game-center/etc scores are available we show our friends'
|
||||||
# scores. Otherwise we show our local high scores.
|
# scores. Otherwise we show our local high scores.
|
||||||
@ -265,7 +265,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
# If we didn't just complete this level but are choosing to play the
|
# If we didn't just complete this level but are choosing to play the
|
||||||
# next one, set it as current (this won't happen otherwise).
|
# next one, set it as current (this won't happen otherwise).
|
||||||
if (self._is_complete and self._is_more_levels
|
if (self._is_complete and self._is_more_levels
|
||||||
and not self._newly_complete):
|
and not self._newly_complete):
|
||||||
assert self._next_level_name is not None
|
assert self._next_level_name is not None
|
||||||
self._campaign.set_selected_level(self._next_level_name)
|
self._campaign.set_selected_level(self._next_level_name)
|
||||||
ba.containerwidget(edit=self._root_ui, transition='out_left')
|
ba.containerwidget(edit=self._root_ui, transition='out_left')
|
||||||
@ -387,8 +387,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
label=ba.Lstr(resource='tournamentStandingsText')
|
label=ba.Lstr(resource='tournamentStandingsText')
|
||||||
if self.session.tournament_id is not None else ba.Lstr(
|
if self.session.tournament_id is not None else ba.Lstr(
|
||||||
resource='worldsBestScoresText') if self._score_type
|
resource='worldsBestScoresText') if self._score_type
|
||||||
== 'points' else ba.Lstr(
|
== 'points' else ba.Lstr(resource='worldsBestTimesText'),
|
||||||
resource='worldsBestTimesText'),
|
|
||||||
autoselect=True,
|
autoselect=True,
|
||||||
on_activate_call=ba.WeakCall(self._ui_worlds_best),
|
on_activate_call=ba.WeakCall(self._ui_worlds_best),
|
||||||
transition_delay=delay + 1.9,
|
transition_delay=delay + 1.9,
|
||||||
@ -549,7 +548,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
ba.timer(1.0, ba.WeakCall(self.request_ui))
|
ba.timer(1.0, ba.WeakCall(self.request_ui))
|
||||||
|
|
||||||
if (self._is_complete and self._victory and self._is_more_levels
|
if (self._is_complete and self._victory and self._is_more_levels
|
||||||
and not ba.app.kiosk_mode):
|
and not ba.app.kiosk_mode):
|
||||||
Text(ba.Lstr(value='${A}:\n',
|
Text(ba.Lstr(value='${A}:\n',
|
||||||
subs=[('${A}', ba.Lstr(resource='levelUnlockedText'))
|
subs=[('${A}', ba.Lstr(resource='levelUnlockedText'))
|
||||||
]) if self._newly_complete else
|
]) if self._newly_complete else
|
||||||
@ -647,11 +646,11 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
transition_delay=2.0)
|
transition_delay=2.0)
|
||||||
self._score_loading_status = Text(ba.Lstr(
|
self._score_loading_status = Text(ba.Lstr(
|
||||||
value='${A}...', subs=[('${A}', ba.Lstr(resource='loadingText'))]),
|
value='${A}...', subs=[('${A}', ba.Lstr(resource='loadingText'))]),
|
||||||
position=(280, 150 + 30),
|
position=(280, 150 + 30),
|
||||||
color=(1, 1, 1, 0.4),
|
color=(1, 1, 1, 0.4),
|
||||||
transition=Text.Transition.FADE_IN,
|
transition=Text.Transition.FADE_IN,
|
||||||
scale=0.7,
|
scale=0.7,
|
||||||
transition_delay=2.0)
|
transition_delay=2.0)
|
||||||
|
|
||||||
if self._score is not None:
|
if self._score is not None:
|
||||||
ba.timer(0.4, ba.WeakCall(self._play_drumroll))
|
ba.timer(0.4, ba.WeakCall(self._play_drumroll))
|
||||||
@ -728,9 +727,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
v_offs = 40
|
v_offs = 40
|
||||||
txt = Text(ba.Lstr(resource='tournamentStandingsText')
|
txt = Text(ba.Lstr(resource='tournamentStandingsText')
|
||||||
if self.session.tournament_id is not None else ba.Lstr(
|
if self.session.tournament_id is not None else ba.Lstr(
|
||||||
resource='worldsBestScoresText') if self._score_type
|
resource='worldsBestScoresText') if self._score_type
|
||||||
== 'points' else ba.Lstr(
|
== 'points' else ba.Lstr(resource='worldsBestTimesText'),
|
||||||
resource='worldsBestTimesText'),
|
|
||||||
maxwidth=210,
|
maxwidth=210,
|
||||||
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
|
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
|
||||||
transition=Text.Transition.IN_LEFT,
|
transition=Text.Transition.IN_LEFT,
|
||||||
@ -766,8 +764,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
ts_h_offs = -480
|
ts_h_offs = -480
|
||||||
v_offs = 40
|
v_offs = 40
|
||||||
Text(ba.Lstr(resource='yourBestScoresText') if self._score_type
|
Text(ba.Lstr(resource='yourBestScoresText') if self._score_type
|
||||||
== 'points' else ba.Lstr(
|
== 'points' else ba.Lstr(resource='yourBestTimesText'),
|
||||||
resource='yourBestTimesText'),
|
|
||||||
maxwidth=210,
|
maxwidth=210,
|
||||||
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
|
position=(ts_h_offs - 10, ts_height / 2 + 25 + v_offs + 20),
|
||||||
transition=Text.Transition.IN_RIGHT,
|
transition=Text.Transition.IN_RIGHT,
|
||||||
@ -1399,12 +1396,12 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
|
|||||||
str(int(self._show_info['results']['rank']))),
|
str(int(self._show_info['results']['rank']))),
|
||||||
('${ALL}', str(self._show_info['results']['total']))
|
('${ALL}', str(self._show_info['results']['total']))
|
||||||
]),
|
]),
|
||||||
position=(0, -155 if self._newly_complete else -145),
|
position=(0, -155 if self._newly_complete else -145),
|
||||||
color=(1, 1, 1, 0.7),
|
color=(1, 1, 1, 0.7),
|
||||||
h_align=Text.HAlign.CENTER,
|
h_align=Text.HAlign.CENTER,
|
||||||
transition=Text.Transition.FADE_IN,
|
transition=Text.Transition.FADE_IN,
|
||||||
scale=0.55,
|
scale=0.55,
|
||||||
transition_delay=1.0).autoretain()
|
transition_delay=1.0).autoretain()
|
||||||
|
|
||||||
new_best = (best_rank > self._old_best_rank and best_rank > 0.0)
|
new_best = (best_rank > self._old_best_rank and best_rank > 0.0)
|
||||||
was_string = ba.Lstr(value=' ${A}',
|
was_string = ba.Lstr(value=' ${A}',
|
||||||
|
|||||||
@ -526,7 +526,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
position=pos,
|
position=pos,
|
||||||
poweruptype=powerupbox.get_factory().get_random_powerup_type(
|
poweruptype=powerupbox.get_factory().get_random_powerup_type(
|
||||||
excludetypes=self._exclude_powerups +
|
excludetypes=self._exclude_powerups +
|
||||||
extra_excludes)).autoretain()
|
extra_excludes)).autoretain()
|
||||||
|
|
||||||
def end_game(self) -> None:
|
def end_game(self) -> None:
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
|
|
||||||
# If we have no living bots, go to the next wave.
|
# If we have no living bots, go to the next wave.
|
||||||
if (self._can_end_wave and not self._bots.have_living_bots()
|
if (self._can_end_wave and not self._bots.have_living_bots()
|
||||||
and not self._game_over and self._lives > 0):
|
and not self._game_over and self._lives > 0):
|
||||||
|
|
||||||
self._can_end_wave = False
|
self._can_end_wave = False
|
||||||
self._time_bonus_timer = None
|
self._time_bonus_timer = None
|
||||||
@ -653,9 +653,9 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
value='+${A} ${B}',
|
value='+${A} ${B}',
|
||||||
subs=[('${A}', str(bonus)),
|
subs=[('${A}', str(bonus)),
|
||||||
('${B}', ba.Lstr(resource='completionBonusText'))]),
|
('${B}', ba.Lstr(resource='completionBonusText'))]),
|
||||||
color=(0.7, 0.7, 1.0, 1),
|
color=(0.7, 0.7, 1.0, 1),
|
||||||
scale=1.6,
|
scale=1.6,
|
||||||
position=(0, 1.5, -1)).autoretain()
|
position=(0, 1.5, -1)).autoretain()
|
||||||
self._score += bonus
|
self._score += bonus
|
||||||
self._update_scores()
|
self._update_scores()
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
len(defender_types))]
|
len(defender_types))]
|
||||||
defender1 = defender2 = None
|
defender1 = defender2 = None
|
||||||
if ((group == 0) or (group == 1 and level > 3)
|
if ((group == 0) or (group == 1 and level > 3)
|
||||||
or (group == 2 and level > 5)):
|
or (group == 2 and level > 5)):
|
||||||
if random.random() < min(0.75, (level - 1) * 0.11):
|
if random.random() < min(0.75, (level - 1) * 0.11):
|
||||||
this_target_point_s, defender1 = _add_defender(
|
this_target_point_s, defender1 = _add_defender(
|
||||||
defender_type1, 'bottom_left')
|
defender_type1, 'bottom_left')
|
||||||
@ -1109,7 +1109,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
|
|||||||
return True
|
return True
|
||||||
if ((ba.is_point_in_box(pos, boxes['b8'])
|
if ((ba.is_point_in_box(pos, boxes['b8'])
|
||||||
and not ba.is_point_in_box(pos, boxes['b9']))
|
and not ba.is_point_in_box(pos, boxes['b9']))
|
||||||
or pos == (0.0, 0.0, 0.0)):
|
or pos == (0.0, 0.0, 0.0)):
|
||||||
# Default to walking right if we're still in the walking area.
|
# Default to walking right if we're still in the walking area.
|
||||||
bot.node.move_left_right = speed
|
bot.node.move_left_right = speed
|
||||||
bot.node.move_up_down = 0
|
bot.node.move_up_down = 0
|
||||||
|
|||||||
@ -627,8 +627,8 @@ class AccountSettingsWindow(ba.Window):
|
|||||||
elif account_type == 'Game Circle':
|
elif account_type == 'Game Circle':
|
||||||
account_type_name = ba.Lstr(resource='gameCircleText')
|
account_type_name = ba.Lstr(resource='gameCircleText')
|
||||||
else:
|
else:
|
||||||
raise ValueError("unknown account type: '" + str(account_type) +
|
raise ValueError("unknown account type: '" +
|
||||||
"'")
|
str(account_type) + "'")
|
||||||
self._game_service_button = btn = ba.buttonwidget(
|
self._game_service_button = btn = ba.buttonwidget(
|
||||||
parent=self._subcontainer,
|
parent=self._subcontainer,
|
||||||
position=((self._sub_width - button_width) * 0.5, v),
|
position=((self._sub_width - button_width) * 0.5, v),
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class MainMenuWindow(ba.Window):
|
|||||||
super().__init__(root_widget=ba.containerwidget(
|
super().__init__(root_widget=ba.containerwidget(
|
||||||
transition=transition,
|
transition=transition,
|
||||||
toolbar_visibility='menu_minimal_no_back' if self.
|
toolbar_visibility='menu_minimal_no_back' if self.
|
||||||
_in_game else 'menu_minimal_no_back'))
|
_in_game else 'menu_minimal_no_back'))
|
||||||
|
|
||||||
self._is_kiosk = ba.app.kiosk_mode
|
self._is_kiosk = ba.app.kiosk_mode
|
||||||
self._tdelay = 0.0
|
self._tdelay = 0.0
|
||||||
@ -95,7 +95,7 @@ class MainMenuWindow(ba.Window):
|
|||||||
_ba.get_local_active_input_devices_count()
|
_ba.get_local_active_input_devices_count()
|
||||||
if (((app.on_tv or app.platform == 'mac')
|
if (((app.on_tv or app.platform == 'mac')
|
||||||
and ba.app.config.get('launchCount', 0) <= 1)
|
and ba.app.config.get('launchCount', 0) <= 1)
|
||||||
or force_test):
|
or force_test):
|
||||||
|
|
||||||
def _check_show_bs_remote_window() -> None:
|
def _check_show_bs_remote_window() -> None:
|
||||||
try:
|
try:
|
||||||
@ -131,7 +131,7 @@ class MainMenuWindow(ba.Window):
|
|||||||
store_char_tex = self._get_store_char_tex()
|
store_char_tex = self._get_store_char_tex()
|
||||||
account_state_num = _ba.get_account_state_num()
|
account_state_num = _ba.get_account_state_num()
|
||||||
if (account_state_num != self._account_state_num
|
if (account_state_num != self._account_state_num
|
||||||
or store_char_tex != self._store_char_tex):
|
or store_char_tex != self._store_char_tex):
|
||||||
self._store_char_tex = store_char_tex
|
self._store_char_tex = store_char_tex
|
||||||
self._account_state_num = account_state_num
|
self._account_state_num = account_state_num
|
||||||
account_state = self._account_state = (_ba.get_account_state())
|
account_state = self._account_state = (_ba.get_account_state())
|
||||||
@ -294,8 +294,8 @@ class MainMenuWindow(ba.Window):
|
|||||||
size=(self._button_width, self._button_height),
|
size=(self._button_width, self._button_height),
|
||||||
scale=scale,
|
scale=scale,
|
||||||
label=ba.Lstr(resource=self._r +
|
label=ba.Lstr(resource=self._r +
|
||||||
('.quitText' if 'Mac' in
|
('.quitText' if 'Mac' in
|
||||||
ba.app.user_agent_string else '.exitGameText')),
|
ba.app.user_agent_string else '.exitGameText')),
|
||||||
on_activate_call=self._quit,
|
on_activate_call=self._quit,
|
||||||
transition_delay=self._tdelay)
|
transition_delay=self._tdelay)
|
||||||
|
|
||||||
@ -320,7 +320,8 @@ class MainMenuWindow(ba.Window):
|
|||||||
# If we're not in-game, have no quit button, and this is android,
|
# If we're not in-game, have no quit button, and this is android,
|
||||||
# we want back presses to quit our activity.
|
# we want back presses to quit our activity.
|
||||||
if (not self._in_game and not self._have_quit_button
|
if (not self._in_game and not self._have_quit_button
|
||||||
and ba.app.platform == 'android'):
|
and ba.app.platform == 'android'):
|
||||||
|
|
||||||
def _do_quit() -> None:
|
def _do_quit() -> None:
|
||||||
confirm.QuitWindow(swish=True, back=True)
|
confirm.QuitWindow(swish=True, back=True)
|
||||||
|
|
||||||
@ -670,8 +671,8 @@ class MainMenuWindow(ba.Window):
|
|||||||
custom_menu_entries = session.get_custom_menu_entries()
|
custom_menu_entries = session.get_custom_menu_entries()
|
||||||
for cme in custom_menu_entries:
|
for cme in custom_menu_entries:
|
||||||
if (not isinstance(cme, dict) or 'label' not in cme
|
if (not isinstance(cme, dict) or 'label' not in cme
|
||||||
or not isinstance(cme['label'], (str, ba.Lstr))
|
or not isinstance(cme['label'], (str, ba.Lstr))
|
||||||
or 'call' not in cme or not callable(cme['call'])):
|
or 'call' not in cme or not callable(cme['call'])):
|
||||||
raise ValueError('invalid custom menu entry: ' +
|
raise ValueError('invalid custom menu entry: ' +
|
||||||
str(cme))
|
str(cme))
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -756,7 +757,7 @@ class MainMenuWindow(ba.Window):
|
|||||||
autoselect=self._use_autoselect)
|
autoselect=self._use_autoselect)
|
||||||
# Add a 'leave' button if the menu-owner has a player.
|
# Add a 'leave' button if the menu-owner has a player.
|
||||||
if ((self._input_player or self._connected_to_remote_player)
|
if ((self._input_player or self._connected_to_remote_player)
|
||||||
and not self._is_kiosk):
|
and not self._is_kiosk):
|
||||||
h, v, scale = positions[self._p_index]
|
h, v, scale = positions[self._p_index]
|
||||||
self._p_index += 1
|
self._p_index += 1
|
||||||
btn = ba.buttonwidget(parent=self._root_widget,
|
btn = ba.buttonwidget(parent=self._root_widget,
|
||||||
@ -769,7 +770,7 @@ class MainMenuWindow(ba.Window):
|
|||||||
autoselect=self._use_autoselect)
|
autoselect=self._use_autoselect)
|
||||||
|
|
||||||
if (player_name != '' and player_name[0] != '<'
|
if (player_name != '' and player_name[0] != '<'
|
||||||
and player_name[-1] != '>'):
|
and player_name[-1] != '>'):
|
||||||
txt = ba.Lstr(resource=self._r + '.justPlayerText',
|
txt = ba.Lstr(resource=self._r + '.justPlayerText',
|
||||||
subs=[('${NAME}', player_name)])
|
subs=[('${NAME}', player_name)])
|
||||||
else:
|
else:
|
||||||
@ -865,7 +866,7 @@ class MainMenuWindow(ba.Window):
|
|||||||
# Select cancel by default; this occasionally gets called by accident
|
# Select cancel by default; this occasionally gets called by accident
|
||||||
# in a fit of button mashing and this will help reduce damage.
|
# in a fit of button mashing and this will help reduce damage.
|
||||||
confirm.ConfirmWindow(ba.Lstr(resource=self._r +
|
confirm.ConfirmWindow(ba.Lstr(resource=self._r +
|
||||||
'.leavePartyConfirmText'),
|
'.leavePartyConfirmText'),
|
||||||
self._leave_party,
|
self._leave_party,
|
||||||
cancel_is_selected=True)
|
cancel_is_selected=True)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user