diff --git a/plugins/minigames/botsvsbots.py b/plugins/minigames/botsvsbots.py index ffa903c..c8cd7b0 100644 --- a/plugins/minigames/botsvsbots.py +++ b/plugins/minigames/botsvsbots.py @@ -15,7 +15,9 @@ from __future__ import annotations from typing import TYPE_CHECKING, override -import logging, random, weakref +import logging +import random +import weakref import bascenev1 as bs import efro.debug as Edebug @@ -40,15 +42,18 @@ from bascenev1lib.actor.spazbot import ( if TYPE_CHECKING: from typing import Any, Sequence, Optional, List + class Player(bs.Player['Team']): """Our player type for this game.""" + class SpazBot2(SpazBot): - #custom bots that have custom behaviours requiring more msg and modules from spaz.py will have them imported here. + # custom bots that have custom behaviours requiring more msg and modules from spaz.py will have them imported here. from bascenev1lib.actor.spaz import Spaz, PunchHitMessage + class BouncyBotSemiLite(BouncyBot): - highlight = (1,1,0.8) + highlight = (1, 1, 0.8) punchiness = 0.85 run = False default_boxing_gloves = False @@ -57,9 +62,9 @@ class BouncyBotSemiLite(BouncyBot): class FroshBot(SpazBot): - #Slightly beefier version of BomberBots, with slightly altered behaviour. - color = (0.13,0.13,0.13) - highlight = (0.2,1,1) + # Slightly beefier version of BomberBots, with slightly altered behaviour. + color = (0.13, 0.13, 0.13) + highlight = (0.2, 1, 1) character = 'Bernard' run = True default_bomb_count = 2 @@ -70,16 +75,19 @@ class FroshBot(SpazBot): charge_speed_min = 0.3 default_hitpoints = 1300 + class FroshBotShielded(FroshBot): default_shields = True + class StickyBotShielded(StickyBot): default_shields = True + class IcePuncherBot(SpazBot2): - #A bot who can freeze anyone on punch and is immune to freezing. - color = (0,0,1) - highlight = (.2,.2,1) + # A bot who can freeze anyone on punch and is immune to freezing. + color = (0, 0, 1) + highlight = (.2, .2, 1) character = 'Pascal' run = True punchiness = 0.8 @@ -91,7 +99,7 @@ class IcePuncherBot(SpazBot2): throw_dist_max = 9999 def handlemessage(self, msg): - #Add the ability to freeze anyone on punch. + # Add the ability to freeze anyone on punch. if isinstance(msg, self.PunchHitMessage): node = bs.getcollision().opposingnode try: @@ -101,38 +109,39 @@ class IcePuncherBot(SpazBot2): print('freeze failed.') return super().handlemessage(msg) elif isinstance(msg, bs.FreezeMessage): - pass #resistant to freezing. + pass # resistant to freezing. else: return super().handlemessage(msg) + class IcePuncherBotShielded(IcePuncherBot): default_shields = True class GliderBot(BrawlerBot): - #A bot who can glide on terrain and navigate it safely as if it's ice skating. - color = (0.5,0.5,0.5) - highlight = (0,10,0) + # A bot who can glide on terrain and navigate it safely as if it's ice skating. + color = (0.5, 0.5, 0.5) + highlight = (0, 10, 0) character = 'B-9000' charge_speed_min = 0.3 charge_speed_max = 1.0 def __init__(self) -> None: super().__init__() - self.node.hockey = True #Added the ability to move fast "like in hockey". + self.node.hockey = True # Added the ability to move fast "like in hockey". + class GliderBotShielded(GliderBot): - #Shielded version of GliderBot. + # Shielded version of GliderBot. default_shields = True - class TeamBotSet(SpazBotSet): """Bots that can gather in a team and kill other bots.""" activity: BotsVSBotsGame - def __init__ (self, team: Team) -> None: + def __init__(self, team: Team) -> None: super().__init__() activity = bs.getactivity() self._pro_bots = activity._pro_bots @@ -141,12 +150,10 @@ class TeamBotSet(SpazBotSet): self.spawn_time = activity.spawn_time self._team = weakref.ref(team) - def colorforteam(self, spaz) -> None: spaz.node.color = self.team.color - - def yell(self) -> None: + def yell(self) -> None: for botlist in self._bot_lists: for bot in botlist: if bot: @@ -191,14 +198,12 @@ class TeamBotSet(SpazBotSet): bot.set_player_points(player_pts) bot.update_ai() - - def get_bot_type(self): bot_types = [ BrawlerBot, ChargerBot, BouncyBotSemiLite, - ] + ] if self._punching_bots_only == False: bot_types += [ SpazBot, @@ -209,11 +214,11 @@ class TeamBotSet(SpazBotSet): BrawlerBotProShielded, ChargerBotProShielded, BouncyBot, - ] + ] if self._punching_bots_only == False: bot_types += [ BomberBotProShielded, - ] + ] if self._bonus_bots == True: bot_types += [ IcePuncherBot, @@ -222,7 +227,7 @@ class TeamBotSet(SpazBotSet): if self._punching_bots_only == False: bot_types += [ FroshBot, - ] + ] if self._bonus_bots and self._pro_bots == True: bot_types += [ IcePuncherBotShielded, @@ -232,11 +237,8 @@ class TeamBotSet(SpazBotSet): bot_types += [ FroshBotShielded, StickyBotShielded, - ] - return random.choice(bot_types) - - - + ] + return random.choice(bot_types) @property def team(self) -> Team: @@ -244,7 +246,6 @@ class TeamBotSet(SpazBotSet): return self._team() - class Team(bs.Team[TeamBotSet]): """Our team type for this game.""" @@ -252,16 +253,13 @@ class Team(bs.Team[TeamBotSet]): self.score = 0 self.bots = TeamBotSet(self) - - - # ba_meta export bascenev1.GameActivity class BotsVSBotsGame(bs.TeamGameActivity[bs.Player, Team]): """A game type based on acquiring kills.""" name = 'Bots VS Bots' - description = 'Sit down and enjoy mobs from your team fight the opposing team for you. \n Feel free to enjoy some popcorn with it or place a bet with your friends.' #, self._score_to_win + description = 'Sit down and enjoy mobs from your team fight the opposing team for you. \n Feel free to enjoy some popcorn with it or place a bet with your friends.' # , self._score_to_win @override @classmethod @@ -287,7 +285,7 @@ class BotsVSBotsGame(bs.TeamGameActivity[bs.Player, Team]): def supports_session_type(cls, sessiontype: type[bs.Session]) -> bool: return issubclass(sessiontype, bs.DualTeamSession) - @override + @override @classmethod def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]: return ['Football Stadium'] @@ -315,9 +313,11 @@ class BotsVSBotsGame(bs.TeamGameActivity[bs.Player, Team]): @override def get_instance_description(self) -> str | Sequence: return 'Enjoy the battle.' + @override def get_instance_description_short(self) -> str | Sequence: return 'Enjoy the battle.' + @override def on_team_join(self, team: Team) -> None: self.spawn_team(team) @@ -328,17 +328,16 @@ class BotsVSBotsGame(bs.TeamGameActivity[bs.Player, Team]): def spawn_player(self, player: Player) -> None: return None - - #def team_pois_set + + # def team_pois_set def spawn_team(self, team: Team) -> None: camp = self.map.get_flag_position(team.id) for i in range(self._bots_per_team): team.bots.spawn_bot(team.bots.get_bot_type(), - (camp[0], camp[1] + 1.8, random.randrange(-4,5)), - self.spawn_time, team.bots.colorforteam) + (camp[0], camp[1] + 1.8, random.randrange(-4, 5)), + self.spawn_time, team.bots.colorforteam) bs.timer(float(self.spawn_time) + 1.7, team.bots.yell) - def update(self) -> None: if len(self._get_living_teams()) < 2: @@ -350,7 +349,6 @@ class BotsVSBotsGame(bs.TeamGameActivity[bs.Player, Team]): for team in self.teams if team.bots.have_living_bots() ] - @override def handlemessage(self, msg: Any) -> Any: @@ -360,8 +358,6 @@ class BotsVSBotsGame(bs.TeamGameActivity[bs.Player, Team]): else: return super().handlemessage(msg) return None - - @override def end_game(self) -> None: