|
|
|
@ -2,6 +2,8 @@ from oyoyo.parse import parse_nick
@@ -2,6 +2,8 @@ from oyoyo.parse import parse_nick
|
|
|
|
|
import vars |
|
|
|
|
import botconfig |
|
|
|
|
import decorators |
|
|
|
|
import time |
|
|
|
|
import random |
|
|
|
|
|
|
|
|
|
COMMANDS = {} |
|
|
|
|
PM_COMMANDS = {} |
|
|
|
@ -17,7 +19,6 @@ def connect_callback(cli):
@@ -17,7 +19,6 @@ def connect_callback(cli):
|
|
|
|
|
cli.identify(botconfig.PASS) |
|
|
|
|
cli.join(botconfig.CHANNEL) |
|
|
|
|
cli.msg("ChanServ", "op "+botconfig.CHANNEL) |
|
|
|
|
cli.msg(botconfig.CHANNEL, "\u0002Wolfbot2 is here.\u0002") |
|
|
|
|
|
|
|
|
|
def reset_game(): |
|
|
|
|
vars.ROLES = {"person" : []} |
|
|
|
@ -29,12 +30,12 @@ def say(cli, nick, rest): # To be removed later
@@ -29,12 +30,12 @@ def say(cli, nick, rest): # To be removed later
|
|
|
|
|
cli.msg(botconfig.CHANNEL, "{0} says: {1}".format(nick, rest)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pmcmd("!bye") |
|
|
|
|
@cmd("!bye") |
|
|
|
|
@pmcmd("!bye", admin_only=True) |
|
|
|
|
@cmd("!bye", admin_only=True) |
|
|
|
|
def forced_exit(cli, nick, *rest): # Admin Only |
|
|
|
|
if nick in botconfig.ADMINS: |
|
|
|
|
cli.quit("Forced quit from admin") |
|
|
|
|
raise SystemExit |
|
|
|
|
reset_game(cli, nick, rest[0], None) |
|
|
|
|
cli.quit("Forced quit from admin") |
|
|
|
|
raise SystemExit |
|
|
|
|
|
|
|
|
|
@cmd("!exec") |
|
|
|
|
def py(cli, nick, chan, rest): |
|
|
|
@ -71,55 +72,165 @@ def pinger(cli, nick, chan, rest):
@@ -71,55 +72,165 @@ def pinger(cli, nick, chan, rest):
|
|
|
|
|
@cmd("!join") |
|
|
|
|
def join(cli, nick, chan, rest): |
|
|
|
|
if vars.PHASE == "none": |
|
|
|
|
cli.mode(chan, "+v", nick, nick+"!*@*") |
|
|
|
|
vars.ROLES["person"].append(nick) |
|
|
|
|
vars.PHASE = "join" |
|
|
|
|
vars.CAN_START_TIME = time.time() + vars.MINIMUM_WAIT |
|
|
|
|
cli.msg(chan, '\u0002{0}\u0002 has started a game of Werewolf. \ |
|
|
|
|
Type "!join" to join. Type "!start" to start the game. \ |
|
|
|
|
Type "!wait" to increase join wait time.'.format(nick)) |
|
|
|
|
elif nick in list_players(): |
|
|
|
|
elif nick in vars.list_players(): |
|
|
|
|
cli.notice(nick, "You're already playing!") |
|
|
|
|
elif vars.PHASE != "join": |
|
|
|
|
cli.notice(nick, "Sorry but the game is already running. Try again next time.") |
|
|
|
|
else: |
|
|
|
|
cli.mode(chan, "+v", nick, nick+"!*@*") |
|
|
|
|
vars.ROLES["person"].append(nick) |
|
|
|
|
cli.msg(chan, '\u0002{0}\u0002 has joined the game.'.format(nick)) |
|
|
|
|
|
|
|
|
|
@cmd("!stats") |
|
|
|
|
def stats(cli, nick, chan, rest): |
|
|
|
|
if vars.PHASE == "none": |
|
|
|
|
cli.notice(nick, "No game is currently running.") |
|
|
|
|
return |
|
|
|
|
pl = list_players() |
|
|
|
|
|
|
|
|
|
pl = vars.list_players() |
|
|
|
|
if len(pl) > 1: |
|
|
|
|
cli.msg(chan, '{0}: {1} players: {2}'.format(nick, |
|
|
|
|
cli.msg(chan, '{0}: \u0002{1}\u0002 players: {2}'.format(nick, |
|
|
|
|
len(pl), ", ".join(pl))) |
|
|
|
|
else: |
|
|
|
|
cli.msg(chan, '{0}: 1 player: {1}'.format(nick, pl[0])) |
|
|
|
|
cli.msg(chan, '{0}: \u00021\u0002 player: {1}'.format(nick, pl[0])) |
|
|
|
|
|
|
|
|
|
if vars.PHASE == "join": |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
msg = [] |
|
|
|
|
for role in vars.ROLES.keys(): |
|
|
|
|
num = len(vars.ROLES[role]) |
|
|
|
|
if num > 1: |
|
|
|
|
msg.append("{0} {1}".format(num, plural(role))) |
|
|
|
|
message = [] |
|
|
|
|
for role in ("wolf", "seer", "harlot"): |
|
|
|
|
count = len(vars.ROLES.get(role,[])) |
|
|
|
|
if count > 1: |
|
|
|
|
message.append("\u0002(0}\u0002 {1}".format(count, vars.plural(role))) |
|
|
|
|
else: |
|
|
|
|
msg.append("{0} {1}".format(num, role)) |
|
|
|
|
if len(msg) > 2: # More than 2 roles to say |
|
|
|
|
msg[-1] = "and "+msg[-1]+"." |
|
|
|
|
msg[0] = "{0}: There are ".format(nick) + msg[0] |
|
|
|
|
cli.msg(chan, ", ".join(msg)) |
|
|
|
|
elif len(msg) == 2: # 2 roles to say |
|
|
|
|
cli.msg(chan, "{0}: There are ".format(nick) + msg[0], |
|
|
|
|
"and", msg[1] + ".") |
|
|
|
|
elif len(msg) == 1: |
|
|
|
|
cli.msg(chan, "{0}: There is ".format(nick) + msg[0] + ".") |
|
|
|
|
message.append("\u0002{0}\u0002 {1}".format(count, role)) |
|
|
|
|
cli.msg(chan, |
|
|
|
|
"{0}: There are {1}, and {2}.".format(nick, |
|
|
|
|
", ".join(message[0:-1]), |
|
|
|
|
message[-1])) |
|
|
|
|
|
|
|
|
|
def transition_night(cli, chan): |
|
|
|
|
vars.PHASE = "night" |
|
|
|
|
|
|
|
|
|
@cmd("!start") |
|
|
|
|
def start(cli, nick, chan, rest): |
|
|
|
|
pl = list_players() |
|
|
|
|
|
|
|
|
|
if(len(pl)) < 4: |
|
|
|
|
pl = vars.list_players() |
|
|
|
|
if vars.PHASE == "none": |
|
|
|
|
cli.notice(nick, "No game is currently running.") |
|
|
|
|
return |
|
|
|
|
if vars.PHASE != "join": |
|
|
|
|
cli.notice(nick, "Werewolf is already in play.") |
|
|
|
|
return |
|
|
|
|
if nick not in pl: |
|
|
|
|
cli.notice(nick, "You're currently not playing.") |
|
|
|
|
return |
|
|
|
|
now = time.time() |
|
|
|
|
if vars.CAN_START_TIME > now: |
|
|
|
|
cli.msg(chan, "Please wait at least {0} more seconds.".format( |
|
|
|
|
int(vars.CAN_START_TIME - now))) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
if len(pl) < 4: |
|
|
|
|
cli.msg(chan, "{0}: Four or more players are required to play.".format(nick)) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
vars.ROLES = {} |
|
|
|
|
nharlots = 0 |
|
|
|
|
nseers = 0 |
|
|
|
|
nwolves = 0 |
|
|
|
|
ndrunk = 0 |
|
|
|
|
ncursed = 0 |
|
|
|
|
|
|
|
|
|
if len(pl) >= 8: |
|
|
|
|
nharlots = 1 |
|
|
|
|
nseers = 1 |
|
|
|
|
nwolves = 2 |
|
|
|
|
ndrunk = 1 |
|
|
|
|
ncursed = 1 |
|
|
|
|
elif(len(pl)) >= 6: |
|
|
|
|
nseers = 1 |
|
|
|
|
nwolves = 1 |
|
|
|
|
ndrunk = 1 |
|
|
|
|
ncursed = 1 |
|
|
|
|
else: |
|
|
|
|
nseers = 1 |
|
|
|
|
nwolves = 1 |
|
|
|
|
|
|
|
|
|
seer = random.choice(pl) |
|
|
|
|
vars.ROLES["seer"] = [seer] |
|
|
|
|
pl.remove(seer) |
|
|
|
|
if nharlots: |
|
|
|
|
harlots = random.sample(pl, nharlots) |
|
|
|
|
vars.ROLES["harlot"] = harlots |
|
|
|
|
for h in harlots: |
|
|
|
|
pl.remove(h) |
|
|
|
|
if nwolves: |
|
|
|
|
wolves = random.sample(pl, nwolves) |
|
|
|
|
vars.ROLES["wolf"] = wolves |
|
|
|
|
for w in wolves: |
|
|
|
|
pl.remove(w) |
|
|
|
|
if ndrunk: |
|
|
|
|
drunk = random.choice(pl) |
|
|
|
|
vars.ROLES["village drunk"] = [drunk] |
|
|
|
|
pl.remove(drunk) |
|
|
|
|
vars.ROLES["villager"] = pl |
|
|
|
|
|
|
|
|
|
if ncursed: |
|
|
|
|
CURSED = random.choice(var.ROLES["villager"] + \ |
|
|
|
|
var.ROLES.get("harlot", []) +\ |
|
|
|
|
var.ROLES.get("village drunk", [])) |
|
|
|
|
|
|
|
|
|
cli.msg(chan, "{0}: Welcome to Werewolf, the popular detective/social \ |
|
|
|
|
party game (a theme of Mafia).".format(", ".join(vars.list_players()))) |
|
|
|
|
cli.mode(chan, "+m") |
|
|
|
|
|
|
|
|
|
vars.ORIGINAL_ROLES = dict(vars.ROLES) # Make a copy |
|
|
|
|
transition_night(cli, chan) |
|
|
|
|
|
|
|
|
|
@cmd("!wait") |
|
|
|
|
def wait(cli, nick, chan, rest): |
|
|
|
|
pl = vars.list_players() |
|
|
|
|
if vars.PHASE == "none": |
|
|
|
|
cli.notice(nick, "No game is currently running.") |
|
|
|
|
return |
|
|
|
|
if vars.PHASE != "join": |
|
|
|
|
cli.notice(nick, "Werewolf is already in play.") |
|
|
|
|
return |
|
|
|
|
if nick not in pl: |
|
|
|
|
cli.notice(nick, "You're currently not playing.") |
|
|
|
|
return |
|
|
|
|
if vars.WAITED >= vars.MAXIMUM_WAITED: |
|
|
|
|
cli.msg(chan, "Limit has already been reached for extending the wait time.") |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
now = time.time() |
|
|
|
|
if now > vars.CAN_START_TIME: |
|
|
|
|
vars.CAN_START_TIME = now + vars.EXTRA_WAIT |
|
|
|
|
else: |
|
|
|
|
vars.CAN_START_TIME += vars.EXTRA_WAIT |
|
|
|
|
vars.WAITED += 1 |
|
|
|
|
cli.msg(chan, "{0} increased the wait \ |
|
|
|
|
time by {1} seconds.".format(nick, vars.EXTRA_WAIT)) |
|
|
|
|
|
|
|
|
|
@cmd("!reset", admin_only = True) |
|
|
|
|
def reset_game(cli, nick, chan, rest): |
|
|
|
|
vars.PHASE = "none" |
|
|
|
|
cli.mode(chan, "-m") |
|
|
|
|
for pl in vars.list_players(): |
|
|
|
|
cli.mode(chan, "-v", pl) |
|
|
|
|
|
|
|
|
|
vars.ROLES = {"person" : []} |
|
|
|
|
vars.ORIGINAL_ROLES = None |
|
|
|
|
vars.CURSED = "" |
|
|
|
|
vars.GAME_START_TIME = 0 |
|
|
|
|
vars.CAN_START_TIME = 0 |
|
|
|
|
vars.GUNNERS = {} |
|
|
|
|
vars.WAITED = 0 |
|
|
|
|
|