order !pstats and !stats using var.role_order()
This commit is contained in:
parent
7d2d65f80d
commit
92a7697584
@ -1048,21 +1048,10 @@ def stats(cli, nick, chan, rest):
|
||||
if var.ROLES[k]]
|
||||
l2 = [k for k in var.ORIGINAL_ROLES.keys()
|
||||
if var.ORIGINAL_ROLES[k]]
|
||||
rs = list(set(l1+l2))
|
||||
rs = set(l1+l2)
|
||||
rs = [role for role in var.role_order() if role in rs]
|
||||
|
||||
# Due to popular demand, picky ordering
|
||||
if "wolf" in rs:
|
||||
rs.remove("wolf")
|
||||
rs.insert(0, "wolf")
|
||||
if "augur" in rs:
|
||||
rs.remove("augur")
|
||||
rs.insert(1, "augur")
|
||||
if "oracle" in rs:
|
||||
rs.remove("oracle")
|
||||
rs.insert(1, "oracle")
|
||||
if "seer" in rs:
|
||||
rs.remove("seer")
|
||||
rs.insert(1, "seer")
|
||||
# picky ordering: villager always last
|
||||
if var.DEFAULT_ROLE in rs:
|
||||
rs.remove(var.DEFAULT_ROLE)
|
||||
rs.append(var.DEFAULT_ROLE)
|
||||
|
@ -311,6 +311,7 @@ def get_templates(nick):
|
||||
|
||||
return tpl
|
||||
|
||||
#order goes: wolfteam roles, then other roles in alphabetical order, then templates
|
||||
def role_order():
|
||||
templates = list(TEMPLATE_RESTRICTIONS.keys())
|
||||
vils = [role for role in ROLE_GUIDE.keys() if role not in WOLFTEAM_ROLES+templates]
|
||||
@ -983,7 +984,11 @@ def get_player_totals(acc):
|
||||
role_tmp[row[0]] += row[1]
|
||||
else:
|
||||
break
|
||||
role_totals = ["\u0002{0}\u0002: {1}".format(role, count) for role, count in role_tmp.items()]
|
||||
order = role_order()
|
||||
#ordered role stats
|
||||
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
|
||||
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,))
|
||||
row = c.fetchone()
|
||||
return "\u0002{0}\u0002's totals | \u0002{1}\u0002 games | {2}".format(player[0], row[0], break_long_message(role_totals, ", "))
|
||||
|
Loading…
x
Reference in New Issue
Block a user