summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-18 14:33:56 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-18 14:33:56 +0100 |
commit | bd380fa5fdb604bf07bc7b58b79b3abc04147b4a (patch) | |
tree | bf70a767fbf2aabccccf8891acfc7093d6bf4bc8 /src | |
parent | 0248c173c88dd551e7976758385faac95e4112fe (diff) |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/battle/struct/btl_character_turn_request.erl | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/battle/struct/btl_character_turn_request.erl b/src/battle/struct/btl_character_turn_request.erl index c8508e2..e26f79c 100644 --- a/src/battle/struct/btl_character_turn_request.erl +++ b/src/battle/struct/btl_character_turn_request.erl @@ -5,6 +5,9 @@ -define(BATTLE_ID_FIELD, <<"bid">>). -define(CHAR_IX_FIELD, <<"cix">>). -define(ACTIONS_FIELD, <<"act">>). +-define(ACTIONS_MOVE_FIELD, <<"mov">>). +-define(ACTIONS_WPS_FIELD, <<"wps">>). +-define(ACTIONS_ATK_FIELD, <<"tar">>). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -49,6 +52,34 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec decode_actions (map()) -> list(btl_battle_action:type()). +decode_actions (Act) -> + S0Result = [], + S1Result = + case + btl_battle_action:maybe_decode_move(maps:get(?ACTIONS_MOVE_FIELD, Act)) + of + [] -> S0Result; + [Move] -> [Move|S0Result] + end, + + S2Result = + case + btl_battle_action:maybe_decode_atk(maps:get(?ACTIONS_ATK_FIELD, Act)) + of + [] -> S1Result; + [Atk] -> [Atk|S1Result] + end, + + S3Result = + case + btl_battle_action:maybe_decode_move(maps:get(?ACTIONS_WPS_FIELD, Act)) + of + [] -> S2Result; + [Wps] -> [Wps|S2Result] + end, + + S3Result. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -57,7 +88,7 @@ decode (Map) -> CharacterIX = maps:get(?CHAR_IX_FIELD, Map), EncodedActions = maps:get(?ACTIONS_FIELD, Map), - Actions = lists:map(fun btl_battle_action:decode/1, EncodedActions), + Actions = decode_actions(EncodedActions), #type { |