summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-10-23 17:46:45 +0200
committernsensfel <SpamShield0@noot-noot.org>2019-10-23 17:46:45 +0200
commit65a2b95f7355b6b495516b95dafa63f8ccaa2bb0 (patch)
tree05011efdd963f8aa017d508bab1386eb90379df2 /src/battle/struct/btl_attack.erl
parent240b60a2a747d073eb001dd92450fd19b91902e9 (diff)
...
Diffstat (limited to 'src/battle/struct/btl_attack.erl')
-rw-r--r--src/battle/struct/btl_attack.erl69
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}
- ]
- }.