Skip to content

Commit 3c2807b

Browse files
committed
matches format fix in bot command and lives balancer.
1 parent 59a1974 commit 3c2807b

2 files changed

Lines changed: 26 additions & 13 deletions

File tree

script/dist/ba_data/python/bascenev1lib/game/elimination.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,21 @@ def _print_lives(self, player: Player) -> None:
506506

507507
@override
508508
def on_player_leave(self, player: Player) -> None:
509+
if player.lives > 0:
510+
members = [tplayer for tplayer in player.team.players if tplayer != player]
511+
lives = player.lives
512+
count = len(members)
513+
if count > 0:
514+
idx = 0
515+
distributed = 0
516+
while distributed < lives:
517+
member = members[idx % count]
518+
if member.is_alive():
519+
member.lives += 1
520+
distributed += 1
521+
idx += 1
522+
if len(self._get_living_teams()) < 2:
523+
self.end_game()
509524
# (Pylint Bug?) pylint: disable=missing-function-docstring
510525
super().on_player_leave(player)
511526
player.icons = []

script/dist/ba_root/mods/utilities/entitybot.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import discord
22
from discord.ext import commands
3-
from discord import app_commands
3+
from discord import app_commands
44
import bacore
55

66

@@ -23,18 +23,16 @@ async def ping(self, ctx):
2323
match_group = app_commands.Group(name='match', description='Match Management')
2424

2525
@match_group.command(name='add',description='Add a match')
26-
async def match_add(self, interaction: discord.Interaction, series_count: int, team_name1: str, team_name2: str, team1_pbids: str, team2_pbids: str):
27-
try:
28-
team1_players = team1_pbids.split(',')
29-
team2_players = team2_pbids.split(',')
30-
if len(team1_players) or len(team2_players) < 4:
31-
await interaction.response.send_message("Enter equal players **4** in both teams")
32-
else:
33-
match = {"series": series_count, "team1": [team_name1, team1_players], "team2": [team_name2, team2_players]}
34-
bacore.tournament.insert(match)
35-
await interaction.response.send_message("Match Appointed")
36-
except Exception as e:
37-
await interaction.response.send_message(e)
26+
async def match_add(self, interaction: discord.Interaction, series_count: int, team_name1: str, team_name2: str, team1_players: list[str], team2_players: list[str]):
27+
try:
28+
if len(team1_players) or len(team2_players) < 1:
29+
await interaction.response.send_message("Every team must have atleast a single player")
30+
else:
31+
match = {"series": series_count, "team1": {team_name1: team1_players}, "team2": {team_name2: team2_players}}
32+
bacore.tournament.insert(match)
33+
await interaction.response.send_message("Match Appointed")
34+
except Exception as e:
35+
await interaction.response.send_message(e)
3836
pass
3937

4038
def main():

0 commit comments

Comments
 (0)