Example #1
0
def processRank(slack, args):
    m = loldb.getmatches()
    # d = ranking.getRankings(m)
    td = theanorank.getRanking(m)
    # print d
    # print td
    mc = loldb.getgamecounts()
    lastg = loldb.getlastgameall()
    out = formatRanking(slack, td, mc, lastg)
    # legstr = ''
    # if numpy.min(mc.values()) < 3:
    #     legstr = '\n* has played less than 3 games'
    return simpleResp('```' + '\n'.join(out) + '```')
Example #2
0
def processRank(slack, args):
    m = loldb.getmatches()
    # d = ranking.getRankings(m)
    td = theanorank.getRanking(m)
    # print d
    # print td
    mc = loldb.getgamecounts()
    lastg = loldb.getlastgameall()
    out = formatRanking(slack, td, mc, lastg)
    # legstr = ''
    # if numpy.min(mc.values()) < 3:
    #     legstr = '\n* has played less than 3 games'
    return simpleResp('```' + '\n'.join(out) + '```')
Example #3
0
def processStats(f, slack, args, user):
    if len(args) == 0:
        uid = user
    elif len(args) != 1:
        return simpleResp("I don't understand...")
    else:
        if not args[0].startswith("<@"):
            return simpleResp("I don't know who %s is" % (args[0]))

        uid = args[0][2:-1]

    print "Stats UID: %s" % (uid)

    allusers = slack.users.list().body

    m = loldb.getmatches(f)
    gameCountsList = loldb.getgamecounts(f)
    if uid in gameCountsList:
        mc = gameCountsList[uid]
    else:
        mc = 0
    if mc != 0:
        lg = loldb.getlastgame(f, uid)
        td = theanorank.getRanking(m)
        wp = theanorank.getWinPercentage(m, uid)
        bw = theanorank.getBestWorst(m, uid)
        r1ta = "Skill level: %.1f" % (10.0 + (10.0 * td[uid]))
        r2ta = "Win percentage: %.1f" % wp
        r3ta = "Last match: %s" % (formatMatch(allusers, lg))

    nn = getNiceName(allusers, uid)

    r1t = "Stats for %s" % nn
    div = '-' * (len(r1t))
    r2t = "Matches played: %i" % (mc)
    allt = [r1t, div]
    if mc != 0:
        allt.append(r1ta)
        allt.append(r2t)
        allt.append(r2ta)
        allt.append(r3ta)
    else:
        allt.append(r2t)

    if mc > 1:
        r3t = "Best recent match: %s" % (formatMatch(allusers, bw[-1][1]))
        r4t = "Worst recent match: %s" % (formatMatch(allusers, bw[0][1]))
        allt.append(r3t)
        allt.append(r4t)

    return simpleResp('```' + '\n'.join(allt) + '```')
Example #4
0
def processStats(f, slack, args, user):
    if len(args) == 0:
        uid = user
    elif len(args) != 1:
        return simpleResp("I don't understand...")
    else:
        if not args[0].startswith("<@"):
            return simpleResp("I don't know who %s is" % (args[0]))

        uid = args[0][2:-1]

    print "Stats UID: %s" % (uid)

    allusers = slack.users.list().body

    m = loldb.getmatches(f)
    gameCountsList = loldb.getgamecounts(f)
    if uid in gameCountsList:
        mc = gameCountsList[uid]
    else:
        mc = 0
    if mc != 0:
        lg = loldb.getlastgame(f, uid)
        td = theanorank.getRanking(m)
        wp = theanorank.getWinPercentage(m, uid)
        bw = theanorank.getBestWorst(m, uid)
        r1ta = "Skill level: %.1f" % (10.0 + (10.0 * td[uid]))
        r2ta = "Win percentage: %.1f" % wp
        r3ta = "Last match: %s" % (formatMatch(allusers, lg))

    nn = getNiceName(allusers, uid)

    r1t = "Stats for %s" % nn
    div = '-' * (len(r1t))
    r2t = "Matches played: %i" % (mc)
    allt = [r1t, div]
    if mc != 0:
        allt.append(r1ta)
        allt.append(r2t)
        allt.append(r2ta)
        allt.append(r3ta)
    else:
        allt.append(r2t)

    if mc > 1:
        r3t = "Best recent match: %s" % (formatMatch(allusers, bw[-1][1]))
        r4t = "Worst recent match: %s" % (formatMatch(allusers, bw[0][1]))
        allt.append(r3t)
        allt.append(r4t)

    return simpleResp('```' + '\n'.join(allt) + '```')