diff --git a/src/db.py b/src/db.py index b6d4e84..279dda3 100644 --- a/src/db.py +++ b/src/db.py @@ -394,21 +394,39 @@ def get_game_stats(mode, size): def get_game_totals(mode): conn = _conn() c = conn.cursor() - c.execute("SELECT COUNT(1) FROM game WHERE gamemode = ?", (mode,)) + + if mode == "all": + c.execute("SELECT COUNT(1) FROM game") + else: + c.execute("SELECT COUNT(1) FROM game WHERE gamemode = ?", (mode,)) + total_games = c.fetchone()[0] if not total_games: return "No games have been played in the {0} game mode.".format(mode) - c.execute("""SELECT - gamesize, - COUNT(1) AS games - FROM game - WHERE gamemode = ? - GROUP BY gamesize - ORDER BY gamesize ASC""", (mode,)) + + if mode == "all": + c.execute("""SELECT + gamesize, + COUNT(1) AS games + FROM game + GROUP BY gamesize + ORDER BY gamesize ASC""") + else: + c.execute("""SELECT + gamesize, + COUNT(1) AS games + FROM game + WHERE gamemode = ? + GROUP BY gamesize + ORDER BY gamesize ASC""", (mode,)) totals = [] for row in c: totals.append("\u0002{0}p\u0002: {1}".format(*row)) - return "Total games (\u0002{0}\u0002): {1} | {2}".format(mode, total_games, ", ".join(totals)) + + if mode == "all": + return "Total games: {0} | {1}".format(total_games, ", ".join(totals)) + else: + return "Total games (\u0002{0}\u0002): {1} | {2}".format(mode, total_games, ", ".join(totals)) def get_warning_points(acc, hostmask): peid, plid = _get_ids(acc, hostmask) diff --git a/src/wolfgame.py b/src/wolfgame.py index c792318..0f20c1b 100644 --- a/src/wolfgame.py +++ b/src/wolfgame.py @@ -7087,13 +7087,13 @@ def game_stats(cli, nick, chan, rest): cli.notice(nick, messages["stats_wait_for_game_end"]) return - gamemode = var.CURRENT_GAMEMODE.name + gamemode = "all" gamesize = None rest = rest.split() # Check for gamemode if len(rest) and not rest[0].isdigit(): gamemode = rest[0] - if gamemode not in var.GAME_MODES.keys(): + if gamemode != "all" and gamemode not in var.GAME_MODES.keys(): gamemode, _ = complete_match(gamemode, var.GAME_MODES.keys()) if not gamemode: cli.notice(nick, messages["invalid_mode_no_list"].format(rest[0]))