summaryrefslogtreecommitdiff
path: root/src/query
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-03-01 13:24:11 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-03-01 13:24:11 +0100
commit55c32019f5b82fd488c4ceed8c80e1b7a0fa114f (patch)
treeb28565216098599b53b8cbe3619e51104c325e88 /src/query
parent9b413bc5936994b66f3a1c693fbbfad0995c0b93 (diff)
Cleaning up the handling of character turns.
Diffstat (limited to 'src/query')
-rw-r--r--src/query/character_turn.erl10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/query/character_turn.erl b/src/query/character_turn.erl
index b24e038..cb4e8ea 100644
--- a/src/query/character_turn.erl
+++ b/src/query/character_turn.erl
@@ -1,4 +1,5 @@
-module(character_turn).
+% FIXME: There's still too much of a mess in this module.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -48,16 +49,21 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+decode_action (EncodedAction) ->
+ JSONActionMap = jiffy:decode(EncodedAction, [return_maps]),
+
-spec parse_input (binary()) -> input().
parse_input (Req) ->
JSONReqMap = jiffy:decode(Req, [return_maps]),
CharacterInstanceIX = binary_to_integer(maps:get(<<"cix">>, JSONReqMap)),
TargetIX = binary_to_integer(maps:get(<<"tix">>, JSONReqMap)),
+ EncodedActions = maps:get(<<"act">>, JSONReqMap),
+ Actions = decode_action_sequence(EncodedActions),
#input
{
player_id = maps:get(<<"pid">>, JSONReqMap),
session_token = maps:get(<<"stk">>, JSONReqMap),
- battlemap_instance_id = maps:get(<<"bmi">>, JSONReqMap),
+ battle_id = maps:get(<<"bid">>, JSONReqMap),
character_instance_ix = CharacterInstanceIX,
path = maps:get(<<"p">>, JSONReqMap),
target_ix = TargetIX
@@ -138,6 +144,8 @@ handle_character_instance_moving (QueryState, Input) ->
ControlledCharacterMovementPoints =
statistics:get_movement_points(ControlledCharacterStatistics),
+ % FIXME: The controlled character's old location should not be considered to
+ % be a forbidden location.
ForbiddenLocations =
array:map
(