|
|
|
@ -1,25 +1,18 @@
|
|
|
|
|
import os
|
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
# from typing import Union
|
|
|
|
|
|
|
|
|
|
import discord
|
|
|
|
|
from discord.ext import commands
|
|
|
|
|
|
|
|
|
|
from redbot.core.utils.chat_formatting import pagify
|
|
|
|
|
from redbot.core.utils.chat_formatting import box
|
|
|
|
|
from redbot.core import Config
|
|
|
|
|
from redbot.core import checks
|
|
|
|
|
from redbot.core.utils.chat_formatting import box
|
|
|
|
|
from redbot.core.utils.chat_formatting import pagify
|
|
|
|
|
|
|
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
# from typing import Union
|
|
|
|
|
|
|
|
|
|
# 0 - Robin, 1 - Single, 2 - Double, 3 - Triple, 4 - Guarentee, 5 - Compass
|
|
|
|
|
# 0 - Robin, 1 - Single, 2 - Double, 3 - Triple, 4 - Guarantee, 5 - Compass
|
|
|
|
|
T_TYPES = {0: "Round Robin", 1: "Single Elimination",
|
|
|
|
|
2: "Double Elimination", 3: "Triple Elimination",
|
|
|
|
|
4: "3 Game Guarentee", 5: "Compass Draw"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4: "3 Game Guarantee", 5: "Compass Draw"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Fight:
|
|
|
|
@ -85,11 +78,8 @@ class Fight:
|
|
|
|
|
self.config.register_global(**default_global)
|
|
|
|
|
self.config.register_guild(**default_guild)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ************************Fight command group start************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@commands.group()
|
|
|
|
|
@commands.guild_only()
|
|
|
|
|
async def fight(self, ctx):
|
|
|
|
@ -189,7 +179,6 @@ class Fight:
|
|
|
|
|
"""Shows the full bracket"""
|
|
|
|
|
await ctx.send("Todo Bracket Full")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# **********************Fightset command group start*********************
|
|
|
|
|
|
|
|
|
|
@commands.group()
|
|
|
|
@ -428,7 +417,6 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
await ctx.send("Tournament Open status is now set to: " + str(currFight["OPEN"]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@fightset.command(name="name")
|
|
|
|
|
async def fightset_name(self, ctx, inname, tID=None):
|
|
|
|
|
"""Renames the tournament"""
|
|
|
|
@ -449,6 +437,7 @@ class Fight:
|
|
|
|
|
@fightset.command(name="start")
|
|
|
|
|
async def fightset_start(self, ctx):
|
|
|
|
|
"""Starts the current tournament, must run setup first"""
|
|
|
|
|
|
|
|
|
|
def check(m): # Check Message from author
|
|
|
|
|
return m.author == ctx.author and m.channel == ctx.channel
|
|
|
|
|
|
|
|
|
@ -472,7 +461,8 @@ class Fight:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if currFight["TYPEDATA"]: # Empty dicionary {} resolves to False
|
|
|
|
|
await ctx.send("Looks like this tournament has already started.\nDo you want to delete all match data and restart? (yes/no)")
|
|
|
|
|
await ctx.send(
|
|
|
|
|
"Looks like this tournament has already started.\nDo you want to delete all match data and restart? (yes/no)")
|
|
|
|
|
# answer = await self.bot.wait_for_message(timeout=120, author=author)
|
|
|
|
|
try:
|
|
|
|
|
answer = await self.bot.wait_for('message', check=check, timeout=120)
|
|
|
|
@ -501,7 +491,8 @@ class Fight:
|
|
|
|
|
Type: 0 (Round Robin)"""
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
# currServ = self.the_data[guild.id]
|
|
|
|
|
tID = str(len(await self.config.guild(ctx.guild).tourneys())) # Can just be len without +1, tourney 0 makes len 1, tourney 1 makes len 2, etc
|
|
|
|
|
tID = str(len(await self.config.guild(
|
|
|
|
|
ctx.guild).tourneys())) # Can just be len without +1, tourney 0 makes len 1, tourney 1 makes len 2, etc
|
|
|
|
|
|
|
|
|
|
# currServ["CURRENT"] = tID
|
|
|
|
|
currFight = self.default_tourney.copy()
|
|
|
|
@ -516,8 +507,10 @@ class Fight:
|
|
|
|
|
@fightset.command(name="stop")
|
|
|
|
|
async def fightset_stop(self, ctx):
|
|
|
|
|
"""Stops current tournament"""
|
|
|
|
|
|
|
|
|
|
def check(m): # Check Message from author
|
|
|
|
|
return m.author == ctx.author and m.channel == ctx.channel
|
|
|
|
|
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
if not await self._activefight(ctx):
|
|
|
|
|
await ctx.send("No active fight to adjust")
|
|
|
|
@ -526,7 +519,8 @@ class Fight:
|
|
|
|
|
# author = ctx.message.author
|
|
|
|
|
# currServ = self.the_data[guild.id]
|
|
|
|
|
|
|
|
|
|
await ctx.send("Current fight ID is "+str(await self.config.guild(ctx.guild).current())+"\nOkay to stop? (yes/no)")
|
|
|
|
|
await ctx.send(
|
|
|
|
|
"Current fight ID is " + str(await self.config.guild(ctx.guild).current()) + "\nOkay to stop? (yes/no)")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
answer = await self.bot.wait_for('message', check=check, timeout=120)
|
|
|
|
@ -882,7 +876,7 @@ class Fight:
|
|
|
|
|
theR = theT["TYPEDATA"]["SCHEDULE"][theT["TYPEDATA"]["ROUND"]]
|
|
|
|
|
|
|
|
|
|
for mID in theR:
|
|
|
|
|
if not await self._rr_matchover(ctx, tID, mID):
|
|
|
|
|
if not await self._rr_matchover(guild, tID, mID):
|
|
|
|
|
match = theT["TYPEDATA"]["MATCHES"][mID]
|
|
|
|
|
if ((match["USERSCORE1"]["SCORE1"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) !=
|
|
|
|
|
(match["USERSCORE1"]["SCORE2"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) and
|
|
|
|
@ -891,8 +885,10 @@ class Fight:
|
|
|
|
|
(match["USERSCORE1"]["SCORE1"] == match["USERSCORE2"]["SCORE1"]) and
|
|
|
|
|
(match["USERSCORE1"]["SCORE2"] == match["USERSCORE2"]["SCORE2"])):
|
|
|
|
|
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["SCORE1"] = theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE1"]["SCORE1"]
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["SCORE1"] = theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE2"]["SCORE2"]
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["SCORE1"] = theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE1"][
|
|
|
|
|
"SCORE1"]
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["SCORE1"] = theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE2"][
|
|
|
|
|
"SCORE2"]
|
|
|
|
|
await self._save_fight(ctx, tID, theT)
|
|
|
|
|
else:
|
|
|
|
|
await self._rr_report_dispute(guild, tID, mID)
|
|
|
|
@ -902,10 +898,11 @@ class Fight:
|
|
|
|
|
matches = theT["TYPEDATA"]["MATCHES"]
|
|
|
|
|
schedule = theT["TYPEDATA"]["SCHEDULE"]
|
|
|
|
|
|
|
|
|
|
for round in schedule:
|
|
|
|
|
for mID in round:
|
|
|
|
|
for rnd in schedule:
|
|
|
|
|
for mID in rnd:
|
|
|
|
|
teamnum = await self._rr_matchperms(guild, tID, userid, mID)
|
|
|
|
|
if teamnum and not await self._rr_matchover(guild, tID, mID): # User is in this match, check if it's done yet
|
|
|
|
|
if teamnum and not await self._rr_matchover(guild, tID,
|
|
|
|
|
mID): # User is in this match, check if it's done yet
|
|
|
|
|
return mID
|
|
|
|
|
|
|
|
|
|
return False # All matches done or not in tourney
|
|
|
|
@ -918,7 +915,6 @@ class Fight:
|
|
|
|
|
(match["SCORE2"] == math.ceil(theT["RULES"]["BESTOF"] / 2))):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
async def _rr_roundover(self, ctx: commands.Context, tID):
|
|
|
|
@ -926,7 +922,7 @@ class Fight:
|
|
|
|
|
theR = theT["TYPEDATA"]["SCHEDULE"][theT["TYPEDATA"]["ROUND"]]
|
|
|
|
|
|
|
|
|
|
for mID in theR:
|
|
|
|
|
if not await self._rr_matchover(ctx, tID, mID):
|
|
|
|
|
if not await self._rr_matchover(ctx.guild, tID, mID):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
@ -986,8 +982,8 @@ class Fight:
|
|
|
|
|
outembed = discord.Embed(title="Match ID: " + mID, color=0x0000bf)
|
|
|
|
|
outembed.add_field(name="Team 1", value=mention1, inline=False)
|
|
|
|
|
outembed.add_field(name="Team 2", value=mention2, inline=False)
|
|
|
|
|
outembed.set_footer(text=(await self._get_win_str())+" Report Win || "+(await self._get_loss_str())+" Report Loss || "+(await self._get_dispute_str())+" Dispute Result")
|
|
|
|
|
|
|
|
|
|
outembed.set_footer(text=(await self._get_win_str()) + " Report Win || " + (
|
|
|
|
|
await self._get_loss_str()) + " Report Loss || " + (await self._get_dispute_str()) + " Dispute Result")
|
|
|
|
|
|
|
|
|
|
if channel:
|
|
|
|
|
message = await channel.send(embed=outembed)
|
|
|
|
@ -1001,7 +997,6 @@ class Fight:
|
|
|
|
|
trackmessage["GUILDID"] = ctx.guild.id
|
|
|
|
|
await self._save_tracker(ctx, message.id, trackmessage)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# await ctx.send(team1 + " vs " + team2 + " || Match ID: " + match)
|
|
|
|
|
|
|
|
|
|
async def _rr_start(self, ctx, tID):
|
|
|
|
@ -1009,7 +1004,6 @@ class Fight:
|
|
|
|
|
await self._rr_setup(ctx, tID)
|
|
|
|
|
channel = await self._get_announcechnnl(ctx.guild)
|
|
|
|
|
if channel:
|
|
|
|
|
|
|
|
|
|
await channel.send("**Tournament is Starting**")
|
|
|
|
|
|
|
|
|
|
await self._rr_printround(ctx, tID, 0)
|
|
|
|
@ -1099,7 +1093,6 @@ class Fight:
|
|
|
|
|
matchLetter = ""
|
|
|
|
|
j = i
|
|
|
|
|
while j + 1 > 26:
|
|
|
|
|
|
|
|
|
|
matchLetter += firstID[int(j + 1) % 26 - 1]
|
|
|
|
|
|
|
|
|
|
j = (j + 1) / 26 - 1
|
|
|
|
@ -1176,7 +1169,6 @@ class Fight:
|
|
|
|
|
channel = guild.get_channel(channel_id)
|
|
|
|
|
message = await channel.get_message(message_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if emoji.is_custom_emoji():
|
|
|
|
|
emoji_id = emoji.id
|
|
|
|
|
else:
|
|
|
|
|