summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-03-06 17:08:00 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-03-06 17:08:00 +0100 |
commit | 98203d4d0034dab5db72737bcfb92017a11f3245 (patch) | |
tree | 9c4fd2a8904468d7ee69d86e39ce27051cc8ca2d /src/struct/turn_result.erl | |
parent | e5bc1b2d1bfcf5f36bd4f0d567e4ec8e0fb22e85 (diff) |
I might have been using JSON the wrong way.refactoring
Diffstat (limited to 'src/struct/turn_result.erl')
-rw-r--r-- | src/struct/turn_result.erl | 55 |
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. |