oops pycharm formatting differ

This commit is contained in:
Roman Trapeznikov 2020-05-21 19:21:48 +03:00
parent 976cf18247
commit 19591e128b
No known key found for this signature in database
GPG Key ID: 827DD41DACE1E018
7 changed files with 46 additions and 47 deletions

View File

@ -78,9 +78,9 @@ class Campaign:
for level in self._levels:
if level.name == name:
return level
raise _error.NotFoundError(
"Level '" + name + "' not found in campaign '" +
self.name + "'")
raise _error.NotFoundError("Level '" + name +
"' not found in campaign '" + self.name +
"'")
def reset(self) -> None:
"""Reset state for the Campaign."""
@ -100,7 +100,7 @@ class Campaign:
"""Return the live config dict for this campaign."""
val: Dict[str, Any] = (_ba.app.config.setdefault('Campaigns',
{}).setdefault(
self._name, {}))
self._name, {}))
assert isinstance(val, dict)
return val

View File

@ -357,7 +357,7 @@ class Map(Actor):
return pnt
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.
If a list of ba.Players is provided; the returned points will be

View File

@ -326,7 +326,8 @@ def get_scan_results() -> ScanResults:
while app.metascan is None:
time.sleep(0.05)
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

View File

@ -172,7 +172,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
self._game_name_str = self._campaign.name + ':' + self._level_name
self._game_config_str = str(len(
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'
# 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
# next one, set it as current (this won't happen otherwise).
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
self._campaign.set_selected_level(self._next_level_name)
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')
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,
@ -549,7 +548,7 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
ba.timer(1.0, ba.WeakCall(self.request_ui))
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',
subs=[('${A}', ba.Lstr(resource='levelUnlockedText'))
]) if self._newly_complete else
@ -647,11 +646,11 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
transition_delay=2.0)
self._score_loading_status = Text(ba.Lstr(
value='${A}...', subs=[('${A}', ba.Lstr(resource='loadingText'))]),
position=(280, 150 + 30),
color=(1, 1, 1, 0.4),
transition=Text.Transition.FADE_IN,
scale=0.7,
transition_delay=2.0)
position=(280, 150 + 30),
color=(1, 1, 1, 0.4),
transition=Text.Transition.FADE_IN,
scale=0.7,
transition_delay=2.0)
if self._score is not None:
ba.timer(0.4, ba.WeakCall(self._play_drumroll))
@ -728,9 +727,8 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
v_offs = 40
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'),
resource='worldsBestScoresText') if self._score_type
== '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,
@ -766,8 +764,7 @@ 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,
@ -1399,12 +1396,12 @@ class CoopScoreScreen(ba.Activity[ba.Player, ba.Team]):
str(int(self._show_info['results']['rank']))),
('${ALL}', str(self._show_info['results']['total']))
]),
position=(0, -155 if self._newly_complete else -145),
color=(1, 1, 1, 0.7),
h_align=Text.HAlign.CENTER,
transition=Text.Transition.FADE_IN,
scale=0.55,
transition_delay=1.0).autoretain()
position=(0, -155 if self._newly_complete else -145),
color=(1, 1, 1, 0.7),
h_align=Text.HAlign.CENTER,
transition=Text.Transition.FADE_IN,
scale=0.55,
transition_delay=1.0).autoretain()
new_best = (best_rank > self._old_best_rank and best_rank > 0.0)
was_string = ba.Lstr(value=' ${A}',

View File

@ -526,7 +526,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
position=pos,
poweruptype=powerupbox.get_factory().get_random_powerup_type(
excludetypes=self._exclude_powerups +
extra_excludes)).autoretain()
extra_excludes)).autoretain()
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 (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._time_bonus_timer = None
@ -653,9 +653,9 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
value='+${A} ${B}',
subs=[('${A}', str(bonus)),
('${B}', ba.Lstr(resource='completionBonusText'))]),
color=(0.7, 0.7, 1.0, 1),
scale=1.6,
position=(0, 1.5, -1)).autoretain()
color=(0.7, 0.7, 1.0, 1),
scale=1.6,
position=(0, 1.5, -1)).autoretain()
self._score += bonus
self._update_scores()
@ -839,7 +839,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
len(defender_types))]
defender1 = defender2 = None
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):
this_target_point_s, defender1 = _add_defender(
defender_type1, 'bottom_left')
@ -1109,7 +1109,7 @@ class RunaroundGame(ba.CoopGameActivity[Player, Team]):
return True
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)):
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

