-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibRepository.js
More file actions
768 lines (617 loc) · 21.9 KB
/
libRepository.js
File metadata and controls
768 lines (617 loc) · 21.9 KB
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
const TAFFY = require('taffy');
const gamesMap = new Map();
function isValidSettingName(setting_name) {
const validNameRegex = /^[a-z0-9]+$/g;
if (typeof setting_name === 'undefined' || setting_name === null || setting_name.length === 0) return false;
return setting_name.match(validNameRegex);
}
function dbMakeDb(guildid) {
return gamesMap.set(guildid, TAFFY());
}
function dbGetGuildGame(guildid) {
if (typeof guildid === 'undefined') throw 'no guildid';
if (!gamesMap.has(guildid)) { console.log('guild keys dump:', gamesMap.keys()); throw 'unknown guildid ' + guildid; }
return gamesMap.get(guildid);
}
function dbMakeKey(guildid, userid, channelid) {
return [userid, channelid].join("-");
}
function dbAddGameAuthor(guildid, authorid, channelid, stuff, targetid) {
if (typeof stuff === 'undefined') stuff = {};
if (typeof targetid !== 'undefined' && targetid !== null) {
stuff.targetid = targetid;
stuff.targetkey = dbMakeKey(guildid, targetid, channelid);
}
const key = dbMakeKey(guildid, authorid, channelid);
dbGetGuildGame(guildid).insert({
key,
isAuthor: true,
channelid,
authorid
}).update(stuff);
}
function dbUpdateGameTarget(guildid, authorid, channelid, targetid, targetStuff) {
if (typeof targetStuff === 'undefined') targetStuff = {};
const targetkey = dbMakeKey(guildid, targetid, channelid);
const authorkey = dbMakeKey(guildid, authorid, channelid);
dbGetGuildGame(guildid).insert({
key: targetkey,
isAuthor: false,
channelid,
targetid,
authorid,
authorkey
}).update(targetStuff);
}
/* updates all properties for where this user is an author or target */
function dbUpdateForGame(guildid, userid, channelid, game) {
if (typeof game === 'undefined') {
console.log('invalid game in dbUpdateForGame'); throw 'invalid game in dbUpdateForGame';
}
dbGetGuildGame(guildid)([{ key: dbGetGameKeysForUser(guildid, userid, channelid) }] ).update(game);
}
function dbIsAny(guildid, userid, channelid) {
const db = dbGetGuildGame(guildid);
return db([
{ authorid: userid, channelid },
{ targetid: userid, channelid }])
.get().length > 0;
}
/* gets all game keys where the user is an author or target */
function dbGetGameKeysForUser(guildid, userid, channelid) {
const findKey
= (typeof channelid === 'undefined')
? [{ authorid: userid },
{ targetid: userid }]
: [{ authorid: userid, channelid },
{ targetid: userid, channelid }];
var db = dbGetGuildGame(guildid);
const keys = db(findKey).select('authorkey', 'targetkey', 'key');
if (keys.length > 0) {
var definedKeys = [];
for (var i = 0; keys.length > i; i++) {
keys[i]
.filter(f => typeof f !== 'undefined')
.forEach(function (val) {
definedKeys.push(val);
});
}
return [ ...new Set(definedKeys) ];
}
return [];
}
/* gets all game rows that 'targetid' and 'channelid' match */
function dbGetGameFromTarget(guildid, targetid, channelid) {
return dbGetGuildGame(guildid)({ targetid, channelid }).get().filter(f => typeof f !== 'undefined');
}
/* updates individual user properties e.g. */
function dbUpdateForUser(guildid, userid, channelid, updates) {
const key = dbMakeKey(guildid, userid, channelid);
dbGetGuildGame(guildid)({ key }).update(updates);
}
/* removes all traces of the game a user is an author or target of */
function dbRemoveGame(guildid, userid, channelid) {
const db = dbGetGuildGame(guildid);
db([{ key: dbGetGameKeysForUser(guildid, userid, channelid) }]).remove();
}
function dbGetGame(guildid, keys) {
const result = dbGetGuildGame(guildid)({ key: keys }).get();
return typeof result === 'undefined'
? [[{}]]
: result;
}
function dbPresentGames(guildid, template) {
const db = dbGetGuildGame(guildid);
return db().supplant(template);
}
function dbGetAll(guildid) {
return dbGetGuildGame(guildid)().get();
}
function dbGetForUserKey(guildid, userid, channelid) {
const db = dbGetGuildGame(guildid);
return db({ key: dbMakeKey(guildid, userid, channelid) }).get().filter(f => typeof f !== 'undefined');
}
/*
https://www.asciiart.eu/electronics/clocks
| |
_|________|_
|____________|
| |
| |
| |
| |
| |
| |
| |
_|__________|_
_/______________\_
/ ______________ \
| | _ _ _ | |
| | |_| o | | _| | |\
| | _| o |_| _| | | |
| |______________| |/
| __ |
| _ _ _ | | |\
| |_| |_| |_| |__| |/
\____________________/
\______________/
| |
| |
| |
| |
| |
| |
| () |
*/
const timerMap = new Map();
function timerAdd(guildid, channelid, messageauthorid, timer) {
return timerMap.set(dbMakeKey(guildid, messageauthorid, channelid), timer);
}
function timerGet(guildid, channelid, messageauthorid) {
return timerMap.get(dbMakeKey(guildid, messageauthorid, channelid));
}
function timerClear(guildid, channelid, messageauthorid) {
return timerMap.delete(dbMakeKey(guildid, messageauthorid, channelid));
}
function timerGetAll() {
return timerMap.values();
}
const fs = require('fs');
const authContent = fs.readFileSync('../guild.auth.json');
const guildAuth = ( JSON.parse( new TextDecoder().decode(authContent)) );
function dbResolveCode(code) {
try
{
return guildAuth[code];
} catch (err) {
console.log("resolve code:", err);
return false;
}
}
const settingsMap = new Map();
function hasSettingsOnDisk(guildid, userid) {
try {
const fn = '../' + guildid + '_' + userid + '.settings';
return fs.existsSync(fn);
} catch (err) {
return false;
}
}
function hasGuildSettingsOnDisk(guildid) {
try {
const fn = './' + guildid + '.settings';
return fs.existsSync(fn);
} catch (err) {
return false;
}
}
function loadGuildSettingsFromDisk(guildid) {
try {
const fn = './' + guildid + '.settings';
if (fs.existsSync(fn)) {
const content = new TextDecoder().decode(fs.readFileSync(fn));
console.log('loadGuildSettingsFromDisk', content);
return JSON.parse(content);
}
else
return {};
} catch (err) {
return { loadSettingsFromDiskError: err };
}
}
function loadSettingsFromDisk(guildid, userid) {
try {
const fn = '../' + guildid + '_' + userid + '.settings';
if (fs.existsSync(fn)) {
const content = new TextDecoder().decode(fs.readFileSync(fn));
console.log('loadSettingsFromDisk', content);
return JSON.parse(content);
}
else
return {};
} catch (err) {
return { loadSettingsFromDiskError: err };
}
}
function saveSettingsToDisk(guildid, userid, settingsObj) {
console.log('saveSettingsToDisk', settingsObj);
const fn = '../' + guildid + '_' + userid + '.settings';
//SAVE EVERYTHING IN UNICODE!!!
//easier to read it back then
var encoded = new TextEncoder('utf-16le').encode(JSON.stringify(settingsObj));
fs.writeFileSync(fn, encoded);
const testObj = loadSettingsFromDisk(guildid, userid);
if (typeof testObj.loadSettingsFromDiskError !== 'undefined')
throw testObj.loadSettingsFromDiskError;
Object.keys(testObj)
.concat(Object.keys(settingsObj))
.forEach(key => {
if (!isValidSettingName(key)) {
return;
}
if (testObj[key] !== settingsObj[key])
throw key + ' not saved!';
});
}
function dbMakeGuildSettingsDb(guildid) {
settings = loadGuildSettingsFromDisk(guildid);
return settingsMap.set(guildid, TAFFY(settings));
}
function dbMakeSettingsDb(guildid, userid) {
settings = loadSettingsFromDisk(guildid, userid);
return settingsMap.set(userid, TAFFY(settings));
}
function dbGetGuildSettings(guildid) {
if (typeof guildid === 'undefined') throw 'no guildid';
if (!settingsMap.has(guildid)) {
dbMakeGuildSettingsDb(guildid);
}
return settingsMap.get(guildid);
}
function dbGetUserSettings(guildid, userid) {
if (typeof guildid === 'undefined') throw 'no guildid';
if (typeof userid === 'undefined') throw 'no userid';
if (!settingsMap.has(userid)) {
dbMakeSettingsDb(guildid, userid);
}
return settingsMap.get(userid);
}
function dbResolveSettings(guildid, userid) {
const guildDb = dbGetGuildSettings(guildid, userid);
const db = dbGetUserSettings(guildid, userid);
const guildSettingsCopy = guildDb().first();
const userSettings = db().first();
Object.keys(userSettings).forEach(function(key, index) {
if (!isValidSettingName(key)) return;
guildSettingsCopy[key] = userSettings[key];
});
return [ guildSettingsCopy ];
//return ( TAFFY(db().get())().merge( guildDb().first()) ).first();//( TAFFY(guildDb().first())().merge( db().first()) ).first();
}
function dbUpdateSetting(guildid, userid, saveSettingObj) {
const db = dbGetUserSettings(guildid, userid);
db().update(saveSettingObj);
saveSettingsToDisk(guildid, userid, db().first());
}
/**
:regional_indicator_a: | :mountain_railway: :unicorn: :innocent: :flushed: :face_with_monocle: :innocent: :unicorn: :mountain_railway:
:regional_indicator_b: | :no_mouth: :no_mouth: :no_mouth: :no_mouth: :no_mouth: :no_mouth: :no_mouth: :no_mouth:
:regional_indicator_c: |
:regional_indicator_d: |
:regional_indicator_e: |
:woman_in_lotus_position: :man_in_lotus_position:
:regional_indicator_a: | :snowboarder: :horse_racing: :person_golfing: :reminder_ribbon: :rosette: :horse_racing: :person_golfing: :snowboarder:
:regional_indicator_b: | :people_wrestling: :people_wrestling: :people_wrestling: :people_wrestling: :people_wrestling: :people_wrestling: :people_wrestling: :people_wrestling:
:regional_indicator_c: |
:regional_indicator_d: |
:regional_indicator_e: |
:regional_indicator_a: | :bus: :scooter: :airplane: :statue_of_liberty: :moyai: :airplane: :scooter: :bus:
:regional_indicator_b: | :blue_car: :blue_car: :blue_car: :blue_car: :blue_car: :blue_car: :blue_car: :blue_car:
:regional_indicator_c: |
:regional_indicator_d: |
:regional_indicator_e: |
*/
//function toUTF16(codePoint) {
// var TEN_BITS = parseInt('1111111111', 2);
// function u(codeUnit) {
// return '\\u' + codeUnit.toString(16).toUpperCase();
// }
// if (codePoint <= 0xFFFF) {
// return u(codePoint);
// }
// codePoint -= 0x10000;
// // Shift right to get to most significant 10 bits
// var leadingSurrogate = 0xD800 | (codePoint >> 10);
// // Mask to get least significant 10 bits
// var trailingSurrogate = 0xDC00 | (codePoint & TEN_BITS);
// return u(leadingSurrogate) + u(trailingSurrogate);
//}
const DEFAULT_AUTOFLIP = true;
const DEFAULT_AUTOREACT = false;
const DEFAULT_EMOJI_SET = {
'1default1': {
/*********************************
+------------------------+
8 | r n b q k b n r |
7 | p p p p p p p p |
6 | . . . . . . . . |
5 | . . . . . . . . |
4 | . . . . . . . . |
3 | . . . . . . . . |
2 | P P P P P P P P |
1 | R N B Q K B N R |
+--- --- --- --- --- --- --- ---+
a b c d e f g h*/
r: '🚌',
n: '🛴',
b: '✈️',
q: '🗽',
k: '🗿',
p: '🚙',
R: '🚞',
N: '🦄',
B: '😇',
Q: '😳',
K: '🧐',
P: '😶',
white: '⬜',//'⬜',▫️
black: '⬛',
keya: '🇦',//\uFEFF\ud83c\udde6',//' 🇦' \uD83C\uDDE6 //https://graphemica.com/%F0%9F%87%A6 \ud83c\udde6\u000a
keyb: '🇧',//\uFEFF\uD83C\uDDE7',//.//🇧', //UTF-16/UTF-16BE (hex) 0xD83C 0xDDE7 (d83cdde7)
keyc: '🇨', //\uFEFF\uD83C\uDDE8',//' 🇨',
keyd: '🇩', //\uFEFF\uD83C\uDDE9',//' 🇩',
keye: '🇪', //\uFEFF\uD83C\uDDEA',//' 🇪',
keyf: '🇫',//\uFEFF\uD83C\uDDEB',//' 🇫', THIS!!! https://onlineutf8tools.com/convert-utf8-to-utf16
keyg: '🇬',//\uFEFF\uD83C\uDDEC',//' 🇬',
keyh: '🇭',//\uFEFF\uD83C\uDDED',//' 🇭',
key1: '1️⃣',
key2: '2️⃣',
key3: '3️⃣',
key4: '4️⃣', //https://en.wikipedia.org/wiki/Byte_order_mark
key5: '5️⃣',
key6: '6️⃣',
key7: '7️⃣',
key8: '8️⃣',
wallplus: '➕',
wallvert: '▪️',
wallhorz: '▪️'
}
};
const DEFAULT_DECKTYPE = '1default1';
function getGuildSettingDeckType(guildid, userid, setting_name) {
if (!settingsMap.has(guildid)) {
if (hasGuildSettingsOnDisk(guildid)) {
dbMakeGuildSettingsDb(guildid);
} else {
//console.log('dbGetSettingDeckType', 'not has ======');
return DEFAULT_DECKTYPE;
}
}
const first = (dbGetGuildSettings(guildid))().first();
if (typeof first.boardtype === 'undefined' || first.boardtype === null) {
return DEFAULT_DECKTYPE;
}
return first.boardtype;
}
// boardtype
function dbGetSettingDeckType(guildid, userid) {
if (!settingsMap.has(userid)) {
if (hasSettingsOnDisk(guildid, userid)) {
dbMakeSettingsDb(guildid, userid);
} else {
return getGuildSettingDeckType(guildid);//DEFAULT_DECKTYPE;
}
}
const first = (dbGetUserSettings(guildid, userid))().first();
if (typeof first.boardtype === 'undefined' || first.boardtype === null) {
return getGuildSettingDeckType(guildid);//DEFAULT_DECKTYPE;
}
return first.boardtype;
}
function dbGetGuildCustomDeck(guildid, boardName) {
if (!settingsMap.has(guildid)) {
if (hasGuildSettingsOnDisk(guildid)) {
dbMakeGuildSettingsDb(guildid);
} else {
return DEFAULT_EMOJI_SET['1default1'];
}
}
const first = (dbGetGuildSettings(guildid))().first();
try {
if (first.hasOwnProperty(boardName)) {
const result2 = {};
const matches = (first[boardName].toString()).split('\n');
for (const match of matches) {
const kv = match.split(':');
const value = kv.length === 4 /*emoji ref '<:doge:662971757174718467>' has been split, so reconstitute */
? [kv[1], kv[2], kv[3]].join(':')
: kv[1];
result2[kv[0]] = value;
}
return result2;
}
} catch (err) {
console.log('dbGetGuildCustomDeck', err);
}
return DEFAULT_EMOJI_SET['1default1'];
}
function dbGetCustomDeck(guildid, userid, boardName) {
if (!settingsMap.has(userid)) {
if (hasSettingsOnDisk(guildid, userid)) {
dbMakeSettingsDb(guildid, userid);
} else {
return dbGetGuildCustomDeck(guildid, boardName);
}
}
const first = (dbGetUserSettings(guildid, userid))().first();
try {
if (first.hasOwnProperty(boardName)) {
const result2 = {};
const matches = (first[boardName].toString()).split('\n');
for (const match of matches) {
const kv = match.split(':');
const value = kv.length === 4 /*emoji ref '<:doge:662971757174718467>' has been split, so reconstitute */
? [kv[1], kv[2], kv[3]].join(':')
: kv[1];
result2[kv[0]] = value;
}
return result2;
}
} catch (err) {
console.log('dbGetCustomDeck', err);
}
return dbGetGuildCustomDeck(guildid, boardName);
}
//function dbGetSettingBigBoard() {
const DEFAULT_BIGBOARD = 'true';
function dbGetSettingBigBoard(guildid) {
if (!settingsMap.has(guildid)) {
if (hasGuildSettingsOnDisk(guildid)) {
dbMakeGuildSettingsDb(guildid);
} else {
return DEFAULT_BIGBOARD;
}
}
const first = (dbGetGuildSettings(guildid))().first();
if (typeof first.bigboard === 'undefined' || first.bigboard === null) {
return DEFAULT_BIGBOARD;
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.bigboard.toString().toLowerCase());
}
function dbGetGuildSettingBigBoard(guildid) {
if (!settingsMap.has(guildid)) {
if (hasGuildSettingsOnDisk(guildid)) {
dbMakeGuildSettingsDb(guildid);
} else {
return DEFAULT_BIGBOARD;
}
}
const first = (dbGetGuildSettings(guildid))().first();
if (typeof first.bigboard === 'undefined' || first.bigboard === null) {
return DEFAULT_BIGBOARD;
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.bigboard.toString().toLowerCase());
}
function dbGetSettingBigBoard(guildid, userid) {
if (!settingsMap.has(userid)) {
if (hasSettingsOnDisk(guildid, userid)) {
dbMakeSettingsDb(guildid, userid);
} else {
return dbGetGuildSettingBigBoard(guildid);
}
}
const first = (dbGetUserSettings(guildid, userid))().first();
if (typeof first.bigboard === 'undefined' || first.bigboard === null) {
return dbGetGuildSettingBigBoard(guildid);
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.bigboard.toString().toLowerCase());
}
//----------------------------------------------
function dbGetGuildSettingAutoFlip(guildid) {
if (!settingsMap.has(guildid)) {
if (hasGuildSettingsOnDisk(guildid)) {
dbMakeGuildSettingsDb(guildid);
} else {
return DEFAULT_AUTOFLIP;
}
}
const first = (dbGetGuildSettings(guildid))().first();
if (typeof first.autoflip === 'undefined' || first.autoflip === null) {
return DEFAULT_AUTOFLIP;
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.autoflip.toString().toLowerCase());
}
function dbGetGuildSettingAutoReact(guildid) {
if (!settingsMap.has(guildid)) {
if (hasGuildSettingsOnDisk(guildid)) {
dbMakeGuildSettingsDb(guildid);
} else {
return DEFAULT_AUTOREACT;
}
}
const first = (dbGetGuildSettings(guildid))().first();
if (typeof first.autoreact === 'undefined' || first.autoreact === null) {
return DEFAULT_AUTOREACT;
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.autoreact.toString().toLowerCase());
}
function dbGetSettingAutoFlip(guildid, userid) {
if (!settingsMap.has(userid)) {
if (hasSettingsOnDisk(guildid, userid)) {
dbMakeSettingsDb(guildid, userid);
} else {
return dbGetGuildSettingAutoFlip(guildid);
}
}
const first = (dbGetUserSettings(guildid, userid))().first();
if (typeof first.autoflip === 'undefined' || first.autoflip === null) {
return dbGetGuildSettingAutoFlip(guildid);
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.autoflip.toString().toLowerCase());
}
function dbGetSettingAutoReact(guildid, userid) {
if (!settingsMap.has(userid)) {
if (hasSettingsOnDisk(guildid, userid)) {
dbMakeSettingsDb(guildid, userid);
} else {
return dbGetGuildSettingAutoReact(guildid);
}
}
const first = (dbGetUserSettings(guildid, userid))().first();
if (typeof first.autoreact === 'undefined' || first.autoreact === null) {
return dbGetGuildSettingAutoReact(guildid);
}
if (first.length > 5) return false; //quick check before a JSON.parse
return JSON.parse(first.autoreact.toString().toLowerCase());
}
var gameCount = 0;
function dbIncrementGameCount() {
gameCount++;
}
function dbDecrementGameCount() {
gameCount--;
}
function dbGetGameCount() {
return gameCount;
}
function pretty(data) {
return JSON.parse(data().stringify());
}
function runTests() {
dbAddGameAuthor(0, 1, 20, { stuff: 'stuff1' });
dbUpdateGameTarget(0, 1, 20, 300, { targetstuff: 'targetstuff1' });
console.log('\n', 'first', pretty(getGame(0)));
dbAddGameAuthor(0, 4, 50, { stuff: 'stuffA' });
dbUpdateGameTarget(0, 4, 50, 600, { targetstuff: 'targetstuff2' });
console.log('\n', 'second', pretty(getGame(0)));
dbAddGameAuthor(0, 7, 80, { stuff: 'stuff()' });
console.log('\n', 'third', pretty(getGame(0)));
const gamekeys = dbGetGameKeysForUser(0, 1, 20);
console.log('\n', 'gamekeys 1, 20', gamekeys);
console.log('\n', 'games for keys', gamekeys.join(" and "), JSON.parse(getGame(0)({ key: gamekeys }).stringify()));
dbUpdateForUser(4, 50, { stuff: 'NOT STUFFA' });
console.log('\n', 'gamekeys 4, 50', pretty(getGame(0)));
console.log('\n', '--------------------------- >-8 ------------------------------', '\n');
console.log(dbGetGuildGame(0)(gamekeys));
//process.exit(0);
//return 0;
}
module.exports = {
dbResolveCode,
dbMakeDb,
dbMakeKey,
dbAddGameAuthor,
dbUpdateGameTarget,
dbUpdateForGame,
dbUpdateForUser,
dbRemoveGame,
dbGetGameFromTarget,
dbGetGameKeysForUser,
dbGetGame,
dbGetForUserKey,
dbPresentGames,
dbGetAll,
dbIsAny,
timerAdd,
timerGet,
timerClear,
timerGetAll,
dbResolveSettings,
dbUpdateSetting,
dbGetSettingAutoFlip,
dbGetSettingAutoReact,
dbGetSettingDeckType,
dbGetSettingBigBoard,
dbGetCustomDeck,
dbIncrementGameCount,
dbDecrementGameCount,
dbGetGameCount,
runTests
};
//runTests();