-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsampleData.js
477 lines (397 loc) · 11.8 KB
/
sampleData.js
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
const db = require("./app/models");
const { createGame } = require("./app/utils/CreateData");
const bcrypt = require('bcryptjs');
// ---------------------- SAMPLE DATA
async function initialSampleData() {
// ---------------------------------------------------------
// USER ACCOUNT & INFO & ROLE & PLAYER
// #### Acount 1: Triet
const trietAccount = await db.UserAccount.create({
username: 'TrietHuynh',
// password: await bcrypt.hash('1234567890', 10),
password: 'c+qOaBlxvL59hjs92YClUH1/Lpmfi7q5U/QFByPX326dJbAfT/3Ee25x0n4/rbwj4ADibI8zH66ObZfHzOJdgQ==',
fullName: 'Huynh Cong Triet'
});
const trietInfo = await db.UserInfo.create({
id: trietAccount.id,
avatar: 'avatar/MaleAvatar'
});
const trietRole1 = await db.Role.create({
userId: trietAccount.id,
role: 'user',
})
const trietRole2 = await db.Role.create({
userId: trietAccount.id,
role: 'admin',
})
const trietPlayer = await db.Player.create({
id: trietAccount.id,
})
// #### Acount 2: Phat
const phatAccount = await db.UserAccount.create({
username: 'PhatCao',
// password: await bcrypt.hash('1234567890', 10),
password: 'c+qOaBlxvL59hjs92YClUH1/Lpmfi7q5U/QFByPX326dJbAfT/3Ee25x0n4/rbwj4ADibI8zH66ObZfHzOJdgQ==',
fullName: 'Cao Quang Phat',
email: 'quangphat18ti@gmail.com'
});
const phatInfo = await db.UserInfo.create({
id: phatAccount.id,
avatar: 'avatar/FemaleAvatar'
});
const phatRole = await db.Role.create({
userId: phatAccount.id,
role: 'user',
});
const phatPlayer = await db.Player.create({
id: phatAccount.id,
})
// ---------------------------------------------------------
// MAP & LAND & CHECKPOINT
// #### Sai Gon Map
const sgMap = await db.Object.create({
type: 'map',
code: "Sai Gon Map",
isActive: true,
});
// #### Lands in Sai Gon Map
// LAND 1 & checkpoints:
const benthanhLand = await db.Object.create(
{
type: 'land',
code: "Cho Ben Thanh",
isActive: true,
},
{
mapId: sgMap.id
}
);
const benthanhCheckpoint1 = await db.Object.create(
{
type: 'checkpoint',
code: "Cua Dong",
isActive: true,
},
{
landId: benthanhLand.id,
ordinal: 1,
}
);
const benthanhCheckpoint2 = await db.Object.create(
{
type: 'checkpoint',
code: "Cua Tay",
isActive: true,
},
{
landId: benthanhLand.id,
ordinal: 2,
}
);
// LAND 2 & checkpoints:
const dinhdoclapLand = await db.Object.create(
{
type: 'land',
code: "Dinh Doc Lap",
isActive: true,
},
{
mapId: sgMap.id
}
)
const dinhdoclapCheckpoint1 = await db.Object.create(
{
type: 'checkpoint',
code: "Phong hop noi cac",
isActive: true,
},
{
landId: dinhdoclapLand.id,
ordinal: 1,
}
);
const dinhdoclapCheckpoint2 = await db.Object.create(
{
type: 'checkpoint',
code: "Phong tiep khach",
isActive: true,
},
{
landId: dinhdoclapLand.id,
ordinal: 2,
}
);
const dinhdoclapCheckpoint3 = await db.Object.create(
{
type: 'checkpoint',
code: "Phong dai yen",
isActive: true,
},
{
landId: dinhdoclapLand.id,
ordinal: 3,
}
);
// ------------------------------------------------------------
const haNoiMap = await db.Object.create({
type: 'map',
code: "Ha Noi Map",
isActive: false,
});
// ------------------------------------------------------------
const dalatMap = await db.Object.create({
type: 'map',
code: "Da Lat Map",
isActive: true,
});
// ---------------------------------------------------------
// LOCATION
const location_sgMap = await db.Location.create({
id: sgMap.id,
lat: 10.775556,
lng: 106.701944,
radius: 20000,
});
const location_benthanhLand = await db.Location.create({
id: benthanhLand.id,
lat: 10.772759203799472,
lng: 106.69797788006473,
radius: 1000,
});
const location_benthanhCheckpoint1 = await db.Location.create({
id: benthanhCheckpoint1.id,
lat: 10.772747861891759,
lng: 106.698437760696,
radius: 5,
});
const location_benthanhCheckpoint2 = await db.Location.create({
id: benthanhCheckpoint2.id,
lat: 10.772317895446271,
lng: 106.69769448596294,
radius: 5,
});
const location_dinhdoclapLand = await db.Location.create({
id: dinhdoclapLand.id,
lat: 10.777289298168423,
lng: 106.69526990890068,
radius: 1000,
});
const location_dinhdoclapCheckpoint1 = await db.Location.create({
id: dinhdoclapCheckpoint1.id,
lat: 10.777289298168392,
lng: 106.69526990890101,
radius: 5,
});
const location_dinhdoclapCheckpoint2 = await db.Location.create({
id: dinhdoclapCheckpoint2.id,
lat: 10.777289298168201,
lng: 106.69526990890168,
radius: 5,
});
const location_dinhdoclapCheckpoint3 = await db.Location.create({
id: dinhdoclapCheckpoint3.id,
lat: 10.777289298168605,
lng: 106.69526990890118,
radius: 5,
jsonData: {
description: "this (lat,lng) is not correct",
}
});
// ---------------------------------------------------------
// PLAYER_Map_OPENS
const trietPlayerMapSaigon = await db.PlayerMapOpen.create({
playerId: trietAccount.id,
mapId: sgMap.id,
});
const trietPlayerMapHanoi = await db.PlayerMapOpen.create({
playerId: trietAccount.id,
mapId: haNoiMap.id,
});
const trietPlayerMapDaLat = await db.PlayerMapOpen.create({
playerId: trietAccount.id,
mapId: dalatMap.id,
});
const phatPlayerMapSaiGon = await db.PlayerMapOpen.create({
playerId: phatAccount.id,
mapId: sgMap.id,
})
// ---------------------------------------------------------
// PLAYER_LAND_OPENS
const trietPlayerBenThanhLand = await db.PlayerLandOpen.create({
playerMapOpenId: trietPlayerMapSaigon.id,
playerId: trietAccount.id,
landId: benthanhLand.id,
});
const trietPlayerDinhDoclapLand = await db.PlayerLandOpen.create({
playerMapOpenId: trietPlayerMapSaigon.id,
playerId: trietAccount.id,
landId: dinhdoclapLand.id,
});
const phatPlayerBenThanhLand = await db.PlayerLandOpen.create({
playerMapOpenId: phatPlayerMapSaiGon.id,
playerId: phatAccount.id,
landId: benthanhLand.id,
})
// ---------------------------------------------------------
// ASSET & OBJECT_ASSETS
const asset1 = await db.Asset.create({
type: 'image', // 'video'
src: "https://shorturl.at/vIdI8"
});
const asset2 = await db.Asset.create({
type: 'image', // 'video'
src: "https://shorturl.at/vIdI8"
});
const asset3 = await db.Asset.create({
type: 'video',
src: "https://i.pinimg.com/originals/70/fb/17/70fb17b1b4fa1c35a3e9a552babdfef5.gif"
});
const asset4 = await db.Asset.create({
type: 'video',
src: "https://i.pinimg.com/originals/70/fb/17/70fb17b1b4fa1c35a3e9a552babdfef5.gif"
});
// add object asset here
sgMap.addAsset(asset1);
benthanhLand.addAsset(asset2);
benthanhLand.addAsset(asset3);
// benthanhCheckpoint1.addAsset(...);
// benthanhCheckpoint2.addAsset(...);
dinhdoclapLand.addAsset(asset1);
dinhdoclapCheckpoint1.addAsset(asset4);
// dinhdoclapCheckpoint2.addAsset(...);
// dinhdoclapCheckpoint3.addAsset(...);
// ---------------------------------------------------------
// GAME TYPES
const hanhDongType = await db.GameType.create({
code: 'hanh dong'
});
const nhapVaiType = await db.GameType.create({
code: 'nhap vai'
});
const moPhongType = await db.GameType.create({
code: 'mo phong'
});
// GAMES
const banXeTankGame = await createGame('ban xe tank', nhapVaiType.id, dinhdoclapCheckpoint1.id)
const ghepAnhGame = await createGame('ghep anh', moPhongType.id, benthanhCheckpoint1.id)
const xeTankTongCongGame = await createGame('xe tank tong cong', moPhongType.id, dinhdoclapCheckpoint2.id)
const banDichGame = await createGame('ban dich', nhapVaiType.id, benthanhCheckpoint2.id)
const canBaangTrungGame = await createGame('can bang trung', moPhongType.id, dinhdoclapCheckpoint3.id)
// ---------------------------------------------------------
// REWARD TYPES
const vuKhiRewardType = await db.RewardType.create({
code: 'vu khi'
});
const daQuyRewardType = await db.RewardType.create({
code: 'da quy'
});
// REWARDS
const kiemReward = await db.Reward.create({
code: 'kiem',
scoreValue: 100,
rewardTypeId: vuKhiRewardType.id,
})
const sungReward = await db.Reward.create({
code: 'sung',
scoreValue: 150,
rewardTypeId: vuKhiRewardType.id,
})
const daDoReward = await db.Reward.create({
code: 'da do',
scoreValue: 70,
rewardTypeId: daQuyRewardType.id,
})
const daXanhReward = await db.Reward.create({
code: 'da xanh',
scoreValue: 90,
rewardTypeId: daQuyRewardType.id,
})
// ---------------------------------------------------------
// OBJECT REWARDS
// saigon Map rewards
const kiem_sgMap_reward = await db.ObjectReward.create({
objectId: sgMap.id,
rewardId: kiemReward.id,
quantity: 5,
});
const daxanh_sgMap_reward = await db.ObjectReward.create({
objectId: sgMap.id,
rewardId: daXanhReward.id,
quantity: 10,
});
// benthanh Land rewards
const sung_benthanhLand_reward = await db.ObjectReward.create({
objectId: benthanhLand.id,
rewardId: sungReward.id,
quantity: 3,
});
// benthanh Checkpoints rewards
const dado_benthanhCheckoint1_reward = await db.ObjectReward.create({
objectId: benthanhCheckpoint1.id,
rewardId: daDoReward.id,
quantity: 1,
});
const daxanh_benthanhCheckoint2_reward = await db.ObjectReward.create({
objectId: benthanhCheckpoint2.id,
rewardId: daXanhReward.id,
quantity: 1,
});
// dinhdoclap Land rewards
const kiem_dinhdoclapLand_reward = await db.ObjectReward.create({
objectId: dinhdoclapLand.id,
rewardId: kiemReward.id,
quantity: 2,
});
// dinhdoclap Checkpoints rewards
const sung_dinhdoclapCheckoint1_reward = await db.ObjectReward.create({
objectId: dinhdoclapCheckpoint1.id,
rewardId: sungReward.id,
quantity: 1,
});
const dado_dinhdoclapCheckoint2_reward = await db.ObjectReward.create({
objectId: dinhdoclapCheckpoint2.id,
rewardId: daDoReward.id,
quantity: 2,
});
const daxanh_dinhdoclapCheckoint3_reward = await db.ObjectReward.create({
objectId: dinhdoclapCheckpoint3.id,
rewardId: daXanhReward.id,
quantity: 1,
});
// ---------------------------------------------------------
// PLAYER LAND CHECKPOINTS
// Triet passed checkpoint 1 of benthanh Land
const triet_benthanhCheckpoint1 = await db.PlayerLandCheckpoint.create({
score: 100,
playerLandOpenId: trietPlayerBenThanhLand.id,
checkpointId: benthanhCheckpoint1.id,
})
// Triet pass dinhdoclap Land
const triet_dinhdoclapCheckpoint1 = await db.PlayerLandCheckpoint.create({
score: 80,
playerLandOpenId: trietPlayerDinhDoclapLand.id,
checkpointId: dinhdoclapCheckpoint1.id,
})
const triet_dinhdoclapCheckpoint2 = await db.PlayerLandCheckpoint.create({
score: 100,
playerLandOpenId: trietPlayerDinhDoclapLand.id,
checkpointId: dinhdoclapCheckpoint2.id,
})
const triet_dinhdoclapCheckpoint3 = await db.PlayerLandCheckpoint.create({
score: 50,
playerLandOpenId: trietPlayerDinhDoclapLand.id,
checkpointId: dinhdoclapCheckpoint3.id,
})
// Phat pass benthanh Land
const phat_benthanhCheckpoint1 = await db.PlayerLandCheckpoint.create({
score: 101,
playerLandOpenId: phatPlayerBenThanhLand.id,
checkpointId: benthanhCheckpoint1.id,
})
const phat_benthanhCheckpoint2 = await db.PlayerLandCheckpoint.create({
score: 65,
playerLandOpenId: phatPlayerBenThanhLand.id,
checkpointId: benthanhCheckpoint2.id,
})
}
module.exports = initialSampleData;