Add total games to !pstats without role

This commit is contained in:
nyuszika7h 2014-02-21 10:15:50 +01:00
parent b90ba46e73
commit 42b98813d0

View File

@ -314,17 +314,19 @@ def get_player_stats(acc, role):
def get_player_totals(acc): def get_player_totals(acc):
role_totals = [] role_totals = []
games = 0
with conn: with conn:
for role in ["villager"] + [v for k, v in ROLE_INDICES.items()]: for role in ["villager"] + [v for k, v in ROLE_INDICES.items()]:
c.execute("SELECT totalgames FROM rolestats WHERE player=? AND role=?", (acc, role)) c.execute("SELECT totalgames FROM rolestats WHERE player=? AND role=?", (acc, role))
row = c.fetchone() row = c.fetchone()
if row: if row:
games += int(*row)
role_totals.append("\u0002{0}\u0002: {1}".format(role, *row)) role_totals.append("\u0002{0}\u0002: {1}".format(role, *row))
if len(role_totals) == 0: if len(role_totals) == 0:
return "{0} has not played any games.".format(acc) return "{0} has not played any games.".format(acc)
else: else:
return "\u0002{0}\u0002's totals | {1}".format(acc, ", ".join(role_totals)) return "\u0002{0}\u0002's totals ({1} games) | {1}".format(acc, games, ", ".join(role_totals))
def get_game_stats(size): def get_game_stats(size):
with conn: with conn: