[ci] auto-format

This commit is contained in:
Loup-Garou911XD 2022-11-03 17:08:09 +00:00 committed by github-actions[bot]
parent 85304770d3
commit d58e326d4c
5 changed files with 564 additions and 530 deletions

View file

@ -13,6 +13,8 @@ if TYPE_CHECKING:
Spaz.oldhandlemessage = Spaz.handlemessage Spaz.oldhandlemessage = Spaz.handlemessage
def handlemessage(self, msg: Any) -> Any: def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, ba.DieMessage): if isinstance(msg, ba.DieMessage):
if self.node: if self.node:

View file

@ -37,6 +37,7 @@ else:
teams_text = 'Teams' teams_text = 'Teams'
ffa_text = 'FFA' ffa_text = 'FFA'
class ConfigNumberEdit: class ConfigNumberEdit:
def __init__(self, def __init__(self,
@ -102,6 +103,7 @@ class ConfigNumberEdit:
cfg['Config Max Players'][self._config] = self._value cfg['Config Max Players'][self._config] = self._value
cfg.apply_and_commit() cfg.apply_and_commit()
class SettingsMaxPlayers(PopupWindow): class SettingsMaxPlayers(PopupWindow):
def __init__(self): def __init__(self):
@ -180,6 +182,7 @@ class SettingsMaxPlayers(PopupWindow):
ba.playsound(ba.getsound('swish')) ba.playsound(ba.getsound('swish'))
self._transition_out() self._transition_out()
def __init__(self) -> None: def __init__(self) -> None:
"""Instantiate a co-op mode session.""" """Instantiate a co-op mode session."""
# pylint: disable=cyclic-import # pylint: disable=cyclic-import
@ -230,6 +233,7 @@ def __init__(self) -> None:
self._next_game_level_name: Optional[str] = None self._next_game_level_name: Optional[str] = None
self._update_on_deck_game_instances() self._update_on_deck_game_instances()
def get_max_players(self) -> int: def get_max_players(self) -> int:
"""Return max number of ba.Players allowed to join the game at once.""" """Return max number of ba.Players allowed to join the game at once."""
if self.use_teams: if self.use_teams:
@ -240,11 +244,15 @@ def get_max_players(self) -> int:
'Free-for-All Max Players', 'Free-for-All Max Players',
cfg['Config Max Players']['ffa_max_players']) cfg['Config Max Players']['ffa_max_players'])
GatherWindow.__old_init__ = GatherWindow.__init__ GatherWindow.__old_init__ = GatherWindow.__init__
def __gather_init__(self, def __gather_init__(self,
transition: Optional[str] = 'in_right', transition: Optional[str] = 'in_right',
origin_widget: ba.Widget = None): origin_widget: ba.Widget = None):
self.__old_init__(transition, origin_widget) self.__old_init__(transition, origin_widget)
def _do_max_players(): def _do_max_players():
SettingsMaxPlayers() SettingsMaxPlayers()
self._max_players_button = ba.buttonwidget( self._max_players_button = ba.buttonwidget(
@ -260,6 +268,7 @@ def __gather_init__(self,
button_type='regular', button_type='regular',
on_activate_call=_do_max_players) on_activate_call=_do_max_players)
def _save_state(self) -> None: def _save_state(self) -> None:
try: try:
for tab in self._tabs.values(): for tab in self._tabs.values():
@ -287,6 +296,7 @@ def _save_state(self) -> None:
except Exception: except Exception:
ba.print_exception(f'Error saving state for {self}.') ba.print_exception(f'Error saving state for {self}.')
def _restore_state(self) -> None: def _restore_state(self) -> None:
from efro.util import enum_by_value from efro.util import enum_by_value
try: try:
@ -326,6 +336,8 @@ def _restore_state(self) -> None:
ba.print_exception('Error restoring gather-win state.') ba.print_exception('Error restoring gather-win state.')
# ba_meta export plugin # ba_meta export plugin
class MaxPlayersPlugin(ba.Plugin): class MaxPlayersPlugin(ba.Plugin):
def has_settings_ui(self) -> bool: def has_settings_ui(self) -> bool:
@ -338,7 +350,7 @@ class MaxPlayersPlugin(ba.Plugin):
old_config = ba.app.config['Config Max Players'] old_config = ba.app.config['Config Max Players']
for setting in cmp: for setting in cmp:
if setting not in old_config: if setting not in old_config:
ba.app.config['Config Max Players'].update({setting:cmp[setting]}) ba.app.config['Config Max Players'].update({setting: cmp[setting]})
remove_list = [] remove_list = []
for setting in old_config: for setting in old_config:
if setting not in cmp: if setting not in cmp:

View file

@ -19,9 +19,9 @@ if TYPE_CHECKING:
lang = ba.app.lang.language lang = ba.app.lang.language
if lang == 'Spanish': if lang == 'Spanish':
custom_txt = 'personalizar...' custom_txt = 'personalizar...'
else: else:
custom_txt = 'custom...' custom_txt = 'custom...'
if 'quick_game_button' in ba.app.config: if 'quick_game_button' in ba.app.config:
@ -31,6 +31,7 @@ else:
ba.app.config['quick_game_button'] = config ba.app.config['quick_game_button'] = config
ba.app.config.commit() ba.app.config.commit()
def start_game(session: ba.Session, fadeout: bool = True): def start_game(session: ba.Session, fadeout: bool = True):
def callback(): def callback():
if fadeout: if fadeout:
@ -50,6 +51,7 @@ def start_game(session: ba.Session, fadeout: bool = True):
else: else:
callback() callback()
class SimplePlaylist: class SimplePlaylist:
def __init__(self, def __init__(self,
@ -66,6 +68,7 @@ class SimplePlaylist:
settings = self.settings['settings'] settings = self.settings['settings']
return dict(resolved_type=self.gametype, settings=settings) return dict(resolved_type=self.gametype, settings=settings)
class CustomSession(FreeForAllSession): class CustomSession(FreeForAllSession):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -305,6 +308,8 @@ class SelectGameWindow(PlaylistAddGameWindow):
PlayWindow._old_init = PlayWindow.__init__ PlayWindow._old_init = PlayWindow.__init__
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self._old_init() self._old_init()
@ -331,6 +336,7 @@ def __init__(self, *args, **kwargs):
self._restore_state() self._restore_state()
def states(self) -> None: def states(self) -> None:
return { return {
'Team Games': self._teams_button, 'Team Games': self._teams_button,
@ -340,6 +346,7 @@ def states(self) -> None:
'Quick Game': self._quick_game_button 'Quick Game': self._quick_game_button
} }
def _save_state(self) -> None: def _save_state(self) -> None:
swapped = {v: k for k, v in states(self).items()} swapped = {v: k for k, v in states(self).items()}
if self._root_widget.get_selected_child() in swapped: if self._root_widget.get_selected_child() in swapped:
@ -349,6 +356,7 @@ def _save_state(self) -> None:
else: else:
ba.print_exception(f'Error saving state for {self}.') ba.print_exception(f'Error saving state for {self}.')
def _restore_state(self) -> None: def _restore_state(self) -> None:
if not hasattr(self, '_quick_game_button'): if not hasattr(self, '_quick_game_button'):
return # ensure that our monkey patched init ran return # ensure that our monkey patched init ran

View file

@ -10,11 +10,11 @@ import random
from bastd.actor import bomb from bastd.actor import bomb
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Sequence from typing import Sequence
class NewBlast(bomb.Blast): class NewBlast(bomb.Blast):
def __init__( def __init__(
self, self,
position: Sequence[float] = (0.0, 1.0, 0.0), position: Sequence[float] = (0.0, 1.0, 0.0),
velocity: Sequence[float] = (0.0, 0.0, 0.0), velocity: Sequence[float] = (0.0, 0.0, 0.0),
@ -24,25 +24,25 @@ class NewBlast(bomb.Blast):
hit_type: str = 'explosion', hit_type: str = 'explosion',
hit_subtype: str = 'normal', hit_subtype: str = 'normal',
): ):
super().__init__(position, velocity, blast_radius, blast_type, super().__init__(position, velocity, blast_radius, blast_type,
source_player, hit_type, hit_subtype) source_player, hit_type, hit_subtype)
scorch_radius = light_radius = self.radius scorch_radius = light_radius = self.radius
if self.blast_type == 'tnt': if self.blast_type == 'tnt':
scorch_radius *= 1.15 scorch_radius *= 1.15
scorch = ba.newnode( scorch = ba.newnode(
'scorch', 'scorch',
attrs={ attrs={
'position': position, 'position': position,
'size': scorch_radius * 0.5, 'size': scorch_radius * 0.5,
'big': (self.blast_type == 'tnt'), 'big': (self.blast_type == 'tnt'),
}, },
) )
random_color = (random.random(), random.random(), random.random()) random_color = (random.random(), random.random(), random.random())
scorch.color = ba.safecolor(random_color) scorch.color = ba.safecolor(random_color)
ba.animate(scorch, 'presence', {3.000: 1, 13.000: 0}) ba.animate(scorch, 'presence', {3.000: 1, 13.000: 0})
ba.timer(13.0, scorch.delete) ba.timer(13.0, scorch.delete)
# ba_meta export plugin # ba_meta export plugin
class RandomColorsPlugin(ba.Plugin): class RandomColorsPlugin(ba.Plugin):
bomb.Blast = NewBlast bomb.Blast = NewBlast

File diff suppressed because it is too large Load diff