1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
-module(btl_add_char).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-export([generate/3]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec rank_to_string (btl_character:rank()) -> binary().
rank_to_string (Rank) ->
case Rank of
optional -> <<"o">>;
target -> <<"t">>;
commander -> <<"c">>
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-spec generate
(
non_neg_integer(),
btl_character:type(),
non_neg_integer()
)
-> {list(any())}.
generate (IX, Character, PlayerIX) ->
{ActiveWeapon, SecondaryWeapon} = btl_character:get_weapon_ids(Character),
CharacterPlayerIX = btl_character:get_player_index(Character),
Location = btl_character:get_location(Character),
{
[
{<<"msg">>, <<"add_char">>},
{<<"ix">>, IX},
{<<"nam">>, btl_character:get_name(Character)},
{<<"rnk">>, rank_to_string(btl_character:get_rank(Character))},
{<<"ico">>, btl_character:get_icon(Character)},
{<<"prt">>, btl_character:get_portrait(Character)},
{
<<"hea">>,
btl_character:get_current_health(Character)
},
{<<"lc">>, btl_location:encode(Location)},
{<<"pla">>, CharacterPlayerIX},
{
<<"ena">>,
(
btl_character:get_is_active(Character)
and (CharacterPlayerIX == PlayerIX)
)
},
{<<"dea">>, btl_character:get_is_defeated(Character)},
{<<"awp">>, ActiveWeapon},
{<<"swp">>, SecondaryWeapon},
{<<"ar">>, btl_character:get_armor_id(Character)},
{
<<"pomni">>,
shr_omnimods:encode(btl_character:get_permanent_omnimods(Character))
}
]
}.
|