View Source ExTTRPGDev.RuleSystems (ExTTRPGDev v0.5.0)
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.
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
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.
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
Checks if the given system is a bundled system
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
iex> ExTTRPGDev.RuleSystems.is_configured?("dnd_5e_srd")
true
iex> ExTTRPGDev.RuleSystems.is_configured?("non_existent_system")
false
Checks if the given system is a local system
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
iex> ExTTRPGDev.RuleSystems.list_bundled_systems()
["dnd_5e_srd"]
List the ExTTRPGDev bundled systems available
Examples
iex> ExTTRPGDev.RuleSystems.list_local_systems()
[]
List the systems available
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
iex> ExTTRPGDev.RuleSystems.load_system!("dnd_5e_srd")
%ExTTRPGDev.RuleSystems.RuleSystem{}
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
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
iex> ExTTRPGDev.RuleSystems.system_path!("dnd_5e_srd")
"/full/path/to/project/ex_ttrpg_dev/system_configs/dnd_5e_srd"