summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-08-18 16:05:23 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-08-18 16:05:23 +0200
commit5266e24e01611fc8026dfa0498ee87d7fba65e88 (patch)
tree72c73402dc959f5d618ac850b54d8eb724f60145 /src/shared/struct/shr_attributes.erl
parentdc742fd9190eadd5eed2e45dd36262ea06550172 (diff)
...
Diffstat (limited to 'src/shared/struct/shr_attributes.erl')
-rw-r--r--src/shared/struct/shr_attributes.erl110
1 files changed, 67 insertions, 43 deletions
diff --git a/src/shared/struct/shr_attributes.erl b/src/shared/struct/shr_attributes.erl
index cd3aedf..44d2e04 100644
--- a/src/shared/struct/shr_attributes.erl
+++ b/src/shared/struct/shr_attributes.erl
@@ -1,5 +1,7 @@
-module(shr_attributes).
+-include("tacticians/attributes.hrl").
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -9,18 +11,36 @@
{
movement_points :: non_neg_integer(),
health :: non_neg_integer(),
- dodges :: integer(),
- parries :: integer(),
+ dodge_chance :: integer(),
+ parry_chance :: integer(),
accuracy :: integer(),
- double_hits :: integer(),
- critical_hits :: integer(),
+ double_hit_chance :: integer(),
+ critical_hit_chance :: integer(),
damage_modifier :: integer()
}
).
-opaque type() :: #attributes{}.
-
--export_type([type/0]).
+-type enum() ::
+ (
+ ?ATTRIBUTE_ACCURACY
+ | ?ATTRIBUTE_CRITICAL_HIT_CHANCE
+ | ?ATTRIBUTE_DAMAGE_MODIFIER
+ | ?ATTRIBUTE_DODGE_CHANCE
+ | ?ATTRIBUTE_DOUBLE_HIT_CHANCE
+ | ?ATTRIBUTE_HEALTH
+ | ?ATTRIBUTE_MOVEMENT_POINTS
+ | ?ATTRIBUTE_PARRY_CHANCE
+ ).
+
+-type meta_enum() ::
+ (
+ enum()
+ | ?ATTRIBUTE_ATTACK_SCORE
+ | ?ATTRIBUTE_DEFENSE_SCORE
+ ).
+
+-export_type([type/0,enum/0,meta_enum/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -31,11 +51,11 @@
[
get_movement_points/1,
get_health/1,
- get_dodges/1,
- get_parries/1,
+ get_dodge_chance/1,
+ get_parry_chance/1,
get_accuracy/1,
- get_double_hits/1,
- get_critical_hits/1,
+ get_double_hit_chance/1,
+ get_critical_hit_chance/1,
get_damage_modifier/1,
get_damage_multiplier/1,
@@ -64,25 +84,25 @@ mod_movement_points (Mod, Atts) ->
mod_health (Mod, Atts) ->
Atts#attributes{ health = (Atts#attributes.health + Mod) }.
--spec mod_dodges (integer(), type()) -> type().
-mod_dodges (Mod, Atts) ->
- Atts#attributes{ dodges = (Atts#attributes.dodges + Mod) }.
+-spec mod_dodge_chance (integer(), type()) -> type().
+mod_dodge_chance (Mod, Atts) ->
+ Atts#attributes{ dodge_chance = (Atts#attributes.dodge_chance + Mod) }.
--spec mod_parries (integer(), type()) -> type().
-mod_parries (Mod, Atts) ->
- Atts#attributes{ parries = (Atts#attributes.parries + Mod) }.
+-spec mod_parry_chance (integer(), type()) -> type().
+mod_parry_chance (Mod, Atts) ->
+ Atts#attributes{ parry_chance = (Atts#attributes.parry_chance + Mod) }.
-spec mod_accuracy (integer(), type()) -> type().
mod_accuracy (Mod, Atts) ->
Atts#attributes{ accuracy = (Atts#attributes.accuracy + Mod) }.
--spec mod_double_hits (integer(), type()) -> type().
-mod_double_hits (Mod, Atts) ->
- Atts#attributes{ double_hits = (Atts#attributes.double_hits + Mod) }.
+-spec mod_double_hit_chance (integer(), type()) -> type().
+mod_double_hit_chance (Mod, Atts) ->
+ Atts#attributes{ double_hit_chance = (Atts#attributes.double_hit_chance + Mod) }.
--spec mod_critical_hits (integer(), type()) -> type().
-mod_critical_hits (Mod, Atts) ->
- Atts#attributes{ critical_hits = (Atts#attributes.critical_hits + Mod) }.
+-spec mod_critical_hit_chance (integer(), type()) -> type().
+mod_critical_hit_chance (Mod, Atts) ->
+ Atts#attributes{ critical_hit_chance = (Atts#attributes.critical_hit_chance + Mod) }.
-spec mod_damage_modifier (integer(), type()) -> type().
mod_damage_modifier (Mod, Atts) ->
@@ -101,20 +121,20 @@ get_movement_points (Atts) -> max(0, Atts#attributes.movement_points).
-spec get_health (type()) -> non_neg_integer().
get_health (Atts) -> max(1, Atts#attributes.health).
--spec get_dodges (type()) -> non_neg_integer().
-get_dodges (Atts) -> max(0, Atts#attributes.dodges).
+-spec get_dodge_chance (type()) -> non_neg_integer().
+get_dodge_chance (Atts) -> max(0, Atts#attributes.dodge_chance).
--spec get_parries (type()) -> non_neg_integer().
-get_parries (Atts) -> max(0, Atts#attributes.parries).
+-spec get_parry_chance (type()) -> non_neg_integer().
+get_parry_chance (Atts) -> max(0, Atts#attributes.parry_chance).
-spec get_accuracy (type()) -> non_neg_integer().
get_accuracy (Atts) -> max(0, Atts#attributes.accuracy).
--spec get_double_hits (type()) -> non_neg_integer().
-get_double_hits (Atts) -> max(0, Atts#attributes.double_hits).
+-spec get_double_hit_chance (type()) -> non_neg_integer().
+get_double_hit_chance (Atts) -> max(0, Atts#attributes.double_hit_chance).
--spec get_critical_hits (type()) -> non_neg_integer().
-get_critical_hits (Atts) -> max(0, Atts#attributes.critical_hits).
+-spec get_critical_hit_chance (type()) -> non_neg_integer().
+get_critical_hit_chance (Atts) -> max(0, Atts#attributes.critical_hit_chance).
-spec get_damage_modifier (type()) -> non_neg_integer().
get_damage_modifier (Atts) -> max(0, Atts#attributes.damage_modifier).
@@ -128,20 +148,24 @@ default () ->
{
movement_points = 0,
health = 1,
- dodges = 0,
- parries = 0,
+ dodge_chance = 0,
+ parry_chance = 0,
accuracy = 0,
- double_hits = 0,
- critical_hits = 0,
+ double_hit_chance = 0,
+ critical_hit_chance = 0,
damage_modifier = 100
}.
--spec apply_mod (atom(), integer(), type()) -> type().
-apply_mod(mheal, Value, Atts) -> mod_health(Value, Atts);
-apply_mod(mpts, Value, Atts) -> mod_movement_points(Value, Atts);
-apply_mod(dodg, Value, Atts) -> mod_dodges(Value, Atts);
-apply_mod(pary, Value, Atts) -> mod_parries(Value, Atts);
-apply_mod(accu, Value, Atts) -> mod_accuracy(Value, Atts);
-apply_mod(dhit, Value, Atts) -> mod_double_hits(Value, Atts);
-apply_mod(crit, Value, Atts) -> mod_critical_hits(Value, Atts);
-apply_mod(dmgm, Value, Atts) -> mod_damage_modifier(Value, Atts).
+-spec apply_mod (enum(), integer(), type()) -> type().
+apply_mod(?ATTRIBUTE_HEALTH, Mod, Atts) -> mod_health(Mod, Atts);
+apply_mod(?ATTRIBUTE_DODGE_CHANCE, Mod, Atts) -> mod_dodge_chance(Mod, Atts);
+apply_mod(?ATTRIBUTE_PARRY_CHANCE, Mod, Atts) -> mod_parry_chance(Mod, Atts);
+apply_mod(?ATTRIBUTE_ACCURACY, Mod, Atts) -> mod_accuracy(Mod, Atts);
+apply_mod(?ATTRIBUTE_MOVEMENT_POINTS, Mod, Atts) ->
+ mod_movement_points(Mod, Atts);
+apply_mod(?ATTRIBUTE_DOUBLE_HIT_CHANCE, Mod, Atts) ->
+ mod_double_hit_chance(Mod, Atts);
+apply_mod(?ATTRIBUTE_CRITICAL_HIT_CHANCE, Mod, Atts) ->
+ mod_critical_hit_chance(Mod, Atts);
+apply_mod(?ATTRIBUTE_DAMAGE_MODIFIER, Mod, Atts) ->
+ mod_damage_modifier(Mod, Atts).