Esempio n. 1
0
 async def check_clan_tracker(self, ctx, name, *stat):
     try:
         name = name.lower()
         clan_tracker_names = get_players_in_tracker(self.cur)
         if name in clan_tracker_names:
             if stat:
                 stat = ("_").join(stat).lower()
                 pretty_stat = get_stat(stat)
                 stat = coded_string(pretty_stat)
             else:
                 stat = "overall"
                 pretty_stat = "Overall"
             skill = is_skill(stat)
             if skill:
                 stat_delta, time_delta = xp_gained_clan(
                     self.cur, name, stat, skill)
                 hours, mins = seconds_to_hours_mins(time_delta.seconds)
                 response = f"{name} has gained {str(stat_delta)} {pretty_stat} xp in the last {time_delta.days}d {hours}h {mins}m."
             else:
                 if tracker_starting_stat(self.cur, name, stat, 0,
                                          'clan_tracker') == -1:
                     response = f"{name} starting {pretty_stat} was not ranked in the hs."
                 else:
                     stat_delta, time_delta = xp_gained_clan(
                         self.cur, name, stat, skill)
                     hours, mins = seconds_to_hours_mins(time_delta.seconds)
                     response = f"{name} has done {str(stat_delta)} {pretty_stat} kills in the last {time_delta.days}d {hours}h {mins}m."
             #self.conn.commit()
         else:
             response = f"{name} is not in the clan tracker."
     except Exception as e:
         response = str(e)
     finally:
         await ctx.send(response)
Esempio n. 2
0
    async def toptracker10(self, ctx, *stat):
        if stat:
            stat = ("_").join(stat).lower()
            pretty_stat = get_stat(stat)
            stat = coded_string(pretty_stat)
        else:
            stat = "overall"
            pretty_stat = "Overall"

        skill = is_skill(stat)

        top = top_stat_to_string(top_tracked(self.cur, stat, skill, 10))
        response = f'```\n{top}```'
        await ctx.send(response)
Esempio n. 3
0
    async def my_hs(self,ctx, *stat):

        try:
            stat = ("_").join(stat).lower()
            name = coded_string(ctx.message.author.display_name)
            stat = coded_string(get_stat(stat))
            skill = is_skill(stat)
            result = get_player_stat(self.cur,name,stat,skill,stats_col_names)[0]
            if skill:
                response = f"{name}'s {stat} level: {result[1]} with {result[2]} xp."
            else:
                response = f"{name}'s {stat} kc: {result[1]}."

        except Exception as e:
            response = e
        finally:
            await ctx.send(response)
Esempio n. 4
0
    async def top10_hs(self,ctx, *stat):

        try:
            response = "```\n"
            stat = ("_").join(stat).lower()
            stat_pretty = get_stat(stat)
            stat = coded_string(stat_pretty)

            response += f"{stat_pretty}\n"
            skill = is_skill(stat)
            result = sql_top_stat(self.cur,stat,10,skill,stats_col_names)
            response += top_stat_to_string(result)
            response += "```"
        except Exception as e:
            response = str(e)
        finally:
            await ctx.send(response)
Esempio n. 5
0
    async def ranks(self,ctx,stat,name):
        try:
            name = name.lower()
            stat_pretty = get_stat(stat.lower())
            stat = coded_string(stat_pretty)
            names = get_players_in_hs(self.cur)
            if name in names:
                skill = is_skill(stat)
                rank = get_player_rank(self.cur,name,stat,skill)
                response = f"{name} is rank {rank} in {stat_pretty}"
            else:
                response = f"{name} is not on the clan's hiscores."


        except Exception as e:
            response = str(e)
        finally:
            await ctx.send(response)
