|
|
|
@ -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:
|
|
|
|
@ -29,66 +22,63 @@ class Fight:
|
|
|
|
|
self.bot = bot
|
|
|
|
|
self.config = Config.get_conf(self, identifier=49564952847684, force_registration=True)
|
|
|
|
|
default_global = {
|
|
|
|
|
"srtracker": {},
|
|
|
|
|
"win": None,
|
|
|
|
|
"winu": None,
|
|
|
|
|
"loss": None,
|
|
|
|
|
"lossu": None,
|
|
|
|
|
"dispute": None,
|
|
|
|
|
"disputeu": None
|
|
|
|
|
}
|
|
|
|
|
"srtracker": {},
|
|
|
|
|
"win": None,
|
|
|
|
|
"winu": None,
|
|
|
|
|
"loss": None,
|
|
|
|
|
"lossu": None,
|
|
|
|
|
"dispute": None,
|
|
|
|
|
"disputeu": None
|
|
|
|
|
}
|
|
|
|
|
default_guild = {
|
|
|
|
|
"current": None,
|
|
|
|
|
"tourneys": {},
|
|
|
|
|
"settings": {
|
|
|
|
|
"selfreport": True,
|
|
|
|
|
"reportchnnl": None,
|
|
|
|
|
"announcechnnl": None,
|
|
|
|
|
"admin": None
|
|
|
|
|
},
|
|
|
|
|
"emoji": {
|
|
|
|
|
"nums": [],
|
|
|
|
|
"undo": None,
|
|
|
|
|
"appr": None
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"current": None,
|
|
|
|
|
"tourneys": {},
|
|
|
|
|
"settings": {
|
|
|
|
|
"selfreport": True,
|
|
|
|
|
"reportchnnl": None,
|
|
|
|
|
"announcechnnl": None,
|
|
|
|
|
"admin": None
|
|
|
|
|
},
|
|
|
|
|
"emoji": {
|
|
|
|
|
"nums": [],
|
|
|
|
|
"undo": None,
|
|
|
|
|
"appr": None
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.default_tourney = {
|
|
|
|
|
"PLAYERS": [],
|
|
|
|
|
"NAME": "Tourney 0",
|
|
|
|
|
"RULES": {"BESTOF": 1, "BESTOFFINAL": 1, "TYPE": 0},
|
|
|
|
|
"TYPEDATA": {},
|
|
|
|
|
"OPEN": False,
|
|
|
|
|
"WINNER": None
|
|
|
|
|
}
|
|
|
|
|
"PLAYERS": [],
|
|
|
|
|
"NAME": "Tourney 0",
|
|
|
|
|
"RULES": {"BESTOF": 1, "BESTOFFINAL": 1, "TYPE": 0},
|
|
|
|
|
"TYPEDATA": {},
|
|
|
|
|
"OPEN": False,
|
|
|
|
|
"WINNER": None
|
|
|
|
|
}
|
|
|
|
|
self.default_match = {
|
|
|
|
|
"TEAM1": [],
|
|
|
|
|
"TEAM2": [],
|
|
|
|
|
"TEAM1": [],
|
|
|
|
|
"TEAM2": [],
|
|
|
|
|
"SCORE1": None,
|
|
|
|
|
"SCORE2": None,
|
|
|
|
|
"USERSCORE1": {
|
|
|
|
|
"SCORE1": None,
|
|
|
|
|
"SCORE2": None
|
|
|
|
|
},
|
|
|
|
|
"USERSCORE2": {
|
|
|
|
|
"SCORE1": None,
|
|
|
|
|
"SCORE2": None,
|
|
|
|
|
"USERSCORE1": {
|
|
|
|
|
"SCORE1": None,
|
|
|
|
|
"SCORE2": None
|
|
|
|
|
},
|
|
|
|
|
"USERSCORE2": {
|
|
|
|
|
"SCORE1": None,
|
|
|
|
|
"SCORE2": None
|
|
|
|
|
},
|
|
|
|
|
"WINNER": None,
|
|
|
|
|
"DISPUTE": False
|
|
|
|
|
}
|
|
|
|
|
"SCORE2": None
|
|
|
|
|
},
|
|
|
|
|
"WINNER": None,
|
|
|
|
|
"DISPUTE": False
|
|
|
|
|
}
|
|
|
|
|
self.default_tracker = {
|
|
|
|
|
"TID": None,
|
|
|
|
|
"MID": None,
|
|
|
|
|
"RID": None,
|
|
|
|
|
"GUILDID": None
|
|
|
|
|
}
|
|
|
|
|
"TID": None,
|
|
|
|
|
"MID": None,
|
|
|
|
|
"RID": None,
|
|
|
|
|
"GUILDID": None
|
|
|
|
|
}
|
|
|
|
|
self.config.register_global(**default_global)
|
|
|
|
|
self.config.register_guild(**default_guild)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ************************Fight command group start************************
|
|
|
|
|
|
|
|
|
|
# ************************Fight command group start************************
|
|
|
|
|
|
|
|
|
|
@commands.group()
|
|
|
|
|
@commands.guild_only()
|
|
|
|
@ -106,7 +96,7 @@ class Fight:
|
|
|
|
|
# await ctx.send("I can do stuff!")
|
|
|
|
|
|
|
|
|
|
@fight.command(name="join")
|
|
|
|
|
async def fight_join(self, ctx, user: discord.Member=None):
|
|
|
|
|
async def fight_join(self, ctx, user: discord.Member = None):
|
|
|
|
|
"""Join the active fight"""
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
if not user:
|
|
|
|
@ -134,36 +124,36 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
# @fight.command(name="score")
|
|
|
|
|
# async def fight_score(self, ctx, tID=None, score1=None, score2=None):
|
|
|
|
|
# """Enters score for current match, or for passed tournament ID"""
|
|
|
|
|
# # guild = ctx.message.guild
|
|
|
|
|
# # user = ctx.message.author
|
|
|
|
|
# """Enters score for current match, or for passed tournament ID"""
|
|
|
|
|
# # guild = ctx.message.guild
|
|
|
|
|
# # user = ctx.message.author
|
|
|
|
|
|
|
|
|
|
# currFight = await self._getcurrentfight(ctx)
|
|
|
|
|
# if not currFight:
|
|
|
|
|
# await ctx.send("No tournament currently running!")
|
|
|
|
|
# return
|
|
|
|
|
# currFight = await self._getcurrentfight(ctx)
|
|
|
|
|
# if not currFight:
|
|
|
|
|
# await ctx.send("No tournament currently running!")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if not tID:
|
|
|
|
|
# tID = await self._activefight(ctx)
|
|
|
|
|
# if not tID:
|
|
|
|
|
# tID = await self._activefight(ctx)
|
|
|
|
|
|
|
|
|
|
# if not await self._infight(ctx, tID, ctx.author.id):
|
|
|
|
|
# await ctx.send("You are not in a current tournament")
|
|
|
|
|
# return
|
|
|
|
|
# if not await self._infight(ctx, tID, ctx.author.id):
|
|
|
|
|
# await ctx.send("You are not in a current tournament")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if not currFight["TYPEDATA"]:
|
|
|
|
|
# await ctx.send("Tournament has not started yet")
|
|
|
|
|
# return
|
|
|
|
|
# if not currFight["TYPEDATA"]:
|
|
|
|
|
# await ctx.send("Tournament has not started yet")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# mID = await self._parseuser(ctx.guild, tID, ctx.author.id)
|
|
|
|
|
# if not mID:
|
|
|
|
|
# await ctx.send("You have no match to update!")
|
|
|
|
|
# return
|
|
|
|
|
# mID = await self._parseuser(ctx.guild, tID, ctx.author.id)
|
|
|
|
|
# if not mID:
|
|
|
|
|
# await ctx.send("You have no match to update!")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if currFight["RULES"]["TYPE"] == 0: # Round-Robin
|
|
|
|
|
# await self._rr_score(ctx, tID, mID, score1, score2)
|
|
|
|
|
# if currFight["RULES"]["TYPE"] == 0: # Round-Robin
|
|
|
|
|
# await self._rr_score(ctx, tID, mID, score1, score2)
|
|
|
|
|
|
|
|
|
|
@fight.command(name="leave")
|
|
|
|
|
async def fight_leave(self, ctx, tID=None, user: discord.Member=None):
|
|
|
|
|
async def fight_leave(self, ctx, tID=None, user: discord.Member = None):
|
|
|
|
|
"""Forfeit your match and all future matches"""
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
if not user:
|
|
|
|
@ -173,10 +163,10 @@ class Fight:
|
|
|
|
|
tID = await self._activefight(ctx)
|
|
|
|
|
await ctx.send("Todo Leave")
|
|
|
|
|
|
|
|
|
|
# @fight.command(name="leaderboard", pass_context=True)
|
|
|
|
|
# async def fight_leaderboard(self, ctx, ctag, ckind="Unranked", irank=0):
|
|
|
|
|
# await ctx.send("Todo Leaderboard")
|
|
|
|
|
# """Adds clan to grab-list"""
|
|
|
|
|
# @fight.command(name="leaderboard", pass_context=True)
|
|
|
|
|
# async def fight_leaderboard(self, ctx, ctag, ckind="Unranked", irank=0):
|
|
|
|
|
# await ctx.send("Todo Leaderboard")
|
|
|
|
|
# """Adds clan to grab-list"""
|
|
|
|
|
|
|
|
|
|
@fight.group(name="bracket")
|
|
|
|
|
async def fight_bracket(self, ctx, tID):
|
|
|
|
@ -189,8 +179,7 @@ class Fight:
|
|
|
|
|
"""Shows the full bracket"""
|
|
|
|
|
await ctx.send("Todo Bracket Full")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# **********************Fightset command group start*********************
|
|
|
|
|
# **********************Fightset command group start*********************
|
|
|
|
|
|
|
|
|
|
@commands.group()
|
|
|
|
|
@commands.guild_only()
|
|
|
|
@ -223,7 +212,7 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
await ctx.send("User has been added to tournament")
|
|
|
|
|
|
|
|
|
|
# **********************Fightset command group start*********************
|
|
|
|
|
# **********************Fightset command group start*********************
|
|
|
|
|
|
|
|
|
|
@commands.group(aliases=['setfight'])
|
|
|
|
|
@commands.guild_only()
|
|
|
|
@ -233,27 +222,27 @@ class Fight:
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
|
|
|
|
|
# if guild.id not in self.the_data:
|
|
|
|
|
# self.the_data[guild.id] = {
|
|
|
|
|
# "CURRENT": None,
|
|
|
|
|
# "TOURNEYS": {},
|
|
|
|
|
# "SETTINGS": {
|
|
|
|
|
# "SELFREPORT": True,
|
|
|
|
|
# "REPORTCHNNL": None,
|
|
|
|
|
# "ANNOUNCECHNNL": None,
|
|
|
|
|
# "ADMIN": None
|
|
|
|
|
# },
|
|
|
|
|
# "SRTRACKER": {
|
|
|
|
|
# "ROUND": None,
|
|
|
|
|
# "CHNNLS": None,
|
|
|
|
|
# },
|
|
|
|
|
# "EMOJI": {
|
|
|
|
|
# "NUMS": [],
|
|
|
|
|
# "UNDO": None,
|
|
|
|
|
# "APPR": None
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# self.the_data[guild.id] = {
|
|
|
|
|
# "CURRENT": None,
|
|
|
|
|
# "TOURNEYS": {},
|
|
|
|
|
# "SETTINGS": {
|
|
|
|
|
# "SELFREPORT": True,
|
|
|
|
|
# "REPORTCHNNL": None,
|
|
|
|
|
# "ANNOUNCECHNNL": None,
|
|
|
|
|
# "ADMIN": None
|
|
|
|
|
# },
|
|
|
|
|
# "SRTRACKER": {
|
|
|
|
|
# "ROUND": None,
|
|
|
|
|
# "CHNNLS": None,
|
|
|
|
|
# },
|
|
|
|
|
# "EMOJI": {
|
|
|
|
|
# "NUMS": [],
|
|
|
|
|
# "UNDO": None,
|
|
|
|
|
# "APPR": None
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
# self.save_data()
|
|
|
|
|
# self.save_data()
|
|
|
|
|
|
|
|
|
|
if ctx.invoked_subcommand is None:
|
|
|
|
|
await ctx.send_help()
|
|
|
|
@ -265,7 +254,7 @@ class Fight:
|
|
|
|
|
message = await ctx.send("Emoji Tests")
|
|
|
|
|
message2 = await ctx.send("Secondary Emoji Tests")
|
|
|
|
|
|
|
|
|
|
needed=["reporting a win","reporting a loss","disputing results"]
|
|
|
|
|
needed = ["reporting a win", "reporting a loss", "disputing results"]
|
|
|
|
|
|
|
|
|
|
for need in needed:
|
|
|
|
|
try:
|
|
|
|
@ -347,13 +336,13 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
currFight["RULES"]["BESTOF"] = num
|
|
|
|
|
await self._save_fight(ctx, tID, currFight)
|
|
|
|
|
await ctx.send("Tourney ID "+tID+" is now Best of "+str(num))
|
|
|
|
|
await ctx.send("Tourney ID " + tID + " is now Best of " + str(num))
|
|
|
|
|
|
|
|
|
|
@fightset.command(name="bestoffinal")
|
|
|
|
|
async def fightset_bestoffinal(self, ctx, incount, tID=None):
|
|
|
|
|
"""Adjust # of games played in finals. Must be an odd number
|
|
|
|
|
(Does not apply to tournament types without finals, such as Round Robin)"""
|
|
|
|
|
#guild = ctx.message.guild
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
if not tID and not await self._activefight(ctx):
|
|
|
|
|
await ctx.send("No active fight to adjust")
|
|
|
|
|
return
|
|
|
|
@ -379,12 +368,12 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
currFight["RULES"]["BESTOFFINAL"] = num
|
|
|
|
|
await self._save_fight(ctx, tID, currFight)
|
|
|
|
|
await ctx.send("Tourney ID "+tID+" is now Best of "+str(num)+" in the Finals")
|
|
|
|
|
await ctx.send("Tourney ID " + tID + " is now Best of " + str(num) + " in the Finals")
|
|
|
|
|
|
|
|
|
|
@fightset.command(name="current")
|
|
|
|
|
async def fightset_current(self, ctx, tID):
|
|
|
|
|
"""Sets the current tournament to passed ID"""
|
|
|
|
|
#guild = ctx.message.guild
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
currFight = await self._getfight(ctx.guild, tID)
|
|
|
|
|
|
|
|
|
|
if not currFight:
|
|
|
|
@ -395,12 +384,12 @@ class Fight:
|
|
|
|
|
# self.save_data()
|
|
|
|
|
await self.config.guild(ctx.guild).current.set(tID)
|
|
|
|
|
|
|
|
|
|
await ctx.send("Current tournament set to "+tID)
|
|
|
|
|
await ctx.send("Current tournament set to " + tID)
|
|
|
|
|
|
|
|
|
|
@fightset.command(name="list")
|
|
|
|
|
async def fightset_list(self, ctx):
|
|
|
|
|
"""Lists all current and past fights"""
|
|
|
|
|
#guild = ctx.message.guild
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
|
|
|
|
|
for page in pagify(str(await self.config.guild(ctx.guild).tourneys())):
|
|
|
|
|
await ctx.send(box(page))
|
|
|
|
@ -415,7 +404,7 @@ class Fight:
|
|
|
|
|
@fightset.command(name="open")
|
|
|
|
|
async def fightset_open(self, ctx):
|
|
|
|
|
"""Toggles the open status of current tournament"""
|
|
|
|
|
#guild = ctx.message.guild
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
if not await self._activefight(ctx):
|
|
|
|
|
await ctx.send("No active fight to adjust")
|
|
|
|
|
return
|
|
|
|
@ -428,11 +417,10 @@ 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"""
|
|
|
|
|
#guild = ctx.message.guild
|
|
|
|
|
# guild = ctx.message.guild
|
|
|
|
|
if not tID and not await self._activefight(ctx):
|
|
|
|
|
await ctx.send("No active fight to adjust")
|
|
|
|
|
return
|
|
|
|
@ -444,12 +432,13 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
currFight["NAME"] = inname
|
|
|
|
|
await self._save_fight(ctx, tID, currFight)
|
|
|
|
|
await ctx.send("Tourney ID "+tID+" is now called "+inname)
|
|
|
|
|
await ctx.send("Tourney ID " + tID + " is now called " + inname)
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
|
|
def check(m): # Check Message from author
|
|
|
|
|
return m.author == ctx.author and m.channel == ctx.channel
|
|
|
|
|
|
|
|
|
|
currFight = await self._getcurrentfight(ctx)
|
|
|
|
@ -459,21 +448,22 @@ class Fight:
|
|
|
|
|
await ctx.send("No current fight to start")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if (await self.config.win()) is None: #Emoji not setup
|
|
|
|
|
if (await self.config.win()) is None: # Emoji not setup
|
|
|
|
|
await ctx.send("Emojis have not been configured, see `[p]fightset emoji`")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if (await self._get_announcechnnl(ctx.guild)) is None: #Announcechnnl not setup
|
|
|
|
|
if (await self._get_announcechnnl(ctx.guild)) is None: # Announcechnnl not setup
|
|
|
|
|
await ctx.send("Announcement channel has not been configured, see `[p]fightset guild announce`")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if (await self._get_reportchnnl(ctx.guild)) is None: #Reportchnnl not setup
|
|
|
|
|
if (await self._get_reportchnnl(ctx.guild)) is None: # Reportchnnl not setup
|
|
|
|
|
await ctx.send("Self-Report channel has not been configured, see `[p]fightset guild report`")
|
|
|
|
|
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)")
|
|
|
|
|
# answer = await self.bot.wait_for_message(timeout=120, author=author)
|
|
|
|
|
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)
|
|
|
|
|
except asyncio.TimeoutError:
|
|
|
|
@ -499,13 +489,14 @@ class Fight:
|
|
|
|
|
Best of (final): 1
|
|
|
|
|
Self Report: True
|
|
|
|
|
Type: 0 (Round Robin)"""
|
|
|
|
|
#guild = ctx.message.guild
|
|
|
|
|
# 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()
|
|
|
|
|
currFight["NAME"] = "Tourney "+str(tID)
|
|
|
|
|
currFight["NAME"] = "Tourney " + str(tID)
|
|
|
|
|
|
|
|
|
|
await self._save_fight(ctx, tID, currFight)
|
|
|
|
|
|
|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
@ -542,7 +536,7 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
await ctx.send("Fight has been stopped")
|
|
|
|
|
|
|
|
|
|
# ***************************Fightset_guild command group start**************************
|
|
|
|
|
# ***************************Fightset_guild command group start**************************
|
|
|
|
|
|
|
|
|
|
@fightset.group(name="guild")
|
|
|
|
|
async def fightset_guild(self, ctx):
|
|
|
|
@ -560,7 +554,7 @@ class Fight:
|
|
|
|
|
await ctx.send("Self-Reporting ability is now set to: " + str(not curflag))
|
|
|
|
|
|
|
|
|
|
@fightset_guild.command(name="report")
|
|
|
|
|
async def fightset_guild_report(self, ctx, channel: discord.TextChannel=None):
|
|
|
|
|
async def fightset_guild_report(self, ctx, channel: discord.TextChannel = None):
|
|
|
|
|
"""Set the channel for self-reporting matches"""
|
|
|
|
|
if channel is None:
|
|
|
|
|
channel = ctx.channel
|
|
|
|
@ -571,7 +565,7 @@ class Fight:
|
|
|
|
|
await ctx.send("Self-Reporting Channel is now set to: " + channel.mention)
|
|
|
|
|
|
|
|
|
|
@fightset_guild.command(name="announce")
|
|
|
|
|
async def fightset_guild_announce(self, ctx, channel: discord.TextChannel=None):
|
|
|
|
|
async def fightset_guild_announce(self, ctx, channel: discord.TextChannel = None):
|
|
|
|
|
"""Set the channel for tournament announcements"""
|
|
|
|
|
if channel is None:
|
|
|
|
|
channel = ctx.channel
|
|
|
|
@ -582,13 +576,13 @@ class Fight:
|
|
|
|
|
await ctx.send("Announcement Channel is now set to: " + channel.mention)
|
|
|
|
|
|
|
|
|
|
@fightset_guild.command(name="setadmin")
|
|
|
|
|
async def fightset_guild_setadmin(self, ctx, role: discord.Role=None):
|
|
|
|
|
async def fightset_guild_setadmin(self, ctx, role: discord.Role = None):
|
|
|
|
|
"""Chooses the tournament-admin role. CAREFUL: This grants the ability to override self-reported scores!"""
|
|
|
|
|
await self.config.guild(ctx.guild).settings.admin.set(role.id)
|
|
|
|
|
|
|
|
|
|
await ctx.send("Tournament Admin role is now set to: " + role.mention)
|
|
|
|
|
|
|
|
|
|
# **********************Private command group start*********************
|
|
|
|
|
# **********************Private command group start*********************
|
|
|
|
|
async def _add_wld(self, message: discord.Message):
|
|
|
|
|
"""Adds assigned Win-Loss-Dispute reactions to message"""
|
|
|
|
|
|
|
|
|
@ -596,7 +590,7 @@ class Fight:
|
|
|
|
|
loss = await self.config.loss()
|
|
|
|
|
dispute = await self.config.dispute()
|
|
|
|
|
|
|
|
|
|
if not (await self.config.winu()): #If not unicode
|
|
|
|
|
if not (await self.config.winu()): # If not unicode
|
|
|
|
|
win = self.bot.get_emoji(win)
|
|
|
|
|
if not (await self.config.lossu()):
|
|
|
|
|
loss = self.bot.get_emoji(loss)
|
|
|
|
@ -611,7 +605,7 @@ class Fight:
|
|
|
|
|
"""Returns win emoji ready for str"""
|
|
|
|
|
win = await self.config.win()
|
|
|
|
|
|
|
|
|
|
if not (await self.config.winu()): #If not unicode
|
|
|
|
|
if not (await self.config.winu()): # If not unicode
|
|
|
|
|
win = str(self.bot.get_emoji(win))
|
|
|
|
|
return win
|
|
|
|
|
|
|
|
|
@ -644,8 +638,8 @@ class Fight:
|
|
|
|
|
"""
|
|
|
|
|
if messagetext:
|
|
|
|
|
message = await ctx.send("Please react to this message with the reaction you"
|
|
|
|
|
" would like for "+messagetext+", you have 20 seconds to"
|
|
|
|
|
" respond.")
|
|
|
|
|
" would like for " + messagetext + ", you have 20 seconds to"
|
|
|
|
|
" respond.")
|
|
|
|
|
else:
|
|
|
|
|
message = await ctx.send("Please react to this message with the reaction you"
|
|
|
|
|
" would like, you have 20 seconds to"
|
|
|
|
@ -739,11 +733,11 @@ class Fight:
|
|
|
|
|
return outlist
|
|
|
|
|
|
|
|
|
|
# async def _getsettings(self, ctx: commands.Context):
|
|
|
|
|
# # return self.the_data[guildID]["SETTINGS"]
|
|
|
|
|
# return await self.config.guild(ctx.guild).settings()
|
|
|
|
|
# # return self.the_data[guildID]["SETTINGS"]
|
|
|
|
|
# return await self.config.guild(ctx.guild).settings()
|
|
|
|
|
|
|
|
|
|
# async def _get_message_from_id_old(self, channelid, messageid):
|
|
|
|
|
# return await self.bot.get_message(self._get_channel_from_id(channelid), messageid)
|
|
|
|
|
# return await self.bot.get_message(self._get_channel_from_id(channelid), messageid)
|
|
|
|
|
|
|
|
|
|
async def _get_message_from_id(self, guild: discord.Guild, message_id: int):
|
|
|
|
|
"""
|
|
|
|
@ -757,7 +751,7 @@ class Fight:
|
|
|
|
|
return await channel.get_message(message_id)
|
|
|
|
|
except discord.NotFound:
|
|
|
|
|
pass
|
|
|
|
|
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
|
|
|
|
except AttributeError: # VoiceChannel object has no attribute 'get_message'
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
@ -789,7 +783,7 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
async def _getcurrentfight(self, ctx: commands.Context):
|
|
|
|
|
# if not self._activefight(guildID):
|
|
|
|
|
# return None
|
|
|
|
|
# return None
|
|
|
|
|
|
|
|
|
|
# return self._getfight(guildID, self._activefight(guildID))
|
|
|
|
|
isactive = await self._activefight(ctx)
|
|
|
|
@ -829,9 +823,9 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# *********** References to "TYPEDATA" must be done per tournament mode (Below this line) *******
|
|
|
|
|
# *********** References to "TYPEDATA" must be done per tournament mode (Below this line) *******
|
|
|
|
|
|
|
|
|
|
# **********************Single Elimination***************************
|
|
|
|
|
# **********************Single Elimination***************************
|
|
|
|
|
async def _elim_setup(self, tID):
|
|
|
|
|
await ctx.send("Elim setup todo")
|
|
|
|
|
|
|
|
|
@ -841,7 +835,7 @@ class Fight:
|
|
|
|
|
async def _elim_update(self, matchID):
|
|
|
|
|
await ctx.send("Elim update todo")
|
|
|
|
|
|
|
|
|
|
# **********************Round-Robin**********************************
|
|
|
|
|
# **********************Round-Robin**********************************
|
|
|
|
|
|
|
|
|
|
async def _rr_report_wl(self, guild: discord.Guild, tID, mID, user: discord.Member, lWin):
|
|
|
|
|
"""User reports a win or loss for member in match"""
|
|
|
|
@ -851,18 +845,18 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
# _rr_parseuser has already be run in on_raw_reaction_add, should be safe to proceed without checking again
|
|
|
|
|
|
|
|
|
|
if (lWin and teamnum==1) or (not lWin and teamnum==2):
|
|
|
|
|
score1 = math.ceil(theT["RULES"]["BESTOF"]/2)
|
|
|
|
|
if (lWin and teamnum == 1) or (not lWin and teamnum == 2):
|
|
|
|
|
score1 = math.ceil(theT["RULES"]["BESTOF"] / 2)
|
|
|
|
|
score2 = 0
|
|
|
|
|
else:
|
|
|
|
|
score1 = 0
|
|
|
|
|
score2 = math.ceil(theT["RULES"]["BESTOF"]/2)
|
|
|
|
|
score2 = math.ceil(theT["RULES"]["BESTOF"] / 2)
|
|
|
|
|
|
|
|
|
|
if teamnum==1:
|
|
|
|
|
if teamnum == 1:
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE1"]["SCORE1"] = score1
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE1"]["SCORE2"] = score2
|
|
|
|
|
|
|
|
|
|
if teamnum==2:
|
|
|
|
|
if teamnum == 2:
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE2"]["SCORE1"] = score1
|
|
|
|
|
theT["TYPEDATA"]["MATCHES"][mID]["USERSCORE2"]["SCORE2"] = score2
|
|
|
|
|
|
|
|
|
@ -882,17 +876,19 @@ 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
|
|
|
|
|
(match["USERSCORE2"]["SCORE1"] == math.ceil(theT["RULES"]["BESTOF"]/2)) !=
|
|
|
|
|
(match["USERSCORE2"]["SCORE2"] == math.ceil(theT["RULES"]["BESTOF"]/2)) and
|
|
|
|
|
(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"]
|
|
|
|
|
if ((match["USERSCORE1"]["SCORE1"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) !=
|
|
|
|
|
(match["USERSCORE1"]["SCORE2"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) and
|
|
|
|
|
(match["USERSCORE2"]["SCORE1"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) !=
|
|
|
|
|
(match["USERSCORE2"]["SCORE2"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) and
|
|
|
|
|
(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"]
|
|
|
|
|
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
|
|
|
|
@ -914,11 +911,10 @@ class Fight:
|
|
|
|
|
theT = await self._getfight(guild, tID)
|
|
|
|
|
match = theT["TYPEDATA"]["MATCHES"][mID]
|
|
|
|
|
|
|
|
|
|
if ((match["SCORE1"] == math.ceil(theT["RULES"]["BESTOF"]/2)) !=
|
|
|
|
|
(match["SCORE2"] == math.ceil(theT["RULES"]["BESTOF"]/2))):
|
|
|
|
|
if ((match["SCORE1"] == math.ceil(theT["RULES"]["BESTOF"] / 2)) !=
|
|
|
|
|
(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
|
|
|
|
|
|
|
|
|
@ -960,8 +956,8 @@ class Fight:
|
|
|
|
|
theD = theT["TYPEDATA"]
|
|
|
|
|
|
|
|
|
|
channel = await self._get_announcechnnl(ctx.guild)
|
|
|
|
|
if channel: # rID starts at 0, so print +1. Never used for computation, so doesn't matter
|
|
|
|
|
await channel.send("**Round "+str(rID+1)+" is starting**")
|
|
|
|
|
if channel: # rID starts at 0, so print +1. Never used for computation, so doesn't matter
|
|
|
|
|
await channel.send("**Round " + str(rID + 1) + " is starting**")
|
|
|
|
|
|
|
|
|
|
channel = await self._get_reportchnnl(ctx.guild)
|
|
|
|
|
|
|
|
|
@ -983,24 +979,23 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
mention1 = ", ".join(team1)
|
|
|
|
|
mention2 = ", ".join(team2)
|
|
|
|
|
outembed=discord.Embed(title="Match ID: " + mID, color=0x0000bf)
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
await self._add_wld(message)
|
|
|
|
|
|
|
|
|
|
trackmessage = self.default_tracker.copy()
|
|
|
|
|
trackmessage["TID"] = tID
|
|
|
|
|
trackmessage["MID"] = mID
|
|
|
|
|
trackmessage["RID"] = rID
|
|
|
|
|
trackmessage["GUILDID"] = ctx.guild.id
|
|
|
|
|
await self._save_tracker(ctx, message.id, trackmessage)
|
|
|
|
|
await self._add_wld(message)
|
|
|
|
|
|
|
|
|
|
trackmessage = self.default_tracker.copy()
|
|
|
|
|
trackmessage["TID"] = tID
|
|
|
|
|
trackmessage["MID"] = mID
|
|
|
|
|
trackmessage["RID"] = rID
|
|
|
|
|
trackmessage["GUILDID"] = ctx.guild.id
|
|
|
|
|
await self._save_tracker(ctx, message.id, trackmessage)
|
|
|
|
|
|
|
|
|
|
# await ctx.send(team1 + " vs " + team2 + " || Match ID: " + match)
|
|
|
|
|
|
|
|
|
@ -1009,71 +1004,70 @@ 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)
|
|
|
|
|
|
|
|
|
|
# async def _rr_score(self, ctx: commands.Context, tID, mID, t1points, t2points):
|
|
|
|
|
# def check(m): #Check Message from author
|
|
|
|
|
# return m.author == ctx.author and m.channel == ctx.channel
|
|
|
|
|
# theT = await self._getfight(ctx.guild, tID)
|
|
|
|
|
# theD = theT["TYPEDATA"]
|
|
|
|
|
|
|
|
|
|
# # if t1points and t2points:
|
|
|
|
|
# # theD["MATCHES"][mID]["SCORE1"] = t1points
|
|
|
|
|
# # theD["MATCHES"][mID]["SCORE2"] = t2points
|
|
|
|
|
# # self.save_data()
|
|
|
|
|
# # return
|
|
|
|
|
|
|
|
|
|
# if not t1points:
|
|
|
|
|
# await ctx.send("Entering scores for match ID: " + mID + "\n\n")
|
|
|
|
|
# await ctx.send("How many points did TEAM1 get?")
|
|
|
|
|
# if await self._rr_matchperms(ctx.guild, tID, ctx.author.id, mID) == 1:
|
|
|
|
|
# await ctx.send("*HINT: You are on TEAM1*")
|
|
|
|
|
# # answer = await self.bot.wait_for_message(timeout=120, author=author)
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# answer = await self.bot.wait_for('message', check=check, timeout=120)
|
|
|
|
|
# except asyncio.TimeoutError:
|
|
|
|
|
# await ctx.send("Cancelled due to timeout")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# t1points = int(answer.content)
|
|
|
|
|
# except:
|
|
|
|
|
# await ctx.send("That's not a number!")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if not t2points:
|
|
|
|
|
# await ctx.send("How many points did TEAM2 get?")
|
|
|
|
|
# if await self._rr_matchperms(ctx.guild, tID, ctx.author.id, mID) == 2:
|
|
|
|
|
# await ctx.send("*HINT: You are on TEAM2*")
|
|
|
|
|
# # answer = await self.bot.wait_for_message(timeout=120, author=author)
|
|
|
|
|
# try:
|
|
|
|
|
# answer = await self.bot.wait_for('message', check=check, timeout=120)
|
|
|
|
|
# except asyncio.TimeoutError:
|
|
|
|
|
# await ctx.send("Cancelled due to timeout")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# t2points = int(answer.content)
|
|
|
|
|
# except:
|
|
|
|
|
# await ctx.send("That's not a number!")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if (t1points == math.ceil(theT["RULES"]["BESTOF"]/2) or
|
|
|
|
|
# t2points == math.ceil(theT["RULES"]["BESTOF"]/2)):
|
|
|
|
|
# theD["MATCHES"][mID]["SCORE1"] = t1points
|
|
|
|
|
# theD["MATCHES"][mID]["SCORE2"] = t2points
|
|
|
|
|
# else:
|
|
|
|
|
# await ctx.send("Invalid scores, nothing will be updated")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# await self._save_fight(theT)
|
|
|
|
|
# await ctx.send("Scores have been saved successfully!")
|
|
|
|
|
|
|
|
|
|
# # if self._rr_checkround(guildID, tID)
|
|
|
|
|
# def check(m): #Check Message from author
|
|
|
|
|
# return m.author == ctx.author and m.channel == ctx.channel
|
|
|
|
|
# theT = await self._getfight(ctx.guild, tID)
|
|
|
|
|
# theD = theT["TYPEDATA"]
|
|
|
|
|
|
|
|
|
|
# # if t1points and t2points:
|
|
|
|
|
# # theD["MATCHES"][mID]["SCORE1"] = t1points
|
|
|
|
|
# # theD["MATCHES"][mID]["SCORE2"] = t2points
|
|
|
|
|
# # self.save_data()
|
|
|
|
|
# # return
|
|
|
|
|
|
|
|
|
|
# if not t1points:
|
|
|
|
|
# await ctx.send("Entering scores for match ID: " + mID + "\n\n")
|
|
|
|
|
# await ctx.send("How many points did TEAM1 get?")
|
|
|
|
|
# if await self._rr_matchperms(ctx.guild, tID, ctx.author.id, mID) == 1:
|
|
|
|
|
# await ctx.send("*HINT: You are on TEAM1*")
|
|
|
|
|
# # answer = await self.bot.wait_for_message(timeout=120, author=author)
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# answer = await self.bot.wait_for('message', check=check, timeout=120)
|
|
|
|
|
# except asyncio.TimeoutError:
|
|
|
|
|
# await ctx.send("Cancelled due to timeout")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# t1points = int(answer.content)
|
|
|
|
|
# except:
|
|
|
|
|
# await ctx.send("That's not a number!")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if not t2points:
|
|
|
|
|
# await ctx.send("How many points did TEAM2 get?")
|
|
|
|
|
# if await self._rr_matchperms(ctx.guild, tID, ctx.author.id, mID) == 2:
|
|
|
|
|
# await ctx.send("*HINT: You are on TEAM2*")
|
|
|
|
|
# # answer = await self.bot.wait_for_message(timeout=120, author=author)
|
|
|
|
|
# try:
|
|
|
|
|
# answer = await self.bot.wait_for('message', check=check, timeout=120)
|
|
|
|
|
# except asyncio.TimeoutError:
|
|
|
|
|
# await ctx.send("Cancelled due to timeout")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# try:
|
|
|
|
|
# t2points = int(answer.content)
|
|
|
|
|
# except:
|
|
|
|
|
# await ctx.send("That's not a number!")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# if (t1points == math.ceil(theT["RULES"]["BESTOF"]/2) or
|
|
|
|
|
# t2points == math.ceil(theT["RULES"]["BESTOF"]/2)):
|
|
|
|
|
# theD["MATCHES"][mID]["SCORE1"] = t1points
|
|
|
|
|
# theD["MATCHES"][mID]["SCORE2"] = t2points
|
|
|
|
|
# else:
|
|
|
|
|
# await ctx.send("Invalid scores, nothing will be updated")
|
|
|
|
|
# return
|
|
|
|
|
|
|
|
|
|
# await self._save_fight(theT)
|
|
|
|
|
# await ctx.send("Scores have been saved successfully!")
|
|
|
|
|
|
|
|
|
|
# # if self._rr_checkround(guildID, tID)
|
|
|
|
|
|
|
|
|
|
def _rr_schedule(self, inlist):
|
|
|
|
|
""" Create a schedule for the teams in the list and return it"""
|
|
|
|
@ -1098,17 +1092,16 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
matchLetter = ""
|
|
|
|
|
j = i
|
|
|
|
|
while j+1 > 26:
|
|
|
|
|
|
|
|
|
|
while j + 1 > 26:
|
|
|
|
|
matchLetter += firstID[int(j + 1) % 26 - 1]
|
|
|
|
|
|
|
|
|
|
j = (j + 1) / 26 - 1
|
|
|
|
|
matchLetter += firstID[int(j+1) % 26-1]
|
|
|
|
|
matchLetter += firstID[int(j + 1) % 26 - 1]
|
|
|
|
|
matchLetter = matchLetter[::-1]
|
|
|
|
|
|
|
|
|
|
matchID = []
|
|
|
|
|
for ix in range(len(l1)):
|
|
|
|
|
matchID += [matchLetter+str(ix)]
|
|
|
|
|
matchID += [matchLetter + str(ix)]
|
|
|
|
|
|
|
|
|
|
rPlayers = list(zip(l1, l2))
|
|
|
|
|
TeamCnt = 0
|
|
|
|
@ -1117,13 +1110,13 @@ class Fight:
|
|
|
|
|
outID[ID]["TEAM1"] = [rPlayers[TeamCnt][0]]
|
|
|
|
|
outID[ID]["TEAM2"] = [rPlayers[TeamCnt][1]]
|
|
|
|
|
# outID[ID] = {
|
|
|
|
|
# "TEAM1": [rPlayers[TeamCnt][0]],
|
|
|
|
|
# "TEAM2": [rPlayers[TeamCnt][1]],
|
|
|
|
|
# "SCORE1": 0,
|
|
|
|
|
# "SCORE2": 0,
|
|
|
|
|
# "USERSCORE1": {"SCORE1": 0, "SCORE2": 0},
|
|
|
|
|
# "USERSCORE2": {"SCORE1": 0, "SCORE2": 0}
|
|
|
|
|
# }
|
|
|
|
|
# "TEAM1": [rPlayers[TeamCnt][0]],
|
|
|
|
|
# "TEAM2": [rPlayers[TeamCnt][1]],
|
|
|
|
|
# "SCORE1": 0,
|
|
|
|
|
# "SCORE2": 0,
|
|
|
|
|
# "USERSCORE1": {"SCORE1": 0, "SCORE2": 0},
|
|
|
|
|
# "USERSCORE2": {"SCORE1": 0, "SCORE2": 0}
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
TeamCnt += 1
|
|
|
|
|
|
|
|
|
@ -1140,7 +1133,7 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
return outlist
|
|
|
|
|
|
|
|
|
|
#**************** Attempt 2, borrow from Squid*******
|
|
|
|
|
# **************** Attempt 2, borrow from Squid*******
|
|
|
|
|
|
|
|
|
|
async def on_raw_reaction_add(self, emoji: discord.PartialReactionEmoji,
|
|
|
|
|
message_id: int, channel_id: int, user_id: int):
|
|
|
|
@ -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:
|
|
|
|
@ -1189,10 +1181,10 @@ class Fight:
|
|
|
|
|
|
|
|
|
|
if emoji_id == wld[0]:
|
|
|
|
|
await self._report_win()
|
|
|
|
|
await log_channel.send("Message ID: "+str(message_id)+" was reporting a win")
|
|
|
|
|
await log_channel.send("Message ID: " + str(message_id) + " was reporting a win")
|
|
|
|
|
if emoji_id == wld[1]:
|
|
|
|
|
await self._report_loss()
|
|
|
|
|
await log_channel.send("Message ID: "+str(message_id)+" was reporting a loss")
|
|
|
|
|
await log_channel.send("Message ID: " + str(message_id) + " was reporting a loss")
|
|
|
|
|
if emoji_id == wld[2]:
|
|
|
|
|
await self._report_dispute(guild, tracker["TID"], tracker["MID"])
|
|
|
|
|
await log_channel.send("Message ID: "+str(message_id)+" was reporting a dispute")
|
|
|
|
|
await log_channel.send("Message ID: " + str(message_id) + " was reporting a dispute")
|
|
|
|
|