summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-08-10 14:49:13 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-08-10 14:49:13 +0200 |
commit | 9d45e68f8daa748c58e28c77434b1377c508e32f (patch) | |
tree | b7f254c97bc3f533bbd9d5a731def016a7f90376 /src/shared | |
parent | 65c103dae552d511a0ec3bd03ef402ecc71501e3 (diff) |
Statistics -> Attributes.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/struct/shr_attributes.erl (renamed from src/shared/struct/shr_statistics.erl) | 78 | ||||
-rw-r--r-- | src/shared/struct/shr_character.erl | 32 | ||||
-rw-r--r-- | src/shared/struct/shr_omnimods.erl | 28 |
3 files changed, 69 insertions, 69 deletions
diff --git a/src/shared/struct/shr_statistics.erl b/src/shared/struct/shr_attributes.erl index a5ba69f..cd3aedf 100644 --- a/src/shared/struct/shr_statistics.erl +++ b/src/shared/struct/shr_attributes.erl @@ -1,11 +1,11 @@ --module(shr_statistics). +-module(shr_attributes). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -record ( - statistics, + attributes, { movement_points :: non_neg_integer(), health :: non_neg_integer(), @@ -18,7 +18,7 @@ } ). --opaque type() :: #statistics{}. +-opaque type() :: #attributes{}. -export_type([type/0]). @@ -54,41 +54,41 @@ %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -spec mod_movement_points (integer(), type()) -> type(). -mod_movement_points (Mod, Stats) -> - Stats#statistics +mod_movement_points (Mod, Atts) -> + Atts#attributes { - movement_points = (Stats#statistics.movement_points + Mod) + movement_points = (Atts#attributes.movement_points + Mod) }. -spec mod_health (integer(), type()) -> type(). -mod_health (Mod, Stats) -> - Stats#statistics{ health = (Stats#statistics.health + Mod) }. +mod_health (Mod, Atts) -> + Atts#attributes{ health = (Atts#attributes.health + Mod) }. -spec mod_dodges (integer(), type()) -> type(). -mod_dodges (Mod, Stats) -> - Stats#statistics{ dodges = (Stats#statistics.dodges + Mod) }. +mod_dodges (Mod, Atts) -> + Atts#attributes{ dodges = (Atts#attributes.dodges + Mod) }. -spec mod_parries (integer(), type()) -> type(). -mod_parries (Mod, Stats) -> - Stats#statistics{ parries = (Stats#statistics.parries + Mod) }. +mod_parries (Mod, Atts) -> + Atts#attributes{ parries = (Atts#attributes.parries + Mod) }. -spec mod_accuracy (integer(), type()) -> type(). -mod_accuracy (Mod, Stats) -> - Stats#statistics{ accuracy = (Stats#statistics.accuracy + Mod) }. +mod_accuracy (Mod, Atts) -> + Atts#attributes{ accuracy = (Atts#attributes.accuracy + Mod) }. -spec mod_double_hits (integer(), type()) -> type(). -mod_double_hits (Mod, Stats) -> - Stats#statistics{ double_hits = (Stats#statistics.double_hits + Mod) }. +mod_double_hits (Mod, Atts) -> + Atts#attributes{ double_hits = (Atts#attributes.double_hits + Mod) }. -spec mod_critical_hits (integer(), type()) -> type(). -mod_critical_hits (Mod, Stats) -> - Stats#statistics{ critical_hits = (Stats#statistics.critical_hits + Mod) }. +mod_critical_hits (Mod, Atts) -> + Atts#attributes{ critical_hits = (Atts#attributes.critical_hits + Mod) }. -spec mod_damage_modifier (integer(), type()) -> type(). -mod_damage_modifier (Mod, Stats) -> - Stats#statistics +mod_damage_modifier (Mod, Atts) -> + Atts#attributes { - damage_modifier = (Stats#statistics.damage_modifier + Mod) + damage_modifier = (Atts#attributes.damage_modifier + Mod) }. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -96,35 +96,35 @@ mod_damage_modifier (Mod, Stats) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Accessors -spec get_movement_points (type()) -> non_neg_integer(). -get_movement_points (Stats) -> max(0, Stats#statistics.movement_points). +get_movement_points (Atts) -> max(0, Atts#attributes.movement_points). -spec get_health (type()) -> non_neg_integer(). -get_health (Stats) -> max(1, Stats#statistics.health). +get_health (Atts) -> max(1, Atts#attributes.health). -spec get_dodges (type()) -> non_neg_integer(). -get_dodges (Stats) -> max(0, Stats#statistics.dodges). +get_dodges (Atts) -> max(0, Atts#attributes.dodges). -spec get_parries (type()) -> non_neg_integer(). -get_parries (Stats) -> max(0, Stats#statistics.parries). +get_parries (Atts) -> max(0, Atts#attributes.parries). -spec get_accuracy (type()) -> non_neg_integer(). -get_accuracy (Stats) -> max(0, Stats#statistics.accuracy). +get_accuracy (Atts) -> max(0, Atts#attributes.accuracy). -spec get_double_hits (type()) -> non_neg_integer(). -get_double_hits (Stats) -> max(0, Stats#statistics.double_hits). +get_double_hits (Atts) -> max(0, Atts#attributes.double_hits). -spec get_critical_hits (type()) -> non_neg_integer(). -get_critical_hits (Stats) -> max(0, Stats#statistics.critical_hits). +get_critical_hits (Atts) -> max(0, Atts#attributes.critical_hits). -spec get_damage_modifier (type()) -> non_neg_integer(). -get_damage_modifier (Stats) -> max(0, Stats#statistics.damage_modifier). +get_damage_modifier (Atts) -> max(0, Atts#attributes.damage_modifier). -spec get_damage_multiplier (type()) -> float(). -get_damage_multiplier (Stats) -> (get_damage_modifier(Stats) / 100). +get_damage_multiplier (Atts) -> (get_damage_modifier(Atts) / 100). -spec default () -> type(). default () -> - #statistics + #attributes { movement_points = 0, health = 1, @@ -137,11 +137,11 @@ default () -> }. -spec apply_mod (atom(), integer(), type()) -> type(). -apply_mod(mheal, Value, Stats) -> mod_health(Value, Stats); -apply_mod(mpts, Value, Stats) -> mod_movement_points(Value, Stats); -apply_mod(dodg, Value, Stats) -> mod_dodges(Value, Stats); -apply_mod(pary, Value, Stats) -> mod_parries(Value, Stats); -apply_mod(accu, Value, Stats) -> mod_accuracy(Value, Stats); -apply_mod(dhit, Value, Stats) -> mod_double_hits(Value, Stats); -apply_mod(crit, Value, Stats) -> mod_critical_hits(Value, Stats); -apply_mod(dmgm, Value, Stats) -> mod_damage_modifier(Value, Stats). +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). diff --git a/src/shared/struct/shr_character.erl b/src/shared/struct/shr_character.erl index c2155cf..869a742 100644 --- a/src/shared/struct/shr_character.erl +++ b/src/shared/struct/shr_character.erl @@ -24,7 +24,7 @@ name :: binary(), equipment :: shr_equipment:type(), is_using_secondary :: boolean(), - statistics :: shr_statistics:type(), + attributes :: shr_attributes:type(), equipment_but_weapons_omnimods :: shr_omnimods:type(), extra_omnimods :: shr_omnimods:type(), omnimods :: shr_omnimods:type() @@ -45,7 +45,7 @@ [ get_name/1, get_equipment/1, - get_statistics/1, + get_attributes/1, get_active_weapon/1, get_inactive_weapon/1, get_omnimods/1, @@ -169,15 +169,15 @@ set_equipment (Eq, Char) when is_record(Char, shr_char) -> Char#shr_char.extra_omnimods ), - NewStatistics = - shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()), + NewAttributes = + shr_omnimods:apply_to_attributes(NewOmnimods, shr_attributes:default()), Char#shr_char { equipment = Eq, equipment_but_weapons_omnimods = EquipmentButWeaponsOmnimods, omnimods = NewOmnimods, - statistics = NewStatistics + attributes = NewAttributes }; set_equipment (EqRef, CharRef) when is_record(CharRef, shr_char_ref) -> CharRef#shr_char_ref{ equipment = EqRef }. @@ -232,14 +232,14 @@ switch_weapons (Char) when is_record(Char, shr_char) -> ActiveWeaponOmnimods ), - NewStatistics = - shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()), + NewAttributes = + shr_omnimods:apply_to_attributes(NewOmnimods, shr_attributes:default()), Char#shr_char { is_using_secondary = (not Char#shr_char.is_using_secondary), omnimods = NewOmnimods, - statistics = NewStatistics + attributes = NewAttributes }; switch_weapons (Char) when is_record(Char, shr_char_ref) -> Char#shr_char_ref @@ -284,8 +284,8 @@ get_inactive_weapon (#shr_char_ref{ is_using_secondary = B, equipment = E }) -> true -> shr_equipment:get_primary_weapon(E) end. --spec get_statistics (type()) -> shr_statistics:type(). -get_statistics (Char) -> Char#shr_char.statistics. +-spec get_attributes (type()) -> shr_attributes:type(). +get_attributes (Char) -> Char#shr_char.attributes. -spec get_omnimods (type()) -> shr_omnimods:type(). get_omnimods (Char) -> Char#shr_char.omnimods. @@ -303,14 +303,14 @@ set_extra_omnimods (O, Char) -> O ), - NewStatistics = - shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()), + NewAttributes = + shr_omnimods:apply_to_attributes(NewOmnimods, shr_attributes:default()), Char#shr_char { extra_omnimods = O, omnimods = NewOmnimods, - statistics = NewStatistics + attributes = NewAttributes }. -spec resolve (shr_omnimods:type(), unresolved()) -> type(). @@ -330,8 +330,8 @@ resolve (LocalOmnimods, CharRef) -> LocalOmnimods ), - NewStatistics = - shr_omnimods:apply_to_statistics(NewOmnimods, shr_statistics:default()), + NewAttributes = + shr_omnimods:apply_to_attributes(NewOmnimods, shr_attributes:default()), #shr_char { @@ -339,7 +339,7 @@ resolve (LocalOmnimods, CharRef) -> equipment_but_weapons_omnimods = EquipmentButWeaponsOmnimods, equipment = Eq, is_using_secondary = CharRef#shr_char_ref.is_using_secondary, - statistics = NewStatistics, + attributes = NewAttributes, omnimods = NewOmnimods, extra_omnimods = LocalOmnimods }. diff --git a/src/shared/struct/shr_omnimods.erl b/src/shared/struct/shr_omnimods.erl index fd35a94..7602e1f 100644 --- a/src/shared/struct/shr_omnimods.erl +++ b/src/shared/struct/shr_omnimods.erl @@ -10,7 +10,7 @@ ( omnimods, { - stamods :: mods(), + attmods :: mods(), atkmods :: mods(), defmods :: mods() } @@ -45,7 +45,7 @@ -export ( [ - apply_to_statistics/2, + apply_to_attributes/2, get_attack_damage/3 ] ). @@ -89,10 +89,10 @@ encode_mods (Mods) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Creation -spec new (list(entry()), list(entry()), list(entry())) -> type(). -new (StatisticMods, AttackMods, DefenseMods) -> +new (AttributeMods, AttackMods, DefenseMods) -> #omnimods { - stamods = dict:from_list(StatisticMods), + attmods = dict:from_list(AttributeMods), atkmods = dict:from_list(AttackMods), defmods = dict:from_list(DefenseMods) }. @@ -105,7 +105,7 @@ default () -> new([], [], []). merge (OmniA, OmniB) -> OmniA#omnimods { - stamods = merge_mods(OmniA#omnimods.stamods, OmniB#omnimods.stamods), + attmods = merge_mods(OmniA#omnimods.attmods, OmniB#omnimods.attmods), atkmods = merge_mods(OmniA#omnimods.atkmods, OmniB#omnimods.atkmods), defmods = merge_mods(OmniA#omnimods.defmods, OmniB#omnimods.defmods) }. @@ -114,23 +114,23 @@ merge (OmniA, OmniB) -> apply_coefficient (Coef, Omnimods) -> Omnimods#omnimods { - stamods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.stamods), + attmods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.attmods), atkmods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.atkmods), defmods = apply_coefficient_to_mods(Coef, Omnimods#omnimods.defmods) }. --spec apply_to_statistics +-spec apply_to_attributes ( type(), - shr_statistics:type() + shr_attributes:type() ) - -> shr_statistics:type(). -apply_to_statistics (Omnimods, Statistics) -> + -> shr_attributes:type(). +apply_to_attributes (Omnimods, Attributes) -> dict:fold ( - fun shr_statistics:apply_mod/3, - Statistics, - Omnimods#omnimods.stamods + fun shr_attributes:apply_mod/3, + Attributes, + Omnimods#omnimods.attmods ). -spec get_attack_damage (float(), type(), type()) -> non_neg_integer(). @@ -196,7 +196,7 @@ get_attack_damage (AttackModifier, AttackerOmnimods, DefenderOmnimods) -> encode (Omnimods) -> { [ - {<<"stam">>, encode_mods(Omnimods#omnimods.stamods)}, + {<<"attm">>, encode_mods(Omnimods#omnimods.attmods)}, {<<"atkm">>, encode_mods(Omnimods#omnimods.atkmods)}, {<<"defm">>, encode_mods(Omnimods#omnimods.defmods)} ] |