示例#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)
示例#2
0
def is_skill(stat):
    """ checks if a stat is a skill return 1 if it is 0 if it isnt"""
    stat = coded_string(stat)
    stat_clean = get_stat(stat)

    if stat_clean in SKILLS:
        return 1
    elif stat_clean in BOSSES + CLUES:
        return 0
    else:
        raise Exception(f"{stat} is not a  valid stat.")
示例#3
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)
示例#4
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)
示例#5
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)
示例#6
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)
示例#7
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)