@opfr/services 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +548 -498
- package/dist/index.umd.js +1 -1
- package/dist/services/AbstractCachedService.d.ts +3 -1
- package/dist/services/AbstractCachedService.d.ts.map +1 -1
- package/dist/services/recipe/definition/schema.d.ts.map +1 -1
- package/dist/services/recipe/helper.d.ts +2 -4
- package/dist/services/recipe/helper.d.ts.map +1 -1
- package/dist/services/recipe/process/findOne.d.ts +1 -1
- package/dist/services/recipe/process/findOne.d.ts.map +1 -1
- package/dist/services/recipe/types.d.ts +7 -10
- package/dist/services/recipe/types.d.ts.map +1 -1
- package/dist/services/story/definition/schema.d.ts.map +1 -1
- package/dist/services/story/helper.d.ts +2 -0
- package/dist/services/story/helper.d.ts.map +1 -1
- package/dist/services/user-inventory/helper.d.ts +5 -8
- package/dist/services/user-inventory/helper.d.ts.map +1 -1
- package/dist/services/user-story/helper.d.ts +2 -6
- package/dist/services/user-story/helper.d.ts.map +1 -1
- package/dist/services/user-story/types.d.ts +17 -1
- package/dist/services/user-story/types.d.ts.map +1 -1
- package/dist/services/user-story/utils.d.ts +1 -1
- package/dist/services/user-story/utils.d.ts.map +1 -1
- package/package.json +3 -4
- package/dist/services/recipe/data.d.ts +0 -3
- package/dist/services/recipe/data.d.ts.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { Schema as
|
|
2
|
-
import { QuestStatus as
|
|
1
|
+
import { Schema as o, models as d, model as l, connect as Qe, Types as Ye } from "mongoose";
|
|
2
|
+
import { QuestStatus as k, DEFAULT_FACTION as Ge, EFFECT_KEYS as We, EQUIPMENT_SLOT as Ie, CHARACTERISTICS as Ve, getComputedCharacteristicValue as Xe, getCurrentLevel as Je, HP_PER_VITALITY as Ze, DEFAULT_MAX_HP as et, transformToDBBuff as tt, RANK_IDS_WITHOUT_BASIC as ge, STORY_MESSAGE_ARGS as nt, STORY_ACTION_TYPES as rt, STORY_STEP_TYPES as at, STORY_SPEAKER_TYPES as st, chapterOne as de, speakers as it } from "@opfr/definitions";
|
|
3
3
|
import ut from "node-cache";
|
|
4
4
|
import * as Ue from "events";
|
|
5
|
-
import { filterNullAndUndefined as
|
|
6
|
-
const
|
|
7
|
-
class
|
|
5
|
+
import { filterNullAndUndefined as Q, recordToArray as F, arrayToRecord as Te, mergeObjects as Y, seededRandom as ot, sortBy as ye, randomBetween as Ee, hasExpire as le, isString as ct, capitalizeAllWords as dt, pickNthByOdds as Se, pickFrom as lt, sameDay as ve, yesterday as G, exclude as z } from "@opfr/utils-lang";
|
|
6
|
+
const W = "___ALL_ENTITIES___";
|
|
7
|
+
class m {
|
|
8
8
|
cache;
|
|
9
|
-
constructor(e) {
|
|
9
|
+
constructor(e, t) {
|
|
10
10
|
this.cache = new ut({
|
|
11
11
|
stdTTL: e,
|
|
12
12
|
checkperiod: e * 0.2,
|
|
13
|
-
useClones: !1
|
|
13
|
+
useClones: !1,
|
|
14
|
+
maxKeys: t?.maxKeys ?? -1
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
async get(e, t) {
|
|
@@ -24,24 +25,24 @@ class y {
|
|
|
24
25
|
const a = await this.updateInDb(e, t, r);
|
|
25
26
|
if (a) {
|
|
26
27
|
const s = this.getKey(a);
|
|
27
|
-
this.cache.del(
|
|
28
|
+
this.cache.del(W), this.cache.set(this.normalizeKey(s), a);
|
|
28
29
|
}
|
|
29
30
|
return a;
|
|
30
31
|
}
|
|
31
32
|
invalidate(e) {
|
|
32
|
-
this.cache.del(
|
|
33
|
+
this.cache.del(W), e && this.cache.del(this.normalizeKey(e));
|
|
33
34
|
}
|
|
34
35
|
clearAll() {
|
|
35
36
|
this.cache.flushAll();
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
class
|
|
39
|
+
class w extends m {
|
|
39
40
|
async getAll() {
|
|
40
|
-
const e = this.cache.get(
|
|
41
|
+
const e = this.cache.get(W);
|
|
41
42
|
if (e)
|
|
42
43
|
return e;
|
|
43
44
|
const t = await this.fetchManyFromDb({}, {});
|
|
44
|
-
return this.cache.set(
|
|
45
|
+
return this.cache.set(W, t), t.forEach((r) => {
|
|
45
46
|
this.cache.set(this.normalizeKey(this.getKey(r)), r);
|
|
46
47
|
}), t;
|
|
47
48
|
}
|
|
@@ -52,14 +53,14 @@ class f extends y {
|
|
|
52
53
|
}), r;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
56
|
+
const Oe = new Ue.EventEmitter(), b = (n, e, t) => {
|
|
57
|
+
Oe.emit(n, e, t);
|
|
57
58
|
}, La = (n) => {
|
|
58
59
|
for (const [e, t] of Object.entries(n))
|
|
59
|
-
|
|
60
|
+
Oe.on(e, (r, a) => {
|
|
60
61
|
t(r, a);
|
|
61
62
|
});
|
|
62
|
-
},
|
|
63
|
+
}, $ = {
|
|
63
64
|
USER: "middleware/quest/USER",
|
|
64
65
|
USER_INVENTORY: "middleware/quest/USER_INVENTORY",
|
|
65
66
|
USER_META: "middleware/quest/USER_META",
|
|
@@ -71,10 +72,10 @@ const De = new Ue.EventEmitter(), S = (n, e, t) => {
|
|
|
71
72
|
USER_STATS_FLAGS: "middleware/quest/USER_STATS_FLAGS",
|
|
72
73
|
USER_STATS_FREQUENCY: "middleware/quest/USER_STATS_FREQUENCY",
|
|
73
74
|
USER_STATS_INVENTORY: "middleware/quest/USER_STATS_INVENTORY"
|
|
74
|
-
},
|
|
75
|
+
}, De = new o(
|
|
75
76
|
{
|
|
76
77
|
user: {
|
|
77
|
-
type:
|
|
78
|
+
type: o.Types.ObjectId,
|
|
78
79
|
required: !0,
|
|
79
80
|
ref: "User",
|
|
80
81
|
index: !0
|
|
@@ -84,22 +85,22 @@ const De = new Ue.EventEmitter(), S = (n, e, t) => {
|
|
|
84
85
|
required: !0,
|
|
85
86
|
index: !0
|
|
86
87
|
},
|
|
87
|
-
status: { type: String, default:
|
|
88
|
+
status: { type: String, default: k.IN_PROGRESS, index: 1 },
|
|
88
89
|
lastCompletionDate: Date,
|
|
89
90
|
streak: Number
|
|
90
91
|
},
|
|
91
92
|
{ minimize: !1 }
|
|
92
93
|
);
|
|
93
|
-
|
|
94
|
-
n &&
|
|
95
|
-
|
|
94
|
+
De.post("findOneAndUpdate", function(n) {
|
|
95
|
+
n && b(
|
|
96
|
+
$.USER_QUEST,
|
|
96
97
|
n.user._id,
|
|
97
98
|
n
|
|
98
99
|
);
|
|
99
100
|
});
|
|
100
|
-
const C = d?.UserQuest || l("UserQuest",
|
|
101
|
+
const C = d?.UserQuest || l("UserQuest", De), pt = new o({
|
|
101
102
|
user: {
|
|
102
|
-
type:
|
|
103
|
+
type: o.Types.ObjectId,
|
|
103
104
|
required: !0,
|
|
104
105
|
unique: !0,
|
|
105
106
|
ref: "User"
|
|
@@ -109,9 +110,9 @@ const C = d?.UserQuest || l("UserQuest", ve), pt = new c({
|
|
|
109
110
|
of: Date,
|
|
110
111
|
default: /* @__PURE__ */ new Map()
|
|
111
112
|
}
|
|
112
|
-
}),
|
|
113
|
+
}), V = d?.UserCooldown || l("UserCooldown", pt), yt = new o({
|
|
113
114
|
user: {
|
|
114
|
-
type:
|
|
115
|
+
type: o.Types.ObjectId,
|
|
115
116
|
required: !0,
|
|
116
117
|
unique: !0,
|
|
117
118
|
ref: "User"
|
|
@@ -125,17 +126,17 @@ const C = d?.UserQuest || l("UserQuest", ve), pt = new c({
|
|
|
125
126
|
},
|
|
126
127
|
previousCompletedQuest: { type: [String], default: [] },
|
|
127
128
|
previousMessageSent: { type: Number, default: 0 }
|
|
128
|
-
}),
|
|
129
|
+
}), X = d?.UserDailyReport || l("UserDailyReport", yt), ft = new o({
|
|
129
130
|
user: {
|
|
130
|
-
type:
|
|
131
|
+
type: o.Types.ObjectId,
|
|
131
132
|
required: !0,
|
|
132
133
|
unique: !0,
|
|
133
134
|
ref: "User"
|
|
134
135
|
},
|
|
135
136
|
encyclopedia: { type: [String], default: [] }
|
|
136
|
-
}),
|
|
137
|
+
}), J = d?.UserEncyclopedia || l("UserEncyclopedia", ft), mt = new o({
|
|
137
138
|
user: {
|
|
138
|
-
type:
|
|
139
|
+
type: o.Types.ObjectId,
|
|
139
140
|
required: !0,
|
|
140
141
|
unique: !0,
|
|
141
142
|
ref: "User",
|
|
@@ -150,10 +151,10 @@ const C = d?.UserQuest || l("UserQuest", ve), pt = new c({
|
|
|
150
151
|
},
|
|
151
152
|
default: null
|
|
152
153
|
}
|
|
153
|
-
}),
|
|
154
|
+
}), Z = d?.UserGames || l("UserGames", mt), xe = new o(
|
|
154
155
|
{
|
|
155
156
|
user: {
|
|
156
|
-
type:
|
|
157
|
+
type: o.Types.ObjectId,
|
|
157
158
|
required: !0,
|
|
158
159
|
unique: !0,
|
|
159
160
|
ref: "User"
|
|
@@ -172,23 +173,23 @@ const C = d?.UserQuest || l("UserQuest", ve), pt = new c({
|
|
|
172
173
|
},
|
|
173
174
|
{ minimize: !1 }
|
|
174
175
|
);
|
|
175
|
-
|
|
176
|
-
n &&
|
|
177
|
-
|
|
176
|
+
xe.post("findOneAndUpdate", function(n) {
|
|
177
|
+
n && b(
|
|
178
|
+
$.USER_INVENTORY,
|
|
178
179
|
n.user._id,
|
|
179
180
|
n
|
|
180
181
|
);
|
|
181
182
|
});
|
|
182
|
-
const
|
|
183
|
+
const ee = d?.UserInventory || l("UserInventory", xe), ht = new Ue.EventEmitter(), gt = (n, e) => {
|
|
183
184
|
ht.emit(n, e);
|
|
184
|
-
},
|
|
185
|
+
}, x = {
|
|
185
186
|
multiplier: { type: Number, default: 0 },
|
|
186
187
|
origin: String,
|
|
187
188
|
expireAt: { type: Date, default: null },
|
|
188
189
|
startAt: { type: Date, default: null }
|
|
189
|
-
},
|
|
190
|
+
}, Me = new o({
|
|
190
191
|
user: {
|
|
191
|
-
type:
|
|
192
|
+
type: o.Types.ObjectId,
|
|
192
193
|
required: !0,
|
|
193
194
|
unique: !0,
|
|
194
195
|
ref: "User"
|
|
@@ -208,33 +209,33 @@ const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter()
|
|
|
208
209
|
buffs: {
|
|
209
210
|
cooldown: {
|
|
210
211
|
casino: {
|
|
211
|
-
type: [
|
|
212
|
+
type: [x],
|
|
212
213
|
default: []
|
|
213
214
|
},
|
|
214
215
|
work: {
|
|
215
|
-
type: [
|
|
216
|
+
type: [x],
|
|
216
217
|
default: []
|
|
217
218
|
}
|
|
218
219
|
},
|
|
219
220
|
berry: {
|
|
220
221
|
work: {
|
|
221
|
-
type: [
|
|
222
|
+
type: [x],
|
|
222
223
|
default: []
|
|
223
224
|
},
|
|
224
225
|
global: {
|
|
225
|
-
type: [
|
|
226
|
+
type: [x],
|
|
226
227
|
default: []
|
|
227
228
|
}
|
|
228
229
|
},
|
|
229
230
|
drop: {
|
|
230
231
|
work: {
|
|
231
|
-
type: [
|
|
232
|
+
type: [x],
|
|
232
233
|
default: []
|
|
233
234
|
}
|
|
234
235
|
},
|
|
235
236
|
xp: {
|
|
236
237
|
global: {
|
|
237
|
-
type: [
|
|
238
|
+
type: [x],
|
|
238
239
|
default: []
|
|
239
240
|
}
|
|
240
241
|
}
|
|
@@ -260,16 +261,16 @@ const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter()
|
|
|
260
261
|
wisdom: { type: Number, default: 0 }
|
|
261
262
|
}
|
|
262
263
|
});
|
|
263
|
-
|
|
264
|
-
n && (
|
|
265
|
-
|
|
264
|
+
Me.post("findOneAndUpdate", async function(n) {
|
|
265
|
+
n && (b(
|
|
266
|
+
$.USER_META,
|
|
266
267
|
n.user._id,
|
|
267
268
|
n
|
|
268
269
|
), n.hp <= 0 && gt("death", n.user._id));
|
|
269
270
|
});
|
|
270
|
-
const
|
|
271
|
+
const D = d?.UserMeta || l("UserMeta", Me), Ae = new o({
|
|
271
272
|
user: {
|
|
272
|
-
type:
|
|
273
|
+
type: o.Types.ObjectId,
|
|
273
274
|
required: !0,
|
|
274
275
|
unique: !0,
|
|
275
276
|
ref: "User"
|
|
@@ -284,16 +285,16 @@ const v = d?.UserMeta || l("UserMeta", xe), qe = new c({
|
|
|
284
285
|
unlockedBags: { type: [String], default: ["default"] },
|
|
285
286
|
selectedBag: { type: String, default: "default" }
|
|
286
287
|
});
|
|
287
|
-
|
|
288
|
-
n &&
|
|
289
|
-
|
|
288
|
+
Ae.post("findOneAndUpdate", function(n) {
|
|
289
|
+
n && b(
|
|
290
|
+
$.USER_ORNAMENT,
|
|
290
291
|
n.user._id,
|
|
291
292
|
n
|
|
292
293
|
);
|
|
293
294
|
});
|
|
294
|
-
const
|
|
295
|
+
const te = d?.UserOrnament || l("UserOrnament", Ae), St = new o({
|
|
295
296
|
user: {
|
|
296
|
-
type:
|
|
297
|
+
type: o.Types.ObjectId,
|
|
297
298
|
required: !0,
|
|
298
299
|
unique: !0,
|
|
299
300
|
ref: "User"
|
|
@@ -310,9 +311,9 @@ const ee = d?.UserOrnament || l("UserOrnament", qe), St = new c({
|
|
|
310
311
|
default: /* @__PURE__ */ new Map()
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
|
-
}),
|
|
314
|
+
}), K = d?.UserSettings || l("UserSettings", St), ke = new o({
|
|
314
315
|
user: {
|
|
315
|
-
type:
|
|
316
|
+
type: o.Types.ObjectId,
|
|
316
317
|
required: !0,
|
|
317
318
|
unique: !0,
|
|
318
319
|
ref: "User"
|
|
@@ -345,16 +346,16 @@ const ee = d?.UserOrnament || l("UserOrnament", qe), St = new c({
|
|
|
345
346
|
guessInOneTryCount: { type: Number, default: 0 }
|
|
346
347
|
}
|
|
347
348
|
});
|
|
348
|
-
|
|
349
|
-
n &&
|
|
350
|
-
|
|
349
|
+
ke.post("findOneAndUpdate", function(n) {
|
|
350
|
+
n && b(
|
|
351
|
+
$.USER_STATS_CASINO,
|
|
351
352
|
n.user._id,
|
|
352
353
|
n
|
|
353
354
|
);
|
|
354
355
|
});
|
|
355
|
-
const
|
|
356
|
+
const q = d?.UserStatsCasino || l("UserStatsCasino", ke), qe = new o({
|
|
356
357
|
user: {
|
|
357
|
-
type:
|
|
358
|
+
type: o.Types.ObjectId,
|
|
358
359
|
required: !0,
|
|
359
360
|
unique: !0,
|
|
360
361
|
ref: "User"
|
|
@@ -362,16 +363,16 @@ const A = d?.UserStatsCasino || l("UserStatsCasino", Ae), ke = new c({
|
|
|
362
363
|
workCount: { type: Number, default: 0 },
|
|
363
364
|
totalSpentInShop: { type: Number, default: 0 }
|
|
364
365
|
});
|
|
365
|
-
|
|
366
|
-
n &&
|
|
367
|
-
|
|
366
|
+
qe.post("findOneAndUpdate", function(n) {
|
|
367
|
+
n && b(
|
|
368
|
+
$.USER_STATS_ECONOMY,
|
|
368
369
|
n.user._id,
|
|
369
370
|
n
|
|
370
371
|
);
|
|
371
372
|
});
|
|
372
|
-
const
|
|
373
|
+
const ne = d?.UserStatsEconomy || l("UserStatsEconomy", qe), Re = new o({
|
|
373
374
|
user: {
|
|
374
|
-
type:
|
|
375
|
+
type: o.Types.ObjectId,
|
|
375
376
|
required: !0,
|
|
376
377
|
unique: !0,
|
|
377
378
|
ref: "User"
|
|
@@ -382,18 +383,18 @@ const te = d?.UserStatsEconomy || l("UserStatsEconomy", ke), Re = new c({
|
|
|
382
383
|
writeDifferentChatIds: { type: [String], default: [] }
|
|
383
384
|
});
|
|
384
385
|
Re.post("findOneAndUpdate", function(n) {
|
|
385
|
-
n &&
|
|
386
|
-
|
|
386
|
+
n && b(
|
|
387
|
+
$.USER_STATS_ENGAGEMENT,
|
|
387
388
|
n.user._id,
|
|
388
389
|
n
|
|
389
390
|
);
|
|
390
391
|
});
|
|
391
|
-
const
|
|
392
|
+
const re = d?.UserStatsEngagement || l(
|
|
392
393
|
"UserStatsEngagement",
|
|
393
394
|
Re
|
|
394
|
-
), Ce = new
|
|
395
|
+
), Ce = new o({
|
|
395
396
|
user: {
|
|
396
|
-
type:
|
|
397
|
+
type: o.Types.ObjectId,
|
|
397
398
|
required: !0,
|
|
398
399
|
unique: !0,
|
|
399
400
|
ref: "User"
|
|
@@ -411,15 +412,15 @@ const ne = d?.UserStatsEngagement || l(
|
|
|
411
412
|
}
|
|
412
413
|
});
|
|
413
414
|
Ce.post("findOneAndUpdate", function(n) {
|
|
414
|
-
n &&
|
|
415
|
-
|
|
415
|
+
n && b(
|
|
416
|
+
$.USER_STATS_FLAGS,
|
|
416
417
|
n.user._id,
|
|
417
418
|
n
|
|
418
419
|
);
|
|
419
420
|
});
|
|
420
|
-
const
|
|
421
|
+
const ae = d?.UserStatsFlags || l("UserStatsFlags", Ce), Be = new o({
|
|
421
422
|
user: {
|
|
422
|
-
type:
|
|
423
|
+
type: o.Types.ObjectId,
|
|
423
424
|
required: !0,
|
|
424
425
|
unique: !0,
|
|
425
426
|
ref: "User"
|
|
@@ -429,19 +430,19 @@ const re = d?.UserStatsFlags || l("UserStatsFlags", Ce), _e = new c({
|
|
|
429
430
|
lastTimeRead: { type: Date, default: /* @__PURE__ */ new Date(), index: !0 }
|
|
430
431
|
}
|
|
431
432
|
});
|
|
432
|
-
|
|
433
|
-
n &&
|
|
434
|
-
|
|
433
|
+
Be.post("findOneAndUpdate", function(n) {
|
|
434
|
+
n && b(
|
|
435
|
+
$.USER_STATS_FREQUENCY,
|
|
435
436
|
n.user._id,
|
|
436
437
|
n
|
|
437
438
|
);
|
|
438
439
|
});
|
|
439
|
-
const
|
|
440
|
+
const O = d?.UserStatsFrequency || l(
|
|
440
441
|
"UserStatsFrequency",
|
|
441
|
-
|
|
442
|
-
),
|
|
442
|
+
Be
|
|
443
|
+
), _e = new o({
|
|
443
444
|
user: {
|
|
444
|
-
type:
|
|
445
|
+
type: o.Types.ObjectId,
|
|
445
446
|
required: !0,
|
|
446
447
|
unique: !0,
|
|
447
448
|
ref: "User"
|
|
@@ -466,17 +467,17 @@ const D = d?.UserStatsFrequency || l(
|
|
|
466
467
|
totalCrafted: { type: Number, default: 0 }
|
|
467
468
|
}
|
|
468
469
|
});
|
|
469
|
-
|
|
470
|
-
n &&
|
|
471
|
-
|
|
470
|
+
_e.post("findOneAndUpdate", function(n) {
|
|
471
|
+
n && b(
|
|
472
|
+
$.USER_STATS_INVENTORY,
|
|
472
473
|
n.user._id,
|
|
473
474
|
n
|
|
474
475
|
);
|
|
475
476
|
});
|
|
476
|
-
const
|
|
477
|
+
const R = d?.UserStatsInventory || l(
|
|
477
478
|
"UserStatsInventory",
|
|
478
|
-
|
|
479
|
-
),
|
|
479
|
+
_e
|
|
480
|
+
), fe = new o({
|
|
480
481
|
discordId: { type: String, required: !0, unique: !0 },
|
|
481
482
|
scam: { type: Boolean, default: !1 },
|
|
482
483
|
birthday: { type: Date, default: null, index: 1 },
|
|
@@ -484,21 +485,21 @@ const k = d?.UserStatsInventory || l(
|
|
|
484
485
|
canChangeFaction: { type: Boolean, default: !1 },
|
|
485
486
|
canChooseFaction: { type: Boolean, default: !1 }
|
|
486
487
|
});
|
|
487
|
-
|
|
488
|
-
n &&
|
|
488
|
+
fe.post("findOneAndUpdate", function(n) {
|
|
489
|
+
n && b($.USER, n._id, n);
|
|
489
490
|
});
|
|
490
|
-
|
|
491
|
+
fe.post("deleteOne", async function() {
|
|
491
492
|
const n = this.getQuery()._id;
|
|
492
|
-
await
|
|
493
|
+
await V.deleteOne({ user: n }), await X.deleteOne({ user: n }), await J.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await D.deleteOne({ user: n }), await te.deleteOne({ user: n }), await C.deleteMany({ user: n }), await K.deleteOne({ user: n }), await q.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await re.deleteOne({ user: n }), await ae.deleteOne({ user: n }), await O.deleteOne({ user: n }), await R.deleteOne({ user: n });
|
|
493
494
|
});
|
|
494
|
-
const
|
|
495
|
-
class wt extends
|
|
495
|
+
const I = d?.User || l("User", fe);
|
|
496
|
+
class wt extends w {
|
|
496
497
|
getByObjectId(e) {
|
|
497
498
|
return this.update({ _id: e }, {});
|
|
498
499
|
}
|
|
499
500
|
getNextBirthdays() {
|
|
500
501
|
const e = /* @__PURE__ */ new Date(), t = e.getFullYear();
|
|
501
|
-
return
|
|
502
|
+
return I.aggregate([
|
|
502
503
|
{
|
|
503
504
|
$match: {
|
|
504
505
|
birthday: { $ne: null }
|
|
@@ -549,7 +550,7 @@ class wt extends f {
|
|
|
549
550
|
]);
|
|
550
551
|
}
|
|
551
552
|
getFactionRanking(e) {
|
|
552
|
-
return
|
|
553
|
+
return I.aggregate([
|
|
553
554
|
{ $match: { faction: e } },
|
|
554
555
|
{
|
|
555
556
|
$lookup: {
|
|
@@ -572,7 +573,7 @@ class wt extends f {
|
|
|
572
573
|
]);
|
|
573
574
|
}
|
|
574
575
|
getGlobalRanking() {
|
|
575
|
-
return
|
|
576
|
+
return I.aggregate([
|
|
576
577
|
{
|
|
577
578
|
$lookup: {
|
|
578
579
|
from: "usermetas",
|
|
@@ -594,7 +595,7 @@ class wt extends f {
|
|
|
594
595
|
]);
|
|
595
596
|
}
|
|
596
597
|
getBerryRanking() {
|
|
597
|
-
return
|
|
598
|
+
return I.aggregate([
|
|
598
599
|
{
|
|
599
600
|
$lookup: {
|
|
600
601
|
from: "usermetas",
|
|
@@ -619,7 +620,7 @@ class wt extends f {
|
|
|
619
620
|
return C.aggregate([
|
|
620
621
|
{
|
|
621
622
|
$match: {
|
|
622
|
-
status:
|
|
623
|
+
status: k.COMPLETED
|
|
623
624
|
}
|
|
624
625
|
},
|
|
625
626
|
{
|
|
@@ -663,7 +664,7 @@ class wt extends f {
|
|
|
663
664
|
}
|
|
664
665
|
getTodayAllBirthday() {
|
|
665
666
|
const e = /* @__PURE__ */ new Date();
|
|
666
|
-
return
|
|
667
|
+
return I.aggregate([
|
|
667
668
|
{ $match: { birthday: { $ne: null } } },
|
|
668
669
|
{
|
|
669
670
|
$addFields: {
|
|
@@ -710,14 +711,14 @@ class wt extends f {
|
|
|
710
711
|
);
|
|
711
712
|
}
|
|
712
713
|
}
|
|
713
|
-
const bt = (n, e) =>
|
|
714
|
+
const bt = (n, e) => I.find(n, {}, e).lean(), y = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), $t = (n) => I.create({
|
|
714
715
|
discordId: n
|
|
715
716
|
});
|
|
716
717
|
async function It(n, { upsert: e = !0, ...t }) {
|
|
717
|
-
const r = await
|
|
718
|
-
return !r && e ?
|
|
718
|
+
const r = await I.findOne({ discordId: n }, {}, t).lean();
|
|
719
|
+
return !r && e ? y(await $t(n)) : r;
|
|
719
720
|
}
|
|
720
|
-
const Ut = (n, e) =>
|
|
721
|
+
const Ut = (n, e) => I.findOneAndUpdate(n, e, {
|
|
721
722
|
upsert: !0,
|
|
722
723
|
returnDocument: "after"
|
|
723
724
|
}).lean();
|
|
@@ -741,10 +742,10 @@ class Tt extends wt {
|
|
|
741
742
|
return Ut(e, t);
|
|
742
743
|
}
|
|
743
744
|
}
|
|
744
|
-
const Et = new Tt(),
|
|
745
|
+
const Et = new Tt(), vt = new o(
|
|
745
746
|
{
|
|
746
747
|
user: {
|
|
747
|
-
type:
|
|
748
|
+
type: o.Types.ObjectId,
|
|
748
749
|
ref: "User",
|
|
749
750
|
required: !0,
|
|
750
751
|
index: !0
|
|
@@ -753,12 +754,12 @@ const Et = new Tt(), Ot = new c(
|
|
|
753
754
|
type: { type: String, required: !0 }
|
|
754
755
|
},
|
|
755
756
|
{ minimize: !1 }
|
|
756
|
-
),
|
|
757
|
-
await
|
|
758
|
-
},
|
|
759
|
-
await
|
|
757
|
+
), H = d?.Reminder || l("Reminder", vt), Ot = async (n) => {
|
|
758
|
+
await H.deleteMany(n);
|
|
759
|
+
}, Dt = async (n, e) => {
|
|
760
|
+
await H.deleteOne({ user: n, type: e });
|
|
760
761
|
};
|
|
761
|
-
class
|
|
762
|
+
class xt extends w {
|
|
762
763
|
getAllPassedReminder() {
|
|
763
764
|
return this.getMany({ date: { $lte: /* @__PURE__ */ new Date() } });
|
|
764
765
|
}
|
|
@@ -777,29 +778,29 @@ class Mt extends f {
|
|
|
777
778
|
]);
|
|
778
779
|
}
|
|
779
780
|
async removeReminder(e, t) {
|
|
780
|
-
await
|
|
781
|
+
await Dt(e, t), this.invalidate({ user: e, type: t });
|
|
781
782
|
}
|
|
782
783
|
async deleteSelectedReminders(e) {
|
|
783
784
|
const t = e.map((r) => r._id);
|
|
784
|
-
await
|
|
785
|
+
await Ot({ _id: { $in: t } }), e.forEach((r) => {
|
|
785
786
|
this.invalidate({ user: r.user, type: r.type });
|
|
786
787
|
});
|
|
787
788
|
}
|
|
788
789
|
}
|
|
789
|
-
function
|
|
790
|
-
return
|
|
790
|
+
function Mt(n, e) {
|
|
791
|
+
return H.find(n, {}, e).lean();
|
|
791
792
|
}
|
|
792
|
-
async function
|
|
793
|
-
const e = await
|
|
793
|
+
async function At(n) {
|
|
794
|
+
const e = await H.findOne(n).lean();
|
|
794
795
|
return e || null;
|
|
795
796
|
}
|
|
796
|
-
async function
|
|
797
|
-
return
|
|
797
|
+
async function kt(n, e, t) {
|
|
798
|
+
return H.findOneAndUpdate(n, e, {
|
|
798
799
|
...t,
|
|
799
800
|
returnDocument: "after"
|
|
800
801
|
}).lean();
|
|
801
802
|
}
|
|
802
|
-
class
|
|
803
|
+
class qt extends xt {
|
|
803
804
|
constructor() {
|
|
804
805
|
super(300);
|
|
805
806
|
}
|
|
@@ -813,44 +814,44 @@ class kt extends Mt {
|
|
|
813
814
|
return `${e.toString()}/${t}`;
|
|
814
815
|
}
|
|
815
816
|
fetchFromDb(e) {
|
|
816
|
-
return
|
|
817
|
+
return At(e);
|
|
817
818
|
}
|
|
818
819
|
fetchManyFromDb(e, t) {
|
|
819
|
-
return
|
|
820
|
+
return Mt(e, t);
|
|
820
821
|
}
|
|
821
822
|
updateInDb(e, t, r = { upsert: !1 }) {
|
|
822
|
-
return
|
|
823
|
+
return kt(e, t, r);
|
|
823
824
|
}
|
|
824
825
|
}
|
|
825
|
-
const Rt = new
|
|
826
|
+
const Rt = new qt(), Ct = new o(
|
|
826
827
|
{
|
|
827
828
|
panoplyId: { unique: !0, index: 1, required: !0, type: String },
|
|
828
829
|
name: { required: !0, type: String },
|
|
829
830
|
equipments: {
|
|
830
831
|
required: !0,
|
|
831
|
-
type: [{ type:
|
|
832
|
+
type: [{ type: o.Types.ObjectId, ref: "Entities" }]
|
|
832
833
|
},
|
|
833
834
|
fullBonusStr: { type: String },
|
|
834
835
|
halfBonusStr: { type: String },
|
|
835
|
-
fullBonus:
|
|
836
|
-
halfBonus:
|
|
836
|
+
fullBonus: o.Types.Mixed,
|
|
837
|
+
halfBonus: o.Types.Mixed
|
|
837
838
|
},
|
|
838
839
|
{ minimize: !1 }
|
|
839
|
-
),
|
|
840
|
+
), P = d?.Panoplies || l("Panoplies", Ct), Bt = (n, e) => P.find(n, {}, e).lean(), _t = async (n, e) => P.find(n, {}, e).populate("equipments");
|
|
840
841
|
async function Ft(n) {
|
|
841
|
-
const e = await
|
|
842
|
+
const e = await P.findOne({ panoplyId: n }).lean();
|
|
842
843
|
return e || null;
|
|
843
844
|
}
|
|
844
|
-
const Nt = async (n) =>
|
|
845
|
-
class Kt extends
|
|
845
|
+
const Nt = async (n) => P.findOne(n).populate("equipments");
|
|
846
|
+
class Kt extends w {
|
|
846
847
|
getAllPopulated() {
|
|
847
|
-
return
|
|
848
|
+
return _t({}, {});
|
|
848
849
|
}
|
|
849
850
|
getPopulated(e) {
|
|
850
851
|
return Nt({ panoplyId: e });
|
|
851
852
|
}
|
|
852
853
|
hasPanoply(e, t) {
|
|
853
|
-
const r =
|
|
854
|
+
const r = Q(Object.values(e)), a = t.equipments.filter(
|
|
854
855
|
(s) => r.find((i) => i.entityId === s.entityId)
|
|
855
856
|
).length;
|
|
856
857
|
if (a === t.equipments.length)
|
|
@@ -861,15 +862,15 @@ class Kt extends f {
|
|
|
861
862
|
async getPanoplyBonus(e) {
|
|
862
863
|
const t = [], r = await this.getAllPopulated();
|
|
863
864
|
for (const a of r) {
|
|
864
|
-
const s =
|
|
865
|
-
(u) => s.find(({ entityId:
|
|
865
|
+
const s = Q(Object.values(e)), i = a.equipments.filter(
|
|
866
|
+
(u) => s.find(({ entityId: c }) => c === u.entityId)
|
|
866
867
|
);
|
|
867
868
|
i.length === a.equipments.length ? t.push([a, "full"]) : i.length >= a.equipments.length / 2 ? t.push([a, "half"]) : i.length >= 1 && t.push([a, null]);
|
|
868
869
|
}
|
|
869
870
|
return t;
|
|
870
871
|
}
|
|
871
872
|
}
|
|
872
|
-
const Ht = async (n, e) =>
|
|
873
|
+
const Ht = async (n, e) => P.findOneAndUpdate(n, e, {
|
|
873
874
|
returnDocument: "after"
|
|
874
875
|
}).lean();
|
|
875
876
|
class Pt extends Kt {
|
|
@@ -889,20 +890,20 @@ class Pt extends Kt {
|
|
|
889
890
|
return Ft(e);
|
|
890
891
|
}
|
|
891
892
|
fetchManyFromDb(e, t) {
|
|
892
|
-
return
|
|
893
|
+
return Bt(e, t);
|
|
893
894
|
}
|
|
894
895
|
}
|
|
895
|
-
const
|
|
896
|
+
const N = new Pt(), jt = new o(
|
|
896
897
|
{
|
|
897
898
|
type: {
|
|
898
899
|
type: String,
|
|
899
900
|
enum: We,
|
|
900
901
|
required: !0
|
|
901
902
|
},
|
|
902
|
-
params: { type:
|
|
903
|
+
params: { type: o.Types.Mixed }
|
|
903
904
|
},
|
|
904
905
|
{ _id: !1 }
|
|
905
|
-
), zt = new
|
|
906
|
+
), zt = new o(
|
|
906
907
|
{
|
|
907
908
|
entityId: { unique: !0, required: !0, type: String }
|
|
908
909
|
},
|
|
@@ -910,7 +911,7 @@ const R = new Pt(), jt = new c(
|
|
|
910
911
|
minimize: !1,
|
|
911
912
|
discriminatorKey: "type"
|
|
912
913
|
}
|
|
913
|
-
), Lt = new
|
|
914
|
+
), Lt = new o({
|
|
914
915
|
category: { required: !0, type: String },
|
|
915
916
|
subtype: { type: String },
|
|
916
917
|
rankId: String,
|
|
@@ -923,17 +924,17 @@ const R = new Pt(), jt = new c(
|
|
|
923
924
|
},
|
|
924
925
|
default: void 0
|
|
925
926
|
}
|
|
926
|
-
}), Qt = new
|
|
927
|
+
}), Qt = new o({
|
|
927
928
|
category: { required: !0, type: String },
|
|
928
929
|
characteristics: {
|
|
929
930
|
_id: !1,
|
|
930
931
|
type: Object
|
|
931
932
|
},
|
|
932
933
|
panoply: String
|
|
933
|
-
}),
|
|
934
|
-
|
|
935
|
-
const Gt = async (n, e) =>
|
|
936
|
-
class Vt extends
|
|
934
|
+
}), B = d?.Entities || l("Entities", zt), Yt = B.discriminator("item", Lt);
|
|
935
|
+
B.discriminator("equipment", Qt);
|
|
936
|
+
const Gt = async (n, e) => B.find(n, {}, e).lean(), Wt = async (n, e) => Yt.find(n, {}, e).lean();
|
|
937
|
+
class Vt extends w {
|
|
937
938
|
isEntity(e) {
|
|
938
939
|
return !!e && "entityId" in e;
|
|
939
940
|
}
|
|
@@ -956,7 +957,7 @@ class Vt extends f {
|
|
|
956
957
|
}
|
|
957
958
|
async recordToEntityTuple(e) {
|
|
958
959
|
const t = await this.getAll();
|
|
959
|
-
return
|
|
960
|
+
return F(e).reduce((r, [a, s]) => {
|
|
960
961
|
const i = t.find(({ entityId: u }) => u === a);
|
|
961
962
|
return i && r.push([i, s]), r;
|
|
962
963
|
}, []);
|
|
@@ -992,18 +993,18 @@ class Vt extends f {
|
|
|
992
993
|
intelligence: 0,
|
|
993
994
|
wisdom: 0
|
|
994
995
|
};
|
|
995
|
-
const r = await
|
|
996
|
+
const r = await N.getAllPopulated();
|
|
996
997
|
for (const a of Ie) {
|
|
997
998
|
const s = e[a];
|
|
998
|
-
s && (t =
|
|
999
|
+
s && (t = Y(
|
|
999
1000
|
t,
|
|
1000
1001
|
(await this.fromDBToEquipableEquipment(s)).characteristics,
|
|
1001
1002
|
(i, u) => i + u
|
|
1002
1003
|
));
|
|
1003
1004
|
}
|
|
1004
1005
|
for (const a of r) {
|
|
1005
|
-
const s =
|
|
1006
|
-
s && !("target" in s) && (t =
|
|
1006
|
+
const s = N.hasPanoply(e, a);
|
|
1007
|
+
s && !("target" in s) && (t = Y(
|
|
1007
1008
|
t,
|
|
1008
1009
|
s,
|
|
1009
1010
|
(i, u) => i + u
|
|
@@ -1034,8 +1035,8 @@ class Vt extends f {
|
|
|
1034
1035
|
return e.entityId === t.entityId && e.seed === t.seed;
|
|
1035
1036
|
}
|
|
1036
1037
|
seedEquipment(e, t) {
|
|
1037
|
-
const r =
|
|
1038
|
-
|
|
1038
|
+
const r = ot(t), a = ye(
|
|
1039
|
+
F(e.characteristics),
|
|
1039
1040
|
([s]) => s
|
|
1040
1041
|
);
|
|
1041
1042
|
return {
|
|
@@ -1055,14 +1056,14 @@ class Vt extends f {
|
|
|
1055
1056
|
);
|
|
1056
1057
|
}
|
|
1057
1058
|
}
|
|
1058
|
-
const Xt = async (n) => await
|
|
1059
|
+
const Xt = async (n) => await B.create({
|
|
1059
1060
|
...n
|
|
1060
1061
|
});
|
|
1061
1062
|
async function Jt(n) {
|
|
1062
|
-
const e = await
|
|
1063
|
+
const e = await B.findOne({ entityId: n }).lean();
|
|
1063
1064
|
return e || null;
|
|
1064
1065
|
}
|
|
1065
|
-
const Zt = (n, e) =>
|
|
1066
|
+
const Zt = (n, e) => B.findOneAndUpdate(n, e, {
|
|
1066
1067
|
returnDocument: "after"
|
|
1067
1068
|
}).lean();
|
|
1068
1069
|
class en extends Vt {
|
|
@@ -1088,8 +1089,8 @@ class en extends Vt {
|
|
|
1088
1089
|
return e.entityId;
|
|
1089
1090
|
}
|
|
1090
1091
|
}
|
|
1091
|
-
const
|
|
1092
|
-
class tn extends
|
|
1092
|
+
const T = new en();
|
|
1093
|
+
class tn extends m {
|
|
1093
1094
|
hasAlreadyFoundEntity(e, t) {
|
|
1094
1095
|
return e.encyclopedia.includes(t);
|
|
1095
1096
|
}
|
|
@@ -1099,14 +1100,14 @@ class tn extends y {
|
|
|
1099
1100
|
});
|
|
1100
1101
|
}
|
|
1101
1102
|
}
|
|
1102
|
-
const nn = async (n) => await
|
|
1103
|
+
const nn = async (n) => await J.create({
|
|
1103
1104
|
user: n
|
|
1104
1105
|
});
|
|
1105
1106
|
async function rn(n) {
|
|
1106
|
-
const e = await
|
|
1107
|
-
return e ||
|
|
1107
|
+
const e = await J.findOne({ user: n }).lean();
|
|
1108
|
+
return e || y(await nn(n));
|
|
1108
1109
|
}
|
|
1109
|
-
const an = (n, e) =>
|
|
1110
|
+
const an = (n, e) => J.findOneAndUpdate({ user: n }, e, {
|
|
1110
1111
|
upsert: !0,
|
|
1111
1112
|
returnDocument: "after"
|
|
1112
1113
|
}).lean();
|
|
@@ -1127,8 +1128,8 @@ class sn extends tn {
|
|
|
1127
1128
|
return an(e, t);
|
|
1128
1129
|
}
|
|
1129
1130
|
}
|
|
1130
|
-
const
|
|
1131
|
-
class un extends
|
|
1131
|
+
const pe = new sn();
|
|
1132
|
+
class un extends m {
|
|
1132
1133
|
async getUserEquipmentsCharacteristics(e) {
|
|
1133
1134
|
let t = {
|
|
1134
1135
|
vitality: 0,
|
|
@@ -1142,8 +1143,8 @@ class un extends y {
|
|
|
1142
1143
|
const a = e.equippedItems?.[r];
|
|
1143
1144
|
if (!a)
|
|
1144
1145
|
continue;
|
|
1145
|
-
const s = await
|
|
1146
|
-
t =
|
|
1146
|
+
const s = await T.fromDBToEquipableEquipment(a);
|
|
1147
|
+
t = Y(
|
|
1147
1148
|
t,
|
|
1148
1149
|
s.characteristics,
|
|
1149
1150
|
(i, u) => i + u
|
|
@@ -1153,7 +1154,7 @@ class un extends y {
|
|
|
1153
1154
|
}
|
|
1154
1155
|
async hasInventoryRequirements(e, t) {
|
|
1155
1156
|
const r = await this.get(e);
|
|
1156
|
-
return
|
|
1157
|
+
return F(t).reduce(
|
|
1157
1158
|
(a, [s, i]) => a && (r.itemList[s] ?? 0) >= (i ?? 0),
|
|
1158
1159
|
!0
|
|
1159
1160
|
);
|
|
@@ -1165,33 +1166,39 @@ class un extends y {
|
|
|
1165
1166
|
return (await this.get(e)).itemList;
|
|
1166
1167
|
}
|
|
1167
1168
|
async calcMinStreakForWorkLoot(e) {
|
|
1168
|
-
const t = await this.get(e), r = (await
|
|
1169
|
+
const t = await this.get(e), r = (await N.getPanoplyBonus(t.equippedItems)).find(
|
|
1169
1170
|
([a, s]) => a.panoplyId === "marine" && s !== null
|
|
1170
1171
|
);
|
|
1171
1172
|
return r && r[1] === "full" ? 10 : r && r[1] === "half" ? 20 : 1 / 0;
|
|
1172
1173
|
}
|
|
1173
1174
|
async hasRevolutionaryBuff(e) {
|
|
1174
1175
|
const t = await this.get(e);
|
|
1175
|
-
return (await
|
|
1176
|
+
return (await N.getPanoplyBonus(t.equippedItems)).find(
|
|
1176
1177
|
([a, s]) => a.panoplyId === "revolutionary" && s !== null
|
|
1177
1178
|
)?.[1] ?? null;
|
|
1178
1179
|
}
|
|
1180
|
+
async hasRecipe(e, t) {
|
|
1181
|
+
return (await this.get(e)).recipes.includes(t);
|
|
1182
|
+
}
|
|
1183
|
+
async getRecipes(e) {
|
|
1184
|
+
return (await this.get(e)).recipes;
|
|
1185
|
+
}
|
|
1179
1186
|
/*
|
|
1180
1187
|
** UPDATES
|
|
1181
1188
|
*/
|
|
1182
1189
|
async addItem(e, t, r) {
|
|
1183
1190
|
await this.update(e, {
|
|
1184
1191
|
$inc: { [`itemList.${t}`]: r }
|
|
1185
|
-
}), await
|
|
1192
|
+
}), await pe.addEntities(e, [t]);
|
|
1186
1193
|
}
|
|
1187
1194
|
async addItems(e, t) {
|
|
1188
1195
|
await this.update(e, {
|
|
1189
1196
|
$inc: Object.fromEntries(
|
|
1190
1197
|
Object.entries(t).filter(([, r]) => (r ?? 0) > 0).map(([r, a]) => [`itemList.${r}`, a])
|
|
1191
1198
|
)
|
|
1192
|
-
}), await
|
|
1199
|
+
}), await pe.addEntities(
|
|
1193
1200
|
e,
|
|
1194
|
-
|
|
1201
|
+
F(t).filter(([, r]) => r > 0).map(([r]) => r)
|
|
1195
1202
|
);
|
|
1196
1203
|
}
|
|
1197
1204
|
async removeItem(e, t, r) {
|
|
@@ -1221,7 +1228,7 @@ class un extends y {
|
|
|
1221
1228
|
async addEquipments(e, t) {
|
|
1222
1229
|
await this.update(e, {
|
|
1223
1230
|
$push: { equipmentList: { $each: t } }
|
|
1224
|
-
}), await
|
|
1231
|
+
}), await pe.addEntities(
|
|
1225
1232
|
e,
|
|
1226
1233
|
t.map((r) => r.entityId)
|
|
1227
1234
|
);
|
|
@@ -1240,51 +1247,44 @@ class un extends y {
|
|
|
1240
1247
|
r?.equipmentSave[t] && await this.equip(e, r.equipmentSave[t]);
|
|
1241
1248
|
}
|
|
1242
1249
|
async equip(e, t) {
|
|
1243
|
-
const r = await
|
|
1244
|
-
|
|
1250
|
+
const r = await v.getMaxHp(e), a = Object.fromEntries(
|
|
1251
|
+
F(t).map(([s, i]) => [
|
|
1245
1252
|
`equippedItems.${s}`,
|
|
1246
1253
|
i
|
|
1247
1254
|
])
|
|
1248
1255
|
);
|
|
1249
1256
|
await this.update(e, {
|
|
1250
1257
|
$set: a
|
|
1251
|
-
}), await
|
|
1258
|
+
}), await v.updateHp(e, r);
|
|
1252
1259
|
}
|
|
1253
1260
|
async unequip(e, t) {
|
|
1254
|
-
const r = await
|
|
1261
|
+
const r = await v.getMaxHp(e);
|
|
1255
1262
|
await this.update(e, {
|
|
1256
1263
|
$set: {
|
|
1257
1264
|
[`equippedItems.${t}`]: null
|
|
1258
1265
|
}
|
|
1259
|
-
}), await
|
|
1266
|
+
}), await v.updateHp(e, r);
|
|
1260
1267
|
}
|
|
1261
1268
|
async craftItem(e, t, r, a) {
|
|
1262
|
-
for (const { entityId: u, size:
|
|
1263
|
-
await this.removeItem(e, u,
|
|
1269
|
+
for (const { entityId: u, size: c } of t.entities)
|
|
1270
|
+
await this.removeItem(e, u, (c ?? 1) * r);
|
|
1264
1271
|
const { entityId: s, size: i } = t.result;
|
|
1265
|
-
await
|
|
1266
|
-
}
|
|
1267
|
-
async dismantleEntity(e, t, r, a, s) {
|
|
1268
|
-
m.isEquipment(t) ? await this.removeEquipment(e, t.entityId, s) : m.isItem(t) && await this.removeItem(e, t.entityId, a);
|
|
1269
|
-
for (const { entityId: i, quantity: u } of r)
|
|
1270
|
-
await m.isEntityId(i, m.isItem) && await this.addItem(e, i, a * u);
|
|
1271
|
-
await this.removeItem(e, "tools", 1);
|
|
1272
|
-
}
|
|
1273
|
-
async enchantItem(e, t, r, a, s) {
|
|
1274
|
-
await this.removeItem(e, t, s * 4), await this.removeItem(e, a, s), await this.addItem(e, r, s);
|
|
1272
|
+
await T.isEntityId(s, T.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: a }]) : await T.isEntityId(s, T.isItem) && await this.addItem(e, s, (i ?? 1) * r);
|
|
1275
1273
|
}
|
|
1276
1274
|
async unlockRecipe(e, t) {
|
|
1277
|
-
await this.
|
|
1275
|
+
await this.hasRecipe(e, t) || await this.update(e, {
|
|
1276
|
+
$push: { recipes: t }
|
|
1277
|
+
});
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
1280
|
-
const
|
|
1280
|
+
const on = (n) => ee.create({
|
|
1281
1281
|
user: n
|
|
1282
1282
|
});
|
|
1283
|
-
async function
|
|
1284
|
-
const e = await
|
|
1285
|
-
return e ||
|
|
1283
|
+
async function cn(n) {
|
|
1284
|
+
const e = await ee.findOne({ user: n }).lean();
|
|
1285
|
+
return e || y(await on(n));
|
|
1286
1286
|
}
|
|
1287
|
-
const dn = (n, e) =>
|
|
1287
|
+
const dn = (n, e) => ee.findOneAndUpdate({ user: n }, e, {
|
|
1288
1288
|
upsert: !0,
|
|
1289
1289
|
returnDocument: "after"
|
|
1290
1290
|
}).lean();
|
|
@@ -1293,7 +1293,7 @@ class ln extends un {
|
|
|
1293
1293
|
super(300);
|
|
1294
1294
|
}
|
|
1295
1295
|
fetchFromDb(e) {
|
|
1296
|
-
return
|
|
1296
|
+
return cn(e);
|
|
1297
1297
|
}
|
|
1298
1298
|
normalizeKey(e) {
|
|
1299
1299
|
return e.toString();
|
|
@@ -1305,8 +1305,8 @@ class ln extends un {
|
|
|
1305
1305
|
return dn(e, t);
|
|
1306
1306
|
}
|
|
1307
1307
|
}
|
|
1308
|
-
const
|
|
1309
|
-
class pn extends
|
|
1308
|
+
const M = new ln();
|
|
1309
|
+
class pn extends w {
|
|
1310
1310
|
async getTotalCharacteristics(e) {
|
|
1311
1311
|
const { characteristics: t, scrolls: r } = await this.get(e);
|
|
1312
1312
|
return Te(
|
|
@@ -1364,7 +1364,7 @@ class pn extends f {
|
|
|
1364
1364
|
t.booster ? 0.25 : 0
|
|
1365
1365
|
);
|
|
1366
1366
|
return a + s + t.buffs.xp.global.reduce(
|
|
1367
|
-
(i, { expireAt: u, startAt:
|
|
1367
|
+
(i, { expireAt: u, startAt: c, multiplier: f }) => c && c > /* @__PURE__ */ new Date() || u && le(u) ? i : i + f,
|
|
1368
1368
|
0
|
|
1369
1369
|
);
|
|
1370
1370
|
}
|
|
@@ -1386,12 +1386,12 @@ class pn extends f {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
async calcBuffMultiplier(e, t, r) {
|
|
1388
1388
|
return (await this.get(e)).buffs[t][r].reduce(
|
|
1389
|
-
(i, { expireAt: u, startAt:
|
|
1389
|
+
(i, { expireAt: u, startAt: c, multiplier: f }) => i + (/* @__PURE__ */ new Date() >= (c ?? /* @__PURE__ */ new Date()) && (!u || !le(u)) ? f : 0),
|
|
1390
1390
|
1
|
|
1391
1391
|
);
|
|
1392
1392
|
}
|
|
1393
1393
|
async getMaxHp(e) {
|
|
1394
|
-
const t = await
|
|
1394
|
+
const t = await M.get(e), { vitality: r } = await this.getTotalCharacteristics(e), a = await M.getUserEquipmentsCharacteristics(
|
|
1395
1395
|
t
|
|
1396
1396
|
);
|
|
1397
1397
|
return (r + a.vitality) * Ze + et;
|
|
@@ -1401,9 +1401,9 @@ class pn extends f {
|
|
|
1401
1401
|
return Math.min(t.hp / r, 1);
|
|
1402
1402
|
}
|
|
1403
1403
|
async hasCharacteristicRequirement(e, t) {
|
|
1404
|
-
const r = await
|
|
1404
|
+
const r = await M.get(e), a = await M.getUserEquipmentsCharacteristics(
|
|
1405
1405
|
r
|
|
1406
|
-
), s =
|
|
1406
|
+
), s = Y(
|
|
1407
1407
|
await this.getTotalCharacteristics(e),
|
|
1408
1408
|
a,
|
|
1409
1409
|
(i, u) => i + u
|
|
@@ -1427,7 +1427,7 @@ class pn extends f {
|
|
|
1427
1427
|
for (const r of Object.values(t.buffs))
|
|
1428
1428
|
for (const a of Object.values(r))
|
|
1429
1429
|
for (const { multiplier: s, startAt: i, expireAt: u } of a)
|
|
1430
|
-
if (s < 0 && (!u || !
|
|
1430
|
+
if (s < 0 && (!u || !le(u)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
|
|
1431
1431
|
return !0;
|
|
1432
1432
|
return !1;
|
|
1433
1433
|
}
|
|
@@ -1578,15 +1578,15 @@ class pn extends f {
|
|
|
1578
1578
|
});
|
|
1579
1579
|
}
|
|
1580
1580
|
async updatePanoplyBuff(e, t, r, a) {
|
|
1581
|
-
const s = await
|
|
1581
|
+
const s = await T.fromDBToEquipableEquipment(t), i = Q(Object.values(r)), c = (await N.getAllPopulated()).find(
|
|
1582
1582
|
(g) => g.panoplyId === s.panoply
|
|
1583
1583
|
);
|
|
1584
|
-
if (!
|
|
1584
|
+
if (!c)
|
|
1585
1585
|
return;
|
|
1586
|
-
const
|
|
1587
|
-
(g) => (i.find((
|
|
1588
|
-
).length,
|
|
1589
|
-
|
|
1586
|
+
const f = c.equipments.filter(
|
|
1587
|
+
(g) => (i.find((S) => g.entityId === S.entityId) || !a && s.entityId === g.entityId) && (a ? s.entityId !== g.entityId : !0)
|
|
1588
|
+
).length, h = f === c.equipments.length ? c.fullBonus : f >= c.equipments.length / 2 ? c.halfBonus : void 0;
|
|
1589
|
+
c.halfBonus && "target" in c.halfBonus && await this.removeBuff(e, c.halfBonus), c.fullBonus && "target" in c.fullBonus && await this.removeBuff(e, c.fullBonus), h && "target" in h && await this.updateBuff(e, h);
|
|
1590
1590
|
}
|
|
1591
1591
|
async gainHp(e, t) {
|
|
1592
1592
|
const r = await this.get(e), s = await this.getMaxHp(e) - r.hp;
|
|
@@ -1691,14 +1691,14 @@ class pn extends f {
|
|
|
1691
1691
|
return await this.addBerry(e, a), a;
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
1694
|
-
const yn = (n) =>
|
|
1694
|
+
const yn = (n) => D.find(n).lean(), fn = async (n) => await D.create({
|
|
1695
1695
|
user: n
|
|
1696
1696
|
});
|
|
1697
1697
|
async function mn(n) {
|
|
1698
|
-
const e = await
|
|
1699
|
-
return e ||
|
|
1698
|
+
const e = await D.findOne({ user: n }).lean();
|
|
1699
|
+
return e || y(await fn(n));
|
|
1700
1700
|
}
|
|
1701
|
-
const hn = (n, e) =>
|
|
1701
|
+
const hn = (n, e) => D.findOneAndUpdate({ user: n }, e, {
|
|
1702
1702
|
returnDocument: "after",
|
|
1703
1703
|
upsert: !0
|
|
1704
1704
|
}).lean();
|
|
@@ -1722,8 +1722,8 @@ class gn extends pn {
|
|
|
1722
1722
|
return hn(e, t);
|
|
1723
1723
|
}
|
|
1724
1724
|
}
|
|
1725
|
-
const
|
|
1726
|
-
class Sn extends
|
|
1725
|
+
const v = new gn();
|
|
1726
|
+
class Sn extends w {
|
|
1727
1727
|
async updateSendDailyQuest(e, t) {
|
|
1728
1728
|
await this.update(e, { $set: { sendDailyQuest: t } });
|
|
1729
1729
|
}
|
|
@@ -1742,14 +1742,14 @@ class Sn extends f {
|
|
|
1742
1742
|
});
|
|
1743
1743
|
}
|
|
1744
1744
|
}
|
|
1745
|
-
const wn = (n) =>
|
|
1745
|
+
const wn = (n) => K.find(n).lean(), bn = async (n) => await K.create({
|
|
1746
1746
|
user: n
|
|
1747
1747
|
});
|
|
1748
1748
|
async function $n(n) {
|
|
1749
|
-
const e = await
|
|
1750
|
-
return e ||
|
|
1749
|
+
const e = await K.findOne({ user: n }).lean();
|
|
1750
|
+
return e || y(await bn(n));
|
|
1751
1751
|
}
|
|
1752
|
-
const In = (n, e) =>
|
|
1752
|
+
const In = (n, e) => K.findOneAndUpdate({ user: n }, e, {
|
|
1753
1753
|
returnDocument: "after",
|
|
1754
1754
|
upsert: !0
|
|
1755
1755
|
}).lean();
|
|
@@ -1774,7 +1774,7 @@ class Un extends Sn {
|
|
|
1774
1774
|
}
|
|
1775
1775
|
}
|
|
1776
1776
|
const Fe = new Un();
|
|
1777
|
-
class Tn extends
|
|
1777
|
+
class Tn extends m {
|
|
1778
1778
|
async getCommandCooldown(e, t) {
|
|
1779
1779
|
return (await this.get(e)).commands[t];
|
|
1780
1780
|
}
|
|
@@ -1783,7 +1783,7 @@ class Tn extends y {
|
|
|
1783
1783
|
$set: {
|
|
1784
1784
|
lockUserCommand: new Date(Date.now() + 2 * 3600 * 1e3)
|
|
1785
1785
|
}
|
|
1786
|
-
}), await
|
|
1786
|
+
}), await v.gainHp(e, 1);
|
|
1787
1787
|
}
|
|
1788
1788
|
async useCommand(e, t, r) {
|
|
1789
1789
|
const { reminder: a } = await Fe.get(e);
|
|
@@ -1798,18 +1798,18 @@ class Tn extends y {
|
|
|
1798
1798
|
);
|
|
1799
1799
|
}
|
|
1800
1800
|
}
|
|
1801
|
-
const En = async (n) => await
|
|
1801
|
+
const En = async (n) => await V.create({
|
|
1802
1802
|
user: n
|
|
1803
1803
|
});
|
|
1804
|
-
async function
|
|
1805
|
-
const e = await
|
|
1806
|
-
return e ||
|
|
1804
|
+
async function vn(n) {
|
|
1805
|
+
const e = await V.findOne({ user: n }).lean();
|
|
1806
|
+
return e || y(await En(n));
|
|
1807
1807
|
}
|
|
1808
|
-
const
|
|
1808
|
+
const On = (n, e) => V.findOneAndUpdate({ user: n }, e, {
|
|
1809
1809
|
returnDocument: "after",
|
|
1810
1810
|
upsert: !0
|
|
1811
1811
|
}).lean();
|
|
1812
|
-
class
|
|
1812
|
+
class Dn extends Tn {
|
|
1813
1813
|
constructor() {
|
|
1814
1814
|
super(300);
|
|
1815
1815
|
}
|
|
@@ -1820,14 +1820,14 @@ class vn extends Tn {
|
|
|
1820
1820
|
return e.user;
|
|
1821
1821
|
}
|
|
1822
1822
|
fetchFromDb(e) {
|
|
1823
|
-
return
|
|
1823
|
+
return vn(e);
|
|
1824
1824
|
}
|
|
1825
1825
|
updateInDb(e, t) {
|
|
1826
|
-
return
|
|
1826
|
+
return On(e, t);
|
|
1827
1827
|
}
|
|
1828
1828
|
}
|
|
1829
|
-
const Qa = new
|
|
1830
|
-
class
|
|
1829
|
+
const Qa = new Dn();
|
|
1830
|
+
class xn extends w {
|
|
1831
1831
|
async isOrnamentIds(e, t = () => !0) {
|
|
1832
1832
|
const a = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
|
|
1833
1833
|
return e.every((s) => a.includes(s));
|
|
@@ -1866,12 +1866,12 @@ class Mn extends f {
|
|
|
1866
1866
|
return (await this.getAll()).filter((e) => this.isShopTitle(e));
|
|
1867
1867
|
}
|
|
1868
1868
|
formatBackgroundId(e) {
|
|
1869
|
-
const t =
|
|
1869
|
+
const t = ct(e) ? e : e.ornamentId;
|
|
1870
1870
|
return t === "background_default" ? "par défaut" : `"${dt(t.split("_").join(" "))}"`;
|
|
1871
1871
|
}
|
|
1872
1872
|
async getSomeShopTitles(e) {
|
|
1873
1873
|
const t = await this.getAllShopTitles();
|
|
1874
|
-
return
|
|
1874
|
+
return ye(
|
|
1875
1875
|
Se(
|
|
1876
1876
|
e,
|
|
1877
1877
|
t,
|
|
@@ -1883,7 +1883,7 @@ class Mn extends f {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
async getSomeBackgrounds(e) {
|
|
1885
1885
|
const t = await this.getAllBackgrounds();
|
|
1886
|
-
return
|
|
1886
|
+
return ye(
|
|
1887
1887
|
Se(
|
|
1888
1888
|
e,
|
|
1889
1889
|
t,
|
|
@@ -1898,7 +1898,7 @@ class Mn extends f {
|
|
|
1898
1898
|
throw new RangeError(
|
|
1899
1899
|
"pickEachRarityOrnament - must give same number of odds than ranks"
|
|
1900
1900
|
);
|
|
1901
|
-
return
|
|
1901
|
+
return Q(
|
|
1902
1902
|
t.map((r, a) => {
|
|
1903
1903
|
const s = ge[a], i = e[s];
|
|
1904
1904
|
return Math.random() > r || !i || !i.length ? null : lt(i);
|
|
@@ -1906,7 +1906,7 @@ class Mn extends f {
|
|
|
1906
1906
|
);
|
|
1907
1907
|
}
|
|
1908
1908
|
}
|
|
1909
|
-
const
|
|
1909
|
+
const Mn = new o(
|
|
1910
1910
|
{
|
|
1911
1911
|
ornamentId: { unique: !0, index: 1, required: !0, type: String },
|
|
1912
1912
|
type: { required: !0, type: String },
|
|
@@ -1920,26 +1920,26 @@ const xn = new c(
|
|
|
1920
1920
|
strength: Number
|
|
1921
1921
|
},
|
|
1922
1922
|
{ minimize: !1 }
|
|
1923
|
-
),
|
|
1924
|
-
async function
|
|
1925
|
-
const e = await
|
|
1923
|
+
), me = d?.Ornaments || l("Ornaments", Mn), An = async (n, e) => me.find(n, {}, e).lean();
|
|
1924
|
+
async function kn(n) {
|
|
1925
|
+
const e = await me.findOne({ ornamentId: n }).lean();
|
|
1926
1926
|
return e || null;
|
|
1927
1927
|
}
|
|
1928
|
-
const
|
|
1928
|
+
const qn = (n, e) => me.findOneAndUpdate(n, e, {
|
|
1929
1929
|
returnDocument: "after"
|
|
1930
1930
|
}).lean();
|
|
1931
|
-
class Rn extends
|
|
1931
|
+
class Rn extends xn {
|
|
1932
1932
|
constructor() {
|
|
1933
1933
|
super(3600);
|
|
1934
1934
|
}
|
|
1935
1935
|
updateInDb(e, t) {
|
|
1936
|
-
return
|
|
1936
|
+
return qn(e, t);
|
|
1937
1937
|
}
|
|
1938
1938
|
fetchFromDb(e) {
|
|
1939
|
-
return
|
|
1939
|
+
return kn(e);
|
|
1940
1940
|
}
|
|
1941
1941
|
fetchManyFromDb(e, t) {
|
|
1942
|
-
return
|
|
1942
|
+
return An(e, t);
|
|
1943
1943
|
}
|
|
1944
1944
|
getKey(e) {
|
|
1945
1945
|
return e.ornamentId;
|
|
@@ -1949,7 +1949,7 @@ class Rn extends Mn {
|
|
|
1949
1949
|
}
|
|
1950
1950
|
}
|
|
1951
1951
|
const U = new Rn();
|
|
1952
|
-
class Cn extends
|
|
1952
|
+
class Cn extends m {
|
|
1953
1953
|
async unlockTitle(e, t) {
|
|
1954
1954
|
await U.isOrnamentIds([t], U.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
|
|
1955
1955
|
}
|
|
@@ -2018,14 +2018,14 @@ class Cn extends y {
|
|
|
2018
2018
|
});
|
|
2019
2019
|
}
|
|
2020
2020
|
}
|
|
2021
|
-
const
|
|
2021
|
+
const Bn = async (n) => await te.create({
|
|
2022
2022
|
user: n
|
|
2023
2023
|
});
|
|
2024
|
-
async function
|
|
2025
|
-
const e = await
|
|
2026
|
-
return e ||
|
|
2024
|
+
async function _n(n) {
|
|
2025
|
+
const e = await te.findOne({ user: n }).lean();
|
|
2026
|
+
return e || y(await Bn(n));
|
|
2027
2027
|
}
|
|
2028
|
-
const Fn = async (n, e) =>
|
|
2028
|
+
const Fn = async (n, e) => te.findOneAndUpdate({ user: n }, e, {
|
|
2029
2029
|
upsert: !0,
|
|
2030
2030
|
returnDocument: "after"
|
|
2031
2031
|
}).lean();
|
|
@@ -2040,14 +2040,14 @@ class Nn extends Cn {
|
|
|
2040
2040
|
return e;
|
|
2041
2041
|
}
|
|
2042
2042
|
fetchFromDb(e) {
|
|
2043
|
-
return
|
|
2043
|
+
return _n(e);
|
|
2044
2044
|
}
|
|
2045
2045
|
updateInDb(e, t) {
|
|
2046
2046
|
return Fn(e, t);
|
|
2047
2047
|
}
|
|
2048
2048
|
}
|
|
2049
2049
|
const we = new Nn();
|
|
2050
|
-
class Kn extends
|
|
2050
|
+
class Kn extends w {
|
|
2051
2051
|
async getStatus(e, t) {
|
|
2052
2052
|
return (await this.get({ user: e, questId: t })).status;
|
|
2053
2053
|
}
|
|
@@ -2056,17 +2056,17 @@ class Kn extends f {
|
|
|
2056
2056
|
}
|
|
2057
2057
|
async isStreaking(e, t) {
|
|
2058
2058
|
const { lastCompletionDate: r } = await this.get({ user: e, questId: t });
|
|
2059
|
-
return !!r &&
|
|
2059
|
+
return !!r && ve(G(), r);
|
|
2060
2060
|
}
|
|
2061
2061
|
async getStreakMultiplier(e, t) {
|
|
2062
2062
|
const r = await this.get({ user: e, questId: t });
|
|
2063
2063
|
return await this.isStreaking(e, t) ? 1 + Math.min(2, (r.streak ?? 0) / 10) : 1;
|
|
2064
2064
|
}
|
|
2065
2065
|
async getCompletedCount(e) {
|
|
2066
|
-
return (await this.getMany({ user: e, status:
|
|
2066
|
+
return (await this.getMany({ user: e, status: k.COMPLETED })).length;
|
|
2067
2067
|
}
|
|
2068
2068
|
async completeQuest(e, t = !1) {
|
|
2069
|
-
const r =
|
|
2069
|
+
const r = G();
|
|
2070
2070
|
r.setHours(0, 0, 0, 0);
|
|
2071
2071
|
const a = /* @__PURE__ */ new Date();
|
|
2072
2072
|
return a.setHours(0, 0, 0, 0), this.update(
|
|
@@ -2089,7 +2089,7 @@ class Kn extends f {
|
|
|
2089
2089
|
}
|
|
2090
2090
|
} : {},
|
|
2091
2091
|
lastCompletionDate: /* @__PURE__ */ new Date(),
|
|
2092
|
-
status:
|
|
2092
|
+
status: k.COMPLETED
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
2095
|
],
|
|
@@ -2105,7 +2105,7 @@ const Pn = async (n) => await C.create({
|
|
|
2105
2105
|
});
|
|
2106
2106
|
async function jn(n) {
|
|
2107
2107
|
const e = await C.findOne(n).lean();
|
|
2108
|
-
return e ||
|
|
2108
|
+
return e || y(await Pn(n));
|
|
2109
2109
|
}
|
|
2110
2110
|
function zn(n, e, t) {
|
|
2111
2111
|
return C.findOneAndUpdate(n, e, {
|
|
@@ -2138,7 +2138,7 @@ class Ln extends Kn {
|
|
|
2138
2138
|
}
|
|
2139
2139
|
}
|
|
2140
2140
|
const be = new Ln();
|
|
2141
|
-
class Qn extends
|
|
2141
|
+
class Qn extends m {
|
|
2142
2142
|
async randomMessageIncrement(e) {
|
|
2143
2143
|
await this.update(e, { $inc: { randomMessageClaimed: 1 } });
|
|
2144
2144
|
}
|
|
@@ -2156,14 +2156,14 @@ class Qn extends y {
|
|
|
2156
2156
|
await this.update(e, { $inc: { totalMinutesInVoice: t } });
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
|
-
const Yn = async (n) => await
|
|
2159
|
+
const Yn = async (n) => await re.create({
|
|
2160
2160
|
user: n
|
|
2161
2161
|
});
|
|
2162
2162
|
async function Gn(n) {
|
|
2163
|
-
const e = await
|
|
2164
|
-
return e ||
|
|
2163
|
+
const e = await re.findOne({ user: n }).lean();
|
|
2164
|
+
return e || y(await Yn(n));
|
|
2165
2165
|
}
|
|
2166
|
-
const Wn = (n, e) =>
|
|
2166
|
+
const Wn = (n, e) => re.findOneAndUpdate({ user: n }, e, {
|
|
2167
2167
|
upsert: !0,
|
|
2168
2168
|
returnDocument: "after"
|
|
2169
2169
|
}).lean();
|
|
@@ -2187,11 +2187,11 @@ class Vn extends Qn {
|
|
|
2187
2187
|
}
|
|
2188
2188
|
}
|
|
2189
2189
|
const $e = new Vn();
|
|
2190
|
-
class Xn extends
|
|
2190
|
+
class Xn extends m {
|
|
2191
2191
|
async updateDailyReport(e) {
|
|
2192
|
-
const t = await
|
|
2192
|
+
const t = await v.get(e), r = await we.get(e), a = await be.getMany({
|
|
2193
2193
|
user: e,
|
|
2194
|
-
status:
|
|
2194
|
+
status: k.COMPLETED
|
|
2195
2195
|
}), s = await $e.get(e);
|
|
2196
2196
|
await this.update(e, {
|
|
2197
2197
|
$set: {
|
|
@@ -2214,22 +2214,22 @@ class Xn extends y {
|
|
|
2214
2214
|
xpYesterday: a,
|
|
2215
2215
|
berryYesterday: s,
|
|
2216
2216
|
previousMessageSent: i
|
|
2217
|
-
} = await this.get(e), u = await
|
|
2217
|
+
} = await this.get(e), u = await v.get(e), c = await be.getMany({
|
|
2218
2218
|
user: e,
|
|
2219
|
-
status:
|
|
2220
|
-
}),
|
|
2219
|
+
status: k.COMPLETED
|
|
2220
|
+
}), f = await we.get(e), h = await $e.get(e), { berry: g, xp: S } = u, { voice: p, amount: He } = S, { unlockedBadges: Pe, unlockedBackgrounds: je, unlockedTitles: ze } = f;
|
|
2221
2221
|
return {
|
|
2222
2222
|
berry: g - s,
|
|
2223
2223
|
xp: He - a,
|
|
2224
|
-
message:
|
|
2225
|
-
voice:
|
|
2226
|
-
quest:
|
|
2227
|
-
|
|
2224
|
+
message: h.messageSent - i,
|
|
2225
|
+
voice: ve(p.lastConnection, G()) ? p.minutesInVoiceToday : 0,
|
|
2226
|
+
quest: z(
|
|
2227
|
+
c.map(({ questId: Le }) => Le),
|
|
2228
2228
|
r
|
|
2229
2229
|
),
|
|
2230
|
-
badge:
|
|
2231
|
-
title:
|
|
2232
|
-
background:
|
|
2230
|
+
badge: z(Pe, t.unlockedBadges),
|
|
2231
|
+
title: z(ze, t.unlockedTitles),
|
|
2232
|
+
background: z(
|
|
2233
2233
|
je,
|
|
2234
2234
|
t.unlockedBackgrounds
|
|
2235
2235
|
)
|
|
@@ -2249,14 +2249,14 @@ class Xn extends y {
|
|
|
2249
2249
|
);
|
|
2250
2250
|
}
|
|
2251
2251
|
}
|
|
2252
|
-
const Jn = (n) =>
|
|
2252
|
+
const Jn = (n) => X.create({
|
|
2253
2253
|
user: n
|
|
2254
2254
|
});
|
|
2255
2255
|
async function Zn(n) {
|
|
2256
|
-
const e = await
|
|
2257
|
-
return e ||
|
|
2256
|
+
const e = await X.findOne({ user: n }).lean();
|
|
2257
|
+
return e || y(await Jn(n));
|
|
2258
2258
|
}
|
|
2259
|
-
const er = (n, e) =>
|
|
2259
|
+
const er = (n, e) => X.findOneAndUpdate({ user: n }, e, {
|
|
2260
2260
|
upsert: !0,
|
|
2261
2261
|
returnDocument: "after"
|
|
2262
2262
|
}).lean();
|
|
@@ -2278,7 +2278,7 @@ class tr extends Xn {
|
|
|
2278
2278
|
}
|
|
2279
2279
|
}
|
|
2280
2280
|
const Ya = new tr();
|
|
2281
|
-
class nr extends
|
|
2281
|
+
class nr extends m {
|
|
2282
2282
|
async setGuessGame(e, t, r, a) {
|
|
2283
2283
|
await this.update(e, {
|
|
2284
2284
|
$set: {
|
|
@@ -2309,14 +2309,14 @@ class nr extends y {
|
|
|
2309
2309
|
});
|
|
2310
2310
|
}
|
|
2311
2311
|
}
|
|
2312
|
-
const rr = async (n) => await
|
|
2312
|
+
const rr = async (n) => await Z.create({
|
|
2313
2313
|
user: n
|
|
2314
2314
|
});
|
|
2315
2315
|
async function ar(n) {
|
|
2316
|
-
const e = await
|
|
2317
|
-
return e ||
|
|
2316
|
+
const e = await Z.findOne({ user: n }).lean();
|
|
2317
|
+
return e || y(await rr(n));
|
|
2318
2318
|
}
|
|
2319
|
-
const sr = (n, e) =>
|
|
2319
|
+
const sr = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
|
|
2320
2320
|
upsert: !0,
|
|
2321
2321
|
returnDocument: "after"
|
|
2322
2322
|
}).lean();
|
|
@@ -2337,9 +2337,9 @@ class ir extends nr {
|
|
|
2337
2337
|
return sr(e, t);
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
|
-
const Ga = new ir(), ur = new
|
|
2340
|
+
const Ga = new ir(), ur = new o({
|
|
2341
2341
|
user: {
|
|
2342
|
-
type:
|
|
2342
|
+
type: o.Types.ObjectId,
|
|
2343
2343
|
required: !0,
|
|
2344
2344
|
unique: !0,
|
|
2345
2345
|
ref: "User"
|
|
@@ -2347,10 +2347,10 @@ const Ga = new ir(), ur = new c({
|
|
|
2347
2347
|
xp: { type: Number, default: 0 },
|
|
2348
2348
|
berry: { type: Number, default: 0 },
|
|
2349
2349
|
faction: { type: Number, default: 0 }
|
|
2350
|
-
}),
|
|
2351
|
-
class
|
|
2350
|
+
}), A = d?.UserRank || l("UserRank", ur);
|
|
2351
|
+
class or extends m {
|
|
2352
2352
|
async computeAllXpRanks() {
|
|
2353
|
-
const t = (await
|
|
2353
|
+
const t = (await D.aggregate([
|
|
2354
2354
|
{
|
|
2355
2355
|
$setWindowFields: {
|
|
2356
2356
|
sortBy: { "xp.amount": -1 },
|
|
@@ -2365,10 +2365,10 @@ class cr extends y {
|
|
|
2365
2365
|
upsert: !0
|
|
2366
2366
|
}
|
|
2367
2367
|
}));
|
|
2368
|
-
t.length > 0 && await
|
|
2368
|
+
t.length > 0 && await A.bulkWrite(t), this.clearAll();
|
|
2369
2369
|
}
|
|
2370
2370
|
async computeAllBerryRanks() {
|
|
2371
|
-
const t = (await
|
|
2371
|
+
const t = (await D.aggregate([
|
|
2372
2372
|
{
|
|
2373
2373
|
$setWindowFields: {
|
|
2374
2374
|
sortBy: { berry: -1 },
|
|
@@ -2383,10 +2383,10 @@ class cr extends y {
|
|
|
2383
2383
|
upsert: !0
|
|
2384
2384
|
}
|
|
2385
2385
|
}));
|
|
2386
|
-
t.length > 0 && await
|
|
2386
|
+
t.length > 0 && await A.bulkWrite(t), this.clearAll();
|
|
2387
2387
|
}
|
|
2388
2388
|
async computeAllFactionRanks() {
|
|
2389
|
-
const t = (await
|
|
2389
|
+
const t = (await I.aggregate([
|
|
2390
2390
|
{
|
|
2391
2391
|
$lookup: {
|
|
2392
2392
|
from: "usermetas",
|
|
@@ -2411,7 +2411,7 @@ class cr extends y {
|
|
|
2411
2411
|
upsert: !0
|
|
2412
2412
|
}
|
|
2413
2413
|
}));
|
|
2414
|
-
t.length > 0 && await
|
|
2414
|
+
t.length > 0 && await A.bulkWrite(t), this.clearAll();
|
|
2415
2415
|
}
|
|
2416
2416
|
async computeAllRanks() {
|
|
2417
2417
|
await Promise.all([
|
|
@@ -2421,18 +2421,18 @@ class cr extends y {
|
|
|
2421
2421
|
]);
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
const
|
|
2424
|
+
const cr = async (n) => await A.create({
|
|
2425
2425
|
user: n
|
|
2426
2426
|
});
|
|
2427
2427
|
async function dr(n) {
|
|
2428
|
-
const e = await
|
|
2429
|
-
return e ||
|
|
2428
|
+
const e = await A.findOne({ user: n }).lean();
|
|
2429
|
+
return e || y(await cr(n));
|
|
2430
2430
|
}
|
|
2431
|
-
const lr = (n, e) =>
|
|
2431
|
+
const lr = (n, e) => A.findOneAndUpdate({ user: n }, e, {
|
|
2432
2432
|
returnDocument: "after",
|
|
2433
2433
|
upsert: !0
|
|
2434
2434
|
}).lean();
|
|
2435
|
-
class pr extends
|
|
2435
|
+
class pr extends or {
|
|
2436
2436
|
constructor() {
|
|
2437
2437
|
super(300);
|
|
2438
2438
|
}
|
|
@@ -2449,14 +2449,15 @@ class pr extends cr {
|
|
|
2449
2449
|
return lr(e, t);
|
|
2450
2450
|
}
|
|
2451
2451
|
}
|
|
2452
|
-
const Wa = new pr(), yr = new
|
|
2452
|
+
const Wa = new pr(), yr = new o(
|
|
2453
2453
|
{
|
|
2454
2454
|
speakerId: { type: String, required: !0 },
|
|
2455
2455
|
order: { type: Number },
|
|
2456
|
+
index: { type: Number },
|
|
2456
2457
|
args: { type: [String], enum: nt, default: void 0 }
|
|
2457
2458
|
},
|
|
2458
2459
|
{ _id: !1 }
|
|
2459
|
-
), fr = new
|
|
2460
|
+
), fr = new o(
|
|
2460
2461
|
{
|
|
2461
2462
|
stepId: { type: String, required: !0 },
|
|
2462
2463
|
type: {
|
|
@@ -2466,11 +2467,11 @@ const Wa = new pr(), yr = new c(
|
|
|
2466
2467
|
},
|
|
2467
2468
|
actionType: { type: String, enum: rt },
|
|
2468
2469
|
messages: { type: [yr], default: void 0 },
|
|
2469
|
-
payload: { type:
|
|
2470
|
+
payload: { type: o.Types.Mixed, default: void 0 },
|
|
2470
2471
|
next: { type: String }
|
|
2471
2472
|
},
|
|
2472
2473
|
{ _id: !1 }
|
|
2473
|
-
), mr = new
|
|
2474
|
+
), mr = new o(
|
|
2474
2475
|
{
|
|
2475
2476
|
sceneId: { type: String, required: !0 },
|
|
2476
2477
|
steps: { type: Map, of: fr, required: !0 },
|
|
@@ -2478,7 +2479,7 @@ const Wa = new pr(), yr = new c(
|
|
|
2478
2479
|
next: { type: String }
|
|
2479
2480
|
},
|
|
2480
2481
|
{ _id: !1 }
|
|
2481
|
-
), hr = new
|
|
2482
|
+
), hr = new o(
|
|
2482
2483
|
{
|
|
2483
2484
|
chapterId: { type: String, required: !0 },
|
|
2484
2485
|
scenes: { type: Map, of: mr, required: !0 },
|
|
@@ -2486,7 +2487,7 @@ const Wa = new pr(), yr = new c(
|
|
|
2486
2487
|
next: { type: String }
|
|
2487
2488
|
},
|
|
2488
2489
|
{ _id: !1 }
|
|
2489
|
-
), gr = new
|
|
2490
|
+
), gr = new o(
|
|
2490
2491
|
{
|
|
2491
2492
|
type: {
|
|
2492
2493
|
type: String,
|
|
@@ -2496,7 +2497,7 @@ const Wa = new pr(), yr = new c(
|
|
|
2496
2497
|
speakerId: { type: String, required: !0 }
|
|
2497
2498
|
},
|
|
2498
2499
|
{ _id: !1 }
|
|
2499
|
-
), Ne = new
|
|
2500
|
+
), Ne = new o({
|
|
2500
2501
|
storyId: {
|
|
2501
2502
|
type: String,
|
|
2502
2503
|
required: !0,
|
|
@@ -2509,20 +2510,24 @@ const Wa = new pr(), yr = new c(
|
|
|
2509
2510
|
Ne.pre("findOneAndUpdate", function() {
|
|
2510
2511
|
this.setOptions({ runValidators: !0 });
|
|
2511
2512
|
});
|
|
2512
|
-
const
|
|
2513
|
+
const se = d?.Story || l("Story", Ne), Sr = async (n) => await se.create(n), _ = {
|
|
2513
2514
|
storyId: "main",
|
|
2514
2515
|
speakers: it,
|
|
2515
2516
|
chapters: {
|
|
2516
|
-
[
|
|
2517
|
+
[de.chapterId]: de
|
|
2517
2518
|
},
|
|
2518
|
-
entryChapterId:
|
|
2519
|
+
entryChapterId: de.chapterId
|
|
2519
2520
|
};
|
|
2520
|
-
class wr extends
|
|
2521
|
+
class wr extends w {
|
|
2521
2522
|
async seed() {
|
|
2522
|
-
return await this.get(
|
|
2523
|
+
return await this.get(_.storyId) ? this.update({ storyId: _.storyId }, { $set: _ }) : Sr(_);
|
|
2524
|
+
}
|
|
2525
|
+
async getStep(e, t, r) {
|
|
2526
|
+
const a = await this.get(_.storyId);
|
|
2527
|
+
return a ? a.chapters?.[e]?.scenes?.[t]?.steps?.[r] : null;
|
|
2523
2528
|
}
|
|
2524
2529
|
}
|
|
2525
|
-
const br = (n, e = {}) =>
|
|
2530
|
+
const br = (n, e = {}) => se.find(n, null, e).lean(), $r = (n) => se.findOne({ storyId: n }).lean(), Ir = (n, e) => se.findOneAndUpdate({ storyId: n }, e, {
|
|
2526
2531
|
returnDocument: "after"
|
|
2527
2532
|
}).lean();
|
|
2528
2533
|
class Ur extends wr {
|
|
@@ -2546,7 +2551,7 @@ class Ur extends wr {
|
|
|
2546
2551
|
return Ir(r, t);
|
|
2547
2552
|
}
|
|
2548
2553
|
}
|
|
2549
|
-
const
|
|
2554
|
+
const E = new Ur(), Tr = new o(
|
|
2550
2555
|
{
|
|
2551
2556
|
chapterId: { type: String, required: !0 },
|
|
2552
2557
|
sceneId: { type: String, required: !0 },
|
|
@@ -2554,9 +2559,9 @@ const T = new Ur(), Tr = new c(
|
|
|
2554
2559
|
value: { type: String, required: !0 }
|
|
2555
2560
|
},
|
|
2556
2561
|
{ _id: !1 }
|
|
2557
|
-
), Ke = new
|
|
2562
|
+
), Ke = new o({
|
|
2558
2563
|
user: {
|
|
2559
|
-
type:
|
|
2564
|
+
type: o.Types.ObjectId,
|
|
2560
2565
|
required: !0,
|
|
2561
2566
|
ref: "User",
|
|
2562
2567
|
index: !0
|
|
@@ -2577,20 +2582,20 @@ const T = new Ur(), Tr = new c(
|
|
|
2577
2582
|
choices: { type: [Tr], default: [] }
|
|
2578
2583
|
});
|
|
2579
2584
|
Ke.index({ user: 1, storyId: 1 }, { unique: !0 });
|
|
2580
|
-
const
|
|
2585
|
+
const j = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => await j.create({
|
|
2581
2586
|
user: n,
|
|
2582
2587
|
storyId: e,
|
|
2583
2588
|
currentChapterId: t,
|
|
2584
2589
|
currentSceneId: r,
|
|
2585
2590
|
currentStepId: a,
|
|
2586
2591
|
status: "in_progress"
|
|
2587
|
-
}),
|
|
2588
|
-
}),
|
|
2592
|
+
}), vr = (n, e) => j.deleteOne({ user: n, storyId: e }).then(() => {
|
|
2593
|
+
}), Or = (n, e, t, r) => {
|
|
2589
2594
|
const a = n.chapters[e];
|
|
2590
2595
|
if (!a) return null;
|
|
2591
2596
|
const s = a.scenes[t];
|
|
2592
2597
|
if (!s) return null;
|
|
2593
|
-
if (s.steps[r])
|
|
2598
|
+
if (r && s.steps[r])
|
|
2594
2599
|
return { chapterId: e, sceneId: t, stepId: r };
|
|
2595
2600
|
if (s.next) {
|
|
2596
2601
|
const i = a.scenes[s.next];
|
|
@@ -2614,101 +2619,113 @@ const H = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => awai
|
|
|
2614
2619
|
}
|
|
2615
2620
|
}
|
|
2616
2621
|
return null;
|
|
2617
|
-
},
|
|
2622
|
+
}, L = (n, e) => {
|
|
2618
2623
|
const t = n.chapters[e.currentChapterId];
|
|
2619
2624
|
if (!t) return null;
|
|
2620
2625
|
const r = t.scenes[e.currentSceneId];
|
|
2621
2626
|
return r ? r.steps[e.currentStepId] ?? null : null;
|
|
2622
|
-
},
|
|
2627
|
+
}, Dr = (n, e, t, r, a) => {
|
|
2623
2628
|
const s = [], i = /* @__PURE__ */ new Set();
|
|
2624
2629
|
let u = n.entryStepId;
|
|
2625
2630
|
for (; u && !i.has(u); ) {
|
|
2626
2631
|
i.add(u);
|
|
2627
|
-
const
|
|
2628
|
-
if (!
|
|
2629
|
-
if (
|
|
2630
|
-
if (s.push({ step:
|
|
2631
|
-
u =
|
|
2632
|
+
const c = n.steps[u];
|
|
2633
|
+
if (!c) break;
|
|
2634
|
+
if (c.type !== "action") {
|
|
2635
|
+
if (s.push({ step: c }), u === a) break;
|
|
2636
|
+
u = c.next;
|
|
2632
2637
|
continue;
|
|
2633
2638
|
}
|
|
2634
|
-
if (
|
|
2635
|
-
const
|
|
2636
|
-
(
|
|
2639
|
+
if (c.actionType === "button") {
|
|
2640
|
+
const f = e.find(
|
|
2641
|
+
(g) => g.chapterId === t && g.sceneId === r && g.stepId === u
|
|
2637
2642
|
);
|
|
2638
|
-
if (!
|
|
2639
|
-
s.push({ step:
|
|
2643
|
+
if (!f) {
|
|
2644
|
+
s.push({ step: c });
|
|
2640
2645
|
break;
|
|
2641
2646
|
}
|
|
2642
|
-
const
|
|
2643
|
-
(
|
|
2647
|
+
const h = c.payload.find(
|
|
2648
|
+
(g) => g.actionId === f.value
|
|
2644
2649
|
);
|
|
2645
|
-
if (!
|
|
2646
|
-
u =
|
|
2650
|
+
if (!h || (s.push({ step: c, selectedAction: h }), u === a)) break;
|
|
2651
|
+
u = h.next;
|
|
2647
2652
|
continue;
|
|
2648
2653
|
}
|
|
2649
|
-
if (
|
|
2650
|
-
|
|
2654
|
+
if (c.actionType === "command") {
|
|
2655
|
+
const f = u, h = Array.from(
|
|
2656
|
+
new Set(
|
|
2657
|
+
e.filter(
|
|
2658
|
+
(S) => S.chapterId === t && S.sceneId === r && S.stepId === f
|
|
2659
|
+
).map((S) => S.value)
|
|
2660
|
+
)
|
|
2661
|
+
);
|
|
2662
|
+
if (s.push({ step: c, validatedActionIds: h }), !c.payload.every(
|
|
2663
|
+
(S) => h.includes(S.actionId)
|
|
2664
|
+
) || u === a) break;
|
|
2665
|
+
u = c.next;
|
|
2666
|
+
}
|
|
2651
2667
|
}
|
|
2652
2668
|
return s;
|
|
2653
2669
|
};
|
|
2654
|
-
class
|
|
2670
|
+
class xr extends w {
|
|
2655
2671
|
async getCurrentStep(e, t) {
|
|
2656
2672
|
const r = await this.get({ user: e, storyId: t });
|
|
2657
2673
|
if (!r) return null;
|
|
2658
|
-
const a = await
|
|
2659
|
-
return a ?
|
|
2674
|
+
const a = await E.get(t);
|
|
2675
|
+
return a ? L(a, r) : null;
|
|
2660
2676
|
}
|
|
2661
2677
|
async getSceneSteps(e, t, r, a) {
|
|
2662
2678
|
const s = await this.get({ user: e, storyId: t });
|
|
2663
2679
|
if (!s) return null;
|
|
2664
|
-
const i = await
|
|
2680
|
+
const i = await E.get(t);
|
|
2665
2681
|
if (!i) return null;
|
|
2666
2682
|
const u = i.chapters[r];
|
|
2667
2683
|
if (!u) return null;
|
|
2668
|
-
const
|
|
2669
|
-
if (!
|
|
2670
|
-
const
|
|
2671
|
-
return
|
|
2672
|
-
|
|
2684
|
+
const c = u.scenes[a];
|
|
2685
|
+
if (!c) return null;
|
|
2686
|
+
const f = s.status === "in_progress" && s.currentChapterId === r && s.currentSceneId === a;
|
|
2687
|
+
return Dr(
|
|
2688
|
+
c,
|
|
2673
2689
|
s.choices,
|
|
2674
2690
|
r,
|
|
2675
2691
|
a,
|
|
2676
|
-
|
|
2692
|
+
f ? s.currentStepId : void 0
|
|
2677
2693
|
);
|
|
2678
2694
|
}
|
|
2679
2695
|
async start(e, t) {
|
|
2680
|
-
const r = await
|
|
2696
|
+
const r = await E.get(t);
|
|
2681
2697
|
if (!r) return null;
|
|
2682
2698
|
const a = r.chapters[r.entryChapterId];
|
|
2683
2699
|
if (!a) return null;
|
|
2684
2700
|
const s = a.scenes[a.entrySceneId];
|
|
2685
2701
|
if (!s) return null;
|
|
2686
|
-
await
|
|
2702
|
+
await vr(e, t), this.invalidate({ user: e, storyId: t });
|
|
2687
2703
|
const i = await Er(
|
|
2688
2704
|
e,
|
|
2689
2705
|
t,
|
|
2690
2706
|
r.entryChapterId,
|
|
2691
2707
|
a.entrySceneId,
|
|
2692
2708
|
s.entryStepId
|
|
2693
|
-
), u =
|
|
2709
|
+
), u = y(i);
|
|
2694
2710
|
return this.cache.set(this.normalizeKey({ user: e, storyId: t }), u), u;
|
|
2695
2711
|
}
|
|
2696
2712
|
async advanceToNext(e, t) {
|
|
2697
2713
|
const r = await this.get({ user: e, storyId: t });
|
|
2698
|
-
if (!r) return { status: "error" };
|
|
2714
|
+
if (!r) return { status: "error", message: "user story not found" };
|
|
2699
2715
|
if (r.status === "completed") return { status: "completed" };
|
|
2700
|
-
const a = await
|
|
2701
|
-
if (!a) return { status: "error" };
|
|
2702
|
-
const s =
|
|
2703
|
-
if (!s) return { status: "error" };
|
|
2716
|
+
const a = await E.get(t);
|
|
2717
|
+
if (!a) return { status: "error", message: "story not found" };
|
|
2718
|
+
const s = L(a, r);
|
|
2719
|
+
if (!s) return { status: "error", message: "current step not found" };
|
|
2704
2720
|
if (s.type === "action") return { status: "action_required" };
|
|
2705
2721
|
if (!s.next) return { status: "scene_ended" };
|
|
2706
2722
|
const i = a.chapters[r.currentChapterId];
|
|
2707
|
-
if (!i)
|
|
2723
|
+
if (!i)
|
|
2724
|
+
return { status: "error", message: "current chapter not found" };
|
|
2708
2725
|
const u = i.scenes[r.currentSceneId];
|
|
2709
|
-
if (!u) return { status: "error" };
|
|
2726
|
+
if (!u) return { status: "error", message: "current scene not found" };
|
|
2710
2727
|
if (!u.steps[s.next]) return { status: "scene_ended" };
|
|
2711
|
-
const
|
|
2728
|
+
const c = await this.advanceTo(
|
|
2712
2729
|
e,
|
|
2713
2730
|
t,
|
|
2714
2731
|
a,
|
|
@@ -2716,12 +2733,12 @@ class Mr extends f {
|
|
|
2716
2733
|
r.currentSceneId,
|
|
2717
2734
|
s.next
|
|
2718
2735
|
);
|
|
2719
|
-
return
|
|
2736
|
+
return c ? { status: "advanced", data: c } : { status: "error", message: "failed to advance step" };
|
|
2720
2737
|
}
|
|
2721
2738
|
async advanceToNextScene(e, t) {
|
|
2722
2739
|
const r = await this.get({ user: e, storyId: t });
|
|
2723
2740
|
if (!r || r.status === "completed") return null;
|
|
2724
|
-
const a = await
|
|
2741
|
+
const a = await E.get(t);
|
|
2725
2742
|
if (!a) return null;
|
|
2726
2743
|
const s = a.chapters[r.currentChapterId];
|
|
2727
2744
|
if (!s) return null;
|
|
@@ -2740,30 +2757,74 @@ class Mr extends f {
|
|
|
2740
2757
|
}
|
|
2741
2758
|
async validateCommandAndAdvance(e, t, r) {
|
|
2742
2759
|
const a = await this.get({ user: e, storyId: t });
|
|
2743
|
-
if (!a || a.status === "completed")
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2760
|
+
if (!a || a.status === "completed")
|
|
2761
|
+
return {
|
|
2762
|
+
status: "error",
|
|
2763
|
+
message: "user story not found or already completed"
|
|
2764
|
+
};
|
|
2765
|
+
const s = await E.get(t);
|
|
2766
|
+
if (!s) return { status: "error", message: "story not found" };
|
|
2767
|
+
const i = L(s, a);
|
|
2747
2768
|
if (!i || i.type !== "action" || i.actionType !== "command")
|
|
2748
|
-
return
|
|
2749
|
-
|
|
2750
|
-
|
|
2769
|
+
return {
|
|
2770
|
+
status: "error",
|
|
2771
|
+
message: "current step is not a command action"
|
|
2772
|
+
};
|
|
2773
|
+
const u = i.payload.find((p) => p.commandId === r);
|
|
2774
|
+
if (!u)
|
|
2775
|
+
return {
|
|
2776
|
+
status: "error",
|
|
2777
|
+
message: `command "${r}" not in step payload`
|
|
2778
|
+
};
|
|
2779
|
+
const c = {
|
|
2780
|
+
chapterId: a.currentChapterId,
|
|
2781
|
+
sceneId: a.currentSceneId,
|
|
2782
|
+
stepId: a.currentStepId,
|
|
2783
|
+
value: u.actionId
|
|
2784
|
+
}, f = a.choices.some(
|
|
2785
|
+
(p) => p.chapterId === c.chapterId && p.sceneId === c.sceneId && p.stepId === c.stepId && p.value === u.actionId
|
|
2786
|
+
), h = new Set(
|
|
2787
|
+
a.choices.filter(
|
|
2788
|
+
(p) => p.chapterId === c.chapterId && p.sceneId === c.sceneId && p.stepId === c.stepId
|
|
2789
|
+
).map((p) => p.value)
|
|
2790
|
+
);
|
|
2791
|
+
if (h.add(u.actionId), !i.payload.every(
|
|
2792
|
+
(p) => h.has(p.actionId)
|
|
2793
|
+
)) {
|
|
2794
|
+
if (f)
|
|
2795
|
+
return {
|
|
2796
|
+
status: "partial",
|
|
2797
|
+
data: a
|
|
2798
|
+
};
|
|
2799
|
+
const p = await this.update(
|
|
2800
|
+
{ user: e, storyId: t },
|
|
2801
|
+
{ $push: { choices: c } }
|
|
2802
|
+
);
|
|
2803
|
+
return p ? {
|
|
2804
|
+
status: "partial",
|
|
2805
|
+
data: p,
|
|
2806
|
+
feedbackStepId: u.next
|
|
2807
|
+
} : { status: "error", message: "failed to record command" };
|
|
2808
|
+
}
|
|
2809
|
+
const S = await this.advanceTo(
|
|
2751
2810
|
e,
|
|
2752
2811
|
t,
|
|
2753
2812
|
s,
|
|
2754
2813
|
a.currentChapterId,
|
|
2755
2814
|
a.currentSceneId,
|
|
2756
|
-
|
|
2757
|
-
|
|
2815
|
+
i.next,
|
|
2816
|
+
f ? void 0 : c
|
|
2817
|
+
);
|
|
2818
|
+
return S ? { status: "advanced", data: S, feedbackStepId: u.next } : { status: "error", message: "failed to advance step" };
|
|
2758
2819
|
}
|
|
2759
2820
|
async validateActionAndAdvance(e, t, r) {
|
|
2760
2821
|
const a = await this.get({ user: e, storyId: t });
|
|
2761
2822
|
if (!a || a.status === "completed") return null;
|
|
2762
|
-
const s = await
|
|
2823
|
+
const s = await E.get(t);
|
|
2763
2824
|
if (!s) return null;
|
|
2764
|
-
const i =
|
|
2825
|
+
const i = L(s, a);
|
|
2765
2826
|
if (!i || i.type !== "action") return null;
|
|
2766
|
-
const u = i.payload.find((
|
|
2827
|
+
const u = i.payload.find((c) => c.actionId === r);
|
|
2767
2828
|
return u ? this.advanceTo(
|
|
2768
2829
|
e,
|
|
2769
2830
|
t,
|
|
@@ -2780,14 +2841,14 @@ class Mr extends f {
|
|
|
2780
2841
|
) : null;
|
|
2781
2842
|
}
|
|
2782
2843
|
async advanceTo(e, t, r, a, s, i, u) {
|
|
2783
|
-
const
|
|
2784
|
-
return
|
|
2844
|
+
const c = Or(r, a, s, i);
|
|
2845
|
+
return c ? this.update(
|
|
2785
2846
|
{ user: e, storyId: t },
|
|
2786
2847
|
{
|
|
2787
2848
|
$set: {
|
|
2788
|
-
currentChapterId:
|
|
2789
|
-
currentSceneId:
|
|
2790
|
-
currentStepId:
|
|
2849
|
+
currentChapterId: c.chapterId,
|
|
2850
|
+
currentSceneId: c.sceneId,
|
|
2851
|
+
currentStepId: c.stepId
|
|
2791
2852
|
},
|
|
2792
2853
|
...u && { $push: { choices: u } }
|
|
2793
2854
|
}
|
|
@@ -2800,12 +2861,12 @@ class Mr extends f {
|
|
|
2800
2861
|
);
|
|
2801
2862
|
}
|
|
2802
2863
|
}
|
|
2803
|
-
const
|
|
2864
|
+
const Mr = (n, e = {}) => j.find(n, null, e).lean(), Ar = (n, e) => j.findOne({ user: n, storyId: e }).lean(), kr = (n, e) => j.findOneAndUpdate(n, e, {
|
|
2804
2865
|
returnDocument: "after"
|
|
2805
2866
|
}).lean();
|
|
2806
|
-
class
|
|
2867
|
+
class qr extends xr {
|
|
2807
2868
|
constructor() {
|
|
2808
|
-
super(
|
|
2869
|
+
super(1800, { maxKeys: 5e4 });
|
|
2809
2870
|
}
|
|
2810
2871
|
normalizeKey(e) {
|
|
2811
2872
|
return `${e.user.toString()}:${e.storyId}`;
|
|
@@ -2814,17 +2875,17 @@ class kr extends Mr {
|
|
|
2814
2875
|
return { user: e.user, storyId: e.storyId };
|
|
2815
2876
|
}
|
|
2816
2877
|
fetchFromDb(e) {
|
|
2817
|
-
return
|
|
2878
|
+
return Ar(e.user, e.storyId);
|
|
2818
2879
|
}
|
|
2819
2880
|
fetchManyFromDb(e, t) {
|
|
2820
|
-
return
|
|
2881
|
+
return Mr(e, t);
|
|
2821
2882
|
}
|
|
2822
2883
|
updateInDb(e, t) {
|
|
2823
|
-
return
|
|
2884
|
+
return kr(e, t);
|
|
2824
2885
|
}
|
|
2825
2886
|
}
|
|
2826
|
-
const Va = new
|
|
2827
|
-
class Rr extends
|
|
2887
|
+
const Va = new qr();
|
|
2888
|
+
class Rr extends m {
|
|
2828
2889
|
async didSevenDoubleAtDoQ(e) {
|
|
2829
2890
|
await this.update(e, {
|
|
2830
2891
|
$inc: { "doubleOrQuit.sevenDoubleInARowCount": 1 }
|
|
@@ -2848,10 +2909,10 @@ class Rr extends y {
|
|
|
2848
2909
|
await this.update(e, { $inc: { drawCount: 1 } });
|
|
2849
2910
|
}
|
|
2850
2911
|
async bet666(e) {
|
|
2851
|
-
const t =
|
|
2912
|
+
const t = G();
|
|
2852
2913
|
t.setHours(0, 0, 0, 0);
|
|
2853
2914
|
const r = /* @__PURE__ */ new Date();
|
|
2854
|
-
r.setHours(0, 0, 0, 0), await
|
|
2915
|
+
r.setHours(0, 0, 0, 0), await q.updateOne(
|
|
2855
2916
|
{
|
|
2856
2917
|
user: e,
|
|
2857
2918
|
"bet666.last": {
|
|
@@ -2860,7 +2921,7 @@ class Rr extends y {
|
|
|
2860
2921
|
}
|
|
2861
2922
|
},
|
|
2862
2923
|
{ $inc: { "bet666.count": 1 }, $set: { "bet666.last": /* @__PURE__ */ new Date() } }
|
|
2863
|
-
), await
|
|
2924
|
+
), await q.updateOne(
|
|
2864
2925
|
{
|
|
2865
2926
|
user: e,
|
|
2866
2927
|
"bet666.last": {
|
|
@@ -2903,14 +2964,14 @@ class Rr extends y {
|
|
|
2903
2964
|
await this.update(e, { $inc: { "dice.drawWithDoubleSixCount": 1 } });
|
|
2904
2965
|
}
|
|
2905
2966
|
}
|
|
2906
|
-
const Cr = async (n) => await
|
|
2967
|
+
const Cr = async (n) => await q.create({
|
|
2907
2968
|
user: n
|
|
2908
2969
|
});
|
|
2909
|
-
async function
|
|
2910
|
-
const e = await
|
|
2911
|
-
return e ||
|
|
2970
|
+
async function Br(n) {
|
|
2971
|
+
const e = await q.findOne({ user: n }).lean();
|
|
2972
|
+
return e || y(await Cr(n));
|
|
2912
2973
|
}
|
|
2913
|
-
const
|
|
2974
|
+
const _r = (n, e) => q.findOneAndUpdate({ user: n }, e, {
|
|
2914
2975
|
upsert: !0,
|
|
2915
2976
|
returnDocument: "after"
|
|
2916
2977
|
}).lean();
|
|
@@ -2925,14 +2986,14 @@ class Fr extends Rr {
|
|
|
2925
2986
|
return e;
|
|
2926
2987
|
}
|
|
2927
2988
|
fetchFromDb(e) {
|
|
2928
|
-
return
|
|
2989
|
+
return Br(e);
|
|
2929
2990
|
}
|
|
2930
2991
|
updateInDb(e, t) {
|
|
2931
|
-
return
|
|
2992
|
+
return _r(e, t);
|
|
2932
2993
|
}
|
|
2933
2994
|
}
|
|
2934
2995
|
const Xa = new Fr();
|
|
2935
|
-
class Nr extends
|
|
2996
|
+
class Nr extends m {
|
|
2936
2997
|
async workIncrement(e) {
|
|
2937
2998
|
await this.update(e, { $inc: { workCount: 1 } });
|
|
2938
2999
|
}
|
|
@@ -2944,14 +3005,14 @@ class Nr extends y {
|
|
|
2944
3005
|
});
|
|
2945
3006
|
}
|
|
2946
3007
|
}
|
|
2947
|
-
const Kr = (n) =>
|
|
3008
|
+
const Kr = (n) => ne.create({
|
|
2948
3009
|
user: n
|
|
2949
3010
|
});
|
|
2950
3011
|
async function Hr(n) {
|
|
2951
|
-
const e = await
|
|
2952
|
-
return e ||
|
|
3012
|
+
const e = await ne.findOne({ user: n }).lean();
|
|
3013
|
+
return e || y(await Kr(n));
|
|
2953
3014
|
}
|
|
2954
|
-
const Pr = (n, e) =>
|
|
3015
|
+
const Pr = (n, e) => ne.findOneAndUpdate({ user: n }, e, {
|
|
2955
3016
|
upsert: !0,
|
|
2956
3017
|
returnDocument: "after"
|
|
2957
3018
|
}).lean();
|
|
@@ -2973,7 +3034,7 @@ class jr extends Nr {
|
|
|
2973
3034
|
}
|
|
2974
3035
|
}
|
|
2975
3036
|
const Ja = new jr();
|
|
2976
|
-
class zr extends
|
|
3037
|
+
class zr extends m {
|
|
2977
3038
|
async hasReportedSomeone(e) {
|
|
2978
3039
|
await this.update(e, { $set: { reportedSomeone: !0 } });
|
|
2979
3040
|
}
|
|
@@ -3004,14 +3065,14 @@ class zr extends y {
|
|
|
3004
3065
|
await this.update(e, { $set: { "gamblingFlags.lose10M": !0 } });
|
|
3005
3066
|
}
|
|
3006
3067
|
}
|
|
3007
|
-
const Lr = async (n) => await
|
|
3068
|
+
const Lr = async (n) => await ae.create({
|
|
3008
3069
|
user: n
|
|
3009
3070
|
});
|
|
3010
3071
|
async function Qr(n) {
|
|
3011
|
-
const e = await
|
|
3012
|
-
return e ||
|
|
3072
|
+
const e = await ae.findOne({ user: n }).lean();
|
|
3073
|
+
return e || y(await Lr(n));
|
|
3013
3074
|
}
|
|
3014
|
-
const Yr = (n, e) =>
|
|
3075
|
+
const Yr = (n, e) => ae.findOneAndUpdate({ user: n }, e, {
|
|
3015
3076
|
upsert: !0,
|
|
3016
3077
|
returnDocument: "after"
|
|
3017
3078
|
}).lean();
|
|
@@ -3033,10 +3094,10 @@ class Gr extends zr {
|
|
|
3033
3094
|
}
|
|
3034
3095
|
}
|
|
3035
3096
|
const Za = new Gr();
|
|
3036
|
-
class Wr extends
|
|
3097
|
+
class Wr extends m {
|
|
3037
3098
|
async readEdito(e) {
|
|
3038
3099
|
const t = /* @__PURE__ */ new Date();
|
|
3039
|
-
t.setHours(0, 0, 0, 0), await
|
|
3100
|
+
t.setHours(0, 0, 0, 0), await O.updateOne(
|
|
3040
3101
|
{
|
|
3041
3102
|
user: e,
|
|
3042
3103
|
"edito.lastTimeRead": {
|
|
@@ -3047,7 +3108,7 @@ class Wr extends y {
|
|
|
3047
3108
|
$inc: { "edito.readToday": 1 },
|
|
3048
3109
|
$set: { "edito.lastTimeRead": /* @__PURE__ */ new Date() }
|
|
3049
3110
|
}
|
|
3050
|
-
), await
|
|
3111
|
+
), await O.updateOne(
|
|
3051
3112
|
{
|
|
3052
3113
|
user: e,
|
|
3053
3114
|
"edito.lastTimeRead": {
|
|
@@ -3061,7 +3122,7 @@ class Wr extends y {
|
|
|
3061
3122
|
}
|
|
3062
3123
|
async getTotalEditoReadToday() {
|
|
3063
3124
|
const e = /* @__PURE__ */ new Date();
|
|
3064
|
-
return e.setHours(0, 0, 0, 0), (await
|
|
3125
|
+
return e.setHours(0, 0, 0, 0), (await O.aggregate([
|
|
3065
3126
|
{
|
|
3066
3127
|
$match: {
|
|
3067
3128
|
"edito.lastTimeRead": { $gte: e },
|
|
@@ -3072,14 +3133,14 @@ class Wr extends y {
|
|
|
3072
3133
|
]))[0]?.total ?? 0;
|
|
3073
3134
|
}
|
|
3074
3135
|
}
|
|
3075
|
-
const Vr = async (n) => await
|
|
3136
|
+
const Vr = async (n) => await O.create({
|
|
3076
3137
|
user: n
|
|
3077
3138
|
});
|
|
3078
3139
|
async function Xr(n) {
|
|
3079
|
-
const e = await
|
|
3080
|
-
return e ||
|
|
3140
|
+
const e = await O.findOne({ user: n }).lean();
|
|
3141
|
+
return e || y(await Vr(n));
|
|
3081
3142
|
}
|
|
3082
|
-
const Jr = (n, e) =>
|
|
3143
|
+
const Jr = (n, e) => O.findOneAndUpdate({ user: n }, e, {
|
|
3083
3144
|
upsert: !0,
|
|
3084
3145
|
returnDocument: "after"
|
|
3085
3146
|
}).lean();
|
|
@@ -3101,10 +3162,10 @@ class Zr extends Wr {
|
|
|
3101
3162
|
}
|
|
3102
3163
|
}
|
|
3103
3164
|
const es = new Zr();
|
|
3104
|
-
class ea extends
|
|
3165
|
+
class ea extends m {
|
|
3105
3166
|
async updateCraftStats(e, t, r) {
|
|
3106
|
-
const a = await
|
|
3107
|
-
!a || !
|
|
3167
|
+
const a = await T.get(r);
|
|
3168
|
+
!a || !T.isItem(a) || await this.update(e, {
|
|
3108
3169
|
$inc: {
|
|
3109
3170
|
"crafts.totalCrafted": t
|
|
3110
3171
|
}
|
|
@@ -3122,7 +3183,7 @@ class ea extends y {
|
|
|
3122
3183
|
}
|
|
3123
3184
|
async incrementBottleUsedToday(e, t) {
|
|
3124
3185
|
const r = /* @__PURE__ */ new Date();
|
|
3125
|
-
r.setHours(0, 0, 0, 0), await
|
|
3186
|
+
r.setHours(0, 0, 0, 0), await R.updateOne(
|
|
3126
3187
|
{
|
|
3127
3188
|
user: e,
|
|
3128
3189
|
"bottle.lastUsed": {
|
|
@@ -3133,7 +3194,7 @@ class ea extends y {
|
|
|
3133
3194
|
$inc: { "bottle.usedToday": t },
|
|
3134
3195
|
$set: { "bottle.lastUsed": /* @__PURE__ */ new Date() }
|
|
3135
3196
|
}
|
|
3136
|
-
), await
|
|
3197
|
+
), await R.updateOne(
|
|
3137
3198
|
{
|
|
3138
3199
|
user: e,
|
|
3139
3200
|
"bottle.lastUsed": {
|
|
@@ -3159,14 +3220,14 @@ class ea extends y {
|
|
|
3159
3220
|
});
|
|
3160
3221
|
}
|
|
3161
3222
|
}
|
|
3162
|
-
const ta = async (n) => await
|
|
3223
|
+
const ta = async (n) => await R.create({
|
|
3163
3224
|
user: n
|
|
3164
3225
|
});
|
|
3165
3226
|
async function na(n) {
|
|
3166
|
-
const e = await
|
|
3167
|
-
return e ||
|
|
3227
|
+
const e = await R.findOne({ user: n }).lean();
|
|
3228
|
+
return e || y(await ta(n));
|
|
3168
3229
|
}
|
|
3169
|
-
const ra = (n, e) =>
|
|
3230
|
+
const ra = (n, e) => R.findOneAndUpdate({ user: n }, e, {
|
|
3170
3231
|
upsert: !0,
|
|
3171
3232
|
returnDocument: "after"
|
|
3172
3233
|
}).lean();
|
|
@@ -3188,73 +3249,62 @@ class aa extends ea {
|
|
|
3188
3249
|
}
|
|
3189
3250
|
}
|
|
3190
3251
|
const ts = new aa();
|
|
3191
|
-
class sa extends
|
|
3252
|
+
class sa extends w {
|
|
3192
3253
|
async maxCraftQuantity(e, t) {
|
|
3193
|
-
const r = await
|
|
3254
|
+
const r = await M.get(e);
|
|
3194
3255
|
let a = 1 / 0;
|
|
3195
3256
|
for (const s of t)
|
|
3196
3257
|
a = Math.min(
|
|
3197
3258
|
a,
|
|
3198
3259
|
Math.floor(
|
|
3199
|
-
(r.itemList[s.entityId] ?? 0) / s.size
|
|
3260
|
+
(r.itemList[s.entityId] ?? 0) / (s.size ?? 1)
|
|
3200
3261
|
)
|
|
3201
3262
|
);
|
|
3202
3263
|
return a;
|
|
3203
3264
|
}
|
|
3204
3265
|
async hasEnoughItemsForRecipe(e, t, r) {
|
|
3205
|
-
const a = await
|
|
3266
|
+
const a = await M.get(e);
|
|
3206
3267
|
for (const s of t.entities)
|
|
3207
|
-
if ((a.itemList[s.entityId] ?? 0) < s.size * r)
|
|
3268
|
+
if ((a.itemList[s.entityId] ?? 0) < (s.size ?? 1) * r)
|
|
3208
3269
|
return !1;
|
|
3209
3270
|
return !0;
|
|
3210
3271
|
}
|
|
3211
|
-
decodeCraftId(e) {
|
|
3212
|
-
return e.split(";").map((t, r) => ({
|
|
3213
|
-
entityId: t === "null" ? null : t,
|
|
3214
|
-
index: r
|
|
3215
|
-
}));
|
|
3216
|
-
}
|
|
3217
|
-
encodeCraftId(e) {
|
|
3218
|
-
return e.map(({ entityId: t }) => `${t}`).join(";");
|
|
3219
|
-
}
|
|
3220
3272
|
async isValidRecipe(e) {
|
|
3221
|
-
return !!(await this.getAll()).find((r) => r.
|
|
3273
|
+
return !!(await this.getAll()).find((r) => r.recipeId === e);
|
|
3222
3274
|
}
|
|
3223
3275
|
async getRecipeResult(e, t) {
|
|
3224
|
-
|
|
3225
|
-
([s, i]) => s.panoplyId === "little_blacksmith" && i !== null
|
|
3226
|
-
);
|
|
3227
|
-
return a?.[1] === "full" && t === "chest_3" ? "chest_blacksmith_3" : a?.[1] === "half" && t === "chest_2" ? "chest_blacksmith_2" : a?.[1] === "half" && t === "chest_1" ? "chest_blacksmith_1" : t;
|
|
3276
|
+
return t;
|
|
3228
3277
|
}
|
|
3229
3278
|
}
|
|
3230
|
-
const ia = new
|
|
3279
|
+
const ia = new o(
|
|
3231
3280
|
{
|
|
3232
3281
|
entityId: { type: String, required: !0 },
|
|
3233
|
-
size: { type: Number,
|
|
3282
|
+
size: { type: Number, default: 1 }
|
|
3234
3283
|
},
|
|
3235
3284
|
{ _id: !1 }
|
|
3236
|
-
), ua = new
|
|
3285
|
+
), ua = new o(
|
|
3237
3286
|
{
|
|
3238
3287
|
entityId: { type: String, required: !0 },
|
|
3239
|
-
size: { type: Number
|
|
3288
|
+
size: { type: Number }
|
|
3240
3289
|
},
|
|
3241
3290
|
{ _id: !1 }
|
|
3242
|
-
),
|
|
3291
|
+
), oa = new o(
|
|
3243
3292
|
{
|
|
3244
|
-
|
|
3245
|
-
|
|
3293
|
+
recipeId: { type: String, unique: !0, required: !0 },
|
|
3294
|
+
rankId: String,
|
|
3295
|
+
type: { type: String, required: !0 },
|
|
3246
3296
|
entities: { type: [ia], required: !0 },
|
|
3247
3297
|
result: { type: ua, required: !0 }
|
|
3248
3298
|
},
|
|
3249
3299
|
{ minimize: !1 }
|
|
3250
|
-
),
|
|
3300
|
+
), ie = d?.Recipes || l("Recipes", oa), ca = async (n) => await ie.create({
|
|
3251
3301
|
...n
|
|
3252
|
-
}), da = async (n, e) =>
|
|
3302
|
+
}), da = async (n, e) => ie.find(n, {}, e).lean();
|
|
3253
3303
|
async function la(n) {
|
|
3254
|
-
const e = await
|
|
3304
|
+
const e = await ie.findOne({ recipeId: n }).lean();
|
|
3255
3305
|
return e || null;
|
|
3256
3306
|
}
|
|
3257
|
-
const pa = (n, e) =>
|
|
3307
|
+
const pa = (n, e) => ie.findOneAndUpdate(n, e, {
|
|
3258
3308
|
returnDocument: "after"
|
|
3259
3309
|
}).lean();
|
|
3260
3310
|
class ya extends sa {
|
|
@@ -3262,7 +3312,7 @@ class ya extends sa {
|
|
|
3262
3312
|
super(3600);
|
|
3263
3313
|
}
|
|
3264
3314
|
createInDb(e) {
|
|
3265
|
-
return
|
|
3315
|
+
return ca(e);
|
|
3266
3316
|
}
|
|
3267
3317
|
updateInDb(e, t) {
|
|
3268
3318
|
return pa(e, t);
|
|
@@ -3277,17 +3327,17 @@ class ya extends sa {
|
|
|
3277
3327
|
return e;
|
|
3278
3328
|
}
|
|
3279
3329
|
getKey(e) {
|
|
3280
|
-
return e.
|
|
3330
|
+
return e.recipeId;
|
|
3281
3331
|
}
|
|
3282
3332
|
}
|
|
3283
|
-
const ns = new ya(), fa = new
|
|
3333
|
+
const ns = new ya(), fa = new o({
|
|
3284
3334
|
bannedUserId: { type: String, index: !0, required: !0 },
|
|
3285
3335
|
authorId: { type: String, required: !0 },
|
|
3286
3336
|
unbannedTimestamp: { type: Date, index: 1 },
|
|
3287
3337
|
reason: { type: String, required: !0 },
|
|
3288
3338
|
guildId: { type: String, required: !0 }
|
|
3289
|
-
}),
|
|
3290
|
-
class ha extends
|
|
3339
|
+
}), ue = d?.Bans || l("Bans", fa), ma = (n, e) => ue.deleteOne({ bannedUserId: n, guildId: e });
|
|
3340
|
+
class ha extends w {
|
|
3291
3341
|
async getUnbanUsers() {
|
|
3292
3342
|
return this.getMany({
|
|
3293
3343
|
unbannedTimestamp: { $lte: /* @__PURE__ */ new Date(), $ne: null }
|
|
@@ -3304,7 +3354,7 @@ class ha extends f {
|
|
|
3304
3354
|
await ma(e, t), this.invalidate({ bannedUserId: e, guildId: t });
|
|
3305
3355
|
}
|
|
3306
3356
|
}
|
|
3307
|
-
const ga = (n) =>
|
|
3357
|
+
const ga = (n) => ue.find(n).lean(), Sa = (n) => ue.findOne(n).lean(), wa = (n, e) => ue.findOneAndUpdate(n, e, {
|
|
3308
3358
|
returnDocument: "after",
|
|
3309
3359
|
upsert: !0
|
|
3310
3360
|
}).lean();
|
|
@@ -3328,14 +3378,14 @@ class ba extends ha {
|
|
|
3328
3378
|
return wa(e, t);
|
|
3329
3379
|
}
|
|
3330
3380
|
}
|
|
3331
|
-
const rs = new ba(), $a = new
|
|
3381
|
+
const rs = new ba(), $a = new o({
|
|
3332
3382
|
senderId: {
|
|
3333
|
-
type:
|
|
3383
|
+
type: o.Types.ObjectId,
|
|
3334
3384
|
required: !0,
|
|
3335
3385
|
ref: "User"
|
|
3336
3386
|
},
|
|
3337
3387
|
receiverId: {
|
|
3338
|
-
type:
|
|
3388
|
+
type: o.Types.ObjectId,
|
|
3339
3389
|
required: !0,
|
|
3340
3390
|
index: !0,
|
|
3341
3391
|
ref: "User"
|
|
@@ -3345,14 +3395,14 @@ const rs = new ba(), $a = new c({
|
|
|
3345
3395
|
meta: {
|
|
3346
3396
|
rps: { type: String, default: void 0 }
|
|
3347
3397
|
}
|
|
3348
|
-
}),
|
|
3398
|
+
}), oe = d?.Invitation || l("Invitation", $a), Ia = (n) => oe.create({
|
|
3349
3399
|
...n
|
|
3350
3400
|
}), Ua = async (n) => {
|
|
3351
|
-
await
|
|
3401
|
+
await oe.deleteMany({
|
|
3352
3402
|
...n
|
|
3353
3403
|
});
|
|
3354
3404
|
};
|
|
3355
|
-
class Ta extends
|
|
3405
|
+
class Ta extends m {
|
|
3356
3406
|
async sendInvitation({
|
|
3357
3407
|
senderId: e,
|
|
3358
3408
|
receiverId: t,
|
|
@@ -3369,12 +3419,12 @@ class Ta extends y {
|
|
|
3369
3419
|
await Ua({ senderId: e, gameMode: r, receiverId: t }), this.invalidate({ senderId: e, gameMode: r, receiverId: t });
|
|
3370
3420
|
}
|
|
3371
3421
|
}
|
|
3372
|
-
const Ea = (n) =>
|
|
3422
|
+
const Ea = (n) => oe.findOne({
|
|
3373
3423
|
...n
|
|
3374
|
-
}).lean(),
|
|
3424
|
+
}).lean(), va = (n, e) => oe.findOneAndUpdate(n, e, {
|
|
3375
3425
|
returnDocument: "after"
|
|
3376
3426
|
}).lean();
|
|
3377
|
-
class
|
|
3427
|
+
class Oa extends Ta {
|
|
3378
3428
|
constructor() {
|
|
3379
3429
|
super(3600);
|
|
3380
3430
|
}
|
|
@@ -3392,11 +3442,11 @@ class Da extends Ta {
|
|
|
3392
3442
|
return Ea(e);
|
|
3393
3443
|
}
|
|
3394
3444
|
updateInDb(e, t) {
|
|
3395
|
-
return
|
|
3445
|
+
return va(e, t);
|
|
3396
3446
|
}
|
|
3397
3447
|
}
|
|
3398
|
-
const as = new
|
|
3399
|
-
class
|
|
3448
|
+
const as = new Oa();
|
|
3449
|
+
class Da extends m {
|
|
3400
3450
|
async randomizeEditoPrice(e) {
|
|
3401
3451
|
const t = Ee(100, 1001);
|
|
3402
3452
|
return await this.update({ guildId: e }, { $set: { "edito.price": t } }), t;
|
|
@@ -3442,7 +3492,7 @@ class va extends y {
|
|
|
3442
3492
|
);
|
|
3443
3493
|
}
|
|
3444
3494
|
}
|
|
3445
|
-
const
|
|
3495
|
+
const xa = new o({
|
|
3446
3496
|
guildId: { type: String, required: !0, unique: !0 },
|
|
3447
3497
|
ranking: {
|
|
3448
3498
|
messageId: { type: String, default: null }
|
|
@@ -3490,16 +3540,16 @@ const Ma = new c({
|
|
|
3490
3540
|
default: []
|
|
3491
3541
|
}
|
|
3492
3542
|
}
|
|
3493
|
-
}),
|
|
3543
|
+
}), he = d?.Settings || l("Settings", xa), Ma = (n) => he.create({
|
|
3494
3544
|
guildId: n
|
|
3495
|
-
}),
|
|
3496
|
-
const e = await
|
|
3497
|
-
return e ||
|
|
3498
|
-
},
|
|
3545
|
+
}), Aa = async (n) => {
|
|
3546
|
+
const e = await he.findOne({ guildId: n }).lean();
|
|
3547
|
+
return e || y(await Ma(n));
|
|
3548
|
+
}, ka = (n, e) => he.findOneAndUpdate(n, e, {
|
|
3499
3549
|
upsert: !0,
|
|
3500
3550
|
returnDocument: "after"
|
|
3501
3551
|
}).lean();
|
|
3502
|
-
class
|
|
3552
|
+
class qa extends Da {
|
|
3503
3553
|
constructor() {
|
|
3504
3554
|
super(3600 * 24 * 30);
|
|
3505
3555
|
}
|
|
@@ -3510,21 +3560,21 @@ class ka extends va {
|
|
|
3510
3560
|
return e;
|
|
3511
3561
|
}
|
|
3512
3562
|
fetchFromDb(e) {
|
|
3513
|
-
return
|
|
3563
|
+
return Aa(e);
|
|
3514
3564
|
}
|
|
3515
3565
|
updateInDb(e, t) {
|
|
3516
|
-
return
|
|
3566
|
+
return ka(e, t);
|
|
3517
3567
|
}
|
|
3518
3568
|
}
|
|
3519
|
-
const ss = new
|
|
3569
|
+
const ss = new qa(), Ra = new o({
|
|
3520
3570
|
warnedUserId: { type: String, required: !0, index: !0 },
|
|
3521
3571
|
authorId: String,
|
|
3522
3572
|
date: { type: Date, default: Date.now() },
|
|
3523
3573
|
reason: { type: String, default: null }
|
|
3524
|
-
}), ce = d?.Warn || l("Warn", Ra), Ca = (n) => ce.countDocuments(n),
|
|
3574
|
+
}), ce = d?.Warn || l("Warn", Ra), Ca = (n) => ce.countDocuments(n), Ba = (n) => ce.create({
|
|
3525
3575
|
...n
|
|
3526
|
-
}),
|
|
3527
|
-
class Fa extends
|
|
3576
|
+
}), _a = (n) => ce.findByIdAndDelete(n).lean();
|
|
3577
|
+
class Fa extends w {
|
|
3528
3578
|
getUserWarns(e) {
|
|
3529
3579
|
return this.getMany({ warnedUserId: e });
|
|
3530
3580
|
}
|
|
@@ -3532,10 +3582,10 @@ class Fa extends f {
|
|
|
3532
3582
|
return Ca({ warnedUserId: e });
|
|
3533
3583
|
}
|
|
3534
3584
|
async createWarn(e) {
|
|
3535
|
-
await
|
|
3585
|
+
await Ba(e);
|
|
3536
3586
|
}
|
|
3537
3587
|
async deleteWarn(e) {
|
|
3538
|
-
const t = await
|
|
3588
|
+
const t = await _a(e);
|
|
3539
3589
|
return t && this.invalidate(this.getKey(t)), t;
|
|
3540
3590
|
}
|
|
3541
3591
|
}
|
|
@@ -3563,29 +3613,29 @@ class Ka extends Fa {
|
|
|
3563
3613
|
const is = new Ka(), us = (n) => {
|
|
3564
3614
|
Qe(n);
|
|
3565
3615
|
};
|
|
3566
|
-
class
|
|
3616
|
+
class os extends Ye.ObjectId {
|
|
3567
3617
|
}
|
|
3568
3618
|
export {
|
|
3569
|
-
|
|
3570
|
-
|
|
3619
|
+
os as ObjectId,
|
|
3620
|
+
$ as QUEST_MIDDLEWARE_EVENT_NAME,
|
|
3571
3621
|
rs as banService,
|
|
3572
3622
|
us as connectToServices,
|
|
3573
|
-
|
|
3574
|
-
|
|
3623
|
+
b as emitQuestMiddlewareEvent,
|
|
3624
|
+
T as entityService,
|
|
3575
3625
|
as as invitationService,
|
|
3576
3626
|
U as ornamentService,
|
|
3577
|
-
|
|
3627
|
+
N as panoplyService,
|
|
3578
3628
|
ns as recipeService,
|
|
3579
3629
|
La as registerQuestMiddlewareEvents,
|
|
3580
3630
|
Rt as reminderService,
|
|
3581
3631
|
ss as settingsService,
|
|
3582
|
-
|
|
3632
|
+
E as storyService,
|
|
3583
3633
|
Qa as userCooldownService,
|
|
3584
3634
|
Ya as userDailyReportService,
|
|
3585
|
-
|
|
3635
|
+
pe as userEncyclopediaService,
|
|
3586
3636
|
Ga as userGamesService,
|
|
3587
|
-
|
|
3588
|
-
|
|
3637
|
+
M as userInventoryService,
|
|
3638
|
+
v as userMetaService,
|
|
3589
3639
|
we as userOrnamentService,
|
|
3590
3640
|
be as userQuestService,
|
|
3591
3641
|
Wa as userRankService,
|