summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/battle/struct/btl_attack.erl')
-rw-r--r-- | src/battle/struct/btl_attack.erl | 69 |
1 files changed, 7 insertions, 62 deletions
diff --git a/src/battle/struct/btl_attack.erl b/src/battle/struct/btl_attack.erl index 27436f2..7e0a834 100644 --- a/src/battle/struct/btl_attack.erl +++ b/src/battle/struct/btl_attack.erl @@ -6,41 +6,26 @@ -type category() :: ('first' | 'second' | 'counter'). -type precision() :: ('misses' | 'grazes' | 'hits'). --record -( - attack, - { - category :: category(), - precision :: precision(), - is_critical :: boolean(), - is_parry :: boolean(), - damage :: non_neg_integer() - } -). - --opaque type() :: #attack{}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export_type([type/0, category/0, precision/0]). - --export -( - [ - new/5 - ] -). +-export_type([category/0, precision/0]). -export ( [ - encode/1 + encode_category/1, + encode_precision/1 ] ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -spec encode_category (category()) -> binary(). encode_category (first) -> <<"f">>; encode_category (counter) -> <<"c">>; @@ -50,43 +35,3 @@ encode_category (second) -> <<"s">>. encode_precision (hits) -> <<"h">>; encode_precision (grazes) -> <<"g">>; encode_precision (misses) -> <<"m">>. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec new - ( - category(), - precision(), - boolean(), - boolean(), - non_neg_integer() - ) - -> type(). -new (Category, Precision, IsCritical, IsParry, Damage) -> - #attack - { - category = Category, - precision = Precision, - is_critical = IsCritical, - is_parry = IsParry, - damage = Damage - }. - --spec encode (type()) -> {list(any())}. -encode (Attack) -> - Category = Attack#attack.category, - Precision = Attack#attack.precision, - IsCritical = Attack#attack.is_critical, - IsParry = Attack#attack.is_parry, - Damage = Attack#attack.damage, - - { - [ - {<<"ord">>, encode_category(Category)}, - {<<"pre">>, encode_precision(Precision)}, - {<<"cri">>, IsCritical}, - {<<"par">>, IsParry}, - {<<"dmg">>, Damage} - ] - }. |