Add event for amnesiac turning (for the random game mode)

This commit is contained in:
Vgr E.Barry 2015-06-14 16:32:39 -04:00
parent 5c4dcec8e6
commit a8984b6a56
2 changed files with 38 additions and 20 deletions

View File

@ -788,6 +788,21 @@ class RandomMode(GameMode):
"misdirection": ( 6 , 1 ),
}
def startup(self):
events.add_listener("amnesiac_turn", self.amnesiac_turn, 1)
def teardown(self):
events.remove_listener("amnesiac_turn", self.amnesiac_turn, 1)
def amnesiac_turn(self, evt, var, amn, role):
var.ROLES["amnesiac"].remove(amn)
var.ROLES[role].append(amn)
var.ORIGINAL_ROLES["amnesiac"].remove(amn)
var.ORIGINAL_ROLES[role].append(amn)
del var.FINAL_ROLES[amn]
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

@ -5264,27 +5264,30 @@ def transition_night(cli):
# convert amnesiac
if var.NIGHT_COUNT == var.AMNESIAC_NIGHTS:
amns = copy.copy(var.ROLES["amnesiac"])
for amn in amns:
amnrole = var.FINAL_ROLES[amn]
var.ROLES["amnesiac"].remove(amn)
var.ROLES[amnrole].append(amn)
var.AMNESIACS.append(amn)
if var.FIRST_NIGHT: # we don't need to tell them twice if they remember right away
continue
showrole = amnrole
if showrole == "time lord":
showrole = "villager"
elif showrole == "vengeful ghost":
showrole = var.DEFAULT_ROLE
n = ""
if showrole.startswith(("a", "e", "i", "o", "u")):
n = "n"
pm(cli, amn, "Your amnesia clears and you now remember that you are a{0} \u0002{1}\u0002!".format(n, showrole))
if amnrole in var.WOLFCHAT_ROLES:
for wolf in var.list_players(var.WOLFCHAT_ROLES):
if wolf != amn: # don't send "Foo is now a wolf!" to 'Foo'
pm(cli, wolf, "\u0002{0}\u0002 is now a \u0002{1}\u0002!".format(amn, showrole))
debuglog("{0} REMEMBER: {1} as {2}".format(amn, amnrole, showrole))
event = Event("amnesiac_turn", {})
if event.dispatch(var, amn, var.FINAL_ROLES[amn]):
amnrole = var.FINAL_ROLES[amn]
var.ROLES["amnesiac"].remove(amn)
var.ROLES[amnrole].append(amn)
var.AMNESIACS.append(amn)
if var.FIRST_NIGHT: # we don't need to tell them twice if they remember right away
continue
showrole = amnrole
if showrole == "time lord":
showrole = "villager"
elif showrole == "vengeful ghost":
showrole = var.DEFAULT_ROLE
n = ""
if showrole.startswith(("a", "e", "i", "o", "u")):
n = "n"
pm(cli, amn, "Your amnesia clears and you now remember that you are a{0} \u0002{1}\u0002!".format(n, showrole))
if amnrole in var.WOLFCHAT_ROLES:
for wolf in var.list_players(var.WOLFCHAT_ROLES):
if wolf != amn: # don't send "Foo is now a wolf!" to 'Foo'
pm(cli, wolf, "\u0002{0}\u0002 is now a \u0002{1}\u0002!".format(amn, showrole))
debuglog("{0} REMEMBER: {1} as {2}".format(amn, amnrole, showrole))
if var.FIRST_NIGHT and chk_win(cli, end_game=False): # prevent game from ending as soon as it begins (useful for the random game mode)
start(cli, botconfig.NICK, botconfig.CHANNEL, restart=var.CURRENT_GAMEMODE.name)