added winning condition check
This commit is contained in:
parent
49a4677aeb
commit
d7e9263aa0
40
wolfgame.py
40
wolfgame.py
@ -256,6 +256,25 @@ def show_votes(cli, nick, chan, rest):
|
|||||||
"to vote.").format(nick, len(pl), votesneeded, avail))
|
"to vote.").format(nick, len(pl), votesneeded, avail))
|
||||||
|
|
||||||
|
|
||||||
|
def chk_win(cli):
|
||||||
|
chan = botconfig.CHANNEL
|
||||||
|
if len(vars.ROLES["wolf"]) >= len(vars.list_players()) / 2:
|
||||||
|
cli.msg(chan, ("Game over! There are the same number of wolves as "+
|
||||||
|
"villagers. The wolves eat everyone, and win."))
|
||||||
|
elif not len(vars.ROLES["wolf"]) and not vars.ROLES["traitor"]:
|
||||||
|
cli.msg(chan, ("Game over! All the wolves are dead! The villagers "+
|
||||||
|
"chop them up, BBQ them, and have a hearty meal."))
|
||||||
|
elif not len(vars.ROLES["wolf"]) and vars.ROLES["traitor"]:
|
||||||
|
pass # WOLVES ARE NOT GONE :O
|
||||||
|
# TODO: transform TRAITOR
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
# TODO: Print the game time stats here
|
||||||
|
reset(cli)
|
||||||
|
# TODO: Reveal roles here
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def del_player(cli, nick, forced_death):
|
def del_player(cli, nick, forced_death):
|
||||||
cli.mode(botconfig.CHANNEL, "-v", "{0} {0}!*@*".format(nick))
|
cli.mode(botconfig.CHANNEL, "-v", "{0} {0}!*@*".format(nick))
|
||||||
@ -263,7 +282,12 @@ def del_player(cli, nick, forced_death):
|
|||||||
cli.mode(botconfig.CHANNEL, "+q", "{0} {0}!*@*".format(nick))
|
cli.mode(botconfig.CHANNEL, "+q", "{0} {0}!*@*".format(nick))
|
||||||
vars.DEAD.append(nick)
|
vars.DEAD.append(nick)
|
||||||
vars.del_player(nick)
|
vars.del_player(nick)
|
||||||
|
chk_win(cli)
|
||||||
|
if vars.VICTIM == nick:
|
||||||
|
vars.VICTIM = ""
|
||||||
if vars.PHASE == "day" and not forced_death: # didn't die from lynching
|
if vars.PHASE == "day" and not forced_death: # didn't die from lynching
|
||||||
|
if nick in vars.VOTES.keys():
|
||||||
|
del vars.VOTES[nick] # Delete his votes
|
||||||
chk_decision(cli)
|
chk_decision(cli)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -426,7 +450,7 @@ def see(cli, nick, rest):
|
|||||||
return
|
return
|
||||||
if vars.CURSED == nick:
|
if vars.CURSED == nick:
|
||||||
role = "wolf"
|
role = "wolf"
|
||||||
elif vars.TRAITOR == nick:
|
if vars.get_role(victim) == "traitor":
|
||||||
role = "villager"
|
role = "villager"
|
||||||
else:
|
else:
|
||||||
role = vars.get_role(victim)
|
role = vars.get_role(victim)
|
||||||
@ -544,31 +568,35 @@ def start(cli, nick, chan, rest):
|
|||||||
seer = random.choice(pl)
|
seer = random.choice(pl)
|
||||||
vars.ROLES["seer"] = [seer]
|
vars.ROLES["seer"] = [seer]
|
||||||
pl.remove(seer)
|
pl.remove(seer)
|
||||||
if nharlots:
|
|
||||||
harlots = random.sample(pl, nharlots)
|
harlots = random.sample(pl, nharlots)
|
||||||
vars.ROLES["harlot"] = harlots
|
vars.ROLES["harlot"] = harlots
|
||||||
for h in harlots:
|
for h in harlots:
|
||||||
pl.remove(h)
|
pl.remove(h)
|
||||||
if nwolves:
|
|
||||||
wolves = random.sample(pl, nwolves)
|
wolves = random.sample(pl, nwolves)
|
||||||
vars.ROLES["wolf"] = wolves
|
vars.ROLES["wolf"] = wolves
|
||||||
for w in wolves:
|
for w in wolves:
|
||||||
pl.remove(w)
|
pl.remove(w)
|
||||||
if ndrunk:
|
|
||||||
drunk = random.choice(pl)
|
drunk = random.choice(pl)
|
||||||
vars.ROLES["village drunk"] = [drunk]
|
vars.ROLES["village drunk"] = [drunk]
|
||||||
pl.remove(drunk)
|
pl.remove(drunk)
|
||||||
|
|
||||||
vars.ROLES["villager"] = pl
|
vars.ROLES["villager"] = pl
|
||||||
|
|
||||||
if ncursed:
|
if ncursed:
|
||||||
vars.CURSED = random.choice(vars.ROLES["villager"] + \
|
vars.CURSED = random.choice(vars.ROLES["villager"] + \
|
||||||
vars.ROLES.get("harlot", []) +\
|
vars.ROLES.get("harlot", []) +\
|
||||||
vars.ROLES.get("village drunk", []))
|
vars.ROLES.get("village drunk", []))
|
||||||
|
else:
|
||||||
|
vars.CURSED = ""
|
||||||
|
|
||||||
if ntraitor:
|
if ntraitor:
|
||||||
possible = vars.ROLES["villager"]
|
possible = vars.ROLES["villager"]
|
||||||
if ncursed:
|
if vars.CURSED:
|
||||||
possible.remove(vars.CURSED) # Cursed traitors are not allowed
|
possible.remove(vars.CURSED) # Cursed traitors are not allowed
|
||||||
vars.TRAITOR = random.choice(possible)
|
vars.ROLES["traitor"] = random.sample(possible, ntraitor)
|
||||||
|
|
||||||
cli.msg(chan, ("{0}: Welcome to Werewolf, the popular detective/social party "+
|
cli.msg(chan, ("{0}: Welcome to Werewolf, the popular detective/social party "+
|
||||||
"game (a theme of Mafia).").format(", ".join(vars.list_players())))
|
"game (a theme of Mafia).").format(", ".join(vars.list_players())))
|
||||||
|
Loading…
Reference in New Issue
Block a user