<commit_before>import discord
import os
import math
from discord.ext import commands

from .utils.dataIO import dataIO
from .utils import checks
from random import randint


# 0 - Robin, 1 - Single, 2 - Double, 3 - Triple, 4 - Guarentee, 5 - Compass
T_TYPES = ["Round Robin", "Single Elimination",
           "Double Elimination", "Triple Elimination",
           "3 Game Guarentee", "Compass Draw"]


class Fight:
    """Cog for organizing fights"""

    def __init__(self, bot):
        self.bot = bot
        self.path = "data/Fox-Cogs/fight/"
        self.file_path = "data/Fox-Cogs/fight/fight.json"
        self.the_data = dataIO.load_json(self.file_path)

    def save_data(self):
        """Saves the json"""
        dataIO.save_json(self.file_path, self.the_data)


# ************************Fight command group start************************
    @commands.group(pass_context=True, no_pm=True)
    async def fight(self, ctx):
        """Participate in active fights!"""
        server = ctx.message.server
        
        if not self._activefight(server.id):
            await self.bot.say("No tournament currently running!")
        else:
            await self.bot.say("Current tournament ID: " + self.the_data[server.id]["TOURNEYS"][self.the_data[server.id]["CURRENT"]])
            
        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
            # await self.bot.say("I can do stuff!")

    @fight.command(name="join", pass_context=True)
    async def fight_join(self, ctx, user: discord.Member=None):
        """Join the active fight"""
        server = ctx.message.server
        if not user:
            user = ctx.message.author
        
        currFight = self._activefight(server.id)
        if not currFight:
            await self.bot.say("No tournament currently running!")
            return
        
        if not currFight["OPEN"]:
            await self.bot.say("Tournament currently not accepting new players")
            return

    @fight.command(name="score", pass_context=True)
    async def fight_score(self, ctx, gameID):
        if gameID is None:
            if ctx.message.author not in currFight["PLAYERS"]:
                await self.bot.say("You are not in a current tournament")
        """Enters score for current match, or for passed game ID"""
        await self.bot.say("Todo Score")

    @fight.command(name="leave", pass_context=True)
    async def fight_leave(self, ctx):
        """Forfeit your match and all future matches"""
        await self.bot.say("Todo Leave")

#    @fight.command(name="leaderboard", pass_context=True)
#    async def fight_leaderboard(self, ctx, ctag, ckind="Unranked", irank=0):
#        """Adds clan to grab-list"""
#        await self.bot.say("Todo Leaderboard")

    @fight.group(name="bracket", pass_context=True)
    async def fight_bracket(self, ctx, ctag):
        """Shows your current match your next opponent,
            run [p]fight bracket full to see all matches"""
        await self.bot.say("Todo Bracket")

        # Your code will go here
        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
        # await self.bot.say("I can do stuff!")

    @fight_bracket.command(name="full")
    async def fight_bracket_full(self, ctag):
        """Shows the full bracket"""
        await self.bot.say("Todo Bracket Full")

