From 3d367f6beab2120d34a50362c203dad60cacb4cd Mon Sep 17 00:00:00 2001 From: Yizhe Shen Date: Sat, 15 Feb 2014 22:11:18 -0500 Subject: [PATCH] Minor changes. Added grand total to the output of "gamestats" command when no size is given. Changed camel case to '_' for a couple of variables. Added identification check for "player" command. --- modules/wolfgame.py | 3 +++ settings/wolfgame.py | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/wolfgame.py b/modules/wolfgame.py index 84caf78..0de018b 100644 --- a/modules/wolfgame.py +++ b/modules/wolfgame.py @@ -2944,6 +2944,9 @@ def player_stats(cli, nick, chan, rest): # Find the player's account if possible. if params[0] in var.USERS: acc = var.USERS[params[0]]["account"] + if acc == "*": + cli.notice(nick, "{0} is not identified with NickServ.".format(params[0])) + return else: acc = params[0] diff --git a/settings/wolfgame.py b/settings/wolfgame.py index 3b7197c..f1ef176 100644 --- a/settings/wolfgame.py +++ b/settings/wolfgame.py @@ -308,18 +308,18 @@ def get_player_stats(acc, role): return "No stats for {0} as {1}.".format(acc, role) def get_player_totals(acc): - roleTotals = [] + role_totals = [] with conn: for role in ["villager"] + [v for k, v in ROLE_INDICES.items()]: c.execute("SELECT totalgames FROM rolestats WHERE player=? AND role=?", (acc, role)) row = c.fetchone() if row: - roleTotals.append("\u0002{0}\u0002: {1}".format(role, *row)) + role_totals.append("\u0002{0}\u0002: {1}".format(role, *row)) - if len(roleTotals) == 0: + if len(role_totals) == 0: return "{0} has not played any games.".format(acc) else: - return "\u0002{0}\u0002's totals | {1}".format(acc, ", ".join(roleTotals)) + return "\u0002{0}\u0002's totals | {1}".format(acc, ", ".join(role_totals)) def get_game_stats(size): with conn: @@ -330,15 +330,17 @@ def get_game_stats(size): return "No stats for \u0002{0}\u0002 player games.".format(size) def get_game_totals(): - sizeList = [] + size_totals = [] + total = 0 with conn: for size in range(4, MAX_PLAYERS): c.execute("SELECT size, totalgames FROM gamestats WHERE size=?", (size,)) row = c.fetchone() if row: - sizeList.append("\u0002{0}p\u0002: {1}".format(*row)) + size_totals.append("\u0002{0}p\u0002: {1}".format(*row)) + total += row[1] - if len(sizeList) == 0: + if len(size_totals) == 0: return "No games have been played." else: - return "Game totals | %s" % ", ".join(sizeList) + return "Total games ({0}) | {1}".format(total, ", ".join(size_totals))