summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-08-28 23:29:55 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-08-28 23:29:55 +0200
commit9b424b11dbea33a41b2129daf232557515de9db1 (patch)
tree97cbe449c02e4273c79448859ceac722a06524b1 /src/shared/struct/shr_attributes.erl
parent68d3f1d7fd3703a8aef68bd6e9f89a84eab5e539 (diff)
Still propagating the changes...
It'll require the attributes and statistics being recalculated every time a character is used, which isn't great. Can't exactly avoid it though: moving and changing weapon are both likely to alter them, and people rarely attack without doing one or the other.
Diffstat (limited to 'src/shared/struct/shr_attributes.erl')
-rw-r--r--src/shared/struct/shr_attributes.erl52
1 files changed, 42 insertions, 10 deletions
diff --git a/src/shared/struct/shr_attributes.erl b/src/shared/struct/shr_attributes.erl
index 23824e4..c402e74 100644
--- a/src/shared/struct/shr_attributes.erl
+++ b/src/shared/struct/shr_attributes.erl
@@ -46,7 +46,9 @@
set_unsafe_intelligence/2,
set_unsafe_mind/2,
set_unsafe_speed/2,
- set_unsafe_strength/2
+ set_unsafe_strength/2,
+
+ apply_mod/3
]
).
@@ -54,7 +56,7 @@
-export
(
[
- random/0
+ default/0
]
).
@@ -64,6 +66,28 @@
-spec make_safe (integer()) -> non_neg_integer().
make_safe (Val) -> max(0, min(100, Val)).
+-spec mod_unsafe_constitution (integer(), type()) -> type().
+mod_unsafe_constitution (Val, Att) ->
+ set_constitution(make_safe(get_constitution(Att) + Val), Att).
+
+-spec mod_unsafe_dexterity (integer(), type()) -> type().
+mod_unsafe_dexterity (Val, Att) ->
+ set_dexterity(make_safe(get_dexterity(Att) + Val), Att).
+
+-spec mod_unsafe_intelligence (integer(), type()) -> type().
+mod_unsafe_intelligence (Val, Att) ->
+ set_intelligence(make_safe(get_intelligence(Att) + Val), Att).
+
+-spec mod_unsafe_mind (integer(), type()) -> type().
+mod_unsafe_mind (Val, Att) -> set_mind(make_safe(get_mind(Att) + Val), Att).
+
+-spec mod_unsafe_speed (integer(), type()) -> type().
+mod_unsafe_speed (Val, Att) -> set_speed(make_safe(get_speed(Att) + Val), Att).
+
+-spec mod_unsafe_strength (integer(), type()) -> type().
+mod_unsafe_strength (Val, Att) ->
+ set_strength(make_safe(get_strength(Att) + Val), Att).
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -122,14 +146,22 @@ set_unsafe_speed (Val, Att) -> set_speed(make_safe(Val), Att).
-spec set_unsafe_strength (integer(), type()) -> type().
set_unsafe_strength (Val, Att) -> set_strength(make_safe(Val), Att).
--spec random () -> type().
-random () ->
+-spec default () -> type().
+default () ->
#attributes
{
- constitution = shr_roll:percentage(),
- dexterity = shr_roll:percentage(),
- intelligence = shr_roll:percentage(),
- mind = shr_roll:percentage(),
- speed = shr_roll:percentage(),
- strength = shr_roll:percentage()
+ constitution = 50,
+ dexterity = 50,
+ intelligence = 50,
+ mind = 50,
+ speed = 50,
+ strength = 50
}.
+
+-spec apply_mod (atom(), integer(), type()) -> type().
+apply_mod (con, Value, Att) -> mod_unsafe_constitution(Value, Att);
+apply_mod (dex, Value, Att) -> mod_unsafe_dexterity(Value, Att);
+apply_mod (int, Value, Att) -> mod_unsafe_intelligence(Value, Att);
+apply_mod (min, Value, Att) -> mod_unsafe_mind(Value, Att);
+apply_mod (spe, Value, Att) -> mod_unsafe_speed(Value, Att);
+apply_mod (str, Value, Att) -> mod_unsafe_strength(Value, Att).