| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-06-06 15:54:18 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-06-06 15:54:18 +0200 | 
| commit | ee9c2ac044cc77b80f30420c8f0788cad4281084 (patch) | |
| tree | 6ce9c45b6c0f0c556839b6f462f84eab06e26594 /src/battlemap/reply | |
| parent | 97f7511e61cebae3676a83aa9c0dc2efb15d8d8c (diff) | |
Figuring out how to organize the src folder(s)...
Diffstat (limited to 'src/battlemap/reply')
| -rw-r--r-- | src/battlemap/reply/add_char.erl | 78 | ||||
| -rw-r--r-- | src/battlemap/reply/set_map.erl | 28 | ||||
| -rw-r--r-- | src/battlemap/reply/set_timeline.erl | 27 | ||||
| -rw-r--r-- | src/battlemap/reply/turn_results.erl | 27 | 
4 files changed, 160 insertions, 0 deletions
diff --git a/src/battlemap/reply/add_char.erl b/src/battlemap/reply/add_char.erl new file mode 100644 index 0000000..86b1e9c --- /dev/null +++ b/src/battlemap/reply/add_char.erl @@ -0,0 +1,78 @@ +-module(add_char). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([generate/3]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec attributes_as_json +   ( +      attributes:type() +   ) -> +   {list({binary(), non_neg_integer()})}. +attributes_as_json (Attributes) -> +   { +      [ +         {<<"con">>, attributes:get_constitution(Attributes)}, +         {<<"dex">>, attributes:get_dexterity(Attributes)}, +         {<<"int">>, attributes:get_intelligence(Attributes)}, +         {<<"min">>, attributes:get_mind(Attributes)}, +         {<<"spe">>, attributes:get_speed(Attributes)}, +         {<<"str">>, attributes:get_strength(Attributes)} +      ] +   }. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec generate +   ( +      non_neg_integer(), +      character:type(), +      player:id() +   ) +   -> {list(any())}. +generate (IX, Character, PlayerID) -> +   IsAlive = character:get_is_alive(Character), +   Attributes = character:get_attributes(Character), +   {ActiveWeapon, SecondaryWeapon} = character:get_weapon_ids(Character), +   OwnerID = character:get_owner_id(Character), +   Location = +      case IsAlive of +         true -> character:get_location(Character); +         _ -> location:get_nowhere() +      end, + +   { +      [ +         {<<"msg">>, <<"add_char">>}, +         {<<"ix">>, IX}, +         {<<"nam">>, character:get_name(Character)}, +         {<<"ico">>, character:get_icon(Character)}, +         {<<"prt">>, character:get_portrait(Character)}, +         { +            <<"hea">>, +            character:get_current_health(Character) +         }, +         {<<"lc">>, location:encode(Location)}, +         {<<"pla">>, OwnerID}, +         { +            <<"ena">>, +            ( +               character:get_is_active(Character) +               and +               (OwnerID == PlayerID) +            ) +         }, +         {<<"att">>, attributes_as_json(Attributes)}, +         {<<"awp">>, ActiveWeapon}, +         {<<"swp">>, SecondaryWeapon} +      ] +   }. diff --git a/src/battlemap/reply/set_map.erl b/src/battlemap/reply/set_map.erl new file mode 100644 index 0000000..8518ac5 --- /dev/null +++ b/src/battlemap/reply/set_map.erl @@ -0,0 +1,28 @@ +-module(set_map). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([generate/1]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec generate (battlemap:type()) -> {list(any())}. +generate (Battlemap) -> +   { +      [ +         {<<"msg">>, <<"set_map">>}, +         {<<"w">>, battlemap:get_width(Battlemap)}, +         {<<"h">>, battlemap:get_height(Battlemap)}, +         {<<"t">>, array:sparse_to_list(battlemap:get_tile_ids(Battlemap))} +      ] +   }. diff --git a/src/battlemap/reply/set_timeline.erl b/src/battlemap/reply/set_timeline.erl new file mode 100644 index 0000000..bfe621a --- /dev/null +++ b/src/battlemap/reply/set_timeline.erl @@ -0,0 +1,27 @@ +-module(set_timeline). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([generate/1]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec generate (list(any())) -> {list(any())}. +generate (EncodedClientUpdate) -> +   io:format("~nSending timeline:~n~p~n", [EncodedClientUpdate]), +   { +      [ +         {<<"msg">>, <<"set_timeline">>}, +         {<<"cnt">>, EncodedClientUpdate} +      ] +   }. diff --git a/src/battlemap/reply/turn_results.erl b/src/battlemap/reply/turn_results.erl new file mode 100644 index 0000000..0f3ff25 --- /dev/null +++ b/src/battlemap/reply/turn_results.erl @@ -0,0 +1,27 @@ +-module(turn_results). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export([generate/1]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec generate (list(any())) -> {list(any())}. +generate (EncodedClientUpdate) -> +   io:format("~nSending turn results:~n~p~n", [EncodedClientUpdate]), +   { +      [ +         {<<"msg">>, <<"turn_results">>}, +         {<<"cnt">>, EncodedClientUpdate} +      ] +   }.  | 


