View Source ExTTRPGDev.RuleSystems (ExTTRPGDev v0.2.1)

Module which enables interactions with the varying defined systems in the system_configs. Basically sytem_configs define what systems are available and how they should be interpreted, and this module is is the beginning of the interpretation.

Link to this section Summary

Functions

Ensures a system is configured. If the system is configured, the system name is returned. If the system isn't configured, an exception is raised.

Checks if the given system is a bundled system

Checks if the given system is configured. Returns true if system is configured, otherwise false.

Checks if the given system is a local system

List the ExTTRPGDev local custom systems available

List the ExTTRPGDev bundled systems available

List the systems available

Reads in all of the JSON files for the specified and decodes the json into a %Systems{} struct

Saves the system specification locally as a JSON file. If a system is a bundled config, an exception is raised. If the system already exists and overwrite wasn't specificed as true, an exception is raised.

Returns the path to to the systems config directory

Link to this section Functions

Link to this function

assert_configured!(system)

View Source

Ensures a system is configured. If the system is configured, the system name is returned. If the system isn't configured, an exception is raised.

examples

Examples

iex> ExTTRPGDev.RuleSystems.assert_configured!("dnd_5e_srd")
"dnd_5e_srd"

iex> ExTTRPGDev.RuleSystems.assert_configured!("not_configured")
** (RuntimeError) System `not_configured` is not congifured
Link to this function

is_bundled_system?(system)

View Source

Checks if the given system is a bundled system

examples

Examples

iex> ExTTRPGDev.RuleSystems.is_bundled_system?("dnd_5e_srd")
true

iex> ExTTRPGDev.RuleSystems.is_bundled_system?("my_custom_rule_system")
false

Checks if the given system is configured. Returns true if system is configured, otherwise false.

examples

Examples

iex> ExTTRPGDev.RuleSystems.is_configured?("dnd_5e_srd")
true

iex> ExTTRPGDev.RuleSystems.is_configured?("non_existent_system")
false
Link to this function

is_local_system?(system)

View Source

Checks if the given system is a local system

examples

Examples

iex> ExTTRPGDev.RuleSystems.is_local_system?("dnd_5e_srd")
false

iex> ExTTRPGDev.RuleSystems.is_local_system?("my_custom_rule_system")
true

List the ExTTRPGDev local custom systems available

examples

Examples

iex> ExTTRPGDev.RuleSystems.list_bundled_systems()
["dnd_5e_srd"]

List the ExTTRPGDev bundled systems available

examples

Examples

iex> ExTTRPGDev.RuleSystems.list_local_systems()
[]

List the systems available

examples

Examples

iex> ExTTRPGDev.RuleSystems.list_systems()
["dnd_5e_srd"]

Reads in all of the JSON files for the specified and decodes the json into a %Systems{} struct

examples

Examples

iex> ExTTRPGDev.RuleSystems.load_system!("dnd_5e_srd")
%ExTTRPGDev.RuleSystems.RuleSystem{}
Link to this function

save_system!(system, overwrite \\ false)

View Source

Saves the system specification locally as a JSON file. If a system is a bundled config, an exception is raised. If the system already exists and overwrite wasn't specificed as true, an exception is raised.

examples

Examples

iex> ExTTRPGDev>RuleSystems.save_system!(%ExTTRPGDev.RuleSystems.RuleSystem{})
:ok

iex> ExTTRPGDev>RuleSystems.save_system!(%ExTTRPGDev.RuleSystems.RuleSystem{})
:error, :config_already_exists

iex> ExTTRPGDev>RuleSystems.save_system!(%ExTTRPGDev.RuleSystems.RuleSystem{}, true)
:ok

Returns the path to to the systems config directory

examples

Examples

iex> ExTTRPGDev.RuleSystems.system_path!("dnd_5e_srd")
"/full/path/to/project/ex_ttrpg_dev/system_configs/dnd_5e_srd"