# **********************Fightset command group start*********************
#    def fightsetdec(func):
#        async def decorated(self, ctx, *args, **kwargs):
#            server = ctx.message.server
#            await func(self, ctx, server, *args, **kwargs)
#        return decorated

    @commands.group(pass_context=True, no_pm=True, aliases=['setfight'])
    @checks.mod_or_permissions(administrator=True)
    async def fightset(self, ctx):
        """Admin command for starting or managing tournaments"""
        server = ctx.message.server
        
        if server.id not in self.the_data:
            self.the_data[server.id] = {
                "CURRENT": None,
                "TOURNEYS": {}
            }
            self.save_data()

        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
        # await self.bot.say("I can do stuff!")

    @fightset.command(name="bestof", pass_context=True)
    async def fightset_bestof(self, ctx, incount, tID=None):
        """Adjust # of games played per match. Must be an odd number"""
        server = ctx.message.server
        if not tID and not self._activefight(server.id):
            await self.bot.say("No active fight to adjust")
            return

        if not tID:
            tID = self._activefight(server.id)
        
        try:
            num = int(incount)
        except:
            await self.bot.say("That is not a number")
            return
        
        if num % 2 != 1:
            await self.bot.say("Must be an odd number")
        
        if num < 1:
            await self.bot.say("Must be greater than 0, idiot")
            
        self._getfight(server.id, tID)["RULES"]["BESTOF"] = num
        self.save_data()
        await self.bot.say("Tourney ID "+tID+" is now Best of "+str(num))

    @fightset.command(name="bestoffinal", pass_context=True)
    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)"""
        server = ctx.message.server
        if not tID and not self._activefight(server.id):
            await self.bot.say("No active fight to adjust")
            return
        
        if not tID:
            tID = self._activefight(server.id)
        
        try:
            num = int(incount)
        except:
            await self.bot.say("That is not a number")
            return
        
        if num % 2 != 1:
            await self.bot.say("Must be an odd number")
        
        if num < 1:
            await self.bot.say("Must be greater than 0, idiot")
            
        self._getfight(server.id, tID)["RULES"]["BESTOFFINAL"] = num
        self.save_data()
        await self.bot.say("Tourney ID "+tID+" is now Best of "+str(num))

    @fightset.command(name="current", pass_context=True)
    async def fightset_current(self, ctx, tID):
        """Sets the current tournament to passed ID"""
        server = ctx.message.server
        try:
            aFight = self.the_data[server.id]["TOURNEYS"][tID]
            
        except:
            await self.bot.say("No tourney found with that ID")
         
        self.the_data[server.id]["CURRENT"] = tID
        self.save_data()
        
        await self.bot.say("Current tournament set to "+tID)
        
    @fightset.command(name="list", pass_context=True)
    async def fightset_list(self, ctx):
        """Lists all current and past fights"""
        server = ctx.message.server
        
        await self.bot.say(self.the_data[server.id]["TOURNEYS"])
        await self.bot.say("Done")<commit_msg>Just ID and don't allow odds<commit_after>import discord
import os
import math
from discord.ext import commands

from .utils.dataIO import dataIO
from .utils import checks
from random import randint


# 0 - Robin, 1 - Single, 2 - Double, 3 - Triple, 4 - Guarentee, 5 - Compass
T_TYPES = ["Round Robin", "Single Elimination",
           "Double Elimination", "Triple Elimination",
           "3 Game Guarentee", "Compass Draw"]


class Fight:
    """Cog for organizing fights"""

    def __init__(self, bot):
        self.bot = bot
        self.path = "data/Fox-Cogs/fight/"
        self.file_path = "data/Fox-Cogs/fight/fight.json"
        self.the_data = dataIO.load_json(self.file_path)

    def save_data(self):
        """Saves the json"""
        dataIO.save_json(self.file_path, self.the_data)


# ************************Fight command group start************************
    @commands.group(pass_context=True, no_pm=True)
    async def fight(self, ctx):
        """Participate in active fights!"""
        server = ctx.message.server
        
        if not self._activefight(server.id):
            await self.bot.say("No tournament currently running!")
        else:
            await self.bot.say("Current tournament ID: " + self.the_data[server.id]["CURRENT"])
            
        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
            # await self.bot.say("I can do stuff!")

    @fight.command(name="join", pass_context=True)
    async def fight_join(self, ctx, user: discord.Member=None):
        """Join the active fight"""
        server = ctx.message.server
        if not user:
            user = ctx.message.author
        
        currFight = self._activefight(server.id)
        if not currFight:
            await self.bot.say("No tournament currently running!")
            return
        
        if not currFight["OPEN"]:
            await self.bot.say("Tournament currently not accepting new players")
            return

    @fight.command(name="score", pass_context=True)
    async def fight_score(self, ctx, gameID):
        if gameID is None:
            if ctx.message.author not in currFight["PLAYERS"]:
                await self.bot.say("You are not in a current tournament")
        """Enters score for current match, or for passed game ID"""
        await self.bot.say("Todo Score")

    @fight.command(name="leave", pass_context=True)
    async def fight_leave(self, ctx):
        """Forfeit your match and all future matches"""
        await self.bot.say("Todo Leave")

#    @fight.command(name="leaderboard", pass_context=True)
#    async def fight_leaderboard(self, ctx, ctag, ckind="Unranked", irank=0):
#        """Adds clan to grab-list"""
#        await self.bot.say("Todo Leaderboard")

    @fight.group(name="bracket", pass_context=True)
    async def fight_bracket(self, ctx, ctag):
        """Shows your current match your next opponent,
            run [p]fight bracket full to see all matches"""
        await self.bot.say("Todo Bracket")

        # Your code will go here
        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
        # await self.bot.say("I can do stuff!")

    @fight_bracket.command(name="full")
    async def fight_bracket_full(self, ctag):
        """Shows the full bracket"""
        await self.bot.say("Todo Bracket Full")

# **********************Fightset command group start*********************
#    def fightsetdec(func):
#        async def decorated(self, ctx, *args, **kwargs):
#            server = ctx.message.server
#            await func(self, ctx, server, *args, **kwargs)
#        return decorated

    @commands.group(pass_context=True, no_pm=True, aliases=['setfight'])
    @checks.mod_or_permissions(administrator=True)
    async def fightset(self, ctx):
        """Admin command for starting or managing tournaments"""
        server = ctx.message.server
        
        if server.id not in self.the_data:
            self.the_data[server.id] = {
                "CURRENT": None,
                "TOURNEYS": {}
            }
            self.save_data()

        if ctx.invoked_subcommand is None:
            await self.bot.send_cmd_help(ctx)
        # await self.bot.say("I can do stuff!")

    @fightset.command(name="bestof", pass_context=True)
    async def fightset_bestof(self, ctx, incount, tID=None):
        """Adjust # of games played per match. Must be an odd number"""
        server = ctx.message.server
        if not tID and not self._activefight(server.id):
            await self.bot.say("No active fight to adjust")
            return

        if not tID:
            tID = self._activefight(server.id)
        
        try:
            num = int(incount)
        except:
            await self.bot.say("That is not a number")
            return
        
        if num % 2 != 1:
            await self.bot.say("Must be an odd number")
            return            
        
        if num < 1:
            await self.bot.say("Must be greater than 0, idiot")
            return
            
        self._getfight(server.id, tID)["RULES"]["BESTOF"] = num
        self.save_data()
        await self.bot.say("Tourney ID "+tID+" is now Best of "+str(num))

    @fightset.command(name="bestoffinal", pass_context=True)
    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)"""
        server = ctx.message.server
        if not tID and not self._activefight(server.id):
            await self.bot.say("No active fight to adjust")
            return
        
        if not tID:
            tID = self._activefight(server.id)
        
        try:
            num = int(incount)
        except:
            await self.bot.say("That is not a number")
            return
        
        if num % 2 != 1:
            await self.bot.say("Must be an odd number")
            return
        
        if num < 1:
            await self.bot.say("Must be greater than 0, idiot")
            return
            
        self._getfight(server.id, tID)["RULES"]["BESTOFFINAL"] = num
        self.save_data()
        await self.bot.say("Tourney ID "+tID+" is now Best of "+str(num))

    @fightset.command(name="current", pass_context=True)
    async def fightset_current(self, ctx, tID):
        """Sets the current tournament to passed ID"""
        server = ctx.message.server
        try:
            aFight = self.the_data[server.id]["TOURNEYS"][tID]
            
        except:
            await self.bot.say("No tourney found with that ID")
         
        self.the_data[server.id]["CURRENT"] = tID
        self.save_data()
        
        await self.bot.say("Current tournament set to "+tID)
        
    @fightset.command(name="list", pass_context=True)
    async def fightset_list(self, ctx):
        """Lists all current and past fights"""
        server = ctx.message.server
        
        await self.bot.say(self.the_data[server.id]["TOURNEYS"])
        await self.bot.say("Done")
{'fraction_non_alphanumeric': 0.1246213455442057, 'fraction_numerical': 0.0022543148996125397, 'mean_word_length': 2.1987381703470033, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1402596', 'n_tokens_mistral': 4276, 'n_tokens_neox': 4169, 'n_words': 1146}