updated the player stats stuff
This commit is contained in:
parent
c488699141
commit
2be2bb98e2
35
var.py
35
var.py
@ -150,6 +150,9 @@ class ChangedRolesMode(object):
|
|||||||
self.ROLES_GUIDE[k] = tuple(lx)
|
self.ROLES_GUIDE[k] = tuple(lx)
|
||||||
|
|
||||||
|
|
||||||
|
# Persistence
|
||||||
|
|
||||||
|
|
||||||
# Load saved settings
|
# Load saved settings
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
@ -171,38 +174,36 @@ def add_away(clk):
|
|||||||
with conn:
|
with conn:
|
||||||
c.execute('INSERT into away values (?)', (clk,))
|
c.execute('INSERT into away values (?)', (clk,))
|
||||||
|
|
||||||
def update_role_stats(clk, role, won):
|
def update_role_stats(clk, role, won, iwon):
|
||||||
role = role+'stats'
|
role = role.replace(" ", "_")+'stats'
|
||||||
with conn:
|
with conn:
|
||||||
print("k")
|
|
||||||
c.execute(('CREATE TABLE IF NOT EXISTS {0} (id INTEGER PRIMARY KEY AUTOINCREMENT, '+
|
c.execute(('CREATE TABLE IF NOT EXISTS {0} (id INTEGER PRIMARY KEY AUTOINCREMENT, '+
|
||||||
'cloak TEXT UNIQUE, wins SMALLINT, total SMALLINT)').format(role))
|
'cloak TEXT UNIQUE, teamwins SMALLINT, individualwins SMALLINT, total SMALLINT)').format(role))
|
||||||
wins, totalgames = 0, 0
|
wins, iwins, totalgames = 0, 0, 0
|
||||||
print("kk")
|
|
||||||
c.execute('SELECT * FROM {0} WHERE cloak=?'.format(role), (clk,))
|
c.execute('SELECT * FROM {0} WHERE cloak=?'.format(role), (clk,))
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
if row:
|
if row:
|
||||||
_, __, wins,totalgames = row
|
_, __, wins, iwins, totalgames = row
|
||||||
if won:
|
if won:
|
||||||
wins += 1
|
wins += 1
|
||||||
|
if iwon:
|
||||||
|
iwins += 1
|
||||||
totalgames += 1
|
totalgames += 1
|
||||||
|
|
||||||
print("uh oh")
|
c.execute(('INSERT OR REPLACE INTO {0} (cloak, teamwins, individualwins, total) '+
|
||||||
|
'values (?,?,?,?)').format(role), (clk, wins, iwins, totalgames))
|
||||||
|
|
||||||
c.execute(('INSERT OR REPLACE INTO {0} (cloak, wins, total) '+
|
|
||||||
'values (?,?,?)').format(role), (clk, wins, totalgames))
|
|
||||||
|
|
||||||
|
|
||||||
def get_role_stats(clk, role):
|
def get_role_stats(clk, role):
|
||||||
role = role+'stats'
|
role = role.replace(" ", "_")+'stats'
|
||||||
with conn:
|
with conn:
|
||||||
print("k")
|
|
||||||
c.execute(('CREATE TABLE IF NOT EXISTS {0} (id INTEGER PRIMARY KEY AUTOINCREMENT, '+
|
c.execute(('CREATE TABLE IF NOT EXISTS {0} (id INTEGER PRIMARY KEY AUTOINCREMENT, '+
|
||||||
'cloak TEXT UNIQUE, wins SMALLINT, total SMALLINT)').format(role))
|
'cloak TEXT UNIQUE, teamwins SMALLINT, individualwins SMALLINT, total SMALLINT)').format(role))
|
||||||
wins, totalgames = 0, 0
|
wins, iwins, totalgames = 0, 0, 0
|
||||||
print("kk")
|
|
||||||
c.execute('SELECT * FROM {0} WHERE cloak=?'.format(role), (clk,))
|
c.execute('SELECT * FROM {0} WHERE cloak=?'.format(role), (clk,))
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
if row:
|
if row:
|
||||||
_, __, wins,totalgames = row
|
_, __, wins, iwins, totalgames = row
|
||||||
return wins, totalgames
|
return wins, iwins, totalgames
|
107
wolfgame.py
107
wolfgame.py
@ -154,8 +154,8 @@ def reset(cli):
|
|||||||
dict.clear(var.DEAD_USERS)
|
dict.clear(var.DEAD_USERS)
|
||||||
|
|
||||||
|
|
||||||
@pmcmd("bye", "die", "off", admin_only=True)
|
@pmcmd("fbye", "fdie", admin_only=True)
|
||||||
@cmd("bye", "die", "off", admin_only=True)
|
@cmd("fbye", "fdie", admin_only=True)
|
||||||
def forced_exit(cli, nick, *rest): # Admin Only
|
def forced_exit(cli, nick, *rest): # Admin Only
|
||||||
"""Forces the bot to close"""
|
"""Forces the bot to close"""
|
||||||
|
|
||||||
@ -173,8 +173,8 @@ def forced_exit(cli, nick, *rest): # Admin Only
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pmcmd("restart", admin_only=True)
|
@pmcmd("frestart", admin_only=True)
|
||||||
@cmd("restart", admin_only=True)
|
@cmd("frestart", admin_only=True)
|
||||||
def restart_program(cli, nick, *rest):
|
def restart_program(cli, nick, *rest):
|
||||||
"""Restarts the bot."""
|
"""Restarts the bot."""
|
||||||
try:
|
try:
|
||||||
@ -194,41 +194,6 @@ def restart_program(cli, nick, *rest):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cmd("op", admin_only=True)
|
|
||||||
def give_op(cli, nick, chan, rest):
|
|
||||||
"""OP [(person)] Makes someone or yourself a channel operator"""
|
|
||||||
if not rest.strip():
|
|
||||||
rest = nick
|
|
||||||
|
|
||||||
for a in re.split(" +",rest):
|
|
||||||
a = a.strip()
|
|
||||||
if not a:
|
|
||||||
continue
|
|
||||||
cli.mode(chan, "+o", a)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pmcmd("op", admin_only=True)
|
|
||||||
def give_op_pm(cli, nick, rest):
|
|
||||||
give_op(cli, nick, botconfig.CHANNEL, rest)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cmd("deop", admin_only=True)
|
|
||||||
def take_op(cli, nick, chan, rest):
|
|
||||||
"""Takes operator rights from someone or yourself."""
|
|
||||||
if not rest.strip():
|
|
||||||
rest = nick
|
|
||||||
|
|
||||||
for a in re.split(" +",rest):
|
|
||||||
a = a.strip()
|
|
||||||
if not a:
|
|
||||||
continue
|
|
||||||
cli.mode(chan, "-o", a)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cmd("ping")
|
@cmd("ping")
|
||||||
def pinger(cli, nick, chan, rest):
|
def pinger(cli, nick, chan, rest):
|
||||||
"""Pings the channel to get people's attention. Rate-Limited."""
|
"""Pings the channel to get people's attention. Rate-Limited."""
|
||||||
@ -391,35 +356,6 @@ def fstart(cli, nick, chan, rest):
|
|||||||
start(cli, nick, nick, rest)
|
start(cli, nick, nick, rest)
|
||||||
|
|
||||||
|
|
||||||
# lol this was funny
|
|
||||||
# @cmd("kpon")
|
|
||||||
# def kpon(cli, nick, chan, rest):
|
|
||||||
# """(Same as !join)"""
|
|
||||||
# join(cli, nick, chan, rest)
|
|
||||||
# if "person" in var.ROLES.keys() and nick in var.ROLES["person"]:
|
|
||||||
# var.ROLES["person"].remove(nick)
|
|
||||||
# if "typo" in var.ROLES.keys():
|
|
||||||
# var.ROLES["typo"].append(nick)
|
|
||||||
# else:
|
|
||||||
# var.ROLES["typo"] = [nick]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cmd("chankick", admin_only=True)
|
|
||||||
def chankick(cli, nick, chan, rest):
|
|
||||||
rest = re.split(" +", rest, 1)
|
|
||||||
if not rest[0]:
|
|
||||||
cli.notice(nick, "Invalid syntax for this command.")
|
|
||||||
return
|
|
||||||
if rest[0] != botconfig.NICK:
|
|
||||||
if len(rest) == 1:
|
|
||||||
cli.kick(chan, rest[0], "Kicked by "+nick+".")
|
|
||||||
else:
|
|
||||||
cli.kick(chan, rest[0], "Kicked by {0}: {1}".format(nick, rest[1]))
|
|
||||||
else:
|
|
||||||
cli.kick(chan, nick, "No.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@hook("kick")
|
@hook("kick")
|
||||||
def on_kicked(cli, nick, chan, victim, reason):
|
def on_kicked(cli, nick, chan, victim, reason):
|
||||||
@ -501,9 +437,10 @@ def hurry_up(cli, gameid=0):
|
|||||||
var.VOTES[maxfound[1]] = [None] * votesneeded
|
var.VOTES[maxfound[1]] = [None] * votesneeded
|
||||||
chk_decision(cli) # Induce a lynch
|
chk_decision(cli) # Induce a lynch
|
||||||
else:
|
else:
|
||||||
cli.msg(chan, "The sun is almost setting.")
|
cli.msg(chan, ("As the sun sets, the villagers agree to "+
|
||||||
for plr in pl:
|
"retire to their beds and wait for morning."))
|
||||||
var.VOTES[plr] = [None] * (votesneeded - 1)
|
transition_night(cli)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -660,7 +597,9 @@ def stop_game(cli, winner = ""):
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
var.update_role_stats(clk, rol, won)
|
iwon = won and plr in var.list_players() # survived, team won = individual win
|
||||||
|
|
||||||
|
var.update_role_stats(clk, rol, won, iwon)
|
||||||
|
|
||||||
reset(cli)
|
reset(cli)
|
||||||
return True
|
return True
|
||||||
@ -2029,6 +1968,20 @@ def coin(cli, nick, chan, rest):
|
|||||||
cli.msg(chan, "The coin lands on \2{0}\2.".format("heads" if random.random() < 0.5 else "tails"))
|
cli.msg(chan, "The coin lands on \2{0}\2.".format("heads" if random.random() < 0.5 else "tails"))
|
||||||
|
|
||||||
|
|
||||||
|
@cmd("flastgame", admin_only=True)
|
||||||
|
@pmcmd("flastgame", admin_only=True)
|
||||||
|
def flastgame(cli, nick, *rest):
|
||||||
|
"""This command may be used in the channel or in a PM, and it disables starting or joining a game."""
|
||||||
|
chan = botconfig.CHANNEL
|
||||||
|
|
||||||
|
if "join" in COMMANDS.keys():
|
||||||
|
del COMMANDS["join"]
|
||||||
|
if "start" in COMMANDS.keys():
|
||||||
|
del COMMANDS["start"]
|
||||||
|
|
||||||
|
cli.msg(chan, "Starting a new game has now been disabled by \02{0}\02.".format(nick))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if botconfig.DEBUG_MODE:
|
if botconfig.DEBUG_MODE:
|
||||||
|
|
||||||
@ -2053,14 +2006,6 @@ if botconfig.DEBUG_MODE:
|
|||||||
cli.msg(chan, str(type(e))+":"+str(e))
|
cli.msg(chan, str(type(e))+":"+str(e))
|
||||||
|
|
||||||
|
|
||||||
@cmd("set", admin_only=True)
|
|
||||||
def set_setting(cli, nick, chan, rest):
|
|
||||||
rest = re.split(" +",rest, 1)
|
|
||||||
if len(rest) != 2 or not rest[0] or not rest[1]:
|
|
||||||
cli.msg(chan, "Invalid syntax.")
|
|
||||||
return
|
|
||||||
cli.msg(chan, "Not implemented yet.")
|
|
||||||
|
|
||||||
|
|
||||||
@cmd("revealroles", admin_only=True)
|
@cmd("revealroles", admin_only=True)
|
||||||
def revroles(cli, nick, chan, rest):
|
def revroles(cli, nick, chan, rest):
|
||||||
@ -2071,7 +2016,7 @@ if botconfig.DEBUG_MODE:
|
|||||||
cli.msg(chan, "Gunners: "+str(list(var.GUNNERS.keys())))
|
cli.msg(chan, "Gunners: "+str(list(var.GUNNERS.keys())))
|
||||||
|
|
||||||
|
|
||||||
@cmd("game", admin_only=True)
|
@cmd("fgame", admin_only=True)
|
||||||
def game(cli, nick, chan, rest):
|
def game(cli, nick, chan, rest):
|
||||||
pl = var.list_players()
|
pl = var.list_players()
|
||||||
if var.PHASE == "none":
|
if var.PHASE == "none":
|
||||||
|
Loading…
Reference in New Issue
Block a user