Skip to content

Node Methods

Max Brauer edited this page Aug 25, 2024 · 1 revision

PhaseNode

func start

Returns true if this is the current start phase. Exactly one phase has to return true and all other ones has to return false. If this is not the case the mode is not allowed to start in this configuration.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Phase

func next

Returns the type of the next phase that will be executed after this one. There is no need that the next phase has a scene that can be executed. The runner will just ask for the next phase again. If during this process a phase is returned twice and no executable scene could be found, the game is aborted and doesn't count to any highscores. If you want to finish a game, you have to use the win conditions. Win conditions are checked before any phase next call.

Info Value
Return Type PhaseType
Required True

Variables:

  • $game: Mode
  • $this: Phase

func background

The resource path to the background image for the current phase.

Info Value
Return Type String
Required True

Variables:

  • $game: Mode
  • $this: Phase

func theme

The current color theme for this phase. Must be in the rgb format '#abcdef'.

Info Value
Return Type String
Required True

Variables:

  • $game: Mode
  • $this: Phase

SceneNode

func enable

Returns true if this scene is enabled for this game mode and configuration at all. This is only evaluated once before the start of the game.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode

func run_on

Checks if this scene can be executed right now. If not the game cycle will check the next scene and so on.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Scene

func can_message

Returns true if $character can send a message in the current scene.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Scene
  • $character: Character

func start

Executed everytime when this scene starts

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Scene

func stop

Executed everytime when this scene is finished and transitioned to the next one. This wont be executed if the game was finished in this scene.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Scene

LabelNode

func view

Returns true, if this label can be seen by $viewer. This label is attached to the character $current. If the viewer is the game master (without a character) or a player that is disabled and is allowed to see details, $viewer is empty. Guests that just joined the lobby cannot see any details and this method is never called for them.

This method is only available if target is set to character.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $current: Character
  • $viewer: Maybe { Character }

func attach_character

The action that is executed if this label is attached to the character $target.

This method is only available if target is set to character.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Character

func attach_phase

The action that is executed if this label is attached to the phase $target.

This method is only available if target is set to phase.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Phase

func attach_scene

The action that is executed if this label is attached to the scene $target.

This method is only available if target is set to scene.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Scene

func attach_voting

The action that is executed if this label is attached to the voting $target.

This method is only available if target is set to voting.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Voting

func detach_character

The action that is executed if this label is detached from the character $target.

This method is only available if target is set to character.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Character

func detach_phase

The action that is executed if this label is detached from the phase $target.

This method is only available if target is set to phase.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Phase

func detach_scene

The action that is executed if this label is detached from the scene $target.

This method is only available if target is set to scene.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Scene

func detach_voting

The action that is executed if this label is detached from the voting $target.

This method is only available if target is set to voting.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Label
  • $target: Voting

CharacterNode

func enable

Returns true if the current character configuration is allowed and the game can be start. This method is called for each character prototype that is a part of the current game. Non selected characters are not checked.

If this method is not defined, the current configuration will always be accepted.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode

func valid_usage

Similar to enable is this executed before the game to check if the preconditions are met to start a game. This function is called everytime when someone changes the current number of characters for this type. There is no $game instance for this function and every method that rely on this cannot be used.

Returning a value differnet to $count is considered as an user error, will be reported and the number will be changed to the returned one. $old will contain the value before any change was done.

Info Value
Return Type Int
Required False

Variables:

  • $count: Int
  • $old: Int

func create

Will be executed when this character is part of the game and the game starts. At this point is this character always enabled.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Character

func view

Returns the character type that is visible to the respective viewer. By default this will return the current character type but you can specify this function to overwrite this behavior and let them see a different character type. Can be used to hide the character role from the player.

This function can be overwritten by the game rules AllCanSeeRoleOfDead and DeadCanSeeAllRoles. The game master (if he has no character) and the character itself can always see the true character type. Guests that just joined the lobby can never see the real character.

Info Value
Return Type CharacterType
Required False

Variables:

  • $game: Mode
  • $this: Character
  • $viewer: Character

func attach

Will be executed if $label is added to this character.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Character
  • $label: Label

func detach

Will be executed if $label is removed from this character.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Character
  • $label: Label

VotingNode

func targets

The list of character that are used as a target for this voting. Only used if target is set to each or multi_each.

voting VotingName {
    target each;
    // The list of all targets. For each one is a voting created that is
    // assigned to only this character.
    func targets { @character }
}
Info Value
Return Type { Character } [1]
Required False

Variables:

  • $game: Mode

func voting_option

Returns a list of options that will be displayed if not otherwise specified at spawn.

Info Value
Return Type { Character, OptionType } [1]
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character

func can_vote

Returns true if the character $voter is allowed to vote in this voting instance. If target each or target multi_each was set, $target will contain the target character for this voting. Otherwise, is the variable $target not available.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character
  • $voter: Character

func can_view

Returns true if the character $viewer is allowed to view this voting instance. If target each or target multi_each was set, $target will contain the target character for this voting. Otherwise, is the variable $target not available.

The game master (if he has no character) can always view any voting. Guests that just joined the lobby and have no character can never see any voting.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character
  • $viewer: Character

func create

Executed when this voting is created and attached to the game.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character

func can_finish

Checks if the current voting can be finished. Only used if target multi_each was set. This function will be called everytime the submit button was pressed.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character
  • $characters: { Character } [1]
  • $choices: { Option } [1]

func choice

Will be executed if a single option got the majority of all voter. $choice contains the selected option. $character contains the selected character if the selected option is one.

If multiple options have the majority, the function unanimous will be executed. If the voting was cancelled prematurely, neither choice nor unanimous will be executed.

If target each or target multi_each was set, $target will contain the target character for this voting. Otherwise, is the variable $target not available.

If target multi_each was set, a finalized voting will always call the handler func unanimous and not this one.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character
  • $character: Maybe { Character }
  • $choice: Character, Option

func unanimous

Will be executed if multiple options got the majority of all voter. $choices contain all the selected options. $characters contain the selected characters out of $choices.

If only one option has the majority, the function unanimous will be executed. If the voting was cancelled prematurely, neither choice nor unanimous will be executed.

If target each or target multi_each was set, $target will contain the target character for this voting. Otherwise, is the variable $target not available.

If target multi_each was set, a finalized voting will always call this handler and not func choice. The submit option wont be included in the resulting list.

Info Value
Return Type mut { Void }
Required False

Variables:

  • $game: Mode
  • $this: Voting
  • $target: Character
  • $characters: { Character } [1]
  • $choices: { Option } [1]

WinNode

func check

Returns true if the win condition is successfull and the game is now finished.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode

func winner

Returns a collection of all character that won this game right now. If this function is not defined, no winner is selected.

Info Value
Return Type { Character } [1]
Required False

Variables:

  • $game: Mode

func has_one

Checks if there is one or more winner. The winner will be returned using this function. If an empty collection is returned, the game is considered as unfinished and will be continued.

If this function is defined, it replaces the functions check and winner. Those two will be ignored and only this will be handled.

Info Value
Return Type { Character } [1]
Required False

Variables:

  • $game: Mode

EventNode

func enable

Returns true if this event is allowed to be triggered at this time.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode

func finished

Returns true if this event is finished and can be removed from the current event list. As long as an event is still contained in the event list, all listed sequences will trigger as long as the specified phase or scene is entered.

Info Value
Return Type Bool
Required False

Variables:

  • $game: Mode
  • $this: Event