aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/struct/turn_result.erl')
-rw-r--r--src/struct/turn_result.erl55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/struct/turn_result.erl b/src/struct/turn_result.erl
index c5cafcd..5f796ca 100644
--- a/src/struct/turn_result.erl
+++ b/src/struct/turn_result.erl
@@ -96,19 +96,16 @@ new_character_attacked (AttackerIX, DefenderIX, AttackSequence) ->
sequence = AttackSequence
}.
--spec encode (struct()) -> binary().
+-spec encode (struct()) -> {list(any())}.
encode (TurnResult) when is_record(TurnResult, switched_weapon) ->
CharacterInstanceIX = TurnResult#switched_weapon.character_instance_ix,
- jiffy:encode
- (
- {
- [
- {<<"t">>, <<"swp">>},
- {<<"ix">>, CharacterInstanceIX}
- ]
- }
- );
+ {
+ [
+ {<<"t">>, <<"swp">>},
+ {<<"ix">>, CharacterInstanceIX}
+ ]
+ };
encode (TurnResult) when is_record(TurnResult, moved) ->
CharacterInstanceIX = TurnResult#moved.character_instance_ix,
Path = TurnResult#moved.path,
@@ -117,17 +114,14 @@ encode (TurnResult) when is_record(TurnResult, moved) ->
EncodedPath = lists:map(fun direction:encode/1, Path),
EncodedNewLocation = location:encode(NewLocation),
- jiffy:encode
- (
- {
- [
- {<<"t">>, <<"mv">>},
- {<<"ix">>, CharacterInstanceIX},
- {<<"p">>, EncodedPath},
- {<<"nlc">>, EncodedNewLocation}
- ]
- }
- );
+ {
+ [
+ {<<"t">>, <<"mv">>},
+ {<<"ix">>, CharacterInstanceIX},
+ {<<"p">>, EncodedPath},
+ {<<"nlc">>, EncodedNewLocation}
+ ]
+ };
encode (TurnResult) when is_record(TurnResult, attacked) ->
AttackerIX = TurnResult#attacked.attacker_ix,
DefenderIX = TurnResult#attacked.defender_ix,
@@ -135,17 +129,14 @@ encode (TurnResult) when is_record(TurnResult, attacked) ->
EncodedSequence = lists:map(fun attack:encode/1, Sequence),
- jiffy:encode
- (
- {
- [
- {<<"t">>, <<"atk">>},
- {<<"aix">>, AttackerIX},
- {<<"dix">>, DefenderIX},
- {<<"seq">>, EncodedSequence}
- ]
- }
- );
+ {
+ [
+ {<<"t">>, <<"atk">>},
+ {<<"aix">>, AttackerIX},
+ {<<"dix">>, DefenderIX},
+ {<<"seq">>, EncodedSequence}
+ ]
+ };
encode (Other) ->
io:format("~n invalid encode param\"~p\"~n", [Other]),
true = Other.