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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
module BattleCharacters.Struct.DataSet exposing
(
Type,
new,
is_ready,
get_weapon,
get_weapons,
add_weapon,
get_armor,
get_armors,
add_armor,
get_portrait,
get_portraits,
add_portrait,
get_glyph,
get_glyphs,
add_glyph,
get_glyph_board,
get_glyph_boards,
add_glyph_board,
get_skill,
get_skills,
add_skill
)
-- Elm -------------------------------------------------------------------------
import Dict
-- Battle ----------------------------------------------------------------------
import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.Glyph
import BattleCharacters.Struct.GlyphBoard
import BattleCharacters.Struct.Portrait
import BattleCharacters.Struct.Skill
import BattleCharacters.Struct.Weapon
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
--------------------------------------------------------------------------------
type alias Type =
{
weapons :
(Dict.Dict
BattleCharacters.Struct.Weapon.Ref
BattleCharacters.Struct.Weapon.Type
),
armors :
(Dict.Dict
BattleCharacters.Struct.Armor.Ref
BattleCharacters.Struct.Armor.Type
),
glyphs :
(Dict.Dict
BattleCharacters.Struct.Glyph.Ref
BattleCharacters.Struct.Glyph.Type
),
glyph_boards :
(Dict.Dict
BattleCharacters.Struct.GlyphBoard.Ref
BattleCharacters.Struct.GlyphBoard.Type
),
portraits :
(Dict.Dict
BattleCharacters.Struct.Portrait.Ref
BattleCharacters.Struct.Portrait.Type
),
skills :
(Dict.Dict
BattleCharacters.Struct.Skill.Ref
BattleCharacters.Struct.Skill.Type
)
}
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
new : Type
new =
{
weapons = (Dict.empty),
armors = (Dict.empty),
glyphs = (Dict.empty),
glyph_boards = (Dict.empty),
portraits = (Dict.empty),
skills = (Dict.empty)
}
is_ready : Type -> Bool
is_ready data_set =
(
(not (Dict.isEmpty data_set.portraits))
&& (not (Dict.isEmpty data_set.weapons))
&& (not (Dict.isEmpty data_set.armors))
&& (not (Dict.isEmpty data_set.glyph_boards))
&& (not (Dict.isEmpty data_set.glyphs))
&& (not (Dict.isEmpty data_set.skills))
)
---- Accessors -----------------------------------------------------------------
----------------
---- Weapon ----
----------------
get_weapons : (
Type ->
(Dict.Dict
BattleCharacters.Struct.Weapon.Ref
BattleCharacters.Struct.Weapon.Type
)
)
get_weapons data_set = data_set.weapons
get_weapon : (
BattleCharacters.Struct.Weapon.Ref ->
Type ->
BattleCharacters.Struct.Weapon.Type
)
get_weapon wp_id data_set =
case (Dict.get wp_id data_set.weapons) of
(Just wp) -> wp
Nothing -> BattleCharacters.Struct.Weapon.none
add_weapon : BattleCharacters.Struct.Weapon.Type -> Type -> Type
add_weapon wp data_set =
{data_set |
weapons =
(Dict.insert
(BattleCharacters.Struct.Weapon.get_id wp)
wp
data_set.weapons
)
}
---------------
---- Armor ----
---------------
get_armors : (
Type ->
(Dict.Dict
BattleCharacters.Struct.Armor.Ref
BattleCharacters.Struct.Armor.Type
)
)
get_armors data_set = data_set.armors
get_armor : (
BattleCharacters.Struct.Armor.Ref ->
Type ->
BattleCharacters.Struct.Armor.Type
)
get_armor ar_id data_set =
case (Dict.get ar_id data_set.armors) of
(Just ar) -> ar
Nothing -> BattleCharacters.Struct.Armor.none
add_armor : BattleCharacters.Struct.Armor.Type -> Type -> Type
add_armor ar data_set =
{data_set |
armors =
(Dict.insert
(BattleCharacters.Struct.Armor.get_id ar)
ar
data_set.armors
)
}
------------------
---- Portrait ----
------------------
get_portraits : (
Type ->
(Dict.Dict
BattleCharacters.Struct.Portrait.Ref
BattleCharacters.Struct.Portrait.Type
)
)
get_portraits data_set = data_set.portraits
get_portrait : (
BattleCharacters.Struct.Portrait.Ref ->
Type ->
BattleCharacters.Struct.Portrait.Type
)
get_portrait pt_id data_set =
case (Dict.get pt_id data_set.portraits) of
(Just pt) -> pt
Nothing -> BattleCharacters.Struct.Portrait.none
add_portrait : BattleCharacters.Struct.Portrait.Type -> Type -> Type
add_portrait pt data_set =
{data_set |
portraits =
(Dict.insert
(BattleCharacters.Struct.Portrait.get_id pt)
pt
data_set.portraits
)
}
---------------
---- Glyph ----
---------------
get_glyphs : (
Type ->
(Dict.Dict
BattleCharacters.Struct.Glyph.Ref
BattleCharacters.Struct.Glyph.Type
)
)
get_glyphs data_set = data_set.glyphs
get_glyph : (
BattleCharacters.Struct.Glyph.Ref ->
Type ->
BattleCharacters.Struct.Glyph.Type
)
get_glyph gl_id data_set =
case (Dict.get gl_id data_set.glyphs) of
(Just gl) -> gl
Nothing -> BattleCharacters.Struct.Glyph.none
add_glyph : BattleCharacters.Struct.Glyph.Type -> Type -> Type
add_glyph gl data_set =
{data_set |
glyphs =
(Dict.insert
(BattleCharacters.Struct.Glyph.get_id gl)
gl
data_set.glyphs
)
}
---------------------
---- Glyph Board ----
---------------------
get_glyph_boards : (
Type ->
(Dict.Dict
BattleCharacters.Struct.GlyphBoard.Ref
BattleCharacters.Struct.GlyphBoard.Type
)
)
get_glyph_boards data_set = data_set.glyph_boards
get_glyph_board : (
BattleCharacters.Struct.GlyphBoard.Ref ->
Type ->
BattleCharacters.Struct.GlyphBoard.Type
)
get_glyph_board gb_id data_set =
case (Dict.get gb_id data_set.glyph_boards) of
(Just gb) -> gb
Nothing -> BattleCharacters.Struct.GlyphBoard.none
add_glyph_board : BattleCharacters.Struct.GlyphBoard.Type -> Type -> Type
add_glyph_board glb data_set =
{data_set |
glyph_boards =
(Dict.insert
(BattleCharacters.Struct.GlyphBoard.get_id glb)
glb
data_set.glyph_boards
)
}
---------------
---- Skill ----
---------------
get_skills : (
Type ->
(Dict.Dict
BattleCharacters.Struct.Skill.Ref
BattleCharacters.Struct.Skill.Type
)
)
get_skills data_set = data_set.skills
get_skill : (
BattleCharacters.Struct.Skill.Ref ->
Type ->
BattleCharacters.Struct.Skill.Type
)
get_skill sk_id data_set =
case (Dict.get sk_id data_set.skills) of
(Just sk) -> sk
Nothing -> BattleCharacters.Struct.Skill.none
add_skill : BattleCharacters.Struct.Skill.Type -> Type -> Type
add_skill sk data_set =
{data_set |
skills =
(Dict.insert
(BattleCharacters.Struct.Skill.get_id sk)
sk
data_set.skills
)
}
|