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/reply | |
parent | 90cdec82cf0c29d00c0c90fd0746ae4fa00d92f3 (diff) |
Sends updated target state upon attack.
Diffstat (limited to 'src/reply')
-rw-r--r-- | src/reply/add_char.erl | 41 | ||||
-rw-r--r-- | src/reply/set_map.erl | 31 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/reply/add_char.erl b/src/reply/add_char.erl new file mode 100644 index 0000000..959c70f --- /dev/null +++ b/src/reply/add_char.erl @@ -0,0 +1,41 @@ +-module(add_char). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([generate/3]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +encode (Char, CharInstance, IsEnabled) -> + {X, Y} = character_instance:get_location(CharInstance), + 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">>, IsEnabled} + ] + } + ). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +generate (Char, CharInstance, IsEnabled) -> + [<<"add_char">>, encode(Char, CharInstance, IsEnabled)]. diff --git a/src/reply/set_map.erl b/src/reply/set_map.erl new file mode 100644 index 0000000..7def653 --- /dev/null +++ b/src/reply/set_map.erl @@ -0,0 +1,31 @@ +-module(set_map). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([generate/1]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +encode (Battlemap) -> + jiffy:encode + ( + { + [ + {<<"width">>, battlemap:get_width(Battlemap)}, + {<<"height">>, battlemap:get_height(Battlemap)}, + {<<"content">>, battlemap:list_tiles(Battlemap)} + ] + } + ). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +generate (Battlemap) -> + [<<"set_map">>, encode(Battlemap)]. |