Events/role_attribution

From Werewolf Wiki
Jump to navigation Jump to search

The role_attribution event allows for customizing which roles are assigned. It is not possible to directly assign a particular role to a particular player with this event.

Event callback

def on_role_attribution(
        event: Event,
        cli: IRCClient,
        chk_win_conditions: func(lpl: int, lwolves: int, lcubs: int, lrealwolves: int, lmonsters: int, ldemoniacs: int, ltraitors: int, lsuccubi: int, lentranced: int, cli: IRCClient, end_game: bool=True, winner: str or None=None) -> bool,
        var: module,
        villagers: list(str)
    )

Do not modify any parameters to this event.

  • The default action is to merge the addroles dict with the default role listing for the gamemode. If the default is prevented, the gamemode roles are not used at all and all roles come from the addroles dict.
  • event: The event object
  • cli: The IRC connection
  • chk_win_conditions: Function used to see if a particular role assignment would result in an instant game over, useful if randomizing roles
  • var: Reference to the src.settings module
  • villagers: List of players

Event data

{
    "addroles": dict(str: int)
}

By default, addroles is an empty dict. It is a mapping of role name to how many players to have in that role. If the default action is not prevented, this is merged with the role list for the gamemode.