aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/reply/add_char.erl')
-rw-r--r--src/reply/add_char.erl76
1 files changed, 32 insertions, 44 deletions
diff --git a/src/reply/add_char.erl b/src/reply/add_char.erl
index a920a2a..b3ef128 100644
--- a/src/reply/add_char.erl
+++ b/src/reply/add_char.erl
@@ -29,58 +29,46 @@ attributes_as_json (Attributes) ->
]
}.
--spec encode
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec generate
(
non_neg_integer(),
character_instance:struct(),
player:id()
)
- -> binary().
-encode (IX, CharacterInstance, PlayerID) ->
+ -> {list(any())}.
+generate (IX, CharacterInstance, PlayerID) ->
Character = character_instance:get_character(CharacterInstance),
Location = character_instance:get_location(CharacterInstance),
Attributes = character:get_attributes(Character),
{ActiveWeapon, SecondaryWeapon} = character:get_weapon_ids(Character),
OwnerID = character:get_owner_id(Character),
- jiffy:encode
- (
- {
- [
- {<<"ix">>, IX},
- {<<"nam">>, character:get_name(Character)},
- {<<"ico">>, character:get_icon(Character)},
- {<<"prt">>, character:get_portrait(Character)},
- {
- <<"hea">>,
- character_instance:get_current_health(CharacterInstance)
- },
- {<<"lc">>, location:encode(Location)},
- {<<"pla">>, OwnerID},
- {
- <<"ena">>,
- (
- character_instance:get_is_active(CharacterInstance)
- and
- (OwnerID == PlayerID)
- )
- },
- {<<"att">>, attributes_as_json(Attributes)},
- {<<"awp">>, ActiveWeapon},
- {<<"swp">>, SecondaryWeapon}
- ]
- }
- ).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec generate
- (
- non_neg_integer(),
- character_instance:struct(),
- player:id()
- )
- -> list(binary()).
-generate (IX, CharacterInstance, PlayerID) ->
- [<<"add_char">>, encode(IX, CharacterInstance, PlayerID)].
+ {
+ [
+ {<<"msg">>, <<"add_char">>},
+ {<<"ix">>, IX},
+ {<<"nam">>, character:get_name(Character)},
+ {<<"ico">>, character:get_icon(Character)},
+ {<<"prt">>, character:get_portrait(Character)},
+ {
+ <<"hea">>,
+ character_instance:get_current_health(CharacterInstance)
+ },
+ {<<"lc">>, location:encode(Location)},
+ {<<"pla">>, OwnerID},
+ {
+ <<"ena">>,
+ (
+ character_instance:get_is_active(CharacterInstance)
+ and
+ (OwnerID == PlayerID)
+ )
+ },
+ {<<"att">>, attributes_as_json(Attributes)},
+ {<<"awp">>, ActiveWeapon},
+ {<<"swp">>, SecondaryWeapon}
+ ]
+ }.