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
|
-module(weapon).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-record
(
weapon,
{
id,
name,
icon,
type,
pwr_min,
pwr_max
}
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-export
(
[
get_id/1,
get_name/1,
get_icon/1,
get_type/1,
get_max_power/1,
get_min_power/1
]
).
-export
(
[
from_id/1,
get_category/1,
get_ranges/1
]
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ranges_of_type (short_bow) -> {2, 4};
ranges_of_type (long_bow) -> {2, 6};
ranges_of_type (crossbow) -> {2, 4};
ranges_of_type (arbalest) -> {2, 4};
ranges_of_type (sword) -> {1, 1};
ranges_of_type (claymore) -> {1, 2};
ranges_of_type (mace) -> {1, 1};
ranges_of_type (war_hammer) -> {1, 2};
ranges_of_type (dagger) -> {1, 1};
ranges_of_type (spear) -> {1, 2}.
category_of_type (short_bow) -> physical;
category_of_type (long_bow) -> physical;
category_of_type (crossbow) -> physical;
category_of_type (arbalest) -> physical;
category_of_type (sword) -> physical;
category_of_type (claymore) -> physical;
category_of_type (mace) -> physical;
category_of_type (war_hammer) -> physical;
category_of_type (dagger) -> physical;
category_of_type (spear) -> physical.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
get_id (Wp) -> Wp#weapon.id.
get_name (Wp) -> Wp#weapon.name.
get_icon (Wp) -> Wp#weapon.icon.
get_type (Wp) -> Wp#weapon.type.
get_max_power (Wp) -> Wp#weapon.pwr_max.
get_min_power (Wp) -> Wp#weapon.pwr_min.
get_ranges (Wp) -> ranges_of_type(Wp#weapon.type).
get_category (Wp) -> category_of_type(Wp#weapon.type).
from_id (0) ->
#weapon{
id = 0,
name = "Shim Weapon 0",
icon = "0",
type = sword,
pwr_min = 10,
pwr_max = 90
}.
|