Add event for amnesiac turning (for the random game mode)
This commit is contained in:
parent
5c4dcec8e6
commit
a8984b6a56
@ -788,6 +788,21 @@ class RandomMode(GameMode):
|
|||||||
"misdirection": ( 6 , 1 ),
|
"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
|
# Credits to Metacity for designing and current name
|
||||||
# Blame arkiwitect for the original name of KrabbyPatty
|
# Blame arkiwitect for the original name of KrabbyPatty
|
||||||
@game_mode("aleatoire", minp = 8, maxp = 24, likelihood = 4)
|
@game_mode("aleatoire", minp = 8, maxp = 24, likelihood = 4)
|
||||||
|
@ -5264,27 +5264,30 @@ def transition_night(cli):
|
|||||||
# convert amnesiac
|
# convert amnesiac
|
||||||
if var.NIGHT_COUNT == var.AMNESIAC_NIGHTS:
|
if var.NIGHT_COUNT == var.AMNESIAC_NIGHTS:
|
||||||
amns = copy.copy(var.ROLES["amnesiac"])
|
amns = copy.copy(var.ROLES["amnesiac"])
|
||||||
|
|
||||||
for amn in amns:
|
for amn in amns:
|
||||||
amnrole = var.FINAL_ROLES[amn]
|
event = Event("amnesiac_turn", {})
|
||||||
var.ROLES["amnesiac"].remove(amn)
|
if event.dispatch(var, amn, var.FINAL_ROLES[amn]):
|
||||||
var.ROLES[amnrole].append(amn)
|
amnrole = var.FINAL_ROLES[amn]
|
||||||
var.AMNESIACS.append(amn)
|
var.ROLES["amnesiac"].remove(amn)
|
||||||
if var.FIRST_NIGHT: # we don't need to tell them twice if they remember right away
|
var.ROLES[amnrole].append(amn)
|
||||||
continue
|
var.AMNESIACS.append(amn)
|
||||||
showrole = amnrole
|
if var.FIRST_NIGHT: # we don't need to tell them twice if they remember right away
|
||||||
if showrole == "time lord":
|
continue
|
||||||
showrole = "villager"
|
showrole = amnrole
|
||||||
elif showrole == "vengeful ghost":
|
if showrole == "time lord":
|
||||||
showrole = var.DEFAULT_ROLE
|
showrole = "villager"
|
||||||
n = ""
|
elif showrole == "vengeful ghost":
|
||||||
if showrole.startswith(("a", "e", "i", "o", "u")):
|
showrole = var.DEFAULT_ROLE
|
||||||
n = "n"
|
n = ""
|
||||||
pm(cli, amn, "Your amnesia clears and you now remember that you are a{0} \u0002{1}\u0002!".format(n, showrole))
|
if showrole.startswith(("a", "e", "i", "o", "u")):
|
||||||
if amnrole in var.WOLFCHAT_ROLES:
|
n = "n"
|
||||||
for wolf in var.list_players(var.WOLFCHAT_ROLES):
|
pm(cli, amn, "Your amnesia clears and you now remember that you are a{0} \u0002{1}\u0002!".format(n, showrole))
|
||||||
if wolf != amn: # don't send "Foo is now a wolf!" to 'Foo'
|
if amnrole in var.WOLFCHAT_ROLES:
|
||||||
pm(cli, wolf, "\u0002{0}\u0002 is now a \u0002{1}\u0002!".format(amn, showrole))
|
for wolf in var.list_players(var.WOLFCHAT_ROLES):
|
||||||
debuglog("{0} REMEMBER: {1} as {2}".format(amn, amnrole, showrole))
|
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)
|
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)
|
start(cli, botconfig.NICK, botconfig.CHANNEL, restart=var.CURRENT_GAMEMODE.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user