fix pstats game totals being too high (counted most templates)

This commit is contained in:
jacob1 2015-03-18 22:25:44 -04:00
parent 4b07779bc3
commit c9a50586b8

View File

@ -1165,10 +1165,13 @@ def get_player_totals(acc):
if player: if player:
c.execute("SELECT role, totalgames FROM rolestats WHERE player=? COLLATE NOCASE ORDER BY totalgames DESC", (acc,)) c.execute("SELECT role, totalgames FROM rolestats WHERE player=? COLLATE NOCASE ORDER BY totalgames DESC", (acc,))
role_tmp = defaultdict(int) role_tmp = defaultdict(int)
totalgames = 0
while True: while True:
row = c.fetchone() row = c.fetchone()
if row: if row:
role_tmp[row[0]] += row[1] role_tmp[row[0]] += row[1]
if row[0] not in TEMPLATE_RESTRICTIONS and row[0] != "lover":
totalgames += row[1]
else: else:
break break
order = role_order() order = role_order()
@ -1176,9 +1179,7 @@ def get_player_totals(acc):
role_totals = ["\u0002{0}\u0002: {1}".format(role, role_tmp[role]) for role in order if role in role_tmp] role_totals = ["\u0002{0}\u0002: {1}".format(role, role_tmp[role]) for role in order if role in role_tmp]
#lover or any other special stats #lover or any other special stats
role_totals += ["\u0002{0}\u0002: {1}".format(role, count) for role, count in role_tmp.items() if role not in order] role_totals += ["\u0002{0}\u0002: {1}".format(role, count) for role, count in role_tmp.items() if role not in order]
c.execute("SELECT SUM(totalgames) from rolestats WHERE player=? COLLATE NOCASE AND role!='cursed villager' AND role!='gunner'", (acc,)) return "\u0002{0}\u0002's totals | \u0002{1}\u0002 games | {2}".format(player[0], totalgames, break_long_message(role_totals, ", "))
row = c.fetchone()
return "\u0002{0}\u0002's totals | \u0002{1}\u0002 games | {2}".format(player[0], row[0], break_long_message(role_totals, ", "))
else: else:
return "\u0002{0}\u0002 has not played any games.".format(acc) return "\u0002{0}\u0002 has not played any games.".format(acc)