Add total winrate output to !p (#341)
Mostly motivated by https://werewolf.chat/leaderboard/ listing only people with 200+ games
This commit is contained in:
parent
a9a664b101
commit
7552c492d6
10
src/db.py
10
src/db.py
@ -352,13 +352,21 @@ def get_player_totals(acc, hostmask):
|
||||
totals = []
|
||||
for row in c:
|
||||
tmp[row[0]] = row[1]
|
||||
c.execute("""SELECT SUM(gp.team_win | gp.indiv_win)
|
||||
FROM game_player gp
|
||||
JOIN player pl
|
||||
ON gp.player = pl.id
|
||||
JOIN person pe
|
||||
ON pl.person = pe.id
|
||||
WHERE pe.id = ?""", (peid,))
|
||||
won_games = c.fetchone()[0]
|
||||
order = role_order()
|
||||
name = _get_display_name(peid)
|
||||
#ordered role stats
|
||||
totals = ["\u0002{0}\u0002: {1}".format(r, tmp[r]) for r in order if r in tmp]
|
||||
#lover or any other special stats
|
||||
totals += ["\u0002{0}\u0002: {1}".format(r, t) for r, t in tmp.items() if r not in order]
|
||||
return "\u0002{0}\u0002's totals | \u0002{1}\u0002 games | {2}".format(name, total_games, break_long_message(totals, ", "))
|
||||
return "\u0002{0}\u0002's totals | \u0002{1}\u0002 games | Winrate: \u0002{2:.0%}\u0002 | {3}".format(name, total_games, won_games / total_games, break_long_message(totals, ", "))
|
||||
|
||||
def get_game_stats(mode, size):
|
||||
conn = _conn()
|
||||
|
Loading…
Reference in New Issue
Block a user