View Source DevJoy.Character behaviour (DevJoy v1.0.0)

A character is an NPC acting in a game.

Data module

A data module is supposed to fetch character basic information like avatar and full name which could be entered in your code or fetched from some API or site. Such module needs to implement get_character/1 callback.

config :dev_joy, DevJoy.Character, data_module: MyApp.DataModule

Extra module

An extra module is supposed to fetch character extra information stored in data field which could be entered in your code or fetched from some API or site. Such module needs to implement get_character_data/1 callback.

config :dev_joy, DevJoy.Character, extra_module: MyApp.ExtraModule

Fetching data

All data is fetched at compile time for every dialog and question. It's recommended to cache all external data in order to avoid long compilation time.

Summary

Types

External url or ralative path within project

Additional data

Full name

Identifier

t()

Character struct

Callbacks

Retrieves information about a character using it's id.

Retrieves information about a character using it's id.

Functions

Gets a data and extra module from configuration. Using a data module it retrieves information about a character using their id. Using an extra module it retrieves additional data for a character using their id.

Types

@type avatar() :: String.t()

External url or ralative path within project

@type data() :: Keyword.t()

Additional data

@type full_name() :: String.t()

Full name

@type id() :: atom()

Identifier

@type t() :: %DevJoy.Character{
  avatar: avatar(),
  data: data(),
  full_name: full_name(),
  id: id()
}

Character struct

Callbacks

Link to this callback

get_character(id)

View Source (optional)
@callback get_character(id()) :: DevJoy.Scene.struct_fields()

Retrieves information about a character using it's id.

Link to this callback

get_character_data(id)

View Source (optional)
@callback get_character_data(id()) :: data()

Retrieves information about a character using it's id.

Functions

@spec get_fields!(id()) :: data() | no_return()

Gets a data and extra module from configuration. Using a data module it retrieves information about a character using their id. Using an extra module it retrieves additional data for a character using their id.