mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
[ci] auto-format
This commit is contained in:
parent
d513809ad3
commit
c052a1d7c1
6 changed files with 883 additions and 824 deletions
|
|
@ -6,7 +6,8 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import ba, _ba
|
||||
import ba
|
||||
import _ba
|
||||
from bastd.actor.playerspaz import PlayerSpaz
|
||||
from bastd.actor.scoreboard import Scoreboard
|
||||
from bastd.actor.powerupbox import PowerupBoxFactory
|
||||
|
|
@ -19,6 +20,7 @@ if TYPE_CHECKING:
|
|||
|
||||
bsuSpaz = None
|
||||
|
||||
|
||||
def getlanguage(text, sub: str = ''):
|
||||
lang = _ba.app.lang.language
|
||||
translate = {
|
||||
|
|
@ -45,16 +47,19 @@ def getlanguage(text, sub: str = ''):
|
|||
}
|
||||
|
||||
languages = ['Spanish', 'Portuguese', 'English']
|
||||
if lang not in languages: lang = 'English'
|
||||
if lang not in languages:
|
||||
lang = 'English'
|
||||
|
||||
if text not in translate:
|
||||
return text
|
||||
return translate[text][lang]
|
||||
|
||||
|
||||
class BallDiedMessage:
|
||||
def __init__(self, ball: Ball):
|
||||
self.ball = ball
|
||||
|
||||
|
||||
class Ball(ba.Actor):
|
||||
def __init__(self, position: Sequence[float] = (0.0, 1.0, 0.0)):
|
||||
super().__init__()
|
||||
|
|
@ -132,12 +137,16 @@ class Team(ba.Team[Player]):
|
|||
def __init__(self) -> None:
|
||||
self.score = 0
|
||||
|
||||
|
||||
class Points:
|
||||
postes = dict()
|
||||
postes['pal_0'] = (10.64702320098877, 0.0000000000000000, 0.0000000000000000) #10.736066818237305, 0.3002409040927887, 0.5281256437301636
|
||||
# 10.736066818237305, 0.3002409040927887, 0.5281256437301636
|
||||
postes['pal_0'] = (10.64702320098877, 0.0000000000000000, 0.0000000000000000)
|
||||
postes['pal_1'] = (-10.64702320098877, 0.0000000000000000, 0.0000000000000000)
|
||||
|
||||
# ba_meta export game
|
||||
|
||||
|
||||
class BasketGame(ba.TeamGameActivity[Player, Team]):
|
||||
|
||||
name = getlanguage('Name')
|
||||
|
|
@ -414,6 +423,7 @@ class BasketGame(ba.TeamGameActivity[Player, Team]):
|
|||
assert self._ball_spawn_pos is not None
|
||||
self._ball = Ball(position=self._ball_spawn_pos)
|
||||
|
||||
|
||||
class Aro(ba.Actor):
|
||||
def __init__(self, team: int = 0,
|
||||
position: Sequence[float] = (0.0, 1.0, 0.0)):
|
||||
|
|
@ -486,7 +496,8 @@ class Aro(ba.Actor):
|
|||
try:
|
||||
id = 0 if team == 1 else 1
|
||||
color = act.teams[id].color
|
||||
except: color = (1,1,1)
|
||||
except:
|
||||
color = (1, 1, 1)
|
||||
|
||||
while locs_count > 1:
|
||||
scale = (1.5 * 0.1 * locs_count) + 0.8
|
||||
|
|
@ -523,6 +534,7 @@ class Aro(ba.Actor):
|
|||
else:
|
||||
super().handlemessage(msg)
|
||||
|
||||
|
||||
class Cuadro(ba.Actor):
|
||||
def __init__(self, team: int = 0,
|
||||
position: Sequence[float] = (0.0, 1.0, 0.0)):
|
||||
|
|
@ -557,7 +569,8 @@ class Cuadro(ba.Actor):
|
|||
try:
|
||||
id = 0 if team == 1 else 1
|
||||
color = act.teams[id].color
|
||||
except: color = (1,1,1)
|
||||
except:
|
||||
color = (1, 1, 1)
|
||||
|
||||
while (count_y != 1):
|
||||
|
||||
|
|
@ -576,7 +589,6 @@ class Cuadro(ba.Actor):
|
|||
'additive': False}))
|
||||
count -= 1
|
||||
|
||||
|
||||
count = old_count
|
||||
pos[1] += 0.2
|
||||
pos[2] = oldpos[2]
|
||||
|
|
@ -589,6 +601,7 @@ class Cuadro(ba.Actor):
|
|||
else:
|
||||
super().handlemessage(msg)
|
||||
|
||||
|
||||
class Palos(ba.Actor):
|
||||
def __init__(self, team: int = 0,
|
||||
position: Sequence[float] = (0.0, 1.0, 0.0)):
|
||||
|
|
@ -656,7 +669,8 @@ class Palos(ba.Actor):
|
|||
position = self._pos
|
||||
if team == 0:
|
||||
pos = (position[0]-0.8, position[1] + 2.0 + _y, position[2])
|
||||
else: pos = (position[0]+0.8, position[1] + 2.0 + _y, position[2])
|
||||
else:
|
||||
pos = (position[0]+0.8, position[1] + 2.0 + _y, position[2])
|
||||
|
||||
if self.aro is None:
|
||||
self.aro = Aro(team, pos).autoretain()
|
||||
|
|
@ -672,6 +686,7 @@ class Palos(ba.Actor):
|
|||
else:
|
||||
super().handlemessage(msg)
|
||||
|
||||
|
||||
class BasketMap(maps.FootballStadium):
|
||||
name = 'BasketBall Stadium'
|
||||
|
||||
|
|
@ -691,6 +706,7 @@ class BasketMap(maps.FootballStadium):
|
|||
gnode.vr_camera_offset = (0, -0.8, -1.1)
|
||||
gnode.vr_near_clip = 0.5
|
||||
|
||||
|
||||
class BasketMapV2(maps.HockeyStadium):
|
||||
name = 'BasketBall Stadium V2'
|
||||
|
||||
|
|
@ -750,5 +766,6 @@ class BasketMapV2(maps.HockeyStadium):
|
|||
'materials': [self.collision]}),
|
||||
]
|
||||
|
||||
|
||||
ba._map.register_map(BasketMap)
|
||||
ba._map.register_map(BasketMapV2)
|
||||
|
|
@ -12,6 +12,7 @@ from ba import _gameutils
|
|||
import ba
|
||||
import random
|
||||
|
||||
|
||||
class CustomText(ba.Actor):
|
||||
"""Text that pops up above a position to denote something special.
|
||||
|
||||
|
|
@ -83,6 +84,7 @@ class CustomText(ba.Actor):
|
|||
self._combine.connectattr('output', self.node, 'color')
|
||||
self._die_timer = ba.Timer(
|
||||
lifespan, ba.WeakCall(self.handlemessage, ba.DieMessage()))
|
||||
|
||||
def handlemessage(self, msg: Any) -> Any:
|
||||
assert not self.expired
|
||||
if isinstance(msg, ba.DieMessage):
|
||||
|
|
@ -91,11 +93,14 @@ class CustomText(ba.Actor):
|
|||
else:
|
||||
super().handlemessage(msg)
|
||||
|
||||
|
||||
class Player(ba.Player['Team']):
|
||||
"""Our player type for this game."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.score = 0
|
||||
|
||||
|
||||
class Team(ba.Team[Player]):
|
||||
"""Our team type for this game."""
|
||||
|
||||
|
|
@ -103,9 +108,12 @@ class Team(ba.Team[Player]):
|
|||
self.score = 0
|
||||
|
||||
# ba_meta export game
|
||||
|
||||
|
||||
class SimonSays(ba.TeamGameActivity[Player, Team]):
|
||||
name = "Simon Says"
|
||||
description = "You have to better do what Simon says!"
|
||||
|
||||
@classmethod
|
||||
def get_available_settings(cls, sessiontype: Type[ba.Session]) -> List[ba.Setting]:
|
||||
settings = [
|
||||
|
|
@ -184,7 +192,8 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
|
|||
self.n9 = ba.newnode('locator', attrs={'shape': 'circle', 'position': (4, 0, 2),
|
||||
'color': (1, 1, 1), 'opacity': 0.5,
|
||||
'draw_beauty': True, 'additive': True})
|
||||
self.options = ["red", "green", "blue", "yellow", "teal", "purple", "gray", "orange", "white", "top", "bottom", "middle row", "left", "right", "center column", "outside"]
|
||||
self.options = ["red", "green", "blue", "yellow", "teal", "purple", "gray", "orange",
|
||||
"white", "top", "bottom", "middle row", "left", "right", "center column", "outside"]
|
||||
self.default_music = ba.MusicType.FLAG_CATCHER
|
||||
|
||||
def get_instance_description(self) -> str:
|
||||
|
|
@ -224,7 +233,8 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
def spawn_player(self, player: PlayerType) -> ba.Actor:
|
||||
assert player
|
||||
spaz = self.spawn_player_spaz(player, position=(0 + random.uniform(-3.6, 3.6), 2.9, -2 + random.uniform(-3.6, 3.6)))
|
||||
spaz = self.spawn_player_spaz(player, position=(
|
||||
0 + random.uniform(-3.6, 3.6), 2.9, -2 + random.uniform(-3.6, 3.6)))
|
||||
assert spaz.node
|
||||
spaz.connect_controls_to_player(
|
||||
enable_bomb=False,
|
||||
|
|
@ -234,24 +244,31 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
|
|||
enable_jump=self.settings["Enable Jumping"])
|
||||
|
||||
def call_round(self) -> None:
|
||||
if self.ended: return
|
||||
if self.ended:
|
||||
return
|
||||
self.round_num += 1
|
||||
self.num = random.randint(0, 15)
|
||||
self.numa = self.num
|
||||
self.simon = random.choice([True, False])
|
||||
false_prefix = random.choices(['Simon say r', 'Simon said r', 'Simon r', 'Simons says r', 'Simons r', 'R'], weights=[35,45,45,39,49,100])[0]
|
||||
false_prefix = random.choices(['Simon say r', 'Simon said r', 'Simon r',
|
||||
'Simons says r', 'Simons r', 'R'], weights=[35, 45, 45, 39, 49, 100])[0]
|
||||
if self.numa < 9:
|
||||
if not self.simon: line = false_prefix + "un to the " + self.options[self.numa] + " circle!"
|
||||
else: line = "Run to the " + self.options[self.numa] + " circle!"
|
||||
if not self.simon:
|
||||
line = false_prefix + "un to the " + self.options[self.numa] + " circle!"
|
||||
else:
|
||||
line = "Run to the " + self.options[self.numa] + " circle!"
|
||||
|
||||
elif self.numa < 15:
|
||||
if not self.simon: line = false_prefix + "un to the " + self.options[self.numa] + "!"
|
||||
else: line = "Run to the " + self.options[self.numa] + "!"
|
||||
if not self.simon:
|
||||
line = false_prefix + "un to the " + self.options[self.numa] + "!"
|
||||
else:
|
||||
line = "Run to the " + self.options[self.numa] + "!"
|
||||
|
||||
else:
|
||||
if not self.simon: line = false_prefix + "un outside of the circles!"
|
||||
else: line = "Run outside of the circles!"
|
||||
|
||||
if not self.simon:
|
||||
line = false_prefix + "un outside of the circles!"
|
||||
else:
|
||||
line = "Run outside of the circles!"
|
||||
|
||||
if self.simon:
|
||||
line = "Simon says " + line[0].lower() + line[1:]
|
||||
|
|
@ -263,9 +280,11 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
|
|||
duration=self.lifespan,
|
||||
scale=2.0).autoretain()
|
||||
self.now = 6
|
||||
|
||||
def dummy_check():
|
||||
self.string = "...."
|
||||
self.check_round()
|
||||
|
||||
def set_counter():
|
||||
self.now = self.now - 1
|
||||
if self.now == 0:
|
||||
|
|
@ -276,39 +295,57 @@ class SimonSays(ba.TeamGameActivity[Player, Team]):
|
|||
else:
|
||||
self.ct_text.text = str(self.now)
|
||||
ba.playsound(ba.getsound('tick'))
|
||||
self.counter_loop = ba.Timer(self.speed, set_counter ,timeformat=ba.TimeFormat.MILLISECONDS,repeat=True)
|
||||
self.counter_loop = ba.Timer(self.speed, set_counter,
|
||||
timeformat=ba.TimeFormat.MILLISECONDS, repeat=True)
|
||||
|
||||
def check_round(self) -> None:
|
||||
if self.ended: return
|
||||
if self.ended:
|
||||
return
|
||||
for player in self.players:
|
||||
if player.is_alive():
|
||||
safe = True if self.options[self.numa] in self.in_circle(player.actor.node.position_center) else False
|
||||
safe = True if self.options[self.numa] in self.in_circle(
|
||||
player.actor.node.position_center) else False
|
||||
if ((self.simon and safe == False) or ((not self.simon) and safe == True)):
|
||||
player.team.score = self.round_num
|
||||
player.actor.handlemessage(ba.DieMessage())
|
||||
ba.timer(1633, self.call_round, timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
|
||||
|
||||
def in_circle(self, pos) -> None:
|
||||
circles = []
|
||||
x = pos[0]
|
||||
z = pos[2]
|
||||
if (x + 4) ** 2 + (z + 6) ** 2 < 4: circles.append("red")
|
||||
elif (x) ** 2 + (z + 6) ** 2 < 4: circles.append("green")
|
||||
elif (x - 4) ** 2 + (z + 6) ** 2 < 4: circles.append("blue")
|
||||
elif (x + 4) ** 2 + (z + 2) ** 2 < 4: circles.append("yellow")
|
||||
elif (x) ** 2 + (z + 2) ** 2 < 4: circles.append("teal")
|
||||
elif (x - 4) ** 2 + (z + 2) ** 2 < 4: circles.append("purple")
|
||||
elif (x + 4) ** 2 + (z - 2) ** 2 < 4: circles.append("gray")
|
||||
elif (x) ** 2 + (z - 2) ** 2 < 4: circles.append("orange")
|
||||
elif (x - 4) ** 2 + (z - 2) ** 2 < 4: circles.append("white")
|
||||
else: circles.append("outside")
|
||||
if x < -2: circles.append("left")
|
||||
if x > 2: circles.append("right")
|
||||
if x > -2 and x < 2: circles.append("center column")
|
||||
if z > 0: circles.append("bottom")
|
||||
if z < -4: circles.append("top")
|
||||
if z < 0 and z > -4: circles.append("middle row")
|
||||
if (x + 4) ** 2 + (z + 6) ** 2 < 4:
|
||||
circles.append("red")
|
||||
elif (x) ** 2 + (z + 6) ** 2 < 4:
|
||||
circles.append("green")
|
||||
elif (x - 4) ** 2 + (z + 6) ** 2 < 4:
|
||||
circles.append("blue")
|
||||
elif (x + 4) ** 2 + (z + 2) ** 2 < 4:
|
||||
circles.append("yellow")
|
||||
elif (x) ** 2 + (z + 2) ** 2 < 4:
|
||||
circles.append("teal")
|
||||
elif (x - 4) ** 2 + (z + 2) ** 2 < 4:
|
||||
circles.append("purple")
|
||||
elif (x + 4) ** 2 + (z - 2) ** 2 < 4:
|
||||
circles.append("gray")
|
||||
elif (x) ** 2 + (z - 2) ** 2 < 4:
|
||||
circles.append("orange")
|
||||
elif (x - 4) ** 2 + (z - 2) ** 2 < 4:
|
||||
circles.append("white")
|
||||
else:
|
||||
circles.append("outside")
|
||||
if x < -2:
|
||||
circles.append("left")
|
||||
if x > 2:
|
||||
circles.append("right")
|
||||
if x > -2 and x < 2:
|
||||
circles.append("center column")
|
||||
if z > 0:
|
||||
circles.append("bottom")
|
||||
if z < -4:
|
||||
circles.append("top")
|
||||
if z < 0 and z > -4:
|
||||
circles.append("middle row")
|
||||
return circles
|
||||
|
||||
def handlemessage(self, msg) -> None:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class NewBlast(Blast):
|
|||
else:
|
||||
return super().handlemessage(msg)
|
||||
|
||||
|
||||
@dataclass
|
||||
class RaceMine:
|
||||
"""Holds info about a mine on the track."""
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class PlayerSpaz_Zom(PlayerSpaz):
|
|||
return super().handlemessage(m)
|
||||
return None
|
||||
|
||||
|
||||
class PlayerZombie(PlayerSpaz):
|
||||
def handlemessage(self, m: Any) -> Any:
|
||||
if isinstance(m, ba.HitMessage):
|
||||
|
|
@ -101,6 +102,7 @@ class PlayerZombie(PlayerSpaz):
|
|||
else:
|
||||
super().handlemessage(m)
|
||||
|
||||
|
||||
class zBotSet(SpazBotSet):
|
||||
def start_moving(self) -> None:
|
||||
"""Start processing bot AI updates so they start doing their thing."""
|
||||
|
|
@ -139,6 +141,7 @@ class zBotSet(SpazBotSet):
|
|||
bot.set_player_points(player_pts)
|
||||
bot.update_ai()
|
||||
|
||||
|
||||
class Team(ba.Team[Player]):
|
||||
"""Our team type for this game."""
|
||||
|
||||
|
|
@ -434,7 +437,6 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
|
|||
icon.update_for_lives()
|
||||
xval += x_offs
|
||||
|
||||
|
||||
def _get_spawn_point(self, player: Player) -> ba.Vec3 | None:
|
||||
del player # Unused.
|
||||
|
||||
|
|
@ -692,7 +694,8 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
elif isinstance(msg, SpazBotDiedMessage):
|
||||
self._onSpazBotDied(msg)
|
||||
super().handlemessage(msg)#bs.PopupText("died",position=self._position,color=popupColor,scale=popupScale).autoRetain()
|
||||
# bs.PopupText("died",position=self._position,color=popupColor,scale=popupScale).autoRetain()
|
||||
super().handlemessage(msg)
|
||||
else:
|
||||
super().handlemessage(msg)
|
||||
|
||||
|
|
@ -764,7 +767,8 @@ class ZombieHorde(ba.TeamGameActivity[Player, Team]):
|
|||
while True:
|
||||
x = 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:
|
||||
break
|
||||
return ((8.0*x, 8.0, -3.5+5.0*y))
|
||||
elif myMap == 'Rampage':
|
||||
x = random.uniform(-6.0, 7.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue