[ci] auto-format

This commit is contained in:
CrossJoy 2022-12-14 13:13:28 +00:00 committed by github-actions[bot]
parent 507667443c
commit 800125c17f
2 changed files with 78 additions and 79 deletions

View file

@ -43,6 +43,8 @@ if TYPE_CHECKING:
from typing import Sequence, Union from typing import Sequence, Union
# Check game ver. # Check game ver.
def is_game_version_lower_than(version): def is_game_version_lower_than(version):
""" """
Returns a boolean value indicating whether the current game Returns a boolean value indicating whether the current game

View file

@ -45,7 +45,8 @@ import random
import weakref import weakref
from enum import Enum from enum import Enum
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import ba, _ba import ba
import _ba
import ba.internal import ba.internal
import bastd import bastd
from bastd.actor.powerupbox import PowerupBox from bastd.actor.powerupbox import PowerupBox
@ -271,7 +272,7 @@ class Practice(Plugin):
}) })
if ba.app.config.get( if ba.app.config.get(
"bombCountdown") and bomb_type not in fuse_bomb: "bombCountdown") and bomb_type not in fuse_bomb:
color = (1.0, 1.0, 0.0) color = (1.0, 1.0, 0.0)
count_bomb(*args, count='3', color=color) count_bomb(*args, count='3', color=color)
color = (1.0, 0.5, 0.0) color = (1.0, 0.5, 0.0)
@ -353,17 +354,17 @@ def _init_spaz_(self, *args, **kwargs):
'position') 'position')
self.curse_visualizer_fatal = ba.newnode('locator', self.curse_visualizer_fatal = ba.newnode('locator',
owner=self.node, owner=self.node,
# Remove itself when the bomb node dies. # Remove itself when the bomb node dies.
attrs={ attrs={
'shape': 'circle', 'shape': 'circle',
'color': ( 'color': (
0.7, 0, 0), 0.7, 0, 0),
'size': (0.0, 0.0, 0.0), 'size': (0.0, 0.0, 0.0),
'opacity': 0.10, 'opacity': 0.10,
'draw_beauty': False, 'draw_beauty': False,
'additive': False 'additive': False
}) })
self.node.connectattr('position', self.node.connectattr('position',
self.curse_visualizer_fatal, self.curse_visualizer_fatal,
'position') 'position')
@ -423,7 +424,6 @@ Spaz.super_handlemessage = Spaz.handlemessage
def bot_handlemessage(self, msg: Any): def bot_handlemessage(self, msg: Any):
if isinstance(msg, ba.PowerupMessage): if isinstance(msg, ba.PowerupMessage):
if msg.poweruptype == 'health': if msg.poweruptype == 'health':
if ba.app.config.get("bombRadiusVisual"): if ba.app.config.get("bombRadiusVisual"):
@ -498,7 +498,6 @@ def bot_handlemessage(self, msg: Any):
}) })
Spaz.handlemessage = bot_handlemessage Spaz.handlemessage = bot_handlemessage
@ -546,48 +545,48 @@ class NewBotSet(SpazBotSet):
super().__init__() super().__init__()
def _update(self) -> None: def _update(self) -> None:
try: try:
with ba.Context(_ba.get_foreground_host_activity()): with ba.Context(_ba.get_foreground_host_activity()):
# Update one of our bot lists each time through. # Update one of our bot lists each time through.
# First off, remove no-longer-existing bots from the list. # First off, remove no-longer-existing bots from the list.
try:
bot_list = self._bot_lists[self._bot_update_list] = ([
b for b in self._bot_lists[self._bot_update_list] if b
])
except Exception:
bot_list = []
ba.print_exception('Error updating bot list: ' +
str(self._bot_lists[
self._bot_update_list]))
self._bot_update_list = (self._bot_update_list +
1) % self._bot_list_count
# Update our list of player points for the bots to use.
player_pts = []
for player in ba.getactivity().players:
assert isinstance(player, ba.Player)
try: try:
bot_list = self._bot_lists[self._bot_update_list] = ([ # TODO: could use abstracted player.position here so we
b for b in self._bot_lists[self._bot_update_list] if b # don't have to assume their actor type, but we have no
]) # abstracted velocity as of yet.
if player.is_alive():
assert isinstance(player.actor, Spaz)
assert player.actor.node
player_pts.append(
(ba.Vec3(player.actor.node.position),
ba.Vec3(
player.actor.node.velocity)))
except Exception: except Exception:
bot_list = [] ba.print_exception('Error on bot-set _update.')
ba.print_exception('Error updating bot list: ' +
str(self._bot_lists[
self._bot_update_list]))
self._bot_update_list = (self._bot_update_list +
1) % self._bot_list_count
# Update our list of player points for the bots to use. for bot in bot_list:
player_pts = [] if not ba.app.config.get('stopBots'):
for player in ba.getactivity().players: bot.set_player_points(player_pts)
assert isinstance(player, ba.Player) bot.update_ai()
try:
# TODO: could use abstracted player.position here so we
# don't have to assume their actor type, but we have no
# abstracted velocity as of yet.
if player.is_alive():
assert isinstance(player.actor, Spaz)
assert player.actor.node
player_pts.append(
(ba.Vec3(player.actor.node.position),
ba.Vec3(
player.actor.node.velocity)))
except Exception:
ba.print_exception('Error on bot-set _update.')
for bot in bot_list: ba.app.config["disablePractice"] = True
if not ba.app.config.get('stopBots'): except:
bot.set_player_points(player_pts) ba.app.config["disablePractice"] = False
bot.update_ai()
ba.app.config["disablePractice"] = True
except:
ba.app.config["disablePractice"] = False
def clear(self) -> None: def clear(self) -> None:
"""Immediately clear out any bots in the set.""" """Immediately clear out any bots in the set."""
@ -603,11 +602,11 @@ class NewBotSet(SpazBotSet):
self._bot_lists[i] = [] self._bot_lists[i] = []
def spawn_bot( def spawn_bot(
self, self,
bot_type: type[SpazBot], bot_type: type[SpazBot],
pos: Sequence[float], pos: Sequence[float],
spawn_time: float = 3.0, spawn_time: float = 3.0,
on_spawn_call: Callable[[SpazBot], Any] | None = None) -> None: on_spawn_call: Callable[[SpazBot], Any] | None = None) -> None:
"""Spawn a bot from this set.""" """Spawn a bot from this set."""
from bastd.actor import spawner from bastd.actor import spawner
spawner.Spawner(pt=pos, spawner.Spawner(pt=pos,
@ -635,24 +634,23 @@ class DummyBotSet(NewBotSet):
def _update(self) -> None: def _update(self) -> None:
try: try:
with ba.Context(_ba.get_foreground_host_activity()): with ba.Context(_ba.get_foreground_host_activity()):
# Update one of our bot lists each time through. # Update one of our bot lists each time through.
# First off, remove no-longer-existing bots from the list. # First off, remove no-longer-existing bots from the list.
try: try:
bot_list = self._bot_lists[self._bot_update_list] = ([ bot_list = self._bot_lists[self._bot_update_list] = ([
b for b in self._bot_lists[self._bot_update_list] if b b for b in self._bot_lists[self._bot_update_list] if b
]) ])
except Exception: except Exception:
ba.print_exception('Error updating bot list: ' + ba.print_exception('Error updating bot list: ' +
str(self._bot_lists[ str(self._bot_lists[
self._bot_update_list])) self._bot_update_list]))
self._bot_update_list = (self._bot_update_list + self._bot_update_list = (self._bot_update_list +
1) % self._bot_list_count 1) % self._bot_list_count
except:
except: pass
pass
class DummyBot(SpazBot): class DummyBot(SpazBot):
@ -1085,7 +1083,7 @@ class BotsPracticeTab(PracticeTab):
'Pro Bomber', 'Pro Brawler', 'Pro Bomber', 'Pro Brawler',
'Pro Trigger', 'Pro Charger', 'Pro Trigger', 'Pro Charger',
'S.Pro Bomber', 'S.Pro Brawler', 'S.Pro Bomber', 'S.Pro Brawler',
'S.Pro Trigger', 'S.Pro Charger'): 'S.Pro Trigger', 'S.Pro Charger'):
tint1 = (1.0, 0.2, 0.1) tint1 = (1.0, 0.2, 0.1)
tint2 = (0.6, 0.1, 0.05) tint2 = (0.6, 0.1, 0.05)
elif self.bot_array_name[self._icon_index] in 'Bouncy': elif self.bot_array_name[self._icon_index] in 'Bouncy':
@ -1097,7 +1095,7 @@ class BotsPracticeTab(PracticeTab):
if self.bot_array_name[self._icon_index] in ( if self.bot_array_name[self._icon_index] in (
'S.Pro Bomber', 'S.Pro Brawler', 'S.Pro Bomber', 'S.Pro Brawler',
'S.Pro Trigger', 'S.Pro Charger'): 'S.Pro Trigger', 'S.Pro Charger'):
color = (1.3, 1.2, 3.0) color = (1.3, 1.2, 3.0)
else: else:
color = (1.0, 1.0, 1.0) color = (1.0, 1.0, 1.0)
@ -1296,8 +1294,7 @@ class PowerUpPracticeTab(PracticeTab):
i.node.position[1], i.node.position[1],
i.node.position[2] + z) i.node.position[2] + z)
PowerupBox(position=pos, PowerupBox(position=pos,
poweruptype= poweruptype=self.power_list_type
self.power_list_type
[self._icon_index]).autoretain() [self._icon_index]).autoretain()
def _power_window(self) -> None: def _power_window(self) -> None: