summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-06-06 15:54:18 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-06-06 15:54:18 +0200
commitee9c2ac044cc77b80f30420c8f0788cad4281084 (patch)
tree6ce9c45b6c0f0c556839b6f462f84eab06e26594 /src/shared/struct/sh_attributes.erl
parent97f7511e61cebae3676a83aa9c0dc2efb15d8d8c (diff)
Figuring out how to organize the src folder(s)...
Diffstat (limited to 'src/shared/struct/sh_attributes.erl')
-rw-r--r--src/shared/struct/sh_attributes.erl108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/shared/struct/sh_attributes.erl b/src/shared/struct/sh_attributes.erl
new file mode 100644
index 0000000..93dcfc6
--- /dev/null
+++ b/src/shared/struct/sh_attributes.erl
@@ -0,0 +1,108 @@
+-module(sh_attributes).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-record
+(
+ attributes,
+ {
+ constitution :: integer(),
+ dexterity :: integer(),
+ intelligence :: integer(),
+ mind :: integer(),
+ speed :: integer(),
+ strength :: integer()
+ }
+).
+
+-opaque type() :: #attributes{}.
+
+-export_type([type/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-export
+(
+ [
+ get_constitution/1,
+ get_dexterity/1,
+ get_intelligence/1,
+ get_mind/1,
+ get_speed/1,
+ get_strength/1,
+
+ set_constitution/2,
+ set_dexterity/2,
+ set_intelligence/2,
+ set_mind/2,
+ set_speed/2,
+ set_strength/2
+ ]
+).
+
+%%%% Accessors
+-export
+(
+ [
+ random/0
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Accessors
+-spec get_constitution (type()) -> integer().
+get_constitution (Att) -> Att#attributes.constitution.
+
+-spec get_dexterity (type()) -> integer().
+get_dexterity (Att) -> Att#attributes.dexterity.
+
+-spec get_intelligence (type()) -> integer().
+get_intelligence (Att) -> Att#attributes.intelligence.
+
+-spec get_mind (type()) -> integer().
+get_mind (Att) -> Att#attributes.mind.
+
+-spec get_speed (type()) -> integer().
+get_speed (Att) -> Att#attributes.speed.
+
+-spec get_strength (type()) -> integer().
+get_strength (Att) -> Att#attributes.strength.
+
+-spec set_constitution (integer(), type()) -> type().
+set_constitution (Val, Att) -> Att#attributes{ constitution = Val }.
+
+-spec set_dexterity (integer(), type()) -> type().
+set_dexterity (Val, Att) -> Att#attributes{ dexterity = Val }.
+
+-spec set_intelligence (integer(), type()) -> type().
+set_intelligence (Val, Att) -> Att#attributes{ intelligence = Val }.
+
+-spec set_mind (integer(), type()) -> type().
+set_mind (Val, Att) -> Att#attributes{ mind = Val }.
+
+-spec set_speed (integer(), type()) -> type().
+set_speed (Val, Att) -> Att#attributes{ speed = Val }.
+
+-spec set_strength (integer(), type()) -> type().
+set_strength (Val, Att) -> Att#attributes{ strength = Val }.
+
+-spec random () -> type().
+random () ->
+ #attributes
+ {
+ constitution = sh_roll:percentage(),
+ dexterity = sh_roll:percentage(),
+ intelligence = sh_roll:percentage(),
+ mind = sh_roll:percentage(),
+ speed = sh_roll:percentage(),
+ strength = sh_roll:percentage()
+ }.