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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
-module(chr_character).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-record
(
character,
{
name :: binary(),
portrait :: binary(),
weapon_ids :: {shr_weapon:id(), shr_weapon:id()},
armor_id :: shr_armor:id(),
glyph_ids :: array:array(shr_glyph:id()),
glyph_board_id :: shr_glyph_board:id()
}
).
-opaque type() :: #character{}.
-export_type([type/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-export
(
[
get_name/1,
get_portrait/1,
get_weapon_ids/1,
get_armor_id/1,
get_glyph_ids/1,
get_glyph_board_id/1,
set_name/2,
set_portrait/2,
set_weapon_ids/2,
set_armor_id/2,
set_glyph_ids/2,
set_glyph_board_id/2,
get_name_field/0,
get_portrait_field/0,
get_weapon_ids_field/0,
get_armor_id_field/0,
get_glyph_ids_field/0,
get_glyph_board_id_field/0
]
).
-export
(
[
random/0
]
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-spec get_name (type()) -> binary().
get_name (Char) -> Char#character.name.
-spec get_portrait (type()) -> binary().
get_portrait (Char) -> Char#character.portrait.
-spec get_weapon_ids (type()) -> {shr_weapon:id(), shr_weapon:id()}.
get_weapon_ids (Char) -> Char#character.weapon_ids.
-spec get_armor_id (type()) -> shr_armor:id().
get_armor_id (Char) -> Char#character.armor_id.
-spec get_glyph_ids (type()) -> array:array(shr_glyph:id()).
get_glyph_ids (Char) -> Char#character.glyph_ids.
-spec get_glyph_board_id (type()) -> shr_glyph_board:id().
get_glyph_board_id (Char) -> Char#character.glyph_board_id.
-spec set_name (binary(), type()) -> type().
set_name (Name, Char) ->
Char#character
{
name = Name
}.
-spec set_portrait (binary(), type()) -> type().
set_portrait (PortraitID, Char) ->
Char#character
{
portrait = PortraitID
}.
-spec set_armor_id (shr_armor:id(), type()) -> type().
set_armor_id (ArmorID, Char) ->
Char#character
{
armor_id = ArmorID
}.
-spec set_weapon_ids ({shr_weapon:id(), shr_weapon:id()}, type()) -> type().
set_weapon_ids (WeaponIDs, Char) ->
Char#character
{
weapon_ids = WeaponIDs
}.
-spec set_glyph_ids (array:array(shr_glyph:id()), type()) -> type().
set_glyph_ids (GlyphIDs, Char) ->
Char#character
{
glyph_ids = GlyphIDs
}.
-spec set_glyph_board_id (shr_glyph_board:id(), type()) -> type().
set_glyph_board_id (GlyphBoardID, Char) ->
Char#character
{
glyph_board_id = GlyphBoardID
}.
-spec random () -> type().
random () ->
#character
{
name = <<"">>,
portrait = <<"0">>,
weapon_ids = {0, 0},
armor_id = 0,
glyph_ids = array:new(),
glyph_board_id = <<"0">>
}.
-spec get_name_field () -> non_neg_integer().
get_name_field () -> #character.name.
-spec get_portrait_field () -> non_neg_integer().
get_portrait_field () -> #character.portrait.
-spec get_armor_id_field () -> non_neg_integer().
get_armor_id_field () -> #character.armor_id.
-spec get_weapon_ids_field () -> non_neg_integer().
get_weapon_ids_field () -> #character.weapon_ids.
-spec get_glyph_ids_field () -> non_neg_integer().
get_glyph_ids_field () -> #character.glyph_ids.
-spec get_glyph_board_id_field () -> non_neg_integer().
get_glyph_board_id_field () -> #character.glyph_board_id.
|