From 98203d4d0034dab5db72737bcfb92017a11f3245 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Tue, 6 Mar 2018 17:08:00 +0100 Subject: I might have been using JSON the wrong way. --- src/struct/turn_result.erl | 55 +++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) (limited to 'src/struct/turn_result.erl') 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. -- cgit v1.2.3-70-g09d2