View File

@ -627,8 +627,8 @@ class AccountSettingsWindow(ba.Window):
elif account_type == 'Game Circle':
account_type_name = ba.Lstr(resource='gameCircleText')
else:
raise ValueError("unknown account type: '" + str(account_type) +
"'")
raise ValueError("unknown account type: '" +
str(account_type) + "'")
self._game_service_button = btn = ba.buttonwidget(
parent=self._subcontainer,
position=((self._sub_width - button_width) * 0.5, v),

View File

@ -49,7 +49,7 @@ class MainMenuWindow(ba.Window):
super().__init__(root_widget=ba.containerwidget(
transition=transition,
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._tdelay = 0.0
@ -95,7 +95,7 @@ class MainMenuWindow(ba.Window):
_ba.get_local_active_input_devices_count()
if (((app.on_tv or app.platform == 'mac')
and ba.app.config.get('launchCount', 0) <= 1)
or force_test):
or force_test):
def _check_show_bs_remote_window() -> None:
try:
@ -131,7 +131,7 @@ class MainMenuWindow(ba.Window):
store_char_tex = self._get_store_char_tex()
account_state_num = _ba.get_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._account_state_num = account_state_num
account_state = self._account_state = (_ba.get_account_state())
@ -294,8 +294,8 @@ class MainMenuWindow(ba.Window):
size=(self._button_width, self._button_height),
scale=scale,
label=ba.Lstr(resource=self._r +
('.quitText' if 'Mac' in
ba.app.user_agent_string else '.exitGameText')),
('.quitText' if 'Mac' in
ba.app.user_agent_string else '.exitGameText')),
on_activate_call=self._quit,
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,
# we want back presses to quit our activity.
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:
confirm.QuitWindow(swish=True, back=True)
@ -670,8 +671,8 @@ class MainMenuWindow(ba.Window):
custom_menu_entries = session.get_custom_menu_entries()
for cme in custom_menu_entries:
if (not isinstance(cme, dict) or 'label' not in cme
or not isinstance(cme['label'], (str, ba.Lstr))
or 'call' not in cme or not callable(cme['call'])):
or not isinstance(cme['label'], (str, ba.Lstr))
or 'call' not in cme or not callable(cme['call'])):
raise ValueError('invalid custom menu entry: ' +
str(cme))
except Exception:
@ -756,7 +757,7 @@ class MainMenuWindow(ba.Window):
autoselect=self._use_autoselect)
# Add a 'leave' button if the menu-owner has a 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]
self._p_index += 1
btn = ba.buttonwidget(parent=self._root_widget,
@ -769,7 +770,7 @@ class MainMenuWindow(ba.Window):
autoselect=self._use_autoselect)
if (player_name != '' and player_name[0] != '<'
and player_name[-1] != '>'):
and player_name[-1] != '>'):
txt = ba.Lstr(resource=self._r + '.justPlayerText',
subs=[('${NAME}', player_name)])
else:
@ -865,7 +866,7 @@ class MainMenuWindow(ba.Window):
# Select cancel by default; this occasionally gets called by accident
# in a fit of button mashing and this will help reduce damage.
confirm.ConfirmWindow(ba.Lstr(resource=self._r +
'.leavePartyConfirmText'),
'.leavePartyConfirmText'),
self._leave_party,
cancel_is_selected=True)