remove end of line whitespace
add comment to PING_MIN_WAIT
This commit is contained in:
parent
5a8b2684fe
commit
f7381a6c39
@ -1,6 +1,6 @@
|
|||||||
PING_WAIT = 300 # Seconds
|
PING_WAIT = 300 # Seconds
|
||||||
PING_MIN_WAIT = 30
|
PING_MIN_WAIT = 30 # How long !start has to wait after a !ping
|
||||||
MINIMUM_WAIT = 60
|
MINIMUM_WAIT = 60
|
||||||
EXTRA_WAIT = 20
|
EXTRA_WAIT = 20
|
||||||
MAXIMUM_WAITED = 2 # limit for amount of !wait's
|
MAXIMUM_WAITED = 2 # limit for amount of !wait's
|
||||||
STATS_RATE_LIMIT = 15
|
STATS_RATE_LIMIT = 15
|
||||||
@ -63,7 +63,7 @@ ROLE_INDICES = {0 : "seer",
|
|||||||
7 : "werecrow",
|
7 : "werecrow",
|
||||||
8 : "guardian angel",
|
8 : "guardian angel",
|
||||||
9 : "detective"}
|
9 : "detective"}
|
||||||
|
|
||||||
INDEX_OF_ROLE = dict((v,k) for k,v in ROLE_INDICES.items())
|
INDEX_OF_ROLE = dict((v,k) for k,v in ROLE_INDICES.items())
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ RULES = (botconfig.CHANNEL + " channel rules: 1) Be nice to others. 2) Do not sh
|
|||||||
"after death. 3) No bots allowed. 4) Do not play with clones.\n"+
|
"after death. 3) No bots allowed. 4) Do not play with clones.\n"+
|
||||||
"5) Do not quit unless you need to leave. 6) Keep it "+
|
"5) Do not quit unless you need to leave. 6) Keep it "+
|
||||||
"safe for work. 7) Do not paste PM's from the bot during the game. "+
|
"safe for work. 7) Do not paste PM's from the bot during the game. "+
|
||||||
"8) Use common sense. 9) Waiting for timeouts is discouraged.")
|
"8) Use common sense. 9) Waiting for timeouts is discouraged.")
|
||||||
|
|
||||||
# Other settings:
|
# Other settings:
|
||||||
START_WITH_DAY = False
|
START_WITH_DAY = False
|
||||||
@ -96,29 +96,29 @@ def plural(role):
|
|||||||
if role == "wolf": return "wolves"
|
if role == "wolf": return "wolves"
|
||||||
elif role == "person": return "people"
|
elif role == "person": return "people"
|
||||||
else: return role + "s"
|
else: return role + "s"
|
||||||
|
|
||||||
def list_players():
|
def list_players():
|
||||||
pl = []
|
pl = []
|
||||||
for x in ROLES.values():
|
for x in ROLES.values():
|
||||||
pl.extend(x)
|
pl.extend(x)
|
||||||
return pl
|
return pl
|
||||||
|
|
||||||
def list_players_and_roles():
|
def list_players_and_roles():
|
||||||
plr = {}
|
plr = {}
|
||||||
for x in ROLES.keys():
|
for x in ROLES.keys():
|
||||||
for p in ROLES[x]:
|
for p in ROLES[x]:
|
||||||
plr[p] = x
|
plr[p] = x
|
||||||
return plr
|
return plr
|
||||||
|
|
||||||
get_role = lambda plyr: list_players_and_roles()[plyr]
|
get_role = lambda plyr: list_players_and_roles()[plyr]
|
||||||
|
|
||||||
|
|
||||||
def del_player(pname):
|
def del_player(pname):
|
||||||
prole = get_role(pname)
|
prole = get_role(pname)
|
||||||
ROLES[prole].remove(pname)
|
ROLES[prole].remove(pname)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidModeException(Exception): pass
|
class InvalidModeException(Exception): pass
|
||||||
def game_mode(name):
|
def game_mode(name):
|
||||||
def decor(c):
|
def decor(c):
|
||||||
@ -126,7 +126,7 @@ def game_mode(name):
|
|||||||
return c
|
return c
|
||||||
return decor
|
return decor
|
||||||
|
|
||||||
|
|
||||||
CHANGEABLE_ROLES = { "seers" : INDEX_OF_ROLE["seer"],
|
CHANGEABLE_ROLES = { "seers" : INDEX_OF_ROLE["seer"],
|
||||||
"wolves" : INDEX_OF_ROLE["wolf"],
|
"wolves" : INDEX_OF_ROLE["wolf"],
|
||||||
"cursed" : INDEX_OF_ROLE["cursed villager"],
|
"cursed" : INDEX_OF_ROLE["cursed villager"],
|
||||||
@ -137,7 +137,7 @@ CHANGEABLE_ROLES = { "seers" : INDEX_OF_ROLE["seer"],
|
|||||||
"werecrows" : INDEX_OF_ROLE["werecrow"],
|
"werecrows" : INDEX_OF_ROLE["werecrow"],
|
||||||
"angels" : INDEX_OF_ROLE["guardian angel"],
|
"angels" : INDEX_OF_ROLE["guardian angel"],
|
||||||
"detectives" : INDEX_OF_ROLE["detective"]}
|
"detectives" : INDEX_OF_ROLE["detective"]}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ CHANGEABLE_ROLES = { "seers" : INDEX_OF_ROLE["seer"],
|
|||||||
@game_mode("roles")
|
@game_mode("roles")
|
||||||
class ChangedRolesMode(object):
|
class ChangedRolesMode(object):
|
||||||
"""Example: !fgame roles=wolves:1,seers:0,angels:1"""
|
"""Example: !fgame roles=wolves:1,seers:0,angels:1"""
|
||||||
|
|
||||||
def __init__(self, arg):
|
def __init__(self, arg):
|
||||||
self.ROLES_GUIDE = ROLES_GUIDE.copy()
|
self.ROLES_GUIDE = ROLES_GUIDE.copy()
|
||||||
lx = list(ROLES_GUIDE[None])
|
lx = list(ROLES_GUIDE[None])
|
||||||
@ -170,10 +170,10 @@ class ChangedRolesMode(object):
|
|||||||
for k in ROLES_GUIDE.keys():
|
for k in ROLES_GUIDE.keys():
|
||||||
self.ROLES_GUIDE[k] = tuple(lx)
|
self.ROLES_GUIDE[k] = tuple(lx)
|
||||||
|
|
||||||
|
|
||||||
# Persistence
|
# Persistence
|
||||||
|
|
||||||
|
|
||||||
# Load saved settings
|
# Load saved settings
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
@ -183,66 +183,66 @@ conn = sqlite3.connect("data.sqlite3", check_same_thread = False)
|
|||||||
with conn:
|
with conn:
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS away (nick TEXT)') # whoops, i mean cloak, not nick
|
c.execute('CREATE TABLE IF NOT EXISTS away (nick TEXT)') # whoops, i mean cloak, not nick
|
||||||
|
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS simple_role_notify (cloak TEXT)') # people who understand each role
|
c.execute('CREATE TABLE IF NOT EXISTS simple_role_notify (cloak TEXT)') # people who understand each role
|
||||||
|
|
||||||
c.execute('SELECT * FROM away')
|
c.execute('SELECT * FROM away')
|
||||||
for row in c:
|
for row in c:
|
||||||
AWAY.append(row[0])
|
AWAY.append(row[0])
|
||||||
|
|
||||||
c.execute('SELECT * FROM simple_role_notify')
|
c.execute('SELECT * FROM simple_role_notify')
|
||||||
for row in c:
|
for row in c:
|
||||||
SIMPLE_NOTIFY.append(row[0])
|
SIMPLE_NOTIFY.append(row[0])
|
||||||
|
|
||||||
# populate the roles table
|
# populate the roles table
|
||||||
c.execute('DROP TABLE IF EXISTS roles')
|
c.execute('DROP TABLE IF EXISTS roles')
|
||||||
c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)')
|
c.execute('CREATE TABLE roles (id INTEGER PRIMARY KEY AUTOINCREMENT, role TEXT)')
|
||||||
|
|
||||||
for x in ["villager"]+list(ROLE_INDICES.values()):
|
for x in ["villager"]+list(ROLE_INDICES.values()):
|
||||||
c.execute("INSERT OR REPLACE INTO roles (role) VALUES (?)", (x,))
|
c.execute("INSERT OR REPLACE INTO roles (role) VALUES (?)", (x,))
|
||||||
|
|
||||||
|
|
||||||
c.execute(('CREATE TABLE IF NOT EXISTS rolestats (player TEXT, role TEXT, '+
|
c.execute(('CREATE TABLE IF NOT EXISTS rolestats (player TEXT, role TEXT, '+
|
||||||
'teamwins SMALLINT, individualwins SMALLINT, totalgames SMALLINT, '+
|
'teamwins SMALLINT, individualwins SMALLINT, totalgames SMALLINT, '+
|
||||||
'UNIQUE(player, role))'))
|
'UNIQUE(player, role))'))
|
||||||
|
|
||||||
if OPT_IN_PING:
|
if OPT_IN_PING:
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS ping (cloak text)')
|
c.execute('CREATE TABLE IF NOT EXISTS ping (cloak text)')
|
||||||
|
|
||||||
c.execute('SELECT * FROM ping')
|
c.execute('SELECT * FROM ping')
|
||||||
for row in c:
|
for row in c:
|
||||||
PING_IN.append(row[0])
|
PING_IN.append(row[0])
|
||||||
|
|
||||||
|
|
||||||
def remove_away(clk):
|
def remove_away(clk):
|
||||||
with conn:
|
with conn:
|
||||||
c.execute('DELETE from away where nick=?', (clk,))
|
c.execute('DELETE from away where nick=?', (clk,))
|
||||||
|
|
||||||
def add_away(clk):
|
def add_away(clk):
|
||||||
with conn:
|
with conn:
|
||||||
c.execute('INSERT into away VALUES (?)', (clk,))
|
c.execute('INSERT into away VALUES (?)', (clk,))
|
||||||
|
|
||||||
def remove_simple_rolemsg(clk):
|
def remove_simple_rolemsg(clk):
|
||||||
with conn:
|
with conn:
|
||||||
c.execute('DELETE from simple_role_notify where cloak=?', (clk,))
|
c.execute('DELETE from simple_role_notify where cloak=?', (clk,))
|
||||||
|
|
||||||
def add_simple_rolemsg(clk):
|
def add_simple_rolemsg(clk):
|
||||||
with conn:
|
with conn:
|
||||||
c.execute('INSERT into simple_role_notify VALUES (?)', (clk,))
|
c.execute('INSERT into simple_role_notify VALUES (?)', (clk,))
|
||||||
|
|
||||||
def remove_ping(clk):
|
def remove_ping(clk):
|
||||||
with conn:
|
with conn:
|
||||||
c.execute('DELETE from ping where cloak=?', (clk,))
|
c.execute('DELETE from ping where cloak=?', (clk,))
|
||||||
def add_ping(clk):
|
def add_ping(clk):
|
||||||
with conn:
|
with conn:
|
||||||
c.execute('INSERT into ping VALUES (?)', (clk,))
|
c.execute('INSERT into ping VALUES (?)', (clk,))
|
||||||
|
|
||||||
|
|
||||||
def update_role_stats(acc, role, won, iwon):
|
def update_role_stats(acc, role, won, iwon):
|
||||||
|
|
||||||
with conn:
|
with conn:
|
||||||
wins, iwins, totalgames = 0, 0, 0
|
wins, iwins, totalgames = 0, 0, 0
|
||||||
|
|
||||||
c.execute(("SELECT teamwins, individualwins, totalgames FROM rolestats "+
|
c.execute(("SELECT teamwins, individualwins, totalgames FROM rolestats "+
|
||||||
"WHERE player=? AND role=?"), (acc, role))
|
"WHERE player=? AND role=?"), (acc, role))
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
@ -250,13 +250,13 @@ def update_role_stats(acc, role, won, iwon):
|
|||||||
wins, iwins, total = row
|
wins, iwins, total = row
|
||||||
else:
|
else:
|
||||||
wins, iwins, total = 0,0,0
|
wins, iwins, total = 0,0,0
|
||||||
|
|
||||||
if won:
|
if won:
|
||||||
wins += 1
|
wins += 1
|
||||||
if iwon:
|
if iwon:
|
||||||
iwins += 1
|
iwins += 1
|
||||||
total += 1
|
total += 1
|
||||||
|
|
||||||
c.execute("INSERT OR REPLACE INTO rolestats VALUES (?,?,?,?,?)",
|
c.execute("INSERT OR REPLACE INTO rolestats VALUES (?,?,?,?,?)",
|
||||||
(acc, role, wins, iwins, total))
|
(acc, role, wins, iwins, total))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user