| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2017-12-01 13:23:53 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2017-12-01 13:23:53 +0100 | 
| commit | 583dfe90bd9ff99c9de67eeb8438f3b4e826c8a4 (patch) | |
| tree | f3813f0d63446f992a6bcc15b8369203120a172b /src/query/load_state.erl | |
| parent | 90cdec82cf0c29d00c0c90fd0746ae4fa00d92f3 (diff) | |
Sends updated target state upon attack.
Diffstat (limited to 'src/query/load_state.erl')
| -rw-r--r-- | src/query/load_state.erl | 71 | 
1 files changed, 15 insertions, 56 deletions
| diff --git a/src/query/load_state.erl b/src/query/load_state.erl index d82c2c6..c738a4c 100644 --- a/src/query/load_state.erl +++ b/src/query/load_state.erl @@ -36,71 +36,30 @@ parse_input (Req) ->        instance_id = maps:get(<<"instance_id">>, JSONReqMap)     }. -generate_set_map (Battlemap) -> -   jiffy:encode -   ( -      { -         [ -            {<<"width">>, battlemap:get_width(Battlemap)}, -            {<<"height">>, battlemap:get_height(Battlemap)}, -            {<<"content">>, battlemap:list_tiles(Battlemap)} -         ] -      } -   ). - -generate_add_char (Char, CharInstance, BattlemapInstance, PlayerID) -> -   {X, Y} = character_instance:get_location(CharInstance), -   CharID = character:get_id(Char), -   jiffy:encode -   ( -      { -         [ -            {<<"id">>, character:get_id(Char)}, -            {<<"name">>, character:get_name(Char)}, -            {<<"icon">>, character:get_icon(Char)}, -            {<<"portrait">>, character:get_portrait(Char)}, -            {<<"health">>, character_instance:get_current_health(CharInstance)}, -            {<<"max_health">>, character:get_max_health(Char)}, -            {<<"loc_x">>, X}, -            {<<"loc_y">>, Y}, -            {<<"team">>, character_instance:get_owner(CharInstance)}, -            {<<"mov_pts">>, character:get_movement_points(Char)}, -            {<<"atk_rg">>, character:get_attack_range(Char)}, -            { -               <<"enabled">>, -               battlemap_instance:can_play_char_instance -               ( -                  BattlemapInstance, -                  PlayerID, -                  CharID -               ) -            } -         ] -      } -   ). -  generate_reply (Battlemap, BattlemapInstance, Characters, PlayerID) ->     jiffy:encode     (        [ -         [ -            <<"set_map">>, -            generate_set_map(Battlemap) -         ] +         set_map:generate(Battlemap)           |           lists:map           ( -            fun ({CharID, CharInstance}) -> -               [ -                  <<"add_char">>, -                  generate_add_char +            fun ({Char, CharInstance}) -> +               add_char:generate +               ( +                  Char, +                  CharInstance,                    ( -                     CharID, -                     CharInstance, -                     BattlemapInstance, -                     PlayerID +                     battlemap_instance:can_play_char_instance +                     ( +                        BattlemapInstance, +                        PlayerID, +                        character:get_id(Char) +                     ) +                     and +                     (not character_instance:is_dead(CharInstance))                    ) -               ] +               )              end,              Characters           ) | 


