[ci] auto-format

This commit is contained in:
SenjuZoro 2023-07-27 10:58:18 +00:00 committed by github-actions[bot]
parent 27bb489a1f
commit 21821c0328

View file

@ -1,9 +1,5 @@
#Made by MythB # Made by MythB
#Ported by: MysteriousBoi # Ported by: MysteriousBoi
# ba_meta require api 8 # ba_meta require api 8
@ -11,7 +7,8 @@ from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import babase import babase
import bauiv1 as bui import bauiv1 as bui
import bascenev1 as bs,random import bascenev1 as bs
import random
from bascenev1lib.actor.playerspaz import PlayerSpaz from bascenev1lib.actor.playerspaz import PlayerSpaz
from bascenev1lib.actor.scoreboard import Scoreboard from bascenev1lib.actor.scoreboard import Scoreboard
from bascenev1lib.actor.powerupbox import PowerupBoxFactory from bascenev1lib.actor.powerupbox import PowerupBoxFactory
@ -27,25 +24,27 @@ class PuckDiedMessage:
def __init__(self, puck: Puck): def __init__(self, puck: Puck):
self.puck = puck self.puck = puck
#goalpost # goalpost
class FlagKale(bs.Actor): class FlagKale(bs.Actor):
def __init__(self,position=(0,2.5,0),color=(1,1,1)): def __init__(self, position=(0, 2.5, 0), color=(1, 1, 1)):
super().__init__() super().__init__()
activity = self.getactivity() activity = self.getactivity()
shared = SharedObjects.get() shared = SharedObjects.get()
self.node = bs.newnode('flag', self.node = bs.newnode('flag',
attrs={'position':(position[0],position[1]+0.75,position[2]), attrs={'position': (position[0], position[1]+0.75, position[2]),
'color_texture':activity._flagKaleTex, 'color_texture': activity._flagKaleTex,
'color':color, 'color': color,
'materials':[shared.object_material,activity._kaleMaterial], 'materials': [shared.object_material, activity._kaleMaterial],
}, },
delegate=self) delegate=self)
def handleMessage(self,m): def handleMessage(self, m):
if isinstance(m,bs.DieMessage): if isinstance(m, bs.DieMessage):
if self.node.exists(): if self.node.exists():
self.node.delete() self.node.delete()
elif isinstance(m,bs.OutOfBoundsMessage): elif isinstance(m, bs.OutOfBoundsMessage):
self.handlemessage(bs.DieMessage()) self.handlemessage(bs.DieMessage())
else: else:
super().handlemessage(msg) super().handlemessage(msg)
@ -76,9 +75,9 @@ class Puck(bs.Actor):
'is_area_of_interest': True, 'is_area_of_interest': True,
'position': self._spawn_pos, 'position': self._spawn_pos,
'materials': pmats, 'materials': pmats,
'body_scale': 4, 'body_scale': 4,
'mesh_scale': 1, 'mesh_scale': 1,
'density': 0.02}) 'density': 0.02})
bs.animate(self.node, 'mesh_scale', {0: 0, 0.2: 1.3, 0.26: 1}) bs.animate(self.node, 'mesh_scale', {0: 0, 0.2: 1.3, 0.26: 1})
def handlemessage(self, msg: Any) -> Any: def handlemessage(self, msg: Any) -> Any:
@ -114,31 +113,33 @@ class Puck(bs.Actor):
else: else:
super().handlemessage(msg) super().handlemessage(msg)
#for night mode: using a actor with large shadow and little mesh scale. Better then tint i think, players and objects more visible # for night mode: using a actor with large shadow and little mesh scale. Better then tint i think, players and objects more visible
class NightMod(bs.Actor): class NightMod(bs.Actor):
def __init__(self,position=(0,0,0)): def __init__(self, position=(0, 0, 0)):
super().__init__() super().__init__()
shared = SharedObjects.get() shared = SharedObjects.get()
activity = self.getactivity() activity = self.getactivity()
# spawn just above the provided point # spawn just above the provided point
self._spawnPos = (position[0],position[1],position[2]) self._spawnPos = (position[0], position[1], position[2])
self.node = bs.newnode("prop", self.node = bs.newnode("prop",
attrs={'mesh': activity._nightModel, attrs={'mesh': activity._nightModel,
'color_texture': activity._nightTex, 'color_texture': activity._nightTex,
'body':'sphere', 'body': 'sphere',
'reflection':'soft', 'reflection': 'soft',
'body_scale': 0.1, 'body_scale': 0.1,
'mesh_scale':0.001, 'mesh_scale': 0.001,
'density':0.010, 'density': 0.010,
'reflection_scale':[0.23], 'reflection_scale': [0.23],
'shadow_size': 999999.0, 'shadow_size': 999999.0,
'is_area_of_interest':True, 'is_area_of_interest': True,
'position':self._spawnPos, 'position': self._spawnPos,
'materials': [activity._nightMaterial] 'materials': [activity._nightMaterial]
}, },
delegate=self) delegate=self)
def handlemssage(self,m): def handlemssage(self, m):
super().handlemessage(m) super().handlemessage(m)
@ -218,28 +219,28 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
self._nightModel = bs.getmesh("shield") self._nightModel = bs.getmesh("shield")
self._nightTex = bs.gettexture("black") self._nightTex = bs.gettexture("black")
self._kaleMaterial = bs.Material() self._kaleMaterial = bs.Material()
#add friction to flags for standing our position (as far as) # add friction to flags for standing our position (as far as)
self._kaleMaterial.add_actions(conditions=("they_have_material",shared.footing_material), self._kaleMaterial.add_actions(conditions=("they_have_material", shared.footing_material),
actions=( ("modify_part_collision","friction",9999.5))) actions=(("modify_part_collision", "friction", 9999.5)))
self._kaleMaterial.add_actions(conditions=( ("we_are_younger_than",1),'and', self._kaleMaterial.add_actions(conditions=(("we_are_younger_than", 1), 'and',
("they_have_material",shared.object_material)), ("they_have_material", shared.object_material)),
actions=( ("modify_part_collision","collide",False))) actions=(("modify_part_collision", "collide", False)))
self._kaleMaterial.add_actions(conditions=("they_have_material",shared.pickup_material), self._kaleMaterial.add_actions(conditions=("they_have_material", shared.pickup_material),
actions=( ("modify_part_collision","collide",False))) actions=(("modify_part_collision", "collide", False)))
self._kaleMaterial.add_actions( self._kaleMaterial.add_actions(
conditions=('they_have_material',shared.object_material), conditions=('they_have_material', shared.object_material),
actions=(('impact_sound',self._kaleSound,2,5))) actions=(('impact_sound', self._kaleSound, 2, 5)))
#we dont wanna hit the night so # we dont wanna hit the night so
self._nightMaterial = bs.Material() self._nightMaterial = bs.Material()
self._nightMaterial.add_actions(conditions=(('they_have_material',shared.pickup_material),'or', self._nightMaterial.add_actions(conditions=(('they_have_material', shared.pickup_material), 'or',
('they_have_material',shared.attack_material)), ('they_have_material', shared.attack_material)),
actions=(('modify_part_collision','collide',False))) actions=(('modify_part_collision', 'collide', False)))
# we also dont want anything moving it # we also dont want anything moving it
self._nightMaterial.add_actions( self._nightMaterial.add_actions(
conditions=(('they_have_material',shared.object_material),'or', conditions=(('they_have_material', shared.object_material), 'or',
('they_dont_have_material',shared.footing_material)), ('they_dont_have_material', shared.footing_material)),
actions=(('modify_part_collision','collide',False), actions=(('modify_part_collision', 'collide', False),
('modify_part_collision','physical',False))) ('modify_part_collision', 'physical', False)))
self.puck_material = bs.Material() self.puck_material = bs.Material()
self.puck_material.add_actions(actions=(('modify_part_collision', self.puck_material.add_actions(actions=(('modify_part_collision',
'friction', 0.5))) 'friction', 0.5)))
@ -306,8 +307,9 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
self.setup_standard_powerup_drops() self.setup_standard_powerup_drops()
self._puck_spawn_pos = self.map.get_flag_position(None) self._puck_spawn_pos = self.map.get_flag_position(None)
self._spawn_puck() self._spawn_puck()
#for night mode we need night actor. And same goodies for nigh mode # for night mode we need night actor. And same goodies for nigh mode
if self._nm: self._nightSpawny(),self._flagKaleFlash() if self._nm:
self._nightSpawny(), self._flagKaleFlash()
# Set up the two score regions. # Set up the two score regions.
defs = self.map.defs defs = self.map.defs
@ -317,7 +319,7 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
bs.newnode('region', bs.newnode('region',
attrs={ attrs={
'position': (13.75, 0.85744967453, 0.1095578275), 'position': (13.75, 0.85744967453, 0.1095578275),
'scale': (1.05,1.1,3.8), 'scale': (1.05, 1.1, 3.8),
'type': 'box', 'type': 'box',
'materials': [self._score_region_material] 'materials': [self._score_region_material]
}))) })))
@ -326,7 +328,7 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
bs.newnode('region', bs.newnode('region',
attrs={ attrs={
'position': (-13.55, 0.85744967453, 0.1095578275), 'position': (-13.55, 0.85744967453, 0.1095578275),
'scale': (1.05,1.1,3.8), 'scale': (1.05, 1.1, 3.8),
'type': 'box', 'type': 'box',
'materials': [self._score_region_material] 'materials': [self._score_region_material]
}))) })))
@ -336,45 +338,46 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
def _nightSpawny(self): def _nightSpawny(self):
self.MythBrk = NightMod(position=(0, 0.05744967453, 0)) self.MythBrk = NightMod(position=(0, 0.05744967453, 0))
#spawn some goodies on nightmode for pretty visuals # spawn some goodies on nightmode for pretty visuals
def _flagKaleFlash(self): def _flagKaleFlash(self):
#flags positions # flags positions
kale1 = (-12.45, 0.05744967453, -2.075) kale1 = (-12.45, 0.05744967453, -2.075)
kale2 = (-12.45, 0.05744967453, 2.075) kale2 = (-12.45, 0.05744967453, 2.075)
kale3 = (12.66, 0.03986567039, 2.075) kale3 = (12.66, 0.03986567039, 2.075)
kale4 = (12.66, 0.03986567039, -2.075) kale4 = (12.66, 0.03986567039, -2.075)
flash = bs.newnode("light", flash = bs.newnode("light",
attrs={'position':kale1, attrs={'position': kale1,
'radius':0.15, 'radius': 0.15,
'color':(1.0,1.0,0.7)}) 'color': (1.0, 1.0, 0.7)})
flash = bs.newnode("light", flash = bs.newnode("light",
attrs={'position':kale2, attrs={'position': kale2,
'radius':0.15, 'radius': 0.15,
'color':(1.0,1.0,0.7)}) 'color': (1.0, 1.0, 0.7)})
flash = bs.newnode("light", flash = bs.newnode("light",
attrs={'position':kale3, attrs={'position': kale3,
'radius':0.15, 'radius': 0.15,
'color':(0.7,1.0,1.0)}) 'color': (0.7, 1.0, 1.0)})
flash = bs.newnode("light", flash = bs.newnode("light",
attrs={'position':kale4, attrs={'position': kale4,
'radius':0.15, 'radius': 0.15,
'color':(0.7,1.0,1.0)}) 'color': (0.7, 1.0, 1.0)})
#flags positions # flags positions
def _flagKalesSpawn(self): def _flagKalesSpawn(self):
for team in self.teams: for team in self.teams:
if team.id == 0: if team.id == 0:
_colorTeam0 = team.color _colorTeam0 = team.color
if team.id == 1: if team.id == 1:
_colorTeam1 = team.color _colorTeam1 = team.color
self._MythB = FlagKale(position=(-12.45, 0.05744967453, -2.075),color=_colorTeam0) self._MythB = FlagKale(position=(-12.45, 0.05744967453, -2.075), color=_colorTeam0)
self._MythB2 =FlagKale(position=(-12.45, 0.05744967453, 2.075),color=_colorTeam0) self._MythB2 = FlagKale(position=(-12.45, 0.05744967453, 2.075), color=_colorTeam0)
self._MythB3 =FlagKale(position=(12.66, 0.03986567039, 2.075),color=_colorTeam1) self._MythB3 = FlagKale(position=(12.66, 0.03986567039, 2.075), color=_colorTeam1)
self._MythB4 =FlagKale(position=(12.66, 0.03986567039, -2.075),color=_colorTeam1) self._MythB4 = FlagKale(position=(12.66, 0.03986567039, -2.075), color=_colorTeam1)
def on_team_join(self, team: Team) -> None: def on_team_join(self, team: Team) -> None:
self._update_scoreboard() self._update_scoreboard()
@ -419,8 +422,10 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
# tell scored team players to celebrate and give them to boxing gloves # tell scored team players to celebrate and give them to boxing gloves
if self._grant_power: if self._grant_power:
for player in team.players: for player in team.players:
try: player.actor.node.handlemessage(bs.PowerupMessage('punch')) try:
except: pass player.actor.node.handlemessage(bs.PowerupMessage('punch'))
except:
pass
# Tell all players to celebrate. # Tell all players to celebrate.
for player in team.players: for player in team.players:
@ -442,8 +447,10 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
else: else:
if self._grant_power: if self._grant_power:
for player in team.players: for player in team.players:
try: player.actor.node.handlemessage(bs.PowerupMessage('shield')) try:
except: pass player.actor.node.handlemessage(bs.PowerupMessage('shield'))
except:
pass
self._foghorn_sound.play() self._foghorn_sound.play()
self._cheer_sound.play() self._cheer_sound.play()
@ -510,8 +517,8 @@ class BBGame(bs.TeamGameActivity[Player, Team]):
self._puck = Puck(position=self._puck_spawn_pos) self._puck = Puck(position=self._puck_spawn_pos)
self._puck.light = bs.newnode('light', self._puck.light = bs.newnode('light',
owner=self._puck.node, owner=self._puck.node,
attrs={'intensity':0.3, attrs={'intensity': 0.3,
'height_attenuated':False, 'height_attenuated': False,
'radius':0.2, 'radius': 0.2,
'color': (0.9,0.2,0.9)}) 'color': (0.9, 0.2, 0.9)})
self._puck.node.connectattr('position',self._puck.light,'position') self._puck.node.connectattr('position', self._puck.light, 'position')