summaryrefslogtreecommitdiff
blob: eb78245e6e2c74599291fa835302f276065d9d45 (plain)
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
152
153
154
155
156
157
158
-module(btl_condition_parameters).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-record
(
   btl_cond_params,
   {
      targets :: list(non_neg_integer()),
      locations :: list(shr_location:type()),
      uses :: (non_neg_integer() | -1),
      chance :: (0..100 | -1),
      other :: any()
   }
).

-type type(OtherDataType) :: #btl_cond_params{ other :: OtherDataType }.

-export_type
(
   [
      type/1
   ]
).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-export
(
   [
      get_targets/1,
      set_targets/2,
      ataxia_set_targets/2,
      ataxia_set_targets/3,

      get_uses/1,
      set_uses/2,
      ataxia_set_uses/2,

      get_chance/1,
      set_chance/2,
      ataxia_set_chance/2,

      get_other/1,
      set_other/2,
      ataxia_set_other/2,
      ataxia_set_other/3
   ]
).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%
%%%% Targets %%%%
%%%%%%%%%%%%%%%%%
-spec get_targets (type(_)) -> list(non_neg_integer()).
get_targets (Params) -> Params#btl_cond_params.targets.

-spec set_targets (list(non_neg_integer()), type(ODT)) -> type(ODT).
set_targets (Targets, Params) -> Params#btl_cond_params{ targets = Targets }.

-spec ataxia_set_targets
   (
      list(non_neg_integer()),
      type(ODT)
   )
   -> {type(ODT), ataxic:basic()}.
ataxia_set_targets (Targets, Params) ->
   ataxia_set_targets(Targets, ataxic:constant(Targets), Params).

-spec ataxia_set_targets
   (
      list(non_neg_integer()),
      ataxic:basic(),
      type(ODT)
   )
   -> {type(ODT), ataxic:basic()}.
ataxia_set_targets (Targets, TargetsAtaxicUpdate, Params) ->
   {
      set_targets(Targets, Params),
      ataxic:update_field(#btl_cond_params.targets, TargetsAtaxicUpdate)
   }.

%%%%%%%%%%%%%%
%%%% Uses %%%%
%%%%%%%%%%%%%%
-spec get_uses (type(_)) -> (non_neg_integer() | -1).
get_uses (Params) -> Params#btl_cond_params.uses.

-spec set_uses ((non_neg_integer() | -1), type(ODT)) -> type(ODT).
set_uses (Uses, Params) -> Params#btl_cond_params{ uses = Uses }.

-spec ataxia_set_uses
   (
      (non_neg_integer() | -1),
      type(ODT)
   )
   -> {type(ODT), ataxic:basic()}.
ataxia_set_uses (Uses, Params) ->
   {
      set_uses(Uses, Params),
      ataxic:update_field(#btl_cond_params.uses, ataxic:constant(Uses))
   }.

%%%%%%%%%%%%%%%%
%%%% Chance %%%%
%%%%%%%%%%%%%%%%
-spec get_chance (type(_)) -> (0..100 | -1).
get_chance (Params) -> Params#btl_cond_params.chance.

-spec set_chance ((0..100 | -1), type(ODT)) -> type(ODT).
set_chance (Chance, Params) -> Params#btl_cond_params{ chance = Chance }.

-spec ataxia_set_chance
   (
      (0..100 | -1),
      type(ODT)
   )
   -> {type(ODT), ataxic:basic()}.
ataxia_set_chance (Chance, Params) ->
   {
      set_chance(Chance, Params),
      ataxic:update_field(#btl_cond_params.chance, ataxic:constant(Chance))
   }.

%%%%%%%%%%%%%%%
%%%% Other %%%%
%%%%%%%%%%%%%%%
-spec get_other (type(ODT)) -> ODT.
get_other (Params) -> Params#btl_cond_params.other.

-spec set_other (ODT, type(ODT)) -> type(ODT).
set_other (Other, Params) -> Params#btl_cond_params{ other = Other }.

-spec ataxia_set_other (ODT, type(ODT)) -> {type(ODT), ataxic:basic()}.
ataxia_set_other (Other, Params) ->
   ataxia_set_other(Other, ataxic:constant(Other), Params).

-spec ataxia_set_other
   (
      ODT,
      ataxic:basic(),
      type(ODT)
   )
   -> {type(ODT), ataxic:basic()}.
ataxia_set_other (Other, OtherAtaxicUpdate, Params) ->
   {
      set_other(Other, Params),
      ataxic:update_field(#btl_cond_params.other, OtherAtaxicUpdate)
   }.