Changed behaviour of "gamestats" command.
"gamestats" without a parameter will list game totals for all game sizes. The role parameter for player stats commands is now case insensitive.
This commit is contained in:
parent
a12128b486
commit
829fd260e2
@ -2880,13 +2880,13 @@ def _flastgame(cli, nick, chan, rest):
|
|||||||
|
|
||||||
@cmd("gamestats", "gstats")
|
@cmd("gamestats", "gstats")
|
||||||
def game_stats(cli, nick, chan, rest):
|
def game_stats(cli, nick, chan, rest):
|
||||||
"""Gets the game stats for a given game size"""
|
"""Gets the game stats for a given game size or lists game totals for all game sizes if no game size is given."""
|
||||||
if var.PHASE not in ("none", "join"):
|
if var.PHASE not in ("none", "join"):
|
||||||
cli.notice(nick, "Wait until the game is over to view stats.")
|
cli.notice(nick, "Wait until the game is over to view stats.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if rest == "":
|
if rest == "":
|
||||||
cli.notice(nick, "Supply a game size")
|
cli.msg(chan, var.get_game_totals())
|
||||||
return
|
return
|
||||||
|
|
||||||
if not rest.isdigit():
|
if not rest.isdigit():
|
||||||
@ -2913,7 +2913,7 @@ def player_stats(cli, nick, chan, rest):
|
|||||||
return
|
return
|
||||||
|
|
||||||
player = params[0]
|
player = params[0]
|
||||||
role = " ".join(params[1:])
|
role = " ".join(params[1:]).lower()
|
||||||
|
|
||||||
msg = var.get_player_stats(player, role)
|
msg = var.get_player_stats(player, role)
|
||||||
if msg == "":
|
if msg == "":
|
||||||
|
@ -314,3 +314,17 @@ def get_game_stats(size):
|
|||||||
return "{0} player games: {1} village wins, {2} wolf wins, and {3} total games.".format(*row)
|
return "{0} player games: {1} village wins, {2} wolf wins, and {3} total games.".format(*row)
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def get_game_totals():
|
||||||
|
sizeList = []
|
||||||
|
with conn:
|
||||||
|
for size in range(4, MAX_PLAYERS):
|
||||||
|
c.execute("SELECT size, totalgames FROM gamestats WHERE size = %d" % size)
|
||||||
|
row = c.fetchone()
|
||||||
|
if row:
|
||||||
|
sizeList.append("{0}p({1})".format(*row))
|
||||||
|
|
||||||
|
if len(sizeList) == 0:
|
||||||
|
return "No games have been played."
|
||||||
|
else:
|
||||||
|
return "Game totals: %s" % ", ".join(sizeList)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user