Events/del_player
The del_player event is called whenever a player dies, after any death triggers happen for that player (this means that for chained deaths, the event is effectively called in reverse order where the start of the chain is called last). This is a rather complicated event and has multiple parameters that are subtly different from each other. Commonly used parameters are passed in the function whereas less-commonly-used ones are passed in event.params.
Event callback
def on_del_player(event: Event, cli: IRCClient, var: module, nick: str, nickrole: str, nicktpls: List[str], death_triggers: bool) -> None
- prevent_default has no effect for this event
event
: The event objectcli
: The IRC connectionvar
: Reference to the src.settings modulenick
: The nick that diednickrole
: What role nick hadnicktpls
: List of templates nick haddeath_triggers
: True if death triggers were fired for nick (e.g. they did not idle out and it is during game)
Extra parameters
The following are available as attributes on event.params
forced_death
: True if nick died due to being lynched, False otherwiseend_game
: True if this death can cause a game end (this is set to False for chained deaths and also during transition_day when performing all night deaths)killer_role
: Role of the person that killed nick (or "villager" if nick was lynched or died to a gun exploding)deadlist
: List of all players that have died thus far in the current group (this may encompass multiple chains, notably for nighttime deaths where everyone that died at night is put into deadlist). Use this to determine whether or not a player is going to be dying right now but the code just hasn't gotten around to them yet. This list should not be mutated; if it needs to be modified to pass into a chained del_player, make a copy and pass in that mutated copy instead.original
: The nick of the person that died originally, this is different than nick if this is a chained death. Even if they are the same, it may still be a chained death, so it is probably best to not rely on this to determine chain death/not chain death (see ismain below for that)ismain
: If True, this is the original death. If False, this is a chain deathdel_player
: If your event kills anyone, call this function to accomplish that.refresh_pl
: If your event kills anyone, you must set event.data["pl"] to the output of this function. Otherwise, chained deaths may result in errors if they contain loops.
None of the parameters should be modified.
Event data
{
"pl": List[str]
}
The only event data is the player list, which is different than list_players() as it excludes people known to be dying but aren't actually dead yet. If the event callback kills anyone, use the following code to accomplish that (replace <nick> and <role> with appropriate values):
event.params.del_player(cli, <nick>, forced_death=True, end_game=False, killer_role=<role>, deadlist=event.params.deadlist, original=event.params.original, ismain=False)
event.data["pl"] = event.params.refresh_pl(event.data["pl"])