summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-01-24 13:06:30 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-01-24 13:06:30 +0100
commit99655bbe4ceefb48126d4c4f01950ac62d8bf050 (patch)
treef9fdb81dfc8d6250ba3b211fb5921507d276baed
parentbf751b384f9207226fc8b7ec662eac32d8bc81eb (diff)
Now sends char attributes to client.
-rw-r--r--src/query/character_turn.erl8
-rw-r--r--src/reply/add_char.erl21
2 files changed, 23 insertions, 6 deletions
diff --git a/src/query/character_turn.erl b/src/query/character_turn.erl
index 624e4d0..5b2063d 100644
--- a/src/query/character_turn.erl
+++ b/src/query/character_turn.erl
@@ -138,7 +138,13 @@ handle_main_char_movement (QueryState) ->
(
QueryState#query_state.battlemap,
character_instance:get_location(QueryState#query_state.main_char_inst),
- character:get_movement_points(QueryState#query_state.main_char),
+ statistics:get_movement_points
+ (
+ character_instance:get_statistics
+ (
+ QueryState#query_state.main_char_inst
+ )
+ ),
QueryState#query_state.input#input.path,
battlemap_instance:get_char_instances
(
diff --git a/src/reply/add_char.erl b/src/reply/add_char.erl
index 99b1d25..c730c24 100644
--- a/src/reply/add_char.erl
+++ b/src/reply/add_char.erl
@@ -12,9 +12,21 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+attributes_as_json (Atts) ->
+ {
+ [
+ {<<"con">>, attributes:get_constitution(Atts)},
+ {<<"dex">>, attributes:get_dexterity(Atts)},
+ {<<"int">>, attributes:get_intelligence(Atts)},
+ {<<"min">>, attributes:get_mind(Atts)},
+ {<<"spe">>, attributes:get_speed(Atts)},
+ {<<"str">>, attributes:get_strength(Atts)}
+ ]
+ }.
+
encode (Char, CharInstance, IsEnabled) ->
{X, Y} = character_instance:get_location(CharInstance),
- Stats = character_instance:get_statistics(CharInstance),
+ Atts = character:get_attributes(Char),
ActWeapon = character_instance:get_active_weapon(CharInstance, Char),
{_MinRg, MaxRg} = weapon:get_ranges(ActWeapon),
jiffy:encode
@@ -29,10 +41,9 @@ encode (Char, CharInstance, IsEnabled) ->
{<<"loc_x">>, X},
{<<"loc_y">>, Y},
{<<"team">>, character_instance:get_owner(CharInstance)},
- {<<"max_health">>, statistics:get_health(Stats)},
- {<<"mov_pts">>, statistics:get_movement_points(Stats)},
- {<<"atk_rg">>, MaxRg},
- {<<"enabled">>, IsEnabled}
+ {<<"enabled">>, IsEnabled},
+ {<<"att">>, attributes_as_json(Atts)},
+ {<<"atk_rg">>, MaxRg}
]
}
).