Esempio n. 6
0
    async def checkallteams(self, ctx, *stat):
        team_nums = get_team_nums(self.cur)
        try:
            response = ""
            if stat:
                stat = ("_").join(stat).lower()
                pretty_stat = get_stat(stat)
                stat = coded_string(pretty_stat)
            else:
                stat = "overall"
                pretty_stat = "Overall"
            skill = is_skill(stat)
            for team_num in team_nums:
                if skill:
                    team_members = get_team(self.cur, team_num)
                    stat_delta = xp_gained_team(self.cur, stat, skill,
                                                team_members)
                    response += f"Team {team_num} has gained **{str(stat_delta)}** {pretty_stat} xp.\n"
                else:
                    team_members = get_team(self.cur, team_num)
                    starting_kc = tracker_starting_stat_multiple(
                        self.cur, team_members, stat, skill, 'clan_tracker')

                    valid_team_members = [
                        x[0] for x in starting_kc if int(x[1]) != -1
                    ]
                    invalid_members = [
                        x for x in team_members if x not in valid_team_members
                    ]
                    if valid_team_members:
                        stat_delta = xp_gained_team(self.cur, stat, skill,
                                                    valid_team_members)
                        response += f"Team {team_num} has done **{str(stat_delta)}** {pretty_stat} kills.\n"
                        if len(invalid_members) > 0:
                            response += f"Kc gained by {invalid_members} is not being counted because their starting kc was not in the hs.\n"
                    else:
                        response += f"Team {team_num} doesn't have any team member being tracked in {pretty_stat} because their starting kc was not in the hs.\n"
        except Exception as e:
            response = str(e)
        finally:
            await ctx.send(response)
Esempio n. 7
0
    async def checkteam(self, ctx, team_num, *stat):
        team_num = int(team_num)
        try:
            if team_num not in range(1, 9):
                response = "Team number must be between 1 and 8 included."
            else:
                if stat:
                    stat = ("_").join(stat).lower()
                    pretty_stat = get_stat(stat)
                    stat = coded_string(pretty_stat)
                else:
                    stat = "overall"
                    pretty_stat = "Overall"
                skill = is_skill(stat)
                if skill:
                    team_members = get_team(self.cur, team_num)
                    stat_delta = xp_gained_team(self.cur, stat, skill,
                                                team_members)
                    response = f"Team {team_num} has gained {str(stat_delta)} {pretty_stat} xp."
                else:
                    team_members = get_team(self.cur, team_num)
                    starting_kc = tracker_starting_stat_multiple(
                        self.cur, team_members, stat, skill, 'clan_tracker')

                    valid_team_members = [
                        x[0] for x in starting_kc if int(x[1]) != -1
                    ]
                    invalid_members = [
                        x for x in team_members if x not in valid_team_members
                    ]
                    if valid_team_members:
                        stat_delta = xp_gained_team(self.cur, stat, skill,
                                                    valid_team_members)
                        response = f"Team {team_num} has done {str(stat_delta)} {pretty_stat} kills."
                        response += f"\nKc gained by {invalid_members} is not being counted because their starting kc was not in the hs."
                    else:
                        response = f"You don't have any team member being tracked in {pretty_stat} because their starting kc was not in the hs."
        except Exception as e:
            response = str(e)
        finally:
            await ctx.send(response)
Esempio n. 8
0
    async def my_tracker(self, ctx, *stat):
        try:
            name = coded_string(ctx.message.author.display_name)
            personal_tracker_names = get_players_in_personal_tracker(self.cur)
            if name in personal_tracker_names:
                if stat:
                    stat = ("_").join(stat).lower()
                    pretty_stat = get_stat(stat)
                    stat = coded_string(pretty_stat)
                else:
                    stat = "overall"
                    pretty_stat = "Overall"
                skill = is_skill(stat)

                if skill:
                    stat_delta, time_delta = xp_gained(self.cur, name, stat,
                                                       skill)
                    hours, mins = seconds_to_hours_mins(time_delta.seconds)
                    response = f"{name} has gained {str(stat_delta)} {pretty_stat} xp in the last {time_delta.days}d {hours}h {mins}m."
                else:
                    if tracker_starting_stat(self.cur, name, stat, 0,
                                             'personal_tracker') == -1:
                        response = f"Your starting {pretty_stat} was not ranked in the hs, if it is now you could do !hs resetmytracker to reset your tracker."
                    else:
                        stat_delta, time_delta = xp_gained(
                            self.cur, name, stat, skill)
                        hours, mins = seconds_to_hours_mins(time_delta.seconds)
                        response = f"{name} has done {str(stat_delta)} {pretty_stat} kills in the last {time_delta.days}d {hours}h {mins}m."

            else:
                response = "You are not being tracked, to start your tracker do !hs startmytracker"

        except Exception as e:
            response = str(e)
        finally:
            await ctx.send(response)