[ci] auto-format

This commit is contained in:
SenjuZoro 2023-08-22 00:51:19 +00:00 committed by github-actions[bot]
parent 27d77b6afd
commit 47a1ca8c54

View file

@ -52,19 +52,22 @@ else:
slow = 'Slow' slow = 'Slow'
slowest = 'Slowest' slowest = 'Slowest'
insane = 'Insane' insane = 'Insane'
def ba_get_api_version(): def ba_get_api_version():
return 6 return 6
def ba_get_levels(): def ba_get_levels():
return [babase._level.Level( return [babase._level.Level(
name, name,
gametype=Infection, gametype=Infection,
settings={}, settings={},
preview_texture_name='footballStadiumPreview')] preview_texture_name='footballStadiumPreview')]
class myMine(Bomb): class myMine(Bomb):
#reason for the mine class is so we can add the death zone # reason for the mine class is so we can add the death zone
def __init__(self, def __init__(self,
pos: Sequence[float] = (0.0, 1.0, 0.0)): pos: Sequence[float] = (0.0, 1.0, 0.0)):
Bomb.__init__(self, position=pos, bomb_type='land_mine') Bomb.__init__(self, position=pos, bomb_type='land_mine')
@ -74,17 +77,17 @@ class myMine(Bomb):
self.zone = bs.newnode( self.zone = bs.newnode(
'locator', 'locator',
attrs={ attrs={
'shape':'circle', 'shape': 'circle',
'position':self.node.position, 'position': self.node.position,
'color':(1,0,0), 'color': (1, 0, 0),
'opacity':0.5, 'opacity': 0.5,
'draw_beauty':showInSpace, 'draw_beauty': showInSpace,
'additive':True}) 'additive': True})
bs.animate_array( bs.animate_array(
self.zone, self.zone,
'size', 'size',
1, 1,
{0:[0.0], 0.05:[2*self.rad]}) {0: [0.0], 0.05: [2*self.rad]})
def handlemessage(self, msg: Any) -> Any: def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, bs.DieMessage): if isinstance(msg, bs.DieMessage):
@ -95,18 +98,21 @@ class myMine(Bomb):
self.zone, self.zone,
'size', 'size',
1, 1,
{0:[2*self.rad], 0.05:[0]}) {0: [2*self.rad], 0.05: [0]})
self.zone = None self.zone = None
super().handlemessage(msg) super().handlemessage(msg)
else: else:
super().handlemessage(msg) super().handlemessage(msg)
class Player(bs.Player['Team']): class Player(bs.Player['Team']):
"""Our player type for this game.""" """Our player type for this game."""
def __init__(self) -> None: def __init__(self) -> None:
self.survival_seconds: Optional[int] = None self.survival_seconds: Optional[int] = None
self.death_time: Optional[float] = None self.death_time: Optional[float] = None
class Team(bs.Team[Player]): class Team(bs.Team[Player]):
"""Our team type for this game.""" """Our team type for this game."""
@ -122,7 +128,6 @@ class Infection(bs.TeamGameActivity[Player, Team]):
announce_player_deaths = True announce_player_deaths = True
allow_mid_activity_joins = False allow_mid_activity_joins = False
@classmethod @classmethod
def get_available_settings( def get_available_settings(
cls, sessiontype: Type[bs.Session]) -> List[babase.Setting]: cls, sessiontype: Type[bs.Session]) -> List[babase.Setting]:
@ -151,7 +156,7 @@ class Infection(bs.TeamGameActivity[Player, Team]):
choices=[ choices=[
('10s', 10), ('10s', 10),
('20s', 20), ('20s', 20),
('30s',30), ('30s', 30),
('1 Minute', 60), ('1 Minute', 60),
], ],
default=20, default=20,
@ -233,7 +238,7 @@ class Infection(bs.TeamGameActivity[Player, Team]):
player.survival_seconds = self._timer.getstarttime() player.survival_seconds = self._timer.getstarttime()
bs.broadcastmessage( bs.broadcastmessage(
babase.Lstr(resource='playerDelayedJoinText', babase.Lstr(resource='playerDelayedJoinText',
subs=[('${PLAYER}', player.getname(full=True))]), subs=[('${PLAYER}', player.getname(full=True))]),
color=(0, 1, 0), color=(0, 1, 0),
) )
return return
@ -256,35 +261,35 @@ class Infection(bs.TeamGameActivity[Player, Team]):
if not m.node: if not m.node:
self.mines.remove(m) self.mines.remove(m)
else: else:
#First, check if any player is within the current death zone # First, check if any player is within the current death zone
for player in self.players: for player in self.players:
if not player.actor is None: if not player.actor is None:
if player.actor.is_alive(): if player.actor.is_alive():
p1 = player.actor.node.position p1 = player.actor.node.position
p2 = m.node.position p2 = m.node.position
diff = (babase.Vec3(p1[0]-p2[0], diff = (babase.Vec3(p1[0]-p2[0],
0.0, 0.0,
p1[2]-p2[2])) p1[2]-p2[2]))
dist = (diff.length()) dist = (diff.length())
if dist < m.rad: if dist < m.rad:
player.actor.handlemessage(bs.DieMessage()) player.actor.handlemessage(bs.DieMessage())
#Now tell the circle to grow to the new size # Now tell the circle to grow to the new size
if m.rad < self._max_size: if m.rad < self._max_size:
bs.animate_array( bs.animate_array(
m.zone, 'size' ,1, m.zone, 'size', 1,
{0:[m.rad*2], {0: [m.rad*2],
self._update_rate:[(m.rad+self._growth_rate)*2]}) self._update_rate: [(m.rad+self._growth_rate)*2]})
# Tell the circle to be the new size. # Tell the circle to be the new size.
# This will be the new check radius next time. # This will be the new check radius next time.
m.rad += self._growth_rate m.rad += self._growth_rate
#make a new mine if needed. # make a new mine if needed.
if self.mine_count < self._max_mines: if self.mine_count < self._max_mines:
pos = self.getRandomPowerupPoint() pos = self.getRandomPowerupPoint()
self.mine_count += 1 self.mine_count += 1
self._flash_mine(pos) self._flash_mine(pos)
bs.timer(0.95, babase.Call(self._make_mine, pos)) bs.timer(0.95, babase.Call(self._make_mine, pos))
def _make_mine(self,posn: Sequence[float]) -> None: def _make_mine(self, posn: Sequence[float]) -> None:
m = myMine(pos=posn) m = myMine(pos=posn)
m.arm() m.arm()
self.mines.append(m) self.mines.append(m)
@ -390,9 +395,9 @@ class Infection(bs.TeamGameActivity[Player, Team]):
light_color = babase._math.normalized_color(color) light_color = babase._math.normalized_color(color)
display_color = _babase.safecolor(color, target_intensity=0.75) display_color = _babase.safecolor(color, target_intensity=0.75)
spaz = PlayerSpaz(color=color, spaz = PlayerSpaz(color=color,
highlight=highlight, highlight=highlight,
character=player.character, character=player.character,
player=player) player=player)
player.actor = spaz player.actor = spaz
assert spaz.node assert spaz.node
@ -426,45 +431,46 @@ class Infection(bs.TeamGameActivity[Player, Team]):
return spaz return spaz
def getRandomPowerupPoint(self) -> None: def getRandomPowerupPoint(self) -> None:
#So far, randomized points only figured out for mostly rectangular maps. # So far, randomized points only figured out for mostly rectangular maps.
#Boxes will still fall through holes, but shouldn't be terrible problem (hopefully) # Boxes will still fall through holes, but shouldn't be terrible problem (hopefully)
#If you add stuff here, need to add to "supported maps" above. # If you add stuff here, need to add to "supported maps" above.
#['Doom Shroom', 'Rampage', 'Hockey Stadium', 'Courtyard', 'Crag Castle', 'Big G', 'Football Stadium'] # ['Doom Shroom', 'Rampage', 'Hockey Stadium', 'Courtyard', 'Crag Castle', 'Big G', 'Football Stadium']
myMap = self.map.getname() myMap = self.map.getname()
#print(myMap) # print(myMap)
if myMap == 'Doom Shroom': if myMap == 'Doom Shroom':
while True: while True:
x = random.uniform(-1.0,1.0) x = random.uniform(-1.0, 1.0)
y = random.uniform(-1.0,1.0) y = random.uniform(-1.0, 1.0)
if x*x+y*y < 1.0: break if x*x+y*y < 1.0:
return ((8.0*x,2.5,-3.5+5.0*y)) break
return ((8.0*x, 2.5, -3.5+5.0*y))
elif myMap == 'Rampage': elif myMap == 'Rampage':
x = random.uniform(-6.0,7.0) x = random.uniform(-6.0, 7.0)
y = random.uniform(-6.0,-2.5) y = random.uniform(-6.0, -2.5)
return ((x, 5.2, y)) return ((x, 5.2, y))
elif myMap == 'Hockey Stadium': elif myMap == 'Hockey Stadium':
x = random.uniform(-11.5,11.5) x = random.uniform(-11.5, 11.5)
y = random.uniform(-4.5,4.5) y = random.uniform(-4.5, 4.5)
return ((x, 0.2, y)) return ((x, 0.2, y))
elif myMap == 'Courtyard': elif myMap == 'Courtyard':
x = random.uniform(-4.3,4.3) x = random.uniform(-4.3, 4.3)
y = random.uniform(-4.4,0.3) y = random.uniform(-4.4, 0.3)
return ((x, 3.0, y)) return ((x, 3.0, y))
elif myMap == 'Crag Castle': elif myMap == 'Crag Castle':
x = random.uniform(-6.7,8.0) x = random.uniform(-6.7, 8.0)
y = random.uniform(-6.0,0.0) y = random.uniform(-6.0, 0.0)
return ((x, 10.0, y)) return ((x, 10.0, y))
elif myMap == 'Big G': elif myMap == 'Big G':
x = random.uniform(-8.7,8.0) x = random.uniform(-8.7, 8.0)
y = random.uniform(-7.5,6.5) y = random.uniform(-7.5, 6.5)
return ((x, 3.5, y)) return ((x, 3.5, y))
elif myMap == 'Football Stadium': elif myMap == 'Football Stadium':
x = random.uniform(-12.5,12.5) x = random.uniform(-12.5, 12.5)
y = random.uniform(-5.0,5.5) y = random.uniform(-5.0, 5.5)
return ((x, 0.32, y)) return ((x, 0.32, y))
else: else:
x = random.uniform(-5.0,5.0) x = random.uniform(-5.0, 5.0)
y = random.uniform(-6.0,0.0) y = random.uniform(-6.0, 0.0)
return ((x, 8.0, y)) return ((x, 8.0, y))
def end_game(self) -> None: def end_game(self) -> None: