Add chk_traitor event (for the random game mode)

This commit is contained in:
Vgr E.Barry 2015-06-14 16:35:14 -04:00
parent aaaf3df0f5
commit 5d8cd14db8
2 changed files with 48 additions and 19 deletions

View File

@ -788,10 +788,12 @@ class RandomMode(GameMode):
def startup(self):
events.add_listener("amnesiac_turn", self.amnesiac_turn, 1)
events.add_listener("roles_check", self.roles_check, 1)
events.add_listener("chk_traitor", self.chk_traitor, 1)
def teardown(self):
events.remove_listener("amnesiac_turn", self.amnesiac_turn, 1)
events.remove_listener("roles_check", self.roles_check, 1)
events.remove_listener("chk_traitor", self.chk_traitor, 1)
def amnesiac_turn(self, evt, var, amn, role):
var.ROLES["amnesiac"].remove(amn)
@ -805,6 +807,25 @@ class RandomMode(GameMode):
def roles_check(self, evt, var, addroles):
evt.prevent_default = True
def chk_traitor(self, evt, cli, var, cubes, betrayers):
if not var.FIRST_NIGHT:
return # use normal chk_traitor
for cube in cubes:
var.ROLES["wolf"].append(cube)
var.ROLES["wolf cub"].remove(cube)
var.ORIGINAL_ROLES["wolf"].append(cube)
var.ORIGINAL_ROLES["wolf cub"].remove(cube)
if len(var.ROLES["wolf"]) == 0:
for betrayer in betrayers:
var.ROLES["wolf"].append(betrayer)
var.ROLES["traitor"].remove(betrayer)
var.ORIGINAL_ROLES["wolf"].append(betrayer)
var.ORIGINAL_ROLES["traitor"].remove(betrayer)
evt.prevent_default = True
# Credits to Metacity for designing and current name
# Blame arkiwitect for the original name of KrabbyPatty
@game_mode("aleatoire", minp = 8, maxp = 24, likelihood = 4)

View File

@ -1632,29 +1632,37 @@ def show_votes(cli, nick, chan, rest):
cli.msg(chan, the_message)
def chk_traitor(cli):
realwolves = var.WOLF_ROLES[:]
realwolves.remove("wolf cub")
if len(var.list_players(realwolves)) > 0:
return # actual wolves still alive
wcl = copy.copy(var.ROLES["wolf cub"])
ttl = copy.copy(var.ROLES["traitor"])
for wc in wcl:
var.ROLES["wolf"].append(wc)
var.ROLES["wolf cub"].remove(wc)
pm(cli, wc, "You have grown up into a wolf and vowed to take revenge for your dead parents!")
debuglog(wc, "(wolf cub) GROW UP")
if len(var.ROLES["wolf"]) == 0:
for tt in ttl:
var.ROLES["wolf"].append(tt)
var.ROLES["traitor"].remove(tt)
if tt in var.ROLES["cursed villager"]:
var.ROLES["cursed villager"].remove(tt)
pm(cli, tt, "HOOOOOOOOOWL. You have become... a wolf!\n"+
"It is up to you to avenge your fallen leaders!")
debuglog(tt, "(traitor) TURNING")
event = Event("chk_traitor", {})
if event.dispatch(cli, var, wcl, ttl):
for wc in wcl:
var.ROLES["wolf"].append(wc)
var.ROLES["wolf cub"].remove(wc)
pm(cli, wc, "You have grown up into a wolf and vowed to take revenge for your dead parents!")
debuglog(wc, "(wolf cub) GROW UP")
# no message if wolf cub becomes wolf for now, may want to change that in future
if len(var.ROLES["wolf"]) > 0:
cli.msg(botconfig.CHANNEL, "\u0002The villagers, during their celebrations, are "+
"frightened as they hear a loud howl. The wolves are "+
"not gone!\u0002")
if len(var.ROLES["wolf"]) == 0:
for tt in ttl:
var.ROLES["wolf"].append(tt)
var.ROLES["traitor"].remove(tt)
if tt in var.ROLES["cursed villager"]:
var.ROLES["cursed villager"].remove(tt)
pm(cli, tt, "HOOOOOOOOOWL. You have become... a wolf!\n"+
"It is up to you to avenge your fallen leaders!")
debuglog(tt, "(traitor) TURNING")
# no message if wolf cub becomes wolf for now, may want to change that in future
if len(var.ROLES["wolf"]) > 0:
cli.msg(botconfig.CHANNEL, "\u0002The villagers, during their celebrations, are "+
"frightened as they hear a loud howl. The wolves are "+
"not gone!\u0002")
def stop_game(cli, winner = "", abort = False):
chan = botconfig.CHANNEL