summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-02-27 14:16:16 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-02-27 14:16:16 +0100
commit292022649270d36c8ab0c813e4d7e07f3e067231 (patch)
tree8e25f8c3e5db7f6bae7001d405f24e29115750f3 /src/struct/attributes.erl
parentbe9a65dd6d24ca8e7006c0b8825a3fa46419e201 (diff)
Starting to specify types everywhere...
Diffstat (limited to 'src/struct/attributes.erl')
-rw-r--r--src/struct/attributes.erl57
1 files changed, 39 insertions, 18 deletions
diff --git a/src/struct/attributes.erl b/src/struct/attributes.erl
index bb68032..6728831 100644
--- a/src/struct/attributes.erl
+++ b/src/struct/attributes.erl
@@ -7,15 +7,19 @@
(
attributes,
{
- constitution,
- dexterity,
- intelligence,
- mind,
- speed,
- strength
+ constitution :: integer(),
+ dexterity :: integer(),
+ intelligence :: integer(),
+ mind :: integer(),
+ speed :: integer(),
+ strength :: integer()
}
).
+-opaque struct() :: #attributes{}.
+
+-export_type([struct/0]).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -55,26 +59,43 @@
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
+-spec get_constitution (struct()) -> integer().
get_constitution (Att) -> Att#attributes.constitution.
+
+-spec get_dexterity (struct()) -> integer().
get_dexterity (Att) -> Att#attributes.dexterity.
+
+-spec get_intelligence (struct()) -> integer().
get_intelligence (Att) -> Att#attributes.intelligence.
+
+-spec get_mind (struct()) -> integer().
get_mind (Att) -> Att#attributes.mind.
+
+-spec get_speed (struct()) -> integer().
get_speed (Att) -> Att#attributes.speed.
+
+-spec get_strength (struct()) -> integer().
get_strength (Att) -> Att#attributes.strength.
-set_constitution (Val, Att) ->
- Att#attributes{ constitution = Val }.
-set_dexterity (Val, Att) ->
- Att#attributes{ dexterity = Val }.
-set_intelligence (Val, Att) ->
- Att#attributes{ intelligence = Val }.
-set_mind (Val, Att) ->
- Att#attributes{ mind = Val }.
-set_speed (Val, Att) ->
- Att#attributes{ speed = Val }.
-set_strength (Val, Att) ->
- Att#attributes{ strength = Val }.
+-spec set_constitution (integer(), struct()) -> struct().
+set_constitution (Val, Att) -> Att#attributes{ constitution = Val }.
+
+-spec set_dexterity (integer(), struct()) -> struct().
+set_dexterity (Val, Att) -> Att#attributes{ dexterity = Val }.
+
+-spec set_intelligence (integer(), struct()) -> struct().
+set_intelligence (Val, Att) -> Att#attributes{ intelligence = Val }.
+
+-spec set_mind (integer(), struct()) -> struct().
+set_mind (Val, Att) -> Att#attributes{ mind = Val }.
+
+-spec set_speed (integer(), struct()) -> struct().
+set_speed (Val, Att) -> Att#attributes{ speed = Val }.
+
+-spec set_strength (integer(), struct()) -> struct().
+set_strength (Val, Att) -> Att#attributes{ strength = Val }.
+-spec random () -> struct().
random () ->
#attributes
{