DevJoy.Scene.Condition (DevJoy v2.0.0)
View SourceConditions are used to choose one of the available choices based on their action which is invoked at runtime. The character would be fetched at runtime making its data customisable using a data module.
Usage
The condition always requires a character id,
action and possible choices.
defmodule MyApp.SceneName do
use DevJoy.Scene
part :condition do
condition :john_doe, &MyApp.some_func/1 do
choice :choiceA, goto(:partA)
choice :choiceB, goto(:partB)
end
end
endSummary
Field types
The type representing the action of the condition. Action in a 1-airty function that takes a character struct and returns a choice content.
Field types
@type action() :: (DevJoy.Character.t() -> DevJoy.Scene.Choice.content())
The type representing the action of the condition. Action in a 1-airty function that takes a character struct and returns a choice content.
If the function returns a non-existent content
the default action would be is called which logs a debug message about the wrong content.
Main
The condition structure contains the following keys:
@type t() :: %DevJoy.Scene.Condition{ action: action(), character: DevJoy.Character.t() | nil }
The type representing the condition structure.