@opfr/services 1.6.0 → 1.8.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 +1138 -790
- package/dist/index.umd.js +1 -1
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.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/reminder/types.d.ts +1 -2
- package/dist/services/reminder/types.d.ts.map +1 -1
- package/dist/services/story/definition/model.d.ts +4 -0
- package/dist/services/story/definition/model.d.ts.map +1 -0
- package/dist/services/story/definition/schema.d.ts +13 -0
- package/dist/services/story/definition/schema.d.ts.map +1 -0
- package/dist/services/story/helper.d.ts +10 -0
- package/dist/services/story/helper.d.ts.map +1 -0
- package/dist/services/story/index.d.ts +3 -0
- package/dist/services/story/index.d.ts.map +1 -0
- package/dist/services/story/process/create.d.ts +3 -0
- package/dist/services/story/process/create.d.ts.map +1 -0
- package/dist/services/story/process/findMany.d.ts +5 -0
- package/dist/services/story/process/findMany.d.ts.map +1 -0
- package/dist/services/story/process/findOne.d.ts +4 -0
- package/dist/services/story/process/findOne.d.ts.map +1 -0
- package/dist/services/story/process/updateOne.d.ts +4 -0
- package/dist/services/story/process/updateOne.d.ts.map +1 -0
- package/dist/services/story/service.d.ts +15 -0
- package/dist/services/story/service.d.ts.map +1 -0
- package/dist/services/story/types.d.ts +11 -0
- package/dist/services/story/types.d.ts.map +1 -0
- package/dist/services/user-cooldown/definition/schema.d.ts.map +1 -1
- package/dist/services/user-cooldown/helper.d.ts +3 -3
- package/dist/services/user-cooldown/helper.d.ts.map +1 -1
- package/dist/services/user-cooldown/index.d.ts +0 -1
- package/dist/services/user-cooldown/index.d.ts.map +1 -1
- package/dist/services/user-cooldown/types.d.ts +1 -8
- package/dist/services/user-cooldown/types.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-settings/definition/schema.d.ts.map +1 -1
- package/dist/services/user-settings/types.d.ts +1 -6
- package/dist/services/user-settings/types.d.ts.map +1 -1
- package/dist/services/user-story/definition/model.d.ts +4 -0
- package/dist/services/user-story/definition/model.d.ts.map +1 -0
- package/dist/services/user-story/definition/schema.d.ts +13 -0
- package/dist/services/user-story/definition/schema.d.ts.map +1 -0
- package/dist/services/user-story/helper.d.ts +31 -0
- package/dist/services/user-story/helper.d.ts.map +1 -0
- package/dist/services/user-story/index.d.ts +3 -0
- package/dist/services/user-story/index.d.ts.map +1 -0
- package/dist/services/user-story/process/create.d.ts +4 -0
- package/dist/services/user-story/process/create.d.ts.map +1 -0
- package/dist/services/user-story/process/deleteOne.d.ts +3 -0
- package/dist/services/user-story/process/deleteOne.d.ts.map +1 -0
- package/dist/services/user-story/process/findMany.d.ts +5 -0
- package/dist/services/user-story/process/findMany.d.ts.map +1 -0
- package/dist/services/user-story/process/findOne.d.ts +5 -0
- package/dist/services/user-story/process/findOne.d.ts.map +1 -0
- package/dist/services/user-story/process/updateOne.d.ts +5 -0
- package/dist/services/user-story/process/updateOne.d.ts.map +1 -0
- package/dist/services/user-story/service.d.ts +15 -0
- package/dist/services/user-story/service.d.ts.map +1 -0
- package/dist/services/user-story/types.d.ts +43 -0
- package/dist/services/user-story/types.d.ts.map +1 -0
- package/dist/services/user-story/utils.d.ts +8 -0
- package/dist/services/user-story/utils.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/services/recipe/data.d.ts +0 -3
- package/dist/services/recipe/data.d.ts.map +0 -1
- package/dist/services/user-cooldown/constants.d.ts +0 -2
- package/dist/services/user-cooldown/constants.d.ts.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { Schema as
|
|
2
|
-
import { QuestStatus as
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import { filterNullAndUndefined as
|
|
6
|
-
const
|
|
1
|
+
import { Schema as c, models as d, model as l, connect as Qe, Types as Ye } from "mongoose";
|
|
2
|
+
import { QuestStatus as A, 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 oe, speakers as it } from "@opfr/definitions";
|
|
3
|
+
import ut from "node-cache";
|
|
4
|
+
import * as Ue from "events";
|
|
5
|
+
import { filterNullAndUndefined as L, recordToArray as B, arrayToRecord as Te, mergeObjects as Q, seededRandom as ct, sortBy as pe, randomBetween as Ee, hasExpire as de, isString as ot, capitalizeAllWords as dt, pickNthByOdds as Se, pickFrom as lt, sameDay as Oe, yesterday as Y, exclude as P } from "@opfr/utils-lang";
|
|
6
|
+
const G = "___ALL_ENTITIES___";
|
|
7
7
|
class y {
|
|
8
8
|
cache;
|
|
9
9
|
constructor(e) {
|
|
10
|
-
this.cache = new
|
|
10
|
+
this.cache = new ut({
|
|
11
11
|
stdTTL: e,
|
|
12
12
|
checkperiod: e * 0.2,
|
|
13
13
|
useClones: !1
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
async get(e, t) {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
17
|
+
const r = this.normalizeKey(e), a = this.cache.get(r);
|
|
18
|
+
if (a)
|
|
19
|
+
return a;
|
|
20
20
|
const s = await this.fetchFromDb(e, t ?? {});
|
|
21
|
-
return s && this.cache.set(
|
|
21
|
+
return s && this.cache.set(r, s), s;
|
|
22
22
|
}
|
|
23
|
-
async update(e, t,
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
const s = this.getKey(
|
|
27
|
-
this.cache.del(
|
|
23
|
+
async update(e, t, r) {
|
|
24
|
+
const a = await this.updateInDb(e, t, r);
|
|
25
|
+
if (a) {
|
|
26
|
+
const s = this.getKey(a);
|
|
27
|
+
this.cache.del(G), this.cache.set(this.normalizeKey(s), a);
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return a;
|
|
30
30
|
}
|
|
31
31
|
invalidate(e) {
|
|
32
|
-
this.cache.del(
|
|
32
|
+
this.cache.del(G), e && this.cache.del(this.normalizeKey(e));
|
|
33
33
|
}
|
|
34
34
|
clearAll() {
|
|
35
35
|
this.cache.flushAll();
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
class
|
|
38
|
+
class f extends y {
|
|
39
39
|
async getAll() {
|
|
40
|
-
const e = this.cache.get(
|
|
40
|
+
const e = this.cache.get(G);
|
|
41
41
|
if (e)
|
|
42
42
|
return e;
|
|
43
43
|
const t = await this.fetchManyFromDb({}, {});
|
|
44
|
-
return this.cache.set(
|
|
45
|
-
this.cache.set(this.normalizeKey(this.getKey(
|
|
44
|
+
return this.cache.set(G, t), t.forEach((r) => {
|
|
45
|
+
this.cache.set(this.normalizeKey(this.getKey(r)), r);
|
|
46
46
|
}), t;
|
|
47
47
|
}
|
|
48
48
|
async getMany(e, t = {}) {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
51
|
-
this.cache.set(this.normalizeKey(this.getKey(
|
|
52
|
-
}),
|
|
49
|
+
const r = await this.fetchManyFromDb(e, t);
|
|
50
|
+
return r.forEach((a) => {
|
|
51
|
+
this.cache.set(this.normalizeKey(this.getKey(a)), a);
|
|
52
|
+
}), r;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
},
|
|
55
|
+
const De = new Ue.EventEmitter(), g = (n, e, t) => {
|
|
56
|
+
De.emit(n, e, t);
|
|
57
|
+
}, La = (n) => {
|
|
58
58
|
for (const [e, t] of Object.entries(n))
|
|
59
|
-
|
|
60
|
-
t(
|
|
59
|
+
De.on(e, (r, a) => {
|
|
60
|
+
t(r, a);
|
|
61
61
|
});
|
|
62
|
-
},
|
|
62
|
+
}, S = {
|
|
63
63
|
USER: "middleware/quest/USER",
|
|
64
64
|
USER_INVENTORY: "middleware/quest/USER_INVENTORY",
|
|
65
65
|
USER_META: "middleware/quest/USER_META",
|
|
@@ -71,10 +71,10 @@ const $e = new ge.EventEmitter(), h = (n, e, t) => {
|
|
|
71
71
|
USER_STATS_FLAGS: "middleware/quest/USER_STATS_FLAGS",
|
|
72
72
|
USER_STATS_FREQUENCY: "middleware/quest/USER_STATS_FREQUENCY",
|
|
73
73
|
USER_STATS_INVENTORY: "middleware/quest/USER_STATS_INVENTORY"
|
|
74
|
-
},
|
|
74
|
+
}, ve = new c(
|
|
75
75
|
{
|
|
76
76
|
user: {
|
|
77
|
-
type:
|
|
77
|
+
type: c.Types.ObjectId,
|
|
78
78
|
required: !0,
|
|
79
79
|
ref: "User",
|
|
80
80
|
index: !0
|
|
@@ -84,42 +84,34 @@ const $e = new ge.EventEmitter(), h = (n, e, t) => {
|
|
|
84
84
|
required: !0,
|
|
85
85
|
index: !0
|
|
86
86
|
},
|
|
87
|
-
status: { type: String, default:
|
|
87
|
+
status: { type: String, default: A.IN_PROGRESS, index: 1 },
|
|
88
88
|
lastCompletionDate: Date,
|
|
89
89
|
streak: Number
|
|
90
90
|
},
|
|
91
91
|
{ minimize: !1 }
|
|
92
92
|
);
|
|
93
|
-
|
|
94
|
-
n &&
|
|
95
|
-
|
|
93
|
+
ve.post("findOneAndUpdate", function(n) {
|
|
94
|
+
n && g(
|
|
95
|
+
S.USER_QUEST,
|
|
96
96
|
n.user._id,
|
|
97
97
|
n
|
|
98
98
|
);
|
|
99
99
|
});
|
|
100
|
-
const R =
|
|
100
|
+
const R = d?.UserQuest || l("UserQuest", ve), pt = new c({
|
|
101
101
|
user: {
|
|
102
|
-
type:
|
|
102
|
+
type: c.Types.ObjectId,
|
|
103
103
|
required: !0,
|
|
104
104
|
unique: !0,
|
|
105
105
|
ref: "User"
|
|
106
106
|
},
|
|
107
|
-
raid: {
|
|
108
|
-
classic: { type: Date, default: /* @__PURE__ */ new Date(0) },
|
|
109
|
-
special: { type: Date, default: /* @__PURE__ */ new Date(0) }
|
|
110
|
-
},
|
|
111
|
-
lockUserCommand: { type: Date, default: /* @__PURE__ */ new Date(0) },
|
|
112
107
|
commands: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
rps: { type: Date, default: /* @__PURE__ */ new Date(0) }
|
|
119
|
-
}
|
|
120
|
-
}), z = c?.UserCooldown || d("UserCooldown", et), tt = new u({
|
|
108
|
+
type: Map,
|
|
109
|
+
of: Date,
|
|
110
|
+
default: /* @__PURE__ */ new Map()
|
|
111
|
+
}
|
|
112
|
+
}), W = d?.UserCooldown || l("UserCooldown", pt), yt = new c({
|
|
121
113
|
user: {
|
|
122
|
-
type:
|
|
114
|
+
type: c.Types.ObjectId,
|
|
123
115
|
required: !0,
|
|
124
116
|
unique: !0,
|
|
125
117
|
ref: "User"
|
|
@@ -133,17 +125,17 @@ const R = c?.UserQuest || d("UserQuest", Ue), et = new u({
|
|
|
133
125
|
},
|
|
134
126
|
previousCompletedQuest: { type: [String], default: [] },
|
|
135
127
|
previousMessageSent: { type: Number, default: 0 }
|
|
136
|
-
}),
|
|
128
|
+
}), V = d?.UserDailyReport || l("UserDailyReport", yt), ft = new c({
|
|
137
129
|
user: {
|
|
138
|
-
type:
|
|
130
|
+
type: c.Types.ObjectId,
|
|
139
131
|
required: !0,
|
|
140
132
|
unique: !0,
|
|
141
133
|
ref: "User"
|
|
142
134
|
},
|
|
143
135
|
encyclopedia: { type: [String], default: [] }
|
|
144
|
-
}),
|
|
136
|
+
}), X = d?.UserEncyclopedia || l("UserEncyclopedia", ft), mt = new c({
|
|
145
137
|
user: {
|
|
146
|
-
type:
|
|
138
|
+
type: c.Types.ObjectId,
|
|
147
139
|
required: !0,
|
|
148
140
|
unique: !0,
|
|
149
141
|
ref: "User",
|
|
@@ -158,10 +150,10 @@ const R = c?.UserQuest || d("UserQuest", Ue), et = new u({
|
|
|
158
150
|
},
|
|
159
151
|
default: null
|
|
160
152
|
}
|
|
161
|
-
}),
|
|
153
|
+
}), J = d?.UserGames || l("UserGames", mt), Me = new c(
|
|
162
154
|
{
|
|
163
155
|
user: {
|
|
164
|
-
type:
|
|
156
|
+
type: c.Types.ObjectId,
|
|
165
157
|
required: !0,
|
|
166
158
|
unique: !0,
|
|
167
159
|
ref: "User"
|
|
@@ -180,23 +172,23 @@ const R = c?.UserQuest || d("UserQuest", Ue), et = new u({
|
|
|
180
172
|
},
|
|
181
173
|
{ minimize: !1 }
|
|
182
174
|
);
|
|
183
|
-
|
|
184
|
-
n &&
|
|
185
|
-
|
|
175
|
+
Me.post("findOneAndUpdate", function(n) {
|
|
176
|
+
n && g(
|
|
177
|
+
S.USER_INVENTORY,
|
|
186
178
|
n.user._id,
|
|
187
179
|
n
|
|
188
180
|
);
|
|
189
181
|
});
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
},
|
|
182
|
+
const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter(), gt = (n, e) => {
|
|
183
|
+
ht.emit(n, e);
|
|
184
|
+
}, v = {
|
|
193
185
|
multiplier: { type: Number, default: 0 },
|
|
194
186
|
origin: String,
|
|
195
187
|
expireAt: { type: Date, default: null },
|
|
196
188
|
startAt: { type: Date, default: null }
|
|
197
|
-
},
|
|
189
|
+
}, xe = new c({
|
|
198
190
|
user: {
|
|
199
|
-
type:
|
|
191
|
+
type: c.Types.ObjectId,
|
|
200
192
|
required: !0,
|
|
201
193
|
unique: !0,
|
|
202
194
|
ref: "User"
|
|
@@ -216,33 +208,33 @@ const W = c?.UserInventory || d("UserInventory", Ee), rt = new ge.EventEmitter()
|
|
|
216
208
|
buffs: {
|
|
217
209
|
cooldown: {
|
|
218
210
|
casino: {
|
|
219
|
-
type: [
|
|
211
|
+
type: [v],
|
|
220
212
|
default: []
|
|
221
213
|
},
|
|
222
214
|
work: {
|
|
223
|
-
type: [
|
|
215
|
+
type: [v],
|
|
224
216
|
default: []
|
|
225
217
|
}
|
|
226
218
|
},
|
|
227
219
|
berry: {
|
|
228
220
|
work: {
|
|
229
|
-
type: [
|
|
221
|
+
type: [v],
|
|
230
222
|
default: []
|
|
231
223
|
},
|
|
232
224
|
global: {
|
|
233
|
-
type: [
|
|
225
|
+
type: [v],
|
|
234
226
|
default: []
|
|
235
227
|
}
|
|
236
228
|
},
|
|
237
229
|
drop: {
|
|
238
230
|
work: {
|
|
239
|
-
type: [
|
|
231
|
+
type: [v],
|
|
240
232
|
default: []
|
|
241
233
|
}
|
|
242
234
|
},
|
|
243
235
|
xp: {
|
|
244
236
|
global: {
|
|
245
|
-
type: [
|
|
237
|
+
type: [v],
|
|
246
238
|
default: []
|
|
247
239
|
}
|
|
248
240
|
}
|
|
@@ -268,16 +260,16 @@ const W = c?.UserInventory || d("UserInventory", Ee), rt = new ge.EventEmitter()
|
|
|
268
260
|
wisdom: { type: Number, default: 0 }
|
|
269
261
|
}
|
|
270
262
|
});
|
|
271
|
-
|
|
272
|
-
n && (
|
|
273
|
-
|
|
263
|
+
xe.post("findOneAndUpdate", async function(n) {
|
|
264
|
+
n && (g(
|
|
265
|
+
S.USER_META,
|
|
274
266
|
n.user._id,
|
|
275
267
|
n
|
|
276
|
-
), n.hp <= 0 &&
|
|
268
|
+
), n.hp <= 0 && gt("death", n.user._id));
|
|
277
269
|
});
|
|
278
|
-
const
|
|
270
|
+
const D = d?.UserMeta || l("UserMeta", xe), Ae = new c({
|
|
279
271
|
user: {
|
|
280
|
-
type:
|
|
272
|
+
type: c.Types.ObjectId,
|
|
281
273
|
required: !0,
|
|
282
274
|
unique: !0,
|
|
283
275
|
ref: "User"
|
|
@@ -292,16 +284,16 @@ const I = c?.UserMeta || d("UserMeta", De), Ie = new u({
|
|
|
292
284
|
unlockedBags: { type: [String], default: ["default"] },
|
|
293
285
|
selectedBag: { type: String, default: "default" }
|
|
294
286
|
});
|
|
295
|
-
|
|
296
|
-
n &&
|
|
297
|
-
|
|
287
|
+
Ae.post("findOneAndUpdate", function(n) {
|
|
288
|
+
n && g(
|
|
289
|
+
S.USER_ORNAMENT,
|
|
298
290
|
n.user._id,
|
|
299
291
|
n
|
|
300
292
|
);
|
|
301
293
|
});
|
|
302
|
-
const
|
|
294
|
+
const ee = d?.UserOrnament || l("UserOrnament", Ae), St = new c({
|
|
303
295
|
user: {
|
|
304
|
-
type:
|
|
296
|
+
type: c.Types.ObjectId,
|
|
305
297
|
required: !0,
|
|
306
298
|
unique: !0,
|
|
307
299
|
ref: "User"
|
|
@@ -312,22 +304,15 @@ const Y = c?.UserOrnament || d("UserOrnament", Ie), it = new u({
|
|
|
312
304
|
sendDailyReport: { type: Boolean, default: !1, index: !0 },
|
|
313
305
|
sendDailyQuest: { type: Boolean, default: !1 },
|
|
314
306
|
reminder: {
|
|
315
|
-
raid: {
|
|
316
|
-
classic: { type: Boolean, default: !1 },
|
|
317
|
-
special: { type: Boolean, default: !1 }
|
|
318
|
-
},
|
|
319
307
|
commands: {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
blackjack: { type: Boolean, default: !1 },
|
|
324
|
-
guess: { type: Boolean, default: !1 },
|
|
325
|
-
rps: { type: Boolean, default: !1 }
|
|
308
|
+
type: Map,
|
|
309
|
+
of: Boolean,
|
|
310
|
+
default: /* @__PURE__ */ new Map()
|
|
326
311
|
}
|
|
327
312
|
}
|
|
328
|
-
}),
|
|
313
|
+
}), F = d?.UserSettings || l("UserSettings", St), qe = new c({
|
|
329
314
|
user: {
|
|
330
|
-
type:
|
|
315
|
+
type: c.Types.ObjectId,
|
|
331
316
|
required: !0,
|
|
332
317
|
unique: !0,
|
|
333
318
|
ref: "User"
|
|
@@ -360,16 +345,16 @@ const Y = c?.UserOrnament || d("UserOrnament", Ie), it = new u({
|
|
|
360
345
|
guessInOneTryCount: { type: Number, default: 0 }
|
|
361
346
|
}
|
|
362
347
|
});
|
|
363
|
-
|
|
364
|
-
n &&
|
|
365
|
-
|
|
348
|
+
qe.post("findOneAndUpdate", function(n) {
|
|
349
|
+
n && g(
|
|
350
|
+
S.USER_STATS_CASINO,
|
|
366
351
|
n.user._id,
|
|
367
352
|
n
|
|
368
353
|
);
|
|
369
354
|
});
|
|
370
|
-
const
|
|
355
|
+
const q = d?.UserStatsCasino || l("UserStatsCasino", qe), ke = new c({
|
|
371
356
|
user: {
|
|
372
|
-
type:
|
|
357
|
+
type: c.Types.ObjectId,
|
|
373
358
|
required: !0,
|
|
374
359
|
unique: !0,
|
|
375
360
|
ref: "User"
|
|
@@ -377,16 +362,16 @@ const M = c?.UserStatsCasino || d("UserStatsCasino", Te), Oe = new u({
|
|
|
377
362
|
workCount: { type: Number, default: 0 },
|
|
378
363
|
totalSpentInShop: { type: Number, default: 0 }
|
|
379
364
|
});
|
|
380
|
-
|
|
381
|
-
n &&
|
|
382
|
-
|
|
365
|
+
ke.post("findOneAndUpdate", function(n) {
|
|
366
|
+
n && g(
|
|
367
|
+
S.USER_STATS_ECONOMY,
|
|
383
368
|
n.user._id,
|
|
384
369
|
n
|
|
385
370
|
);
|
|
386
371
|
});
|
|
387
|
-
const
|
|
372
|
+
const te = d?.UserStatsEconomy || l("UserStatsEconomy", ke), Re = new c({
|
|
388
373
|
user: {
|
|
389
|
-
type:
|
|
374
|
+
type: c.Types.ObjectId,
|
|
390
375
|
required: !0,
|
|
391
376
|
unique: !0,
|
|
392
377
|
ref: "User"
|
|
@@ -396,19 +381,19 @@ const V = c?.UserStatsEconomy || d("UserStatsEconomy", Oe), ve = new u({
|
|
|
396
381
|
randomMessageClaimed: { type: Number, default: 0 },
|
|
397
382
|
writeDifferentChatIds: { type: [String], default: [] }
|
|
398
383
|
});
|
|
399
|
-
|
|
400
|
-
n &&
|
|
401
|
-
|
|
384
|
+
Re.post("findOneAndUpdate", function(n) {
|
|
385
|
+
n && g(
|
|
386
|
+
S.USER_STATS_ENGAGEMENT,
|
|
402
387
|
n.user._id,
|
|
403
388
|
n
|
|
404
389
|
);
|
|
405
390
|
});
|
|
406
|
-
const
|
|
391
|
+
const ne = d?.UserStatsEngagement || l(
|
|
407
392
|
"UserStatsEngagement",
|
|
408
|
-
|
|
409
|
-
),
|
|
393
|
+
Re
|
|
394
|
+
), Ce = new c({
|
|
410
395
|
user: {
|
|
411
|
-
type:
|
|
396
|
+
type: c.Types.ObjectId,
|
|
412
397
|
required: !0,
|
|
413
398
|
unique: !0,
|
|
414
399
|
ref: "User"
|
|
@@ -425,16 +410,16 @@ const X = c?.UserStatsEngagement || d(
|
|
|
425
410
|
loseEverything: { type: Boolean, default: !1 }
|
|
426
411
|
}
|
|
427
412
|
});
|
|
428
|
-
|
|
429
|
-
n &&
|
|
430
|
-
|
|
413
|
+
Ce.post("findOneAndUpdate", function(n) {
|
|
414
|
+
n && g(
|
|
415
|
+
S.USER_STATS_FLAGS,
|
|
431
416
|
n.user._id,
|
|
432
417
|
n
|
|
433
418
|
);
|
|
434
419
|
});
|
|
435
|
-
const
|
|
420
|
+
const re = d?.UserStatsFlags || l("UserStatsFlags", Ce), Be = new c({
|
|
436
421
|
user: {
|
|
437
|
-
type:
|
|
422
|
+
type: c.Types.ObjectId,
|
|
438
423
|
required: !0,
|
|
439
424
|
unique: !0,
|
|
440
425
|
ref: "User"
|
|
@@ -444,19 +429,19 @@ const J = c?.UserStatsFlags || d("UserStatsFlags", Me), ke = new u({
|
|
|
444
429
|
lastTimeRead: { type: Date, default: /* @__PURE__ */ new Date(), index: !0 }
|
|
445
430
|
}
|
|
446
431
|
});
|
|
447
|
-
|
|
448
|
-
n &&
|
|
449
|
-
|
|
432
|
+
Be.post("findOneAndUpdate", function(n) {
|
|
433
|
+
n && g(
|
|
434
|
+
S.USER_STATS_FREQUENCY,
|
|
450
435
|
n.user._id,
|
|
451
436
|
n
|
|
452
437
|
);
|
|
453
438
|
});
|
|
454
|
-
const
|
|
439
|
+
const O = d?.UserStatsFrequency || l(
|
|
455
440
|
"UserStatsFrequency",
|
|
456
|
-
|
|
457
|
-
),
|
|
441
|
+
Be
|
|
442
|
+
), _e = new c({
|
|
458
443
|
user: {
|
|
459
|
-
type:
|
|
444
|
+
type: c.Types.ObjectId,
|
|
460
445
|
required: !0,
|
|
461
446
|
unique: !0,
|
|
462
447
|
ref: "User"
|
|
@@ -481,33 +466,33 @@ const D = c?.UserStatsFrequency || d(
|
|
|
481
466
|
totalCrafted: { type: Number, default: 0 }
|
|
482
467
|
}
|
|
483
468
|
});
|
|
484
|
-
|
|
485
|
-
n &&
|
|
486
|
-
|
|
469
|
+
_e.post("findOneAndUpdate", function(n) {
|
|
470
|
+
n && g(
|
|
471
|
+
S.USER_STATS_INVENTORY,
|
|
487
472
|
n.user._id,
|
|
488
473
|
n
|
|
489
474
|
);
|
|
490
475
|
});
|
|
491
|
-
const k =
|
|
476
|
+
const k = d?.UserStatsInventory || l(
|
|
492
477
|
"UserStatsInventory",
|
|
493
|
-
|
|
494
|
-
),
|
|
478
|
+
_e
|
|
479
|
+
), ye = new c({
|
|
495
480
|
discordId: { type: String, required: !0, unique: !0 },
|
|
496
481
|
scam: { type: Boolean, default: !1 },
|
|
497
482
|
birthday: { type: Date, default: null, index: 1 },
|
|
498
|
-
faction: { type: String, default:
|
|
483
|
+
faction: { type: String, default: Ge, index: 1 },
|
|
499
484
|
canChangeFaction: { type: Boolean, default: !1 },
|
|
500
485
|
canChooseFaction: { type: Boolean, default: !1 }
|
|
501
486
|
});
|
|
502
|
-
|
|
503
|
-
n &&
|
|
487
|
+
ye.post("findOneAndUpdate", function(n) {
|
|
488
|
+
n && g(S.USER, n._id, n);
|
|
504
489
|
});
|
|
505
|
-
|
|
490
|
+
ye.post("deleteOne", async function() {
|
|
506
491
|
const n = this.getQuery()._id;
|
|
507
|
-
await
|
|
492
|
+
await W.deleteOne({ user: n }), await V.deleteOne({ user: n }), await X.deleteOne({ user: n }), await J.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await D.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await R.deleteMany({ user: n }), await F.deleteOne({ user: n }), await q.deleteOne({ user: n }), await te.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await re.deleteOne({ user: n }), await O.deleteOne({ user: n }), await k.deleteOne({ user: n });
|
|
508
493
|
});
|
|
509
|
-
const w =
|
|
510
|
-
class
|
|
494
|
+
const w = d?.User || l("User", ye);
|
|
495
|
+
class wt extends f {
|
|
511
496
|
getByObjectId(e) {
|
|
512
497
|
return this.update({ _id: e }, {});
|
|
513
498
|
}
|
|
@@ -634,7 +619,7 @@ class ut extends m {
|
|
|
634
619
|
return R.aggregate([
|
|
635
620
|
{
|
|
636
621
|
$match: {
|
|
637
|
-
status:
|
|
622
|
+
status: A.COMPLETED
|
|
638
623
|
}
|
|
639
624
|
},
|
|
640
625
|
{
|
|
@@ -725,18 +710,18 @@ class ut extends m {
|
|
|
725
710
|
);
|
|
726
711
|
}
|
|
727
712
|
}
|
|
728
|
-
const
|
|
713
|
+
const bt = (n, e) => w.find(n, {}, e).lean(), p = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), $t = (n) => w.create({
|
|
729
714
|
discordId: n
|
|
730
715
|
});
|
|
731
|
-
async function
|
|
732
|
-
const
|
|
733
|
-
return !
|
|
716
|
+
async function It(n, { upsert: e = !0, ...t }) {
|
|
717
|
+
const r = await w.findOne({ discordId: n }, {}, t).lean();
|
|
718
|
+
return !r && e ? p(await $t(n)) : r;
|
|
734
719
|
}
|
|
735
|
-
const
|
|
720
|
+
const Ut = (n, e) => w.findOneAndUpdate(n, e, {
|
|
736
721
|
upsert: !0,
|
|
737
722
|
returnDocument: "after"
|
|
738
723
|
}).lean();
|
|
739
|
-
class
|
|
724
|
+
class Tt extends wt {
|
|
740
725
|
constructor() {
|
|
741
726
|
super(3600);
|
|
742
727
|
}
|
|
@@ -747,19 +732,19 @@ class pt extends ut {
|
|
|
747
732
|
return e;
|
|
748
733
|
}
|
|
749
734
|
fetchFromDb(e, t) {
|
|
750
|
-
return
|
|
735
|
+
return It(e, t);
|
|
751
736
|
}
|
|
752
737
|
fetchManyFromDb(e, t) {
|
|
753
|
-
return
|
|
738
|
+
return bt(e, t);
|
|
754
739
|
}
|
|
755
740
|
updateInDb(e, t) {
|
|
756
|
-
return
|
|
741
|
+
return Ut(e, t);
|
|
757
742
|
}
|
|
758
743
|
}
|
|
759
|
-
const
|
|
744
|
+
const Et = new Tt(), Ot = new c(
|
|
760
745
|
{
|
|
761
746
|
user: {
|
|
762
|
-
type:
|
|
747
|
+
type: c.Types.ObjectId,
|
|
763
748
|
ref: "User",
|
|
764
749
|
required: !0,
|
|
765
750
|
index: !0
|
|
@@ -768,53 +753,53 @@ const yt = new pt(), yr = ["work", ...Ke], ft = new u(
|
|
|
768
753
|
type: { type: String, required: !0 }
|
|
769
754
|
},
|
|
770
755
|
{ minimize: !1 }
|
|
771
|
-
),
|
|
772
|
-
await
|
|
773
|
-
},
|
|
774
|
-
await
|
|
756
|
+
), N = d?.Reminder || l("Reminder", Ot), Dt = async (n) => {
|
|
757
|
+
await N.deleteMany(n);
|
|
758
|
+
}, vt = async (n, e) => {
|
|
759
|
+
await N.deleteOne({ user: n, type: e });
|
|
775
760
|
};
|
|
776
|
-
class
|
|
761
|
+
class Mt extends f {
|
|
777
762
|
getAllPassedReminder() {
|
|
778
763
|
return this.getMany({ date: { $lte: /* @__PURE__ */ new Date() } });
|
|
779
764
|
}
|
|
780
|
-
async addReminder(e, t,
|
|
781
|
-
await this.update({ user: e, type: t }, { $set: { date:
|
|
765
|
+
async addReminder(e, t, r) {
|
|
766
|
+
await this.update({ user: e, type: t }, { $set: { date: r } }, { upsert: !0 });
|
|
782
767
|
}
|
|
783
|
-
async updateReminderDate(e, t,
|
|
768
|
+
async updateReminderDate(e, t, r) {
|
|
784
769
|
await this.update({ user: e, type: t }, [
|
|
785
770
|
{
|
|
786
771
|
$set: {
|
|
787
772
|
date: {
|
|
788
|
-
$add: ["$date",
|
|
773
|
+
$add: ["$date", r]
|
|
789
774
|
}
|
|
790
775
|
}
|
|
791
776
|
}
|
|
792
777
|
]);
|
|
793
778
|
}
|
|
794
779
|
async removeReminder(e, t) {
|
|
795
|
-
await
|
|
780
|
+
await vt(e, t), this.invalidate({ user: e, type: t });
|
|
796
781
|
}
|
|
797
782
|
async deleteSelectedReminders(e) {
|
|
798
|
-
const t = e.map((
|
|
799
|
-
await
|
|
800
|
-
this.invalidate({ user:
|
|
783
|
+
const t = e.map((r) => r._id);
|
|
784
|
+
await Dt({ _id: { $in: t } }), e.forEach((r) => {
|
|
785
|
+
this.invalidate({ user: r.user, type: r.type });
|
|
801
786
|
});
|
|
802
787
|
}
|
|
803
788
|
}
|
|
804
|
-
function
|
|
805
|
-
return
|
|
789
|
+
function xt(n, e) {
|
|
790
|
+
return N.find(n, {}, e).lean();
|
|
806
791
|
}
|
|
807
|
-
async function
|
|
808
|
-
const e = await
|
|
792
|
+
async function At(n) {
|
|
793
|
+
const e = await N.findOne(n).lean();
|
|
809
794
|
return e || null;
|
|
810
795
|
}
|
|
811
|
-
async function
|
|
812
|
-
return
|
|
796
|
+
async function qt(n, e, t) {
|
|
797
|
+
return N.findOneAndUpdate(n, e, {
|
|
813
798
|
...t,
|
|
814
799
|
returnDocument: "after"
|
|
815
800
|
}).lean();
|
|
816
801
|
}
|
|
817
|
-
class
|
|
802
|
+
class kt extends Mt {
|
|
818
803
|
constructor() {
|
|
819
804
|
super(300);
|
|
820
805
|
}
|
|
@@ -828,66 +813,66 @@ class $t extends gt {
|
|
|
828
813
|
return `${e.toString()}/${t}`;
|
|
829
814
|
}
|
|
830
815
|
fetchFromDb(e) {
|
|
831
|
-
return
|
|
816
|
+
return At(e);
|
|
832
817
|
}
|
|
833
818
|
fetchManyFromDb(e, t) {
|
|
834
|
-
return
|
|
819
|
+
return xt(e, t);
|
|
835
820
|
}
|
|
836
|
-
updateInDb(e, t,
|
|
837
|
-
return
|
|
821
|
+
updateInDb(e, t, r = { upsert: !1 }) {
|
|
822
|
+
return qt(e, t, r);
|
|
838
823
|
}
|
|
839
824
|
}
|
|
840
|
-
const
|
|
825
|
+
const Rt = new kt(), Ct = new c(
|
|
841
826
|
{
|
|
842
827
|
panoplyId: { unique: !0, index: 1, required: !0, type: String },
|
|
843
828
|
name: { required: !0, type: String },
|
|
844
829
|
equipments: {
|
|
845
830
|
required: !0,
|
|
846
|
-
type: [{ type:
|
|
831
|
+
type: [{ type: c.Types.ObjectId, ref: "Entities" }]
|
|
847
832
|
},
|
|
848
833
|
fullBonusStr: { type: String },
|
|
849
834
|
halfBonusStr: { type: String },
|
|
850
|
-
fullBonus:
|
|
851
|
-
halfBonus:
|
|
835
|
+
fullBonus: c.Types.Mixed,
|
|
836
|
+
halfBonus: c.Types.Mixed
|
|
852
837
|
},
|
|
853
838
|
{ minimize: !1 }
|
|
854
|
-
),
|
|
855
|
-
async function
|
|
856
|
-
const e = await
|
|
839
|
+
), K = d?.Panoplies || l("Panoplies", Ct), Bt = (n, e) => K.find(n, {}, e).lean(), _t = async (n, e) => K.find(n, {}, e).populate("equipments");
|
|
840
|
+
async function Ft(n) {
|
|
841
|
+
const e = await K.findOne({ panoplyId: n }).lean();
|
|
857
842
|
return e || null;
|
|
858
843
|
}
|
|
859
|
-
const
|
|
860
|
-
class
|
|
844
|
+
const Nt = async (n) => K.findOne(n).populate("equipments");
|
|
845
|
+
class Kt extends f {
|
|
861
846
|
getAllPopulated() {
|
|
862
|
-
return
|
|
847
|
+
return _t({}, {});
|
|
863
848
|
}
|
|
864
849
|
getPopulated(e) {
|
|
865
|
-
return
|
|
850
|
+
return Nt({ panoplyId: e });
|
|
866
851
|
}
|
|
867
852
|
hasPanoply(e, t) {
|
|
868
|
-
const
|
|
869
|
-
(s) =>
|
|
853
|
+
const r = L(Object.values(e)), a = t.equipments.filter(
|
|
854
|
+
(s) => r.find((i) => i.entityId === s.entityId)
|
|
870
855
|
).length;
|
|
871
|
-
if (
|
|
856
|
+
if (a === t.equipments.length)
|
|
872
857
|
return t.fullBonus;
|
|
873
|
-
if (
|
|
858
|
+
if (a >= t.equipments.length / 2)
|
|
874
859
|
return t.halfBonus;
|
|
875
860
|
}
|
|
876
861
|
async getPanoplyBonus(e) {
|
|
877
|
-
const t = [],
|
|
878
|
-
for (const
|
|
879
|
-
const s =
|
|
880
|
-
(
|
|
862
|
+
const t = [], r = await this.getAllPopulated();
|
|
863
|
+
for (const a of r) {
|
|
864
|
+
const s = L(Object.values(e)), i = a.equipments.filter(
|
|
865
|
+
(u) => s.find(({ entityId: o }) => o === u.entityId)
|
|
881
866
|
);
|
|
882
|
-
i.length ===
|
|
867
|
+
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]);
|
|
883
868
|
}
|
|
884
869
|
return t;
|
|
885
870
|
}
|
|
886
871
|
}
|
|
887
|
-
const
|
|
872
|
+
const Ht = async (n, e) => K.findOneAndUpdate(n, e, {
|
|
888
873
|
returnDocument: "after"
|
|
889
874
|
}).lean();
|
|
890
|
-
class
|
|
875
|
+
class Pt extends Kt {
|
|
891
876
|
constructor() {
|
|
892
877
|
super(3600);
|
|
893
878
|
}
|
|
@@ -898,26 +883,26 @@ class kt extends vt {
|
|
|
898
883
|
return e;
|
|
899
884
|
}
|
|
900
885
|
updateInDb(e, t) {
|
|
901
|
-
return
|
|
886
|
+
return Ht(e, t);
|
|
902
887
|
}
|
|
903
888
|
fetchFromDb(e) {
|
|
904
|
-
return
|
|
889
|
+
return Ft(e);
|
|
905
890
|
}
|
|
906
891
|
fetchManyFromDb(e, t) {
|
|
907
|
-
return
|
|
892
|
+
return Bt(e, t);
|
|
908
893
|
}
|
|
909
894
|
}
|
|
910
|
-
const
|
|
895
|
+
const _ = new Pt(), jt = new c(
|
|
911
896
|
{
|
|
912
897
|
type: {
|
|
913
898
|
type: String,
|
|
914
|
-
enum:
|
|
899
|
+
enum: We,
|
|
915
900
|
required: !0
|
|
916
901
|
},
|
|
917
|
-
params: { type:
|
|
902
|
+
params: { type: c.Types.Mixed }
|
|
918
903
|
},
|
|
919
904
|
{ _id: !1 }
|
|
920
|
-
),
|
|
905
|
+
), zt = new c(
|
|
921
906
|
{
|
|
922
907
|
entityId: { unique: !0, required: !0, type: String }
|
|
923
908
|
},
|
|
@@ -925,11 +910,11 @@ const A = new kt(), At = new u(
|
|
|
925
910
|
minimize: !1,
|
|
926
911
|
discriminatorKey: "type"
|
|
927
912
|
}
|
|
928
|
-
),
|
|
913
|
+
), Lt = new c({
|
|
929
914
|
category: { required: !0, type: String },
|
|
930
915
|
subtype: { type: String },
|
|
931
916
|
rankId: String,
|
|
932
|
-
effects: { type: [
|
|
917
|
+
effects: { type: [jt], default: [] },
|
|
933
918
|
usage: {
|
|
934
919
|
_id: !1,
|
|
935
920
|
type: {
|
|
@@ -938,17 +923,17 @@ const A = new kt(), At = new u(
|
|
|
938
923
|
},
|
|
939
924
|
default: void 0
|
|
940
925
|
}
|
|
941
|
-
}),
|
|
926
|
+
}), Qt = new c({
|
|
942
927
|
category: { required: !0, type: String },
|
|
943
928
|
characteristics: {
|
|
944
929
|
_id: !1,
|
|
945
930
|
type: Object
|
|
946
931
|
},
|
|
947
932
|
panoply: String
|
|
948
|
-
}),
|
|
949
|
-
|
|
950
|
-
const
|
|
951
|
-
class
|
|
933
|
+
}), C = d?.Entities || l("Entities", zt), Yt = C.discriminator("item", Lt);
|
|
934
|
+
C.discriminator("equipment", Qt);
|
|
935
|
+
const Gt = async (n, e) => C.find(n, {}, e).lean(), Wt = async (n, e) => Yt.find(n, {}, e).lean();
|
|
936
|
+
class Vt extends f {
|
|
952
937
|
isEntity(e) {
|
|
953
938
|
return !!e && "entityId" in e;
|
|
954
939
|
}
|
|
@@ -959,7 +944,7 @@ class Ft extends m {
|
|
|
959
944
|
return e.type === "equipment";
|
|
960
945
|
}
|
|
961
946
|
async isEntityId(e, t = () => !0) {
|
|
962
|
-
return (await this.getAll()).filter(t).map(({ entityId:
|
|
947
|
+
return (await this.getAll()).filter(t).map(({ entityId: a }) => a).includes(e);
|
|
963
948
|
}
|
|
964
949
|
async idArrayToEntities(e) {
|
|
965
950
|
return (await this.getAll()).filter(
|
|
@@ -971,14 +956,14 @@ class Ft extends m {
|
|
|
971
956
|
}
|
|
972
957
|
async recordToEntityTuple(e) {
|
|
973
958
|
const t = await this.getAll();
|
|
974
|
-
return B(e).reduce((
|
|
975
|
-
const i = t.find(({ entityId:
|
|
976
|
-
return i &&
|
|
959
|
+
return B(e).reduce((r, [a, s]) => {
|
|
960
|
+
const i = t.find(({ entityId: u }) => u === a);
|
|
961
|
+
return i && r.push([i, s]), r;
|
|
977
962
|
}, []);
|
|
978
963
|
}
|
|
979
964
|
async getAllEntitiesLimit() {
|
|
980
965
|
const e = await this.getAll();
|
|
981
|
-
return
|
|
966
|
+
return Te(
|
|
982
967
|
e.map((t) => [t.entityId, t.shop?.limit ?? 0])
|
|
983
968
|
);
|
|
984
969
|
}
|
|
@@ -986,17 +971,17 @@ class Ft extends m {
|
|
|
986
971
|
return (await this.getAll()).filter(e);
|
|
987
972
|
}
|
|
988
973
|
async getAllItemsBy(e) {
|
|
989
|
-
return (await
|
|
974
|
+
return (await Wt({}, {})).filter(e);
|
|
990
975
|
}
|
|
991
976
|
async fromDBToEquipableEquipment(e) {
|
|
992
|
-
const
|
|
993
|
-
(
|
|
977
|
+
const r = (await this.getAll()).filter(
|
|
978
|
+
(a) => this.isEquipment(a)
|
|
994
979
|
).find(
|
|
995
|
-
({ entityId:
|
|
980
|
+
({ entityId: a }) => a === e.entityId
|
|
996
981
|
);
|
|
997
|
-
if (!
|
|
982
|
+
if (!r)
|
|
998
983
|
throw new Error(`cannot find any equipment: ${e.entityId}`);
|
|
999
|
-
return this.seedEquipment(
|
|
984
|
+
return this.seedEquipment(r, e.seed);
|
|
1000
985
|
}
|
|
1001
986
|
async getUserEquipmentsCharacteristics(e) {
|
|
1002
987
|
let t = {
|
|
@@ -1007,21 +992,21 @@ class Ft extends m {
|
|
|
1007
992
|
intelligence: 0,
|
|
1008
993
|
wisdom: 0
|
|
1009
994
|
};
|
|
1010
|
-
const
|
|
1011
|
-
for (const
|
|
1012
|
-
const s = e[
|
|
1013
|
-
s && (t =
|
|
995
|
+
const r = await _.getAllPopulated();
|
|
996
|
+
for (const a of Ie) {
|
|
997
|
+
const s = e[a];
|
|
998
|
+
s && (t = Q(
|
|
1014
999
|
t,
|
|
1015
1000
|
(await this.fromDBToEquipableEquipment(s)).characteristics,
|
|
1016
|
-
(i,
|
|
1001
|
+
(i, u) => i + u
|
|
1017
1002
|
));
|
|
1018
1003
|
}
|
|
1019
|
-
for (const
|
|
1020
|
-
const s =
|
|
1021
|
-
s && !("target" in s) && (t =
|
|
1004
|
+
for (const a of r) {
|
|
1005
|
+
const s = _.hasPanoply(e, a);
|
|
1006
|
+
s && !("target" in s) && (t = Q(
|
|
1022
1007
|
t,
|
|
1023
1008
|
s,
|
|
1024
|
-
(i,
|
|
1009
|
+
(i, u) => i + u
|
|
1025
1010
|
));
|
|
1026
1011
|
}
|
|
1027
1012
|
return t;
|
|
@@ -1049,7 +1034,7 @@ class Ft extends m {
|
|
|
1049
1034
|
return e.entityId === t.entityId && e.seed === t.seed;
|
|
1050
1035
|
}
|
|
1051
1036
|
seedEquipment(e, t) {
|
|
1052
|
-
const
|
|
1037
|
+
const r = ct(t), a = pe(
|
|
1053
1038
|
B(e.characteristics),
|
|
1054
1039
|
([s]) => s
|
|
1055
1040
|
);
|
|
@@ -1057,44 +1042,44 @@ class Ft extends m {
|
|
|
1057
1042
|
...e,
|
|
1058
1043
|
seed: t,
|
|
1059
1044
|
characteristics: Object.fromEntries(
|
|
1060
|
-
|
|
1045
|
+
a.map(([s, i]) => [
|
|
1061
1046
|
s,
|
|
1062
|
-
Array.isArray(i) ?
|
|
1047
|
+
Array.isArray(i) ? Ee(i[0], i[1] + 1, r) : i
|
|
1063
1048
|
])
|
|
1064
1049
|
)
|
|
1065
1050
|
};
|
|
1066
1051
|
}
|
|
1067
1052
|
isEquipped(e, t) {
|
|
1068
1053
|
return !!Object.values(e).find(
|
|
1069
|
-
(
|
|
1054
|
+
(r) => r && this.isSameEquipment(r, t)
|
|
1070
1055
|
);
|
|
1071
1056
|
}
|
|
1072
1057
|
}
|
|
1073
|
-
const
|
|
1058
|
+
const Xt = async (n) => await C.create({
|
|
1074
1059
|
...n
|
|
1075
1060
|
});
|
|
1076
|
-
async function
|
|
1077
|
-
const e = await
|
|
1061
|
+
async function Jt(n) {
|
|
1062
|
+
const e = await C.findOne({ entityId: n }).lean();
|
|
1078
1063
|
return e || null;
|
|
1079
1064
|
}
|
|
1080
|
-
const
|
|
1065
|
+
const Zt = (n, e) => C.findOneAndUpdate(n, e, {
|
|
1081
1066
|
returnDocument: "after"
|
|
1082
1067
|
}).lean();
|
|
1083
|
-
class
|
|
1068
|
+
class en extends Vt {
|
|
1084
1069
|
constructor() {
|
|
1085
1070
|
super(3600);
|
|
1086
1071
|
}
|
|
1087
1072
|
createInDb(e) {
|
|
1088
|
-
return
|
|
1073
|
+
return Xt(e);
|
|
1089
1074
|
}
|
|
1090
1075
|
updateInDb(e, t) {
|
|
1091
|
-
return
|
|
1076
|
+
return Zt(e, t);
|
|
1092
1077
|
}
|
|
1093
1078
|
fetchFromDb(e) {
|
|
1094
|
-
return
|
|
1079
|
+
return Jt(e);
|
|
1095
1080
|
}
|
|
1096
1081
|
fetchManyFromDb(e, t) {
|
|
1097
|
-
return
|
|
1082
|
+
return Gt(e, t);
|
|
1098
1083
|
}
|
|
1099
1084
|
normalizeKey(e) {
|
|
1100
1085
|
return e;
|
|
@@ -1103,8 +1088,8 @@ class jt extends Ft {
|
|
|
1103
1088
|
return e.entityId;
|
|
1104
1089
|
}
|
|
1105
1090
|
}
|
|
1106
|
-
const
|
|
1107
|
-
class
|
|
1091
|
+
const U = new en();
|
|
1092
|
+
class tn extends y {
|
|
1108
1093
|
hasAlreadyFoundEntity(e, t) {
|
|
1109
1094
|
return e.encyclopedia.includes(t);
|
|
1110
1095
|
}
|
|
@@ -1114,23 +1099,23 @@ class Pt extends y {
|
|
|
1114
1099
|
});
|
|
1115
1100
|
}
|
|
1116
1101
|
}
|
|
1117
|
-
const
|
|
1102
|
+
const nn = async (n) => await X.create({
|
|
1118
1103
|
user: n
|
|
1119
1104
|
});
|
|
1120
|
-
async function
|
|
1121
|
-
const e = await
|
|
1122
|
-
return e || p(await
|
|
1105
|
+
async function rn(n) {
|
|
1106
|
+
const e = await X.findOne({ user: n }).lean();
|
|
1107
|
+
return e || p(await nn(n));
|
|
1123
1108
|
}
|
|
1124
|
-
const
|
|
1109
|
+
const an = (n, e) => X.findOneAndUpdate({ user: n }, e, {
|
|
1125
1110
|
upsert: !0,
|
|
1126
1111
|
returnDocument: "after"
|
|
1127
1112
|
}).lean();
|
|
1128
|
-
class
|
|
1113
|
+
class sn extends tn {
|
|
1129
1114
|
constructor() {
|
|
1130
1115
|
super(300);
|
|
1131
1116
|
}
|
|
1132
1117
|
fetchFromDb(e) {
|
|
1133
|
-
return
|
|
1118
|
+
return rn(e);
|
|
1134
1119
|
}
|
|
1135
1120
|
getKey({ user: e }) {
|
|
1136
1121
|
return e;
|
|
@@ -1139,11 +1124,11 @@ class Gt extends Pt {
|
|
|
1139
1124
|
return e.toString();
|
|
1140
1125
|
}
|
|
1141
1126
|
updateInDb(e, t) {
|
|
1142
|
-
return
|
|
1127
|
+
return an(e, t);
|
|
1143
1128
|
}
|
|
1144
1129
|
}
|
|
1145
|
-
const
|
|
1146
|
-
class
|
|
1130
|
+
const le = new sn();
|
|
1131
|
+
class un extends y {
|
|
1147
1132
|
async getUserEquipmentsCharacteristics(e) {
|
|
1148
1133
|
let t = {
|
|
1149
1134
|
vitality: 0,
|
|
@@ -1153,79 +1138,85 @@ class Wt extends y {
|
|
|
1153
1138
|
intelligence: 0,
|
|
1154
1139
|
wisdom: 0
|
|
1155
1140
|
};
|
|
1156
|
-
for (const
|
|
1157
|
-
const
|
|
1158
|
-
if (!
|
|
1141
|
+
for (const r of Ie) {
|
|
1142
|
+
const a = e.equippedItems?.[r];
|
|
1143
|
+
if (!a)
|
|
1159
1144
|
continue;
|
|
1160
|
-
const s = await
|
|
1161
|
-
t =
|
|
1145
|
+
const s = await U.fromDBToEquipableEquipment(a);
|
|
1146
|
+
t = Q(
|
|
1162
1147
|
t,
|
|
1163
1148
|
s.characteristics,
|
|
1164
|
-
(i,
|
|
1149
|
+
(i, u) => i + u
|
|
1165
1150
|
);
|
|
1166
1151
|
}
|
|
1167
1152
|
return t;
|
|
1168
1153
|
}
|
|
1169
1154
|
async hasInventoryRequirements(e, t) {
|
|
1170
|
-
const
|
|
1155
|
+
const r = await this.get(e);
|
|
1171
1156
|
return B(t).reduce(
|
|
1172
|
-
(
|
|
1157
|
+
(a, [s, i]) => a && (r.itemList[s] ?? 0) >= (i ?? 0),
|
|
1173
1158
|
!0
|
|
1174
1159
|
);
|
|
1175
1160
|
}
|
|
1176
|
-
async hasEnoughEntity(e, t,
|
|
1177
|
-
return ((await this.get(e)).itemList[
|
|
1161
|
+
async hasEnoughEntity(e, t, r) {
|
|
1162
|
+
return ((await this.get(e)).itemList[r] ?? 0) >= t;
|
|
1178
1163
|
}
|
|
1179
1164
|
async getItemList(e) {
|
|
1180
1165
|
return (await this.get(e)).itemList;
|
|
1181
1166
|
}
|
|
1182
1167
|
async calcMinStreakForWorkLoot(e) {
|
|
1183
|
-
const t = await this.get(e),
|
|
1184
|
-
([
|
|
1168
|
+
const t = await this.get(e), r = (await _.getPanoplyBonus(t.equippedItems)).find(
|
|
1169
|
+
([a, s]) => a.panoplyId === "marine" && s !== null
|
|
1185
1170
|
);
|
|
1186
|
-
return
|
|
1171
|
+
return r && r[1] === "full" ? 10 : r && r[1] === "half" ? 20 : 1 / 0;
|
|
1187
1172
|
}
|
|
1188
1173
|
async hasRevolutionaryBuff(e) {
|
|
1189
1174
|
const t = await this.get(e);
|
|
1190
|
-
return (await
|
|
1191
|
-
([
|
|
1175
|
+
return (await _.getPanoplyBonus(t.equippedItems)).find(
|
|
1176
|
+
([a, s]) => a.panoplyId === "revolutionary" && s !== null
|
|
1192
1177
|
)?.[1] ?? null;
|
|
1193
1178
|
}
|
|
1179
|
+
async hasRecipe(e, t) {
|
|
1180
|
+
return (await this.get(e)).recipes.includes(t);
|
|
1181
|
+
}
|
|
1182
|
+
async getRecipes(e) {
|
|
1183
|
+
return (await this.get(e)).recipes;
|
|
1184
|
+
}
|
|
1194
1185
|
/*
|
|
1195
1186
|
** UPDATES
|
|
1196
1187
|
*/
|
|
1197
|
-
async addItem(e, t,
|
|
1188
|
+
async addItem(e, t, r) {
|
|
1198
1189
|
await this.update(e, {
|
|
1199
|
-
$inc: { [`itemList.${t}`]:
|
|
1200
|
-
}), await
|
|
1190
|
+
$inc: { [`itemList.${t}`]: r }
|
|
1191
|
+
}), await le.addEntities(e, [t]);
|
|
1201
1192
|
}
|
|
1202
1193
|
async addItems(e, t) {
|
|
1203
1194
|
await this.update(e, {
|
|
1204
1195
|
$inc: Object.fromEntries(
|
|
1205
|
-
Object.entries(t).filter(([,
|
|
1196
|
+
Object.entries(t).filter(([, r]) => (r ?? 0) > 0).map(([r, a]) => [`itemList.${r}`, a])
|
|
1206
1197
|
)
|
|
1207
|
-
}), await
|
|
1198
|
+
}), await le.addEntities(
|
|
1208
1199
|
e,
|
|
1209
|
-
B(t).filter(([,
|
|
1200
|
+
B(t).filter(([, r]) => r > 0).map(([r]) => r)
|
|
1210
1201
|
);
|
|
1211
1202
|
}
|
|
1212
|
-
async removeItem(e, t,
|
|
1213
|
-
|
|
1203
|
+
async removeItem(e, t, r) {
|
|
1204
|
+
r !== 0 && await this.update(e, [
|
|
1214
1205
|
{
|
|
1215
1206
|
$set: {
|
|
1216
1207
|
[`itemList.${t}`]: {
|
|
1217
|
-
$max: [{ $add: [`$itemList.${t}`, -
|
|
1208
|
+
$max: [{ $add: [`$itemList.${t}`, -r] }, 0]
|
|
1218
1209
|
}
|
|
1219
1210
|
}
|
|
1220
1211
|
}
|
|
1221
1212
|
]);
|
|
1222
1213
|
}
|
|
1223
|
-
async removeEquipment(e, t,
|
|
1214
|
+
async removeEquipment(e, t, r) {
|
|
1224
1215
|
await this.update(e, {
|
|
1225
1216
|
$pull: {
|
|
1226
1217
|
equipmentList: {
|
|
1227
1218
|
entityId: t,
|
|
1228
|
-
seed:
|
|
1219
|
+
seed: r
|
|
1229
1220
|
}
|
|
1230
1221
|
}
|
|
1231
1222
|
});
|
|
@@ -1236,9 +1227,9 @@ class Wt extends y {
|
|
|
1236
1227
|
async addEquipments(e, t) {
|
|
1237
1228
|
await this.update(e, {
|
|
1238
1229
|
$push: { equipmentList: { $each: t } }
|
|
1239
|
-
}), await
|
|
1230
|
+
}), await le.addEntities(
|
|
1240
1231
|
e,
|
|
1241
|
-
t.map((
|
|
1232
|
+
t.map((r) => r.entityId)
|
|
1242
1233
|
);
|
|
1243
1234
|
}
|
|
1244
1235
|
async saveEquipments(e) {
|
|
@@ -1251,64 +1242,57 @@ class Wt extends y {
|
|
|
1251
1242
|
]);
|
|
1252
1243
|
}
|
|
1253
1244
|
async changeEquippedEquipment(e, t) {
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1245
|
+
const r = await this.get(e);
|
|
1246
|
+
r?.equipmentSave[t] && await this.equip(e, r.equipmentSave[t]);
|
|
1256
1247
|
}
|
|
1257
1248
|
async equip(e, t) {
|
|
1258
|
-
const
|
|
1249
|
+
const r = await E.getMaxHp(e), a = Object.fromEntries(
|
|
1259
1250
|
B(t).map(([s, i]) => [
|
|
1260
1251
|
`equippedItems.${s}`,
|
|
1261
1252
|
i
|
|
1262
1253
|
])
|
|
1263
1254
|
);
|
|
1264
1255
|
await this.update(e, {
|
|
1265
|
-
$set:
|
|
1266
|
-
}), await E.updateHp(e,
|
|
1256
|
+
$set: a
|
|
1257
|
+
}), await E.updateHp(e, r);
|
|
1267
1258
|
}
|
|
1268
1259
|
async unequip(e, t) {
|
|
1269
|
-
const
|
|
1260
|
+
const r = await E.getMaxHp(e);
|
|
1270
1261
|
await this.update(e, {
|
|
1271
1262
|
$set: {
|
|
1272
1263
|
[`equippedItems.${t}`]: null
|
|
1273
1264
|
}
|
|
1274
|
-
}), await E.updateHp(e,
|
|
1265
|
+
}), await E.updateHp(e, r);
|
|
1275
1266
|
}
|
|
1276
|
-
async craftItem(e, t,
|
|
1277
|
-
for (const { entityId:
|
|
1278
|
-
await this.removeItem(e,
|
|
1267
|
+
async craftItem(e, t, r, a) {
|
|
1268
|
+
for (const { entityId: u, size: o } of t.entities)
|
|
1269
|
+
await this.removeItem(e, u, (o ?? 1) * r);
|
|
1279
1270
|
const { entityId: s, size: i } = t.result;
|
|
1280
|
-
await
|
|
1281
|
-
}
|
|
1282
|
-
async dismantleEntity(e, t, a, r, s) {
|
|
1283
|
-
f.isEquipment(t) ? await this.removeEquipment(e, t.entityId, s) : f.isItem(t) && await this.removeItem(e, t.entityId, r);
|
|
1284
|
-
for (const { entityId: i, quantity: o } of a)
|
|
1285
|
-
await f.isEntityId(i, f.isItem) && await this.addItem(e, i, r * o);
|
|
1286
|
-
await this.removeItem(e, "tools", 1);
|
|
1287
|
-
}
|
|
1288
|
-
async enchantItem(e, t, a, r, s) {
|
|
1289
|
-
await this.removeItem(e, t, s * 4), await this.removeItem(e, r, s), await this.addItem(e, a, s);
|
|
1271
|
+
await U.isEntityId(s, U.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: a }]) : await U.isEntityId(s, U.isItem) && await this.addItem(e, s, (i ?? 1) * r);
|
|
1290
1272
|
}
|
|
1291
1273
|
async unlockRecipe(e, t) {
|
|
1292
|
-
await this.
|
|
1274
|
+
await this.hasRecipe(e, t) || await this.update(e, {
|
|
1275
|
+
$push: { recipes: t }
|
|
1276
|
+
});
|
|
1293
1277
|
}
|
|
1294
1278
|
}
|
|
1295
|
-
const
|
|
1279
|
+
const cn = (n) => Z.create({
|
|
1296
1280
|
user: n
|
|
1297
1281
|
});
|
|
1298
|
-
async function
|
|
1299
|
-
const e = await
|
|
1300
|
-
return e || p(await
|
|
1282
|
+
async function on(n) {
|
|
1283
|
+
const e = await Z.findOne({ user: n }).lean();
|
|
1284
|
+
return e || p(await cn(n));
|
|
1301
1285
|
}
|
|
1302
|
-
const
|
|
1286
|
+
const dn = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
|
|
1303
1287
|
upsert: !0,
|
|
1304
1288
|
returnDocument: "after"
|
|
1305
1289
|
}).lean();
|
|
1306
|
-
class
|
|
1290
|
+
class ln extends un {
|
|
1307
1291
|
constructor() {
|
|
1308
1292
|
super(300);
|
|
1309
1293
|
}
|
|
1310
1294
|
fetchFromDb(e) {
|
|
1311
|
-
return
|
|
1295
|
+
return on(e);
|
|
1312
1296
|
}
|
|
1313
1297
|
normalizeKey(e) {
|
|
1314
1298
|
return e.toString();
|
|
@@ -1317,17 +1301,17 @@ class Jt extends Wt {
|
|
|
1317
1301
|
return e;
|
|
1318
1302
|
}
|
|
1319
1303
|
updateInDb(e, t) {
|
|
1320
|
-
return
|
|
1304
|
+
return dn(e, t);
|
|
1321
1305
|
}
|
|
1322
1306
|
}
|
|
1323
|
-
const
|
|
1324
|
-
class
|
|
1307
|
+
const M = new ln();
|
|
1308
|
+
class pn extends f {
|
|
1325
1309
|
async getTotalCharacteristics(e) {
|
|
1326
|
-
const { characteristics: t, scrolls:
|
|
1327
|
-
return
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1310
|
+
const { characteristics: t, scrolls: r } = await this.get(e);
|
|
1311
|
+
return Te(
|
|
1312
|
+
Ve.map((a) => [
|
|
1313
|
+
a,
|
|
1314
|
+
Xe(t[a]) + r[a]
|
|
1331
1315
|
])
|
|
1332
1316
|
);
|
|
1333
1317
|
}
|
|
@@ -1374,59 +1358,59 @@ class Zt extends m {
|
|
|
1374
1358
|
});
|
|
1375
1359
|
}
|
|
1376
1360
|
async calcXpBoost(e) {
|
|
1377
|
-
const t = await this.get(e), { boost:
|
|
1361
|
+
const t = await this.get(e), { boost: r } = t.xp, a = r !== null && Date.now() < r.getTime() ? 0.2 : 0, s = Math.max(
|
|
1378
1362
|
t.premium ? 0.5 : 0,
|
|
1379
1363
|
t.booster ? 0.25 : 0
|
|
1380
1364
|
);
|
|
1381
|
-
return
|
|
1382
|
-
(i, { expireAt:
|
|
1365
|
+
return a + s + t.buffs.xp.global.reduce(
|
|
1366
|
+
(i, { expireAt: u, startAt: o, multiplier: m }) => o && o > /* @__PURE__ */ new Date() || u && de(u) ? i : i + m,
|
|
1383
1367
|
0
|
|
1384
1368
|
);
|
|
1385
1369
|
}
|
|
1386
1370
|
calcMessageXp(e) {
|
|
1387
|
-
const t = e.trim().length,
|
|
1388
|
-
return t < 10 ? 10 *
|
|
1371
|
+
const t = e.trim().length, r = 2;
|
|
1372
|
+
return t < 10 ? 10 * r : t > 300 ? 300 * r : t * r;
|
|
1389
1373
|
}
|
|
1390
1374
|
async getXpDeathPenalties(e) {
|
|
1391
|
-
const t = await this.get(e),
|
|
1392
|
-
return
|
|
1375
|
+
const t = await this.get(e), r = Je(t.xp.amount);
|
|
1376
|
+
return r <= 10 ? 5e3 : r <= 20 ? 1e4 : r <= 30 ? 2e4 : r <= 40 ? 3e4 : r <= 50 ? 5e4 : r <= 60 ? 75e3 : r <= 70 ? 15e4 : r <= 80 ? 25e4 : r <= 90 ? 4e5 : r <= 100 ? 75e4 : 14e6;
|
|
1393
1377
|
}
|
|
1394
|
-
async calcXp(e, t,
|
|
1395
|
-
return t *= 1 + await this.calcXpBoost(e), Math.ceil(t *
|
|
1378
|
+
async calcXp(e, t, r) {
|
|
1379
|
+
return t *= 1 + await this.calcXpBoost(e), Math.ceil(t * r);
|
|
1396
1380
|
}
|
|
1397
|
-
async calcBerry(e, t,
|
|
1381
|
+
async calcBerry(e, t, r) {
|
|
1398
1382
|
if (t <= 0) return t;
|
|
1399
|
-
const
|
|
1400
|
-
return Math.ceil(t * (
|
|
1383
|
+
const a = r ? 1 : await this.calcBuffMultiplier(e, "berry", "global");
|
|
1384
|
+
return Math.ceil(t * (a || 1));
|
|
1401
1385
|
}
|
|
1402
|
-
async calcBuffMultiplier(e, t,
|
|
1403
|
-
return (await this.get(e)).buffs[t][
|
|
1404
|
-
(i, { expireAt:
|
|
1386
|
+
async calcBuffMultiplier(e, t, r) {
|
|
1387
|
+
return (await this.get(e)).buffs[t][r].reduce(
|
|
1388
|
+
(i, { expireAt: u, startAt: o, multiplier: m }) => i + (/* @__PURE__ */ new Date() >= (o ?? /* @__PURE__ */ new Date()) && (!u || !de(u)) ? m : 0),
|
|
1405
1389
|
1
|
|
1406
1390
|
);
|
|
1407
1391
|
}
|
|
1408
1392
|
async getMaxHp(e) {
|
|
1409
|
-
const t = await
|
|
1393
|
+
const t = await M.get(e), { vitality: r } = await this.getTotalCharacteristics(e), a = await M.getUserEquipmentsCharacteristics(
|
|
1410
1394
|
t
|
|
1411
1395
|
);
|
|
1412
|
-
return (
|
|
1396
|
+
return (r + a.vitality) * Ze + et;
|
|
1413
1397
|
}
|
|
1414
1398
|
async getHpRatio(e) {
|
|
1415
|
-
const t = await this.get(e),
|
|
1416
|
-
return Math.min(t.hp /
|
|
1399
|
+
const t = await this.get(e), r = await this.getMaxHp(e);
|
|
1400
|
+
return Math.min(t.hp / r, 1);
|
|
1417
1401
|
}
|
|
1418
1402
|
async hasCharacteristicRequirement(e, t) {
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1421
|
-
), s =
|
|
1403
|
+
const r = await M.get(e), a = await M.getUserEquipmentsCharacteristics(
|
|
1404
|
+
r
|
|
1405
|
+
), s = Q(
|
|
1422
1406
|
await this.getTotalCharacteristics(e),
|
|
1423
|
-
|
|
1424
|
-
(i,
|
|
1407
|
+
a,
|
|
1408
|
+
(i, u) => i + u
|
|
1425
1409
|
);
|
|
1426
1410
|
if ("sum" in t) {
|
|
1427
1411
|
let i = 0;
|
|
1428
|
-
for (const
|
|
1429
|
-
i += s[
|
|
1412
|
+
for (const u of t.characteristics)
|
|
1413
|
+
i += s[u] ?? 0;
|
|
1430
1414
|
return i >= t.sum;
|
|
1431
1415
|
} else {
|
|
1432
1416
|
for (const i of Object.keys(
|
|
@@ -1439,10 +1423,10 @@ class Zt extends m {
|
|
|
1439
1423
|
}
|
|
1440
1424
|
async hasMalusBuff(e) {
|
|
1441
1425
|
const t = await this.get(e);
|
|
1442
|
-
for (const
|
|
1443
|
-
for (const
|
|
1444
|
-
for (const { multiplier: s, startAt: i, expireAt:
|
|
1445
|
-
if (s < 0 && (!
|
|
1426
|
+
for (const r of Object.values(t.buffs))
|
|
1427
|
+
for (const a of Object.values(r))
|
|
1428
|
+
for (const { multiplier: s, startAt: i, expireAt: u } of a)
|
|
1429
|
+
if (s < 0 && (!u || !de(u)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
|
|
1446
1430
|
return !0;
|
|
1447
1431
|
return !1;
|
|
1448
1432
|
}
|
|
@@ -1471,7 +1455,7 @@ class Zt extends m {
|
|
|
1471
1455
|
}
|
|
1472
1456
|
async updateBoost(e, t) {
|
|
1473
1457
|
const {
|
|
1474
|
-
xp: { boost:
|
|
1458
|
+
xp: { boost: r }
|
|
1475
1459
|
} = await this.update(e, [
|
|
1476
1460
|
{
|
|
1477
1461
|
$set: {
|
|
@@ -1490,15 +1474,15 @@ class Zt extends m {
|
|
|
1490
1474
|
}
|
|
1491
1475
|
}
|
|
1492
1476
|
]);
|
|
1493
|
-
return
|
|
1477
|
+
return r;
|
|
1494
1478
|
}
|
|
1495
1479
|
async updateBuff(e, t) {
|
|
1496
1480
|
if (Array.isArray(t)) {
|
|
1497
|
-
for (const
|
|
1498
|
-
await this.updateBuff(e,
|
|
1481
|
+
for (const a of t)
|
|
1482
|
+
await this.updateBuff(e, a);
|
|
1499
1483
|
return;
|
|
1500
1484
|
}
|
|
1501
|
-
const
|
|
1485
|
+
const r = tt(t);
|
|
1502
1486
|
await this.update(e, [
|
|
1503
1487
|
{
|
|
1504
1488
|
$set: {
|
|
@@ -1523,10 +1507,10 @@ class Zt extends m {
|
|
|
1523
1507
|
then: {
|
|
1524
1508
|
multiplier: t.multiplier,
|
|
1525
1509
|
origin: t.origin,
|
|
1526
|
-
expireAt:
|
|
1510
|
+
expireAt: r.expireAt ? {
|
|
1527
1511
|
$cond: {
|
|
1528
1512
|
if: { $lt: ["$$buff.expireAt", /* @__PURE__ */ new Date()] },
|
|
1529
|
-
then:
|
|
1513
|
+
then: r.expireAt,
|
|
1530
1514
|
else: {
|
|
1531
1515
|
$add: [
|
|
1532
1516
|
"$$buff.expireAt",
|
|
@@ -1579,7 +1563,7 @@ class Zt extends m {
|
|
|
1579
1563
|
},
|
|
1580
1564
|
then: `$buffs.${t.target}`,
|
|
1581
1565
|
else: {
|
|
1582
|
-
$concatArrays: [`$buffs.${t.target}`, [{ ...
|
|
1566
|
+
$concatArrays: [`$buffs.${t.target}`, [{ ...r }]]
|
|
1583
1567
|
}
|
|
1584
1568
|
}
|
|
1585
1569
|
}
|
|
@@ -1592,21 +1576,21 @@ class Zt extends m {
|
|
|
1592
1576
|
$pull: { [`buffs.${t.target}`]: { origin: t.origin } }
|
|
1593
1577
|
});
|
|
1594
1578
|
}
|
|
1595
|
-
async updatePanoplyBuff(e, t,
|
|
1596
|
-
const s = await
|
|
1597
|
-
(
|
|
1579
|
+
async updatePanoplyBuff(e, t, r, a) {
|
|
1580
|
+
const s = await U.fromDBToEquipableEquipment(t), i = L(Object.values(r)), o = (await _.getAllPopulated()).find(
|
|
1581
|
+
(h) => h.panoplyId === s.panoply
|
|
1598
1582
|
);
|
|
1599
|
-
if (!
|
|
1583
|
+
if (!o)
|
|
1600
1584
|
return;
|
|
1601
|
-
const
|
|
1602
|
-
(
|
|
1603
|
-
).length,
|
|
1604
|
-
|
|
1585
|
+
const m = o.equipments.filter(
|
|
1586
|
+
(h) => (i.find((b) => h.entityId === b.entityId) || !a && s.entityId === h.entityId) && (a ? s.entityId !== h.entityId : !0)
|
|
1587
|
+
).length, $ = m === o.equipments.length ? o.fullBonus : m >= o.equipments.length / 2 ? o.halfBonus : void 0;
|
|
1588
|
+
o.halfBonus && "target" in o.halfBonus && await this.removeBuff(e, o.halfBonus), o.fullBonus && "target" in o.fullBonus && await this.removeBuff(e, o.fullBonus), $ && "target" in $ && await this.updateBuff(e, $);
|
|
1605
1589
|
}
|
|
1606
1590
|
async gainHp(e, t) {
|
|
1607
|
-
const
|
|
1591
|
+
const r = await this.get(e), s = await this.getMaxHp(e) - r.hp;
|
|
1608
1592
|
await this.update(e, {
|
|
1609
|
-
$set: { hp:
|
|
1593
|
+
$set: { hp: r.hp + Math.floor(Math.min(t, s)) }
|
|
1610
1594
|
});
|
|
1611
1595
|
}
|
|
1612
1596
|
async loseHp(e, t) {
|
|
@@ -1617,14 +1601,14 @@ class Zt extends m {
|
|
|
1617
1601
|
]);
|
|
1618
1602
|
}
|
|
1619
1603
|
async updateHp(e, t) {
|
|
1620
|
-
const
|
|
1604
|
+
const r = await this.getMaxHp(e);
|
|
1621
1605
|
await this.update(e, [
|
|
1622
1606
|
{
|
|
1623
1607
|
$set: {
|
|
1624
1608
|
hp: {
|
|
1625
1609
|
$round: [
|
|
1626
1610
|
{
|
|
1627
|
-
$multiply: [{ $divide: ["$hp", t] },
|
|
1611
|
+
$multiply: [{ $divide: ["$hp", t] }, r]
|
|
1628
1612
|
},
|
|
1629
1613
|
0
|
|
1630
1614
|
]
|
|
@@ -1634,23 +1618,23 @@ class Zt extends m {
|
|
|
1634
1618
|
]);
|
|
1635
1619
|
}
|
|
1636
1620
|
async addCharacteristics(e, t) {
|
|
1637
|
-
const
|
|
1621
|
+
const r = await this.getMaxHp(e), a = Object.fromEntries(
|
|
1638
1622
|
Object.entries(t).filter(([, s]) => s !== 0).map(([s, i]) => [`characteristics.${s}`, i])
|
|
1639
1623
|
);
|
|
1640
1624
|
await this.update(e, {
|
|
1641
|
-
$inc:
|
|
1642
|
-
}), await this.updateHp(e,
|
|
1625
|
+
$inc: a
|
|
1626
|
+
}), await this.updateHp(e, r);
|
|
1643
1627
|
}
|
|
1644
1628
|
async addScrollCharacteristic(e, t) {
|
|
1645
|
-
const
|
|
1629
|
+
const r = await this.getMaxHp(e), a = Object.fromEntries(
|
|
1646
1630
|
Object.entries(t).filter(([, s]) => s !== 0).map(([s, i]) => [`scrolls.${s}`, i])
|
|
1647
1631
|
);
|
|
1648
1632
|
await this.update(e, {
|
|
1649
|
-
$inc:
|
|
1650
|
-
}), await this.updateHp(e,
|
|
1633
|
+
$inc: a
|
|
1634
|
+
}), await this.updateHp(e, r);
|
|
1651
1635
|
}
|
|
1652
1636
|
async resetCharacteristics(e) {
|
|
1653
|
-
const t = await this.getMaxHp(e),
|
|
1637
|
+
const t = await this.getMaxHp(e), r = {
|
|
1654
1638
|
vitality: 0,
|
|
1655
1639
|
strength: 0,
|
|
1656
1640
|
agility: 0,
|
|
@@ -1660,7 +1644,7 @@ class Zt extends m {
|
|
|
1660
1644
|
};
|
|
1661
1645
|
await this.update(e, {
|
|
1662
1646
|
$set: {
|
|
1663
|
-
characteristics:
|
|
1647
|
+
characteristics: r
|
|
1664
1648
|
},
|
|
1665
1649
|
$inc: {
|
|
1666
1650
|
berry: -1e8
|
|
@@ -1694,30 +1678,30 @@ class Zt extends m {
|
|
|
1694
1678
|
});
|
|
1695
1679
|
}
|
|
1696
1680
|
async updateUserXp(e, t) {
|
|
1697
|
-
const
|
|
1681
|
+
const r = await this.calcXp(
|
|
1698
1682
|
e,
|
|
1699
1683
|
t,
|
|
1700
1684
|
await this.getHpRatio(e)
|
|
1701
1685
|
);
|
|
1702
|
-
return await this.addXp(e,
|
|
1686
|
+
return await this.addXp(e, r), r;
|
|
1703
1687
|
}
|
|
1704
|
-
async updateUserBerry(e, t,
|
|
1705
|
-
const
|
|
1706
|
-
return await this.addBerry(e,
|
|
1688
|
+
async updateUserBerry(e, t, r) {
|
|
1689
|
+
const a = await this.calcBerry(e, t, r);
|
|
1690
|
+
return await this.addBerry(e, a), a;
|
|
1707
1691
|
}
|
|
1708
1692
|
}
|
|
1709
|
-
const
|
|
1693
|
+
const yn = (n) => D.find(n).lean(), fn = async (n) => await D.create({
|
|
1710
1694
|
user: n
|
|
1711
1695
|
});
|
|
1712
|
-
async function
|
|
1713
|
-
const e = await
|
|
1714
|
-
return e || p(await
|
|
1696
|
+
async function mn(n) {
|
|
1697
|
+
const e = await D.findOne({ user: n }).lean();
|
|
1698
|
+
return e || p(await fn(n));
|
|
1715
1699
|
}
|
|
1716
|
-
const
|
|
1700
|
+
const hn = (n, e) => D.findOneAndUpdate({ user: n }, e, {
|
|
1717
1701
|
returnDocument: "after",
|
|
1718
1702
|
upsert: !0
|
|
1719
1703
|
}).lean();
|
|
1720
|
-
class
|
|
1704
|
+
class gn extends pn {
|
|
1721
1705
|
constructor() {
|
|
1722
1706
|
super(300);
|
|
1723
1707
|
}
|
|
@@ -1728,17 +1712,17 @@ class rn extends Zt {
|
|
|
1728
1712
|
return e;
|
|
1729
1713
|
}
|
|
1730
1714
|
fetchFromDb(e) {
|
|
1731
|
-
return
|
|
1715
|
+
return mn(e);
|
|
1732
1716
|
}
|
|
1733
1717
|
fetchManyFromDb(e) {
|
|
1734
|
-
return
|
|
1718
|
+
return yn(e);
|
|
1735
1719
|
}
|
|
1736
1720
|
updateInDb(e, t) {
|
|
1737
|
-
return
|
|
1721
|
+
return hn(e, t);
|
|
1738
1722
|
}
|
|
1739
1723
|
}
|
|
1740
|
-
const E = new
|
|
1741
|
-
class
|
|
1724
|
+
const E = new gn();
|
|
1725
|
+
class Sn extends f {
|
|
1742
1726
|
async updateSendDailyQuest(e, t) {
|
|
1743
1727
|
await this.update(e, { $set: { sendDailyQuest: t } });
|
|
1744
1728
|
}
|
|
@@ -1748,8 +1732,8 @@ class sn extends m {
|
|
|
1748
1732
|
async updateInventorySort(e, t) {
|
|
1749
1733
|
await this.update(e, { $set: { "sort.inventory": t } });
|
|
1750
1734
|
}
|
|
1751
|
-
async updateReminderSettings(e, t,
|
|
1752
|
-
await this.update(e, { $set: { [`reminder.${t}`]:
|
|
1735
|
+
async updateReminderSettings(e, t, r) {
|
|
1736
|
+
await this.update(e, { $set: { [`reminder.${t}`]: r } });
|
|
1753
1737
|
}
|
|
1754
1738
|
getUsersWithDailyReportEnable() {
|
|
1755
1739
|
return this.getMany({
|
|
@@ -1757,18 +1741,18 @@ class sn extends m {
|
|
|
1757
1741
|
});
|
|
1758
1742
|
}
|
|
1759
1743
|
}
|
|
1760
|
-
const
|
|
1744
|
+
const wn = (n) => F.find(n).lean(), bn = async (n) => await F.create({
|
|
1761
1745
|
user: n
|
|
1762
1746
|
});
|
|
1763
|
-
async function
|
|
1764
|
-
const e = await
|
|
1765
|
-
return e || p(await
|
|
1747
|
+
async function $n(n) {
|
|
1748
|
+
const e = await F.findOne({ user: n }).lean();
|
|
1749
|
+
return e || p(await bn(n));
|
|
1766
1750
|
}
|
|
1767
|
-
const
|
|
1751
|
+
const In = (n, e) => F.findOneAndUpdate({ user: n }, e, {
|
|
1768
1752
|
returnDocument: "after",
|
|
1769
1753
|
upsert: !0
|
|
1770
1754
|
}).lean();
|
|
1771
|
-
class
|
|
1755
|
+
class Un extends Sn {
|
|
1772
1756
|
constructor() {
|
|
1773
1757
|
super(3600);
|
|
1774
1758
|
}
|
|
@@ -1779,17 +1763,17 @@ class ln extends sn {
|
|
|
1779
1763
|
return e.user;
|
|
1780
1764
|
}
|
|
1781
1765
|
fetchFromDb(e) {
|
|
1782
|
-
return
|
|
1766
|
+
return $n(e);
|
|
1783
1767
|
}
|
|
1784
1768
|
fetchManyFromDb(e) {
|
|
1785
|
-
return
|
|
1769
|
+
return wn(e);
|
|
1786
1770
|
}
|
|
1787
1771
|
updateInDb(e, t) {
|
|
1788
|
-
return
|
|
1772
|
+
return In(e, t);
|
|
1789
1773
|
}
|
|
1790
1774
|
}
|
|
1791
|
-
const
|
|
1792
|
-
class
|
|
1775
|
+
const Fe = new Un();
|
|
1776
|
+
class Tn extends y {
|
|
1793
1777
|
async getCommandCooldown(e, t) {
|
|
1794
1778
|
return (await this.get(e)).commands[t];
|
|
1795
1779
|
}
|
|
@@ -1800,31 +1784,31 @@ class pn extends y {
|
|
|
1800
1784
|
}
|
|
1801
1785
|
}), await E.gainHp(e, 1);
|
|
1802
1786
|
}
|
|
1803
|
-
async useCommand(e, t,
|
|
1804
|
-
const { reminder:
|
|
1787
|
+
async useCommand(e, t, r) {
|
|
1788
|
+
const { reminder: a } = await Fe.get(e);
|
|
1805
1789
|
await this.update(e, {
|
|
1806
1790
|
$set: {
|
|
1807
|
-
[`commands.${t}`]: new Date(Date.now() +
|
|
1791
|
+
[`commands.${t}`]: new Date(Date.now() + r)
|
|
1808
1792
|
}
|
|
1809
|
-
}),
|
|
1793
|
+
}), a.commands[t] && await Rt.addReminder(
|
|
1810
1794
|
e,
|
|
1811
1795
|
`commands/${t}`,
|
|
1812
|
-
new Date(Date.now() +
|
|
1796
|
+
new Date(Date.now() + r)
|
|
1813
1797
|
);
|
|
1814
1798
|
}
|
|
1815
1799
|
}
|
|
1816
|
-
const
|
|
1800
|
+
const En = async (n) => await W.create({
|
|
1817
1801
|
user: n
|
|
1818
1802
|
});
|
|
1819
|
-
async function
|
|
1820
|
-
const e = await
|
|
1821
|
-
return e || p(await
|
|
1803
|
+
async function On(n) {
|
|
1804
|
+
const e = await W.findOne({ user: n }).lean();
|
|
1805
|
+
return e || p(await En(n));
|
|
1822
1806
|
}
|
|
1823
|
-
const
|
|
1807
|
+
const Dn = (n, e) => W.findOneAndUpdate({ user: n }, e, {
|
|
1824
1808
|
returnDocument: "after",
|
|
1825
1809
|
upsert: !0
|
|
1826
1810
|
}).lean();
|
|
1827
|
-
class
|
|
1811
|
+
class vn extends Tn {
|
|
1828
1812
|
constructor() {
|
|
1829
1813
|
super(300);
|
|
1830
1814
|
}
|
|
@@ -1835,17 +1819,17 @@ class hn extends pn {
|
|
|
1835
1819
|
return e.user;
|
|
1836
1820
|
}
|
|
1837
1821
|
fetchFromDb(e) {
|
|
1838
|
-
return
|
|
1822
|
+
return On(e);
|
|
1839
1823
|
}
|
|
1840
1824
|
updateInDb(e, t) {
|
|
1841
|
-
return
|
|
1825
|
+
return Dn(e, t);
|
|
1842
1826
|
}
|
|
1843
1827
|
}
|
|
1844
|
-
const
|
|
1845
|
-
class
|
|
1828
|
+
const Qa = new vn();
|
|
1829
|
+
class Mn extends f {
|
|
1846
1830
|
async isOrnamentIds(e, t = () => !0) {
|
|
1847
|
-
const
|
|
1848
|
-
return e.every((s) =>
|
|
1831
|
+
const a = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
|
|
1832
|
+
return e.every((s) => a.includes(s));
|
|
1849
1833
|
}
|
|
1850
1834
|
isOrnament(e) {
|
|
1851
1835
|
return !!e && "ornamentId" in e;
|
|
@@ -1881,47 +1865,47 @@ class gn extends m {
|
|
|
1881
1865
|
return (await this.getAll()).filter((e) => this.isShopTitle(e));
|
|
1882
1866
|
}
|
|
1883
1867
|
formatBackgroundId(e) {
|
|
1884
|
-
const t =
|
|
1885
|
-
return t === "background_default" ? "par défaut" : `"${
|
|
1868
|
+
const t = ot(e) ? e : e.ornamentId;
|
|
1869
|
+
return t === "background_default" ? "par défaut" : `"${dt(t.split("_").join(" "))}"`;
|
|
1886
1870
|
}
|
|
1887
1871
|
async getSomeShopTitles(e) {
|
|
1888
1872
|
const t = await this.getAllShopTitles();
|
|
1889
|
-
return
|
|
1890
|
-
|
|
1873
|
+
return pe(
|
|
1874
|
+
Se(
|
|
1891
1875
|
e,
|
|
1892
1876
|
t,
|
|
1893
|
-
(
|
|
1894
|
-
(
|
|
1877
|
+
(r) => r.ornamentId,
|
|
1878
|
+
(r) => r.odd ?? 0
|
|
1895
1879
|
),
|
|
1896
|
-
(
|
|
1880
|
+
(r) => r.price
|
|
1897
1881
|
);
|
|
1898
1882
|
}
|
|
1899
1883
|
async getSomeBackgrounds(e) {
|
|
1900
1884
|
const t = await this.getAllBackgrounds();
|
|
1901
|
-
return
|
|
1902
|
-
|
|
1885
|
+
return pe(
|
|
1886
|
+
Se(
|
|
1903
1887
|
e,
|
|
1904
1888
|
t,
|
|
1905
|
-
(
|
|
1906
|
-
(
|
|
1889
|
+
(r) => r.ornamentId,
|
|
1890
|
+
(r) => r.odd ?? 0
|
|
1907
1891
|
),
|
|
1908
|
-
(
|
|
1892
|
+
(r) => r.price ?? 0
|
|
1909
1893
|
);
|
|
1910
1894
|
}
|
|
1911
1895
|
pickEachRarityOrnament(e, t) {
|
|
1912
|
-
if (t.length !==
|
|
1896
|
+
if (t.length !== ge.length)
|
|
1913
1897
|
throw new RangeError(
|
|
1914
1898
|
"pickEachRarityOrnament - must give same number of odds than ranks"
|
|
1915
1899
|
);
|
|
1916
|
-
return
|
|
1917
|
-
t.map((
|
|
1918
|
-
const s =
|
|
1919
|
-
return Math.random() >
|
|
1900
|
+
return L(
|
|
1901
|
+
t.map((r, a) => {
|
|
1902
|
+
const s = ge[a], i = e[s];
|
|
1903
|
+
return Math.random() > r || !i || !i.length ? null : lt(i);
|
|
1920
1904
|
})
|
|
1921
1905
|
);
|
|
1922
1906
|
}
|
|
1923
1907
|
}
|
|
1924
|
-
const
|
|
1908
|
+
const xn = new c(
|
|
1925
1909
|
{
|
|
1926
1910
|
ornamentId: { unique: !0, index: 1, required: !0, type: String },
|
|
1927
1911
|
type: { required: !0, type: String },
|
|
@@ -1935,26 +1919,26 @@ const wn = new u(
|
|
|
1935
1919
|
strength: Number
|
|
1936
1920
|
},
|
|
1937
1921
|
{ minimize: !1 }
|
|
1938
|
-
),
|
|
1939
|
-
async function
|
|
1940
|
-
const e = await
|
|
1922
|
+
), fe = d?.Ornaments || l("Ornaments", xn), An = async (n, e) => fe.find(n, {}, e).lean();
|
|
1923
|
+
async function qn(n) {
|
|
1924
|
+
const e = await fe.findOne({ ornamentId: n }).lean();
|
|
1941
1925
|
return e || null;
|
|
1942
1926
|
}
|
|
1943
|
-
const
|
|
1927
|
+
const kn = (n, e) => fe.findOneAndUpdate(n, e, {
|
|
1944
1928
|
returnDocument: "after"
|
|
1945
1929
|
}).lean();
|
|
1946
|
-
class
|
|
1930
|
+
class Rn extends Mn {
|
|
1947
1931
|
constructor() {
|
|
1948
1932
|
super(3600);
|
|
1949
1933
|
}
|
|
1950
1934
|
updateInDb(e, t) {
|
|
1951
|
-
return
|
|
1935
|
+
return kn(e, t);
|
|
1952
1936
|
}
|
|
1953
1937
|
fetchFromDb(e) {
|
|
1954
|
-
return
|
|
1938
|
+
return qn(e);
|
|
1955
1939
|
}
|
|
1956
1940
|
fetchManyFromDb(e, t) {
|
|
1957
|
-
return
|
|
1941
|
+
return An(e, t);
|
|
1958
1942
|
}
|
|
1959
1943
|
getKey(e) {
|
|
1960
1944
|
return e.ornamentId;
|
|
@@ -1963,13 +1947,13 @@ class Un extends gn {
|
|
|
1963
1947
|
return e;
|
|
1964
1948
|
}
|
|
1965
1949
|
}
|
|
1966
|
-
const
|
|
1967
|
-
class
|
|
1950
|
+
const I = new Rn();
|
|
1951
|
+
class Cn extends y {
|
|
1968
1952
|
async unlockTitle(e, t) {
|
|
1969
|
-
await
|
|
1953
|
+
await I.isOrnamentIds([t], I.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
|
|
1970
1954
|
}
|
|
1971
1955
|
async unlockTitles(e, t) {
|
|
1972
|
-
await
|
|
1956
|
+
await I.isOrnamentIds(t, I.isTitle) && await this.update(e, {
|
|
1973
1957
|
$addToSet: { unlockedTitles: { $each: t } }
|
|
1974
1958
|
});
|
|
1975
1959
|
}
|
|
@@ -1977,17 +1961,17 @@ class En extends y {
|
|
|
1977
1961
|
await this.update(e, { $set: { selectedTitle: t } });
|
|
1978
1962
|
}
|
|
1979
1963
|
async unlockBackground(e, t) {
|
|
1980
|
-
await
|
|
1964
|
+
await I.isOrnamentIds(
|
|
1981
1965
|
[t],
|
|
1982
|
-
|
|
1966
|
+
I.isBackground
|
|
1983
1967
|
) && await this.update(e, {
|
|
1984
1968
|
$addToSet: { unlockedBackgrounds: t }
|
|
1985
1969
|
});
|
|
1986
1970
|
}
|
|
1987
1971
|
async unlockBackgrounds(e, t) {
|
|
1988
|
-
await
|
|
1972
|
+
await I.isOrnamentIds(
|
|
1989
1973
|
t,
|
|
1990
|
-
|
|
1974
|
+
I.isBackground
|
|
1991
1975
|
) && await this.update(e, {
|
|
1992
1976
|
$addToSet: { unlockedBackgrounds: { $each: t } }
|
|
1993
1977
|
});
|
|
@@ -1997,9 +1981,9 @@ class En extends y {
|
|
|
1997
1981
|
$set: { selectedBackground: t }
|
|
1998
1982
|
});
|
|
1999
1983
|
}
|
|
2000
|
-
async unlockBadge(e, t,
|
|
1984
|
+
async unlockBadge(e, t, r) {
|
|
2001
1985
|
t.isProgressive ? await this.update(e, {
|
|
2002
|
-
$addToSet: { unlockedBadges: `${t.id}_${
|
|
1986
|
+
$addToSet: { unlockedBadges: `${t.id}_${r}` }
|
|
2003
1987
|
}) : await this.update(e, {
|
|
2004
1988
|
$addToSet: { unlockedBadges: t.id }
|
|
2005
1989
|
});
|
|
@@ -2033,18 +2017,18 @@ class En extends y {
|
|
|
2033
2017
|
});
|
|
2034
2018
|
}
|
|
2035
2019
|
}
|
|
2036
|
-
const
|
|
2020
|
+
const Bn = async (n) => await ee.create({
|
|
2037
2021
|
user: n
|
|
2038
2022
|
});
|
|
2039
|
-
async function
|
|
2040
|
-
const e = await
|
|
2041
|
-
return e || p(await
|
|
2023
|
+
async function _n(n) {
|
|
2024
|
+
const e = await ee.findOne({ user: n }).lean();
|
|
2025
|
+
return e || p(await Bn(n));
|
|
2042
2026
|
}
|
|
2043
|
-
const
|
|
2027
|
+
const Fn = async (n, e) => ee.findOneAndUpdate({ user: n }, e, {
|
|
2044
2028
|
upsert: !0,
|
|
2045
2029
|
returnDocument: "after"
|
|
2046
2030
|
}).lean();
|
|
2047
|
-
class
|
|
2031
|
+
class Nn extends Cn {
|
|
2048
2032
|
constructor() {
|
|
2049
2033
|
super(300);
|
|
2050
2034
|
}
|
|
@@ -2055,14 +2039,14 @@ class On extends En {
|
|
|
2055
2039
|
return e;
|
|
2056
2040
|
}
|
|
2057
2041
|
fetchFromDb(e) {
|
|
2058
|
-
return
|
|
2042
|
+
return _n(e);
|
|
2059
2043
|
}
|
|
2060
2044
|
updateInDb(e, t) {
|
|
2061
|
-
return
|
|
2045
|
+
return Fn(e, t);
|
|
2062
2046
|
}
|
|
2063
2047
|
}
|
|
2064
|
-
const
|
|
2065
|
-
class
|
|
2048
|
+
const we = new Nn();
|
|
2049
|
+
class Kn extends f {
|
|
2066
2050
|
async getStatus(e, t) {
|
|
2067
2051
|
return (await this.get({ user: e, questId: t })).status;
|
|
2068
2052
|
}
|
|
@@ -2070,21 +2054,21 @@ class vn extends m {
|
|
|
2070
2054
|
return await this.getStatus(e, t) === "COMPLETED";
|
|
2071
2055
|
}
|
|
2072
2056
|
async isStreaking(e, t) {
|
|
2073
|
-
const { lastCompletionDate:
|
|
2074
|
-
return !!
|
|
2057
|
+
const { lastCompletionDate: r } = await this.get({ user: e, questId: t });
|
|
2058
|
+
return !!r && Oe(Y(), r);
|
|
2075
2059
|
}
|
|
2076
2060
|
async getStreakMultiplier(e, t) {
|
|
2077
|
-
const
|
|
2078
|
-
return await this.isStreaking(e, t) ? 1 + Math.min(2, (
|
|
2061
|
+
const r = await this.get({ user: e, questId: t });
|
|
2062
|
+
return await this.isStreaking(e, t) ? 1 + Math.min(2, (r.streak ?? 0) / 10) : 1;
|
|
2079
2063
|
}
|
|
2080
2064
|
async getCompletedCount(e) {
|
|
2081
|
-
return (await this.getMany({ user: e, status:
|
|
2065
|
+
return (await this.getMany({ user: e, status: A.COMPLETED })).length;
|
|
2082
2066
|
}
|
|
2083
2067
|
async completeQuest(e, t = !1) {
|
|
2084
|
-
const
|
|
2085
|
-
|
|
2086
|
-
const
|
|
2087
|
-
return
|
|
2068
|
+
const r = Y();
|
|
2069
|
+
r.setHours(0, 0, 0, 0);
|
|
2070
|
+
const a = /* @__PURE__ */ new Date();
|
|
2071
|
+
return a.setHours(0, 0, 0, 0), this.update(
|
|
2088
2072
|
e,
|
|
2089
2073
|
[
|
|
2090
2074
|
{
|
|
@@ -2094,8 +2078,8 @@ class vn extends m {
|
|
|
2094
2078
|
$cond: {
|
|
2095
2079
|
if: {
|
|
2096
2080
|
$and: [
|
|
2097
|
-
{ $gte: ["$lastCompletionDate",
|
|
2098
|
-
{ $lt: ["$lastCompletionDate",
|
|
2081
|
+
{ $gte: ["$lastCompletionDate", r] },
|
|
2082
|
+
{ $lt: ["$lastCompletionDate", a] }
|
|
2099
2083
|
]
|
|
2100
2084
|
},
|
|
2101
2085
|
then: { $add: [{ $ifNull: ["$streak", 0] }, 1] },
|
|
@@ -2104,7 +2088,7 @@ class vn extends m {
|
|
|
2104
2088
|
}
|
|
2105
2089
|
} : {},
|
|
2106
2090
|
lastCompletionDate: /* @__PURE__ */ new Date(),
|
|
2107
|
-
status:
|
|
2091
|
+
status: A.COMPLETED
|
|
2108
2092
|
}
|
|
2109
2093
|
}
|
|
2110
2094
|
],
|
|
@@ -2112,24 +2096,24 @@ class vn extends m {
|
|
|
2112
2096
|
);
|
|
2113
2097
|
}
|
|
2114
2098
|
}
|
|
2115
|
-
function
|
|
2099
|
+
function Hn(n) {
|
|
2116
2100
|
return R.find(n).lean();
|
|
2117
2101
|
}
|
|
2118
|
-
const
|
|
2102
|
+
const Pn = async (n) => await R.create({
|
|
2119
2103
|
...n
|
|
2120
2104
|
});
|
|
2121
|
-
async function
|
|
2105
|
+
async function jn(n) {
|
|
2122
2106
|
const e = await R.findOne(n).lean();
|
|
2123
|
-
return e || p(await
|
|
2107
|
+
return e || p(await Pn(n));
|
|
2124
2108
|
}
|
|
2125
|
-
function
|
|
2109
|
+
function zn(n, e, t) {
|
|
2126
2110
|
return R.findOneAndUpdate(n, e, {
|
|
2127
2111
|
upsert: !0,
|
|
2128
2112
|
...t,
|
|
2129
2113
|
returnDocument: "after"
|
|
2130
2114
|
}).lean();
|
|
2131
2115
|
}
|
|
2132
|
-
class
|
|
2116
|
+
class Ln extends Kn {
|
|
2133
2117
|
constructor() {
|
|
2134
2118
|
super(3600);
|
|
2135
2119
|
}
|
|
@@ -2143,17 +2127,17 @@ class qn extends vn {
|
|
|
2143
2127
|
return { user: e, questId: t };
|
|
2144
2128
|
}
|
|
2145
2129
|
fetchFromDb(e) {
|
|
2146
|
-
return
|
|
2130
|
+
return jn(e);
|
|
2147
2131
|
}
|
|
2148
2132
|
fetchManyFromDb(e) {
|
|
2149
|
-
return
|
|
2133
|
+
return Hn(e);
|
|
2150
2134
|
}
|
|
2151
|
-
updateInDb(e, t,
|
|
2152
|
-
return
|
|
2135
|
+
updateInDb(e, t, r) {
|
|
2136
|
+
return zn(e, t, r);
|
|
2153
2137
|
}
|
|
2154
2138
|
}
|
|
2155
|
-
const
|
|
2156
|
-
class
|
|
2139
|
+
const be = new Ln();
|
|
2140
|
+
class Qn extends y {
|
|
2157
2141
|
async randomMessageIncrement(e) {
|
|
2158
2142
|
await this.update(e, { $inc: { randomMessageClaimed: 1 } });
|
|
2159
2143
|
}
|
|
@@ -2171,18 +2155,18 @@ class xn extends y {
|
|
|
2171
2155
|
await this.update(e, { $inc: { totalMinutesInVoice: t } });
|
|
2172
2156
|
}
|
|
2173
2157
|
}
|
|
2174
|
-
const
|
|
2158
|
+
const Yn = async (n) => await ne.create({
|
|
2175
2159
|
user: n
|
|
2176
2160
|
});
|
|
2177
|
-
async function
|
|
2178
|
-
const e = await
|
|
2179
|
-
return e || p(await
|
|
2161
|
+
async function Gn(n) {
|
|
2162
|
+
const e = await ne.findOne({ user: n }).lean();
|
|
2163
|
+
return e || p(await Yn(n));
|
|
2180
2164
|
}
|
|
2181
|
-
const
|
|
2165
|
+
const Wn = (n, e) => ne.findOneAndUpdate({ user: n }, e, {
|
|
2182
2166
|
upsert: !0,
|
|
2183
2167
|
returnDocument: "after"
|
|
2184
2168
|
}).lean();
|
|
2185
|
-
class
|
|
2169
|
+
class Vn extends Qn {
|
|
2186
2170
|
constructor() {
|
|
2187
2171
|
super(300);
|
|
2188
2172
|
}
|
|
@@ -2195,29 +2179,29 @@ class Fn extends xn {
|
|
|
2195
2179
|
return e;
|
|
2196
2180
|
}
|
|
2197
2181
|
fetchFromDb(e) {
|
|
2198
|
-
return
|
|
2182
|
+
return Gn(e);
|
|
2199
2183
|
}
|
|
2200
2184
|
updateInDb(e, t) {
|
|
2201
|
-
return
|
|
2185
|
+
return Wn(e, t);
|
|
2202
2186
|
}
|
|
2203
2187
|
}
|
|
2204
|
-
const
|
|
2205
|
-
class
|
|
2188
|
+
const $e = new Vn();
|
|
2189
|
+
class Xn extends y {
|
|
2206
2190
|
async updateDailyReport(e) {
|
|
2207
|
-
const t = await E.get(e),
|
|
2191
|
+
const t = await E.get(e), r = await we.get(e), a = await be.getMany({
|
|
2208
2192
|
user: e,
|
|
2209
|
-
status:
|
|
2210
|
-
}), s = await
|
|
2193
|
+
status: A.COMPLETED
|
|
2194
|
+
}), s = await $e.get(e);
|
|
2211
2195
|
await this.update(e, {
|
|
2212
2196
|
$set: {
|
|
2213
2197
|
xpYesterday: t.xp.amount,
|
|
2214
2198
|
berryYesterday: t.berry,
|
|
2215
|
-
previousCompletedQuest:
|
|
2199
|
+
previousCompletedQuest: a.map(
|
|
2216
2200
|
({ questId: i }) => i
|
|
2217
2201
|
),
|
|
2218
|
-
"previousOrnament.unlockedBadges":
|
|
2219
|
-
"previousOrnament.unlockedTitles":
|
|
2220
|
-
"previousOrnament.unlockedBackgrounds":
|
|
2202
|
+
"previousOrnament.unlockedBadges": r.unlockedBadges,
|
|
2203
|
+
"previousOrnament.unlockedTitles": r.unlockedTitles,
|
|
2204
|
+
"previousOrnament.unlockedBackgrounds": r.unlockedBackgrounds,
|
|
2221
2205
|
previousMessageSent: s.messageSent
|
|
2222
2206
|
}
|
|
2223
2207
|
});
|
|
@@ -2225,57 +2209,57 @@ class Nn extends y {
|
|
|
2225
2209
|
async getDailyReport(e) {
|
|
2226
2210
|
const {
|
|
2227
2211
|
previousOrnament: t,
|
|
2228
|
-
previousCompletedQuest:
|
|
2229
|
-
xpYesterday:
|
|
2212
|
+
previousCompletedQuest: r,
|
|
2213
|
+
xpYesterday: a,
|
|
2230
2214
|
berryYesterday: s,
|
|
2231
2215
|
previousMessageSent: i
|
|
2232
|
-
} = await this.get(e),
|
|
2216
|
+
} = await this.get(e), u = await E.get(e), o = await be.getMany({
|
|
2233
2217
|
user: e,
|
|
2234
|
-
status:
|
|
2235
|
-
}),
|
|
2218
|
+
status: A.COMPLETED
|
|
2219
|
+
}), m = await we.get(e), $ = await $e.get(e), { berry: h, xp: b } = u, { voice: he, amount: He } = b, { unlockedBadges: Pe, unlockedBackgrounds: je, unlockedTitles: ze } = m;
|
|
2236
2220
|
return {
|
|
2237
|
-
berry:
|
|
2238
|
-
xp:
|
|
2239
|
-
message:
|
|
2240
|
-
voice:
|
|
2241
|
-
quest:
|
|
2242
|
-
|
|
2243
|
-
|
|
2221
|
+
berry: h - s,
|
|
2222
|
+
xp: He - a,
|
|
2223
|
+
message: $.messageSent - i,
|
|
2224
|
+
voice: Oe(he.lastConnection, Y()) ? he.minutesInVoiceToday : 0,
|
|
2225
|
+
quest: P(
|
|
2226
|
+
o.map(({ questId: Le }) => Le),
|
|
2227
|
+
r
|
|
2244
2228
|
),
|
|
2245
|
-
badge:
|
|
2246
|
-
title:
|
|
2247
|
-
background:
|
|
2248
|
-
|
|
2229
|
+
badge: P(Pe, t.unlockedBadges),
|
|
2230
|
+
title: P(ze, t.unlockedTitles),
|
|
2231
|
+
background: P(
|
|
2232
|
+
je,
|
|
2249
2233
|
t.unlockedBackgrounds
|
|
2250
2234
|
)
|
|
2251
2235
|
};
|
|
2252
2236
|
}
|
|
2253
2237
|
async getAllDailyReportsToSend() {
|
|
2254
|
-
const e = await
|
|
2255
|
-
_id: { $in: e.map(({ user:
|
|
2238
|
+
const e = await Fe.getUsersWithDailyReportEnable(), t = await Et.getMany({
|
|
2239
|
+
_id: { $in: e.map(({ user: r }) => r) },
|
|
2256
2240
|
faction: { $ne: "citizen" }
|
|
2257
2241
|
});
|
|
2258
2242
|
return await Promise.all(
|
|
2259
|
-
t.map(async ({ _id:
|
|
2260
|
-
report: await this.getDailyReport(
|
|
2261
|
-
user:
|
|
2262
|
-
discordId:
|
|
2243
|
+
t.map(async ({ _id: r, discordId: a }) => ({
|
|
2244
|
+
report: await this.getDailyReport(r),
|
|
2245
|
+
user: r,
|
|
2246
|
+
discordId: a
|
|
2263
2247
|
}))
|
|
2264
2248
|
);
|
|
2265
2249
|
}
|
|
2266
2250
|
}
|
|
2267
|
-
const
|
|
2251
|
+
const Jn = (n) => V.create({
|
|
2268
2252
|
user: n
|
|
2269
2253
|
});
|
|
2270
|
-
async function
|
|
2271
|
-
const e = await
|
|
2272
|
-
return e || p(await
|
|
2254
|
+
async function Zn(n) {
|
|
2255
|
+
const e = await V.findOne({ user: n }).lean();
|
|
2256
|
+
return e || p(await Jn(n));
|
|
2273
2257
|
}
|
|
2274
|
-
const
|
|
2258
|
+
const er = (n, e) => V.findOneAndUpdate({ user: n }, e, {
|
|
2275
2259
|
upsert: !0,
|
|
2276
2260
|
returnDocument: "after"
|
|
2277
2261
|
}).lean();
|
|
2278
|
-
class
|
|
2262
|
+
class tr extends Xn {
|
|
2279
2263
|
constructor() {
|
|
2280
2264
|
super(60);
|
|
2281
2265
|
}
|
|
@@ -2286,21 +2270,21 @@ class Pn extends Nn {
|
|
|
2286
2270
|
return e.user;
|
|
2287
2271
|
}
|
|
2288
2272
|
fetchFromDb(e) {
|
|
2289
|
-
return
|
|
2273
|
+
return Zn(e);
|
|
2290
2274
|
}
|
|
2291
2275
|
updateInDb(e, t) {
|
|
2292
|
-
return
|
|
2276
|
+
return er(e, t);
|
|
2293
2277
|
}
|
|
2294
2278
|
}
|
|
2295
|
-
const
|
|
2296
|
-
class
|
|
2297
|
-
async setGuessGame(e, t,
|
|
2279
|
+
const Ya = new tr();
|
|
2280
|
+
class nr extends y {
|
|
2281
|
+
async setGuessGame(e, t, r, a) {
|
|
2298
2282
|
await this.update(e, {
|
|
2299
2283
|
$set: {
|
|
2300
2284
|
guess: {
|
|
2301
2285
|
amount: t,
|
|
2302
|
-
tries:
|
|
2303
|
-
numberToGuess:
|
|
2286
|
+
tries: r,
|
|
2287
|
+
numberToGuess: a,
|
|
2304
2288
|
lastGuess: 0
|
|
2305
2289
|
}
|
|
2306
2290
|
}
|
|
@@ -2324,18 +2308,18 @@ class zn extends y {
|
|
|
2324
2308
|
});
|
|
2325
2309
|
}
|
|
2326
2310
|
}
|
|
2327
|
-
const
|
|
2311
|
+
const rr = async (n) => await J.create({
|
|
2328
2312
|
user: n
|
|
2329
2313
|
});
|
|
2330
|
-
async function
|
|
2331
|
-
const e = await
|
|
2332
|
-
return e || p(await
|
|
2314
|
+
async function ar(n) {
|
|
2315
|
+
const e = await J.findOne({ user: n }).lean();
|
|
2316
|
+
return e || p(await rr(n));
|
|
2333
2317
|
}
|
|
2334
|
-
const
|
|
2318
|
+
const sr = (n, e) => J.findOneAndUpdate({ user: n }, e, {
|
|
2335
2319
|
upsert: !0,
|
|
2336
2320
|
returnDocument: "after"
|
|
2337
2321
|
}).lean();
|
|
2338
|
-
class
|
|
2322
|
+
class ir extends nr {
|
|
2339
2323
|
constructor() {
|
|
2340
2324
|
super(300);
|
|
2341
2325
|
}
|
|
@@ -2346,15 +2330,15 @@ class Wn extends zn {
|
|
|
2346
2330
|
return e;
|
|
2347
2331
|
}
|
|
2348
2332
|
fetchFromDb(e) {
|
|
2349
|
-
return
|
|
2333
|
+
return ar(e);
|
|
2350
2334
|
}
|
|
2351
2335
|
updateInDb(e, t) {
|
|
2352
|
-
return
|
|
2336
|
+
return sr(e, t);
|
|
2353
2337
|
}
|
|
2354
2338
|
}
|
|
2355
|
-
const
|
|
2339
|
+
const Ga = new ir(), ur = new c({
|
|
2356
2340
|
user: {
|
|
2357
|
-
type:
|
|
2341
|
+
type: c.Types.ObjectId,
|
|
2358
2342
|
required: !0,
|
|
2359
2343
|
unique: !0,
|
|
2360
2344
|
ref: "User"
|
|
@@ -2362,10 +2346,10 @@ const hr = new Wn(), Yn = new u({
|
|
|
2362
2346
|
xp: { type: Number, default: 0 },
|
|
2363
2347
|
berry: { type: Number, default: 0 },
|
|
2364
2348
|
faction: { type: Number, default: 0 }
|
|
2365
|
-
}),
|
|
2366
|
-
class
|
|
2349
|
+
}), x = d?.UserRank || l("UserRank", ur);
|
|
2350
|
+
class cr extends y {
|
|
2367
2351
|
async computeAllXpRanks() {
|
|
2368
|
-
const t = (await
|
|
2352
|
+
const t = (await D.aggregate([
|
|
2369
2353
|
{
|
|
2370
2354
|
$setWindowFields: {
|
|
2371
2355
|
sortBy: { "xp.amount": -1 },
|
|
@@ -2373,17 +2357,17 @@ class Vn extends y {
|
|
|
2373
2357
|
}
|
|
2374
2358
|
},
|
|
2375
2359
|
{ $project: { user: 1, xpRank: 1 } }
|
|
2376
|
-
])).map(({ user:
|
|
2360
|
+
])).map(({ user: r, xpRank: a }) => ({
|
|
2377
2361
|
updateOne: {
|
|
2378
|
-
filter: { user:
|
|
2379
|
-
update: { $set: { xp:
|
|
2362
|
+
filter: { user: r },
|
|
2363
|
+
update: { $set: { xp: a } },
|
|
2380
2364
|
upsert: !0
|
|
2381
2365
|
}
|
|
2382
2366
|
}));
|
|
2383
|
-
t.length > 0 && await
|
|
2367
|
+
t.length > 0 && await x.bulkWrite(t), this.clearAll();
|
|
2384
2368
|
}
|
|
2385
2369
|
async computeAllBerryRanks() {
|
|
2386
|
-
const t = (await
|
|
2370
|
+
const t = (await D.aggregate([
|
|
2387
2371
|
{
|
|
2388
2372
|
$setWindowFields: {
|
|
2389
2373
|
sortBy: { berry: -1 },
|
|
@@ -2391,14 +2375,14 @@ class Vn extends y {
|
|
|
2391
2375
|
}
|
|
2392
2376
|
},
|
|
2393
2377
|
{ $project: { user: 1, berryRank: 1 } }
|
|
2394
|
-
])).map(({ user:
|
|
2378
|
+
])).map(({ user: r, berryRank: a }) => ({
|
|
2395
2379
|
updateOne: {
|
|
2396
|
-
filter: { user:
|
|
2397
|
-
update: { $set: { berry:
|
|
2380
|
+
filter: { user: r },
|
|
2381
|
+
update: { $set: { berry: a } },
|
|
2398
2382
|
upsert: !0
|
|
2399
2383
|
}
|
|
2400
2384
|
}));
|
|
2401
|
-
t.length > 0 && await
|
|
2385
|
+
t.length > 0 && await x.bulkWrite(t), this.clearAll();
|
|
2402
2386
|
}
|
|
2403
2387
|
async computeAllFactionRanks() {
|
|
2404
2388
|
const t = (await w.aggregate([
|
|
@@ -2419,14 +2403,14 @@ class Vn extends y {
|
|
|
2419
2403
|
}
|
|
2420
2404
|
},
|
|
2421
2405
|
{ $project: { factionRank: 1 } }
|
|
2422
|
-
])).map(({ _id:
|
|
2406
|
+
])).map(({ _id: r, factionRank: a }) => ({
|
|
2423
2407
|
updateOne: {
|
|
2424
|
-
filter: { user:
|
|
2425
|
-
update: { $set: { faction:
|
|
2408
|
+
filter: { user: r },
|
|
2409
|
+
update: { $set: { faction: a } },
|
|
2426
2410
|
upsert: !0
|
|
2427
2411
|
}
|
|
2428
2412
|
}));
|
|
2429
|
-
t.length > 0 && await
|
|
2413
|
+
t.length > 0 && await x.bulkWrite(t), this.clearAll();
|
|
2430
2414
|
}
|
|
2431
2415
|
async computeAllRanks() {
|
|
2432
2416
|
await Promise.all([
|
|
@@ -2436,18 +2420,18 @@ class Vn extends y {
|
|
|
2436
2420
|
]);
|
|
2437
2421
|
}
|
|
2438
2422
|
}
|
|
2439
|
-
const
|
|
2423
|
+
const or = async (n) => await x.create({
|
|
2440
2424
|
user: n
|
|
2441
2425
|
});
|
|
2442
|
-
async function
|
|
2443
|
-
const e = await
|
|
2444
|
-
return e || p(await
|
|
2426
|
+
async function dr(n) {
|
|
2427
|
+
const e = await x.findOne({ user: n }).lean();
|
|
2428
|
+
return e || p(await or(n));
|
|
2445
2429
|
}
|
|
2446
|
-
const
|
|
2430
|
+
const lr = (n, e) => x.findOneAndUpdate({ user: n }, e, {
|
|
2447
2431
|
returnDocument: "after",
|
|
2448
2432
|
upsert: !0
|
|
2449
2433
|
}).lean();
|
|
2450
|
-
class
|
|
2434
|
+
class pr extends cr {
|
|
2451
2435
|
constructor() {
|
|
2452
2436
|
super(300);
|
|
2453
2437
|
}
|
|
@@ -2458,14 +2442,388 @@ class ea extends Vn {
|
|
|
2458
2442
|
return e.user;
|
|
2459
2443
|
}
|
|
2460
2444
|
fetchFromDb(e) {
|
|
2461
|
-
return
|
|
2445
|
+
return dr(e);
|
|
2446
|
+
}
|
|
2447
|
+
updateInDb(e, t) {
|
|
2448
|
+
return lr(e, t);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
const Wa = new pr(), yr = new c(
|
|
2452
|
+
{
|
|
2453
|
+
speakerId: { type: String, required: !0 },
|
|
2454
|
+
order: { type: Number },
|
|
2455
|
+
args: { type: [String], enum: nt, default: void 0 }
|
|
2456
|
+
},
|
|
2457
|
+
{ _id: !1 }
|
|
2458
|
+
), fr = new c(
|
|
2459
|
+
{
|
|
2460
|
+
stepId: { type: String, required: !0 },
|
|
2461
|
+
type: {
|
|
2462
|
+
type: String,
|
|
2463
|
+
required: !0,
|
|
2464
|
+
enum: at
|
|
2465
|
+
},
|
|
2466
|
+
actionType: { type: String, enum: rt },
|
|
2467
|
+
messages: { type: [yr], default: void 0 },
|
|
2468
|
+
payload: { type: c.Types.Mixed, default: void 0 },
|
|
2469
|
+
next: { type: String }
|
|
2470
|
+
},
|
|
2471
|
+
{ _id: !1 }
|
|
2472
|
+
), mr = new c(
|
|
2473
|
+
{
|
|
2474
|
+
sceneId: { type: String, required: !0 },
|
|
2475
|
+
steps: { type: Map, of: fr, required: !0 },
|
|
2476
|
+
entryStepId: { type: String, required: !0 },
|
|
2477
|
+
next: { type: String }
|
|
2478
|
+
},
|
|
2479
|
+
{ _id: !1 }
|
|
2480
|
+
), hr = new c(
|
|
2481
|
+
{
|
|
2482
|
+
chapterId: { type: String, required: !0 },
|
|
2483
|
+
scenes: { type: Map, of: mr, required: !0 },
|
|
2484
|
+
entrySceneId: { type: String, required: !0 },
|
|
2485
|
+
next: { type: String }
|
|
2486
|
+
},
|
|
2487
|
+
{ _id: !1 }
|
|
2488
|
+
), gr = new c(
|
|
2489
|
+
{
|
|
2490
|
+
type: {
|
|
2491
|
+
type: String,
|
|
2492
|
+
required: !0,
|
|
2493
|
+
enum: st
|
|
2494
|
+
},
|
|
2495
|
+
speakerId: { type: String, required: !0 }
|
|
2496
|
+
},
|
|
2497
|
+
{ _id: !1 }
|
|
2498
|
+
), Ne = new c({
|
|
2499
|
+
storyId: {
|
|
2500
|
+
type: String,
|
|
2501
|
+
required: !0,
|
|
2502
|
+
unique: !0
|
|
2503
|
+
},
|
|
2504
|
+
speakers: { type: [gr], required: !0 },
|
|
2505
|
+
chapters: { type: Map, of: hr, required: !0 },
|
|
2506
|
+
entryChapterId: { type: String, required: !0 }
|
|
2507
|
+
});
|
|
2508
|
+
Ne.pre("findOneAndUpdate", function() {
|
|
2509
|
+
this.setOptions({ runValidators: !0 });
|
|
2510
|
+
});
|
|
2511
|
+
const ae = d?.Story || l("Story", Ne), Sr = async (n) => await ae.create(n), j = {
|
|
2512
|
+
storyId: "main",
|
|
2513
|
+
speakers: it,
|
|
2514
|
+
chapters: {
|
|
2515
|
+
[oe.chapterId]: oe
|
|
2516
|
+
},
|
|
2517
|
+
entryChapterId: oe.chapterId
|
|
2518
|
+
};
|
|
2519
|
+
class wr extends f {
|
|
2520
|
+
async seed() {
|
|
2521
|
+
return await this.get(j.storyId) ? this.update({ storyId: j.storyId }, { $set: j }) : Sr(j);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
const br = (n, e = {}) => ae.find(n, null, e).lean(), $r = (n) => ae.findOne({ storyId: n }).lean(), Ir = (n, e) => ae.findOneAndUpdate({ storyId: n }, e, {
|
|
2525
|
+
returnDocument: "after"
|
|
2526
|
+
}).lean();
|
|
2527
|
+
class Ur extends wr {
|
|
2528
|
+
constructor() {
|
|
2529
|
+
super(86400);
|
|
2530
|
+
}
|
|
2531
|
+
normalizeKey(e) {
|
|
2532
|
+
return e;
|
|
2533
|
+
}
|
|
2534
|
+
getKey(e) {
|
|
2535
|
+
return e.storyId;
|
|
2536
|
+
}
|
|
2537
|
+
fetchFromDb(e) {
|
|
2538
|
+
return $r(e);
|
|
2539
|
+
}
|
|
2540
|
+
fetchManyFromDb(e, t) {
|
|
2541
|
+
return br(e, t);
|
|
2542
|
+
}
|
|
2543
|
+
updateInDb(e, t) {
|
|
2544
|
+
const r = typeof e == "string" ? e : e.storyId;
|
|
2545
|
+
return Ir(r, t);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
const T = new Ur(), Tr = new c(
|
|
2549
|
+
{
|
|
2550
|
+
chapterId: { type: String, required: !0 },
|
|
2551
|
+
sceneId: { type: String, required: !0 },
|
|
2552
|
+
stepId: { type: String, required: !0 },
|
|
2553
|
+
value: { type: String, required: !0 }
|
|
2554
|
+
},
|
|
2555
|
+
{ _id: !1 }
|
|
2556
|
+
), Ke = new c({
|
|
2557
|
+
user: {
|
|
2558
|
+
type: c.Types.ObjectId,
|
|
2559
|
+
required: !0,
|
|
2560
|
+
ref: "User",
|
|
2561
|
+
index: !0
|
|
2562
|
+
},
|
|
2563
|
+
storyId: {
|
|
2564
|
+
type: String,
|
|
2565
|
+
required: !0
|
|
2566
|
+
},
|
|
2567
|
+
currentChapterId: { type: String, required: !0 },
|
|
2568
|
+
currentSceneId: { type: String, required: !0 },
|
|
2569
|
+
currentStepId: { type: String, required: !0 },
|
|
2570
|
+
status: {
|
|
2571
|
+
type: String,
|
|
2572
|
+
required: !0,
|
|
2573
|
+
enum: ["in_progress", "completed"],
|
|
2574
|
+
default: "in_progress"
|
|
2575
|
+
},
|
|
2576
|
+
choices: { type: [Tr], default: [] }
|
|
2577
|
+
});
|
|
2578
|
+
Ke.index({ user: 1, storyId: 1 }, { unique: !0 });
|
|
2579
|
+
const H = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => await H.create({
|
|
2580
|
+
user: n,
|
|
2581
|
+
storyId: e,
|
|
2582
|
+
currentChapterId: t,
|
|
2583
|
+
currentSceneId: r,
|
|
2584
|
+
currentStepId: a,
|
|
2585
|
+
status: "in_progress"
|
|
2586
|
+
}), Or = (n, e) => H.deleteOne({ user: n, storyId: e }).then(() => {
|
|
2587
|
+
}), Dr = (n, e, t, r) => {
|
|
2588
|
+
const a = n.chapters[e];
|
|
2589
|
+
if (!a) return null;
|
|
2590
|
+
const s = a.scenes[t];
|
|
2591
|
+
if (!s) return null;
|
|
2592
|
+
if (s.steps[r])
|
|
2593
|
+
return { chapterId: e, sceneId: t, stepId: r };
|
|
2594
|
+
if (s.next) {
|
|
2595
|
+
const i = a.scenes[s.next];
|
|
2596
|
+
if (i)
|
|
2597
|
+
return {
|
|
2598
|
+
chapterId: e,
|
|
2599
|
+
sceneId: s.next,
|
|
2600
|
+
stepId: i.entryStepId
|
|
2601
|
+
};
|
|
2602
|
+
}
|
|
2603
|
+
if (a.next) {
|
|
2604
|
+
const i = n.chapters[a.next];
|
|
2605
|
+
if (i) {
|
|
2606
|
+
const u = i.scenes[i.entrySceneId];
|
|
2607
|
+
if (u)
|
|
2608
|
+
return {
|
|
2609
|
+
chapterId: a.next,
|
|
2610
|
+
sceneId: i.entrySceneId,
|
|
2611
|
+
stepId: u.entryStepId
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
return null;
|
|
2616
|
+
}, z = (n, e) => {
|
|
2617
|
+
const t = n.chapters[e.currentChapterId];
|
|
2618
|
+
if (!t) return null;
|
|
2619
|
+
const r = t.scenes[e.currentSceneId];
|
|
2620
|
+
return r ? r.steps[e.currentStepId] ?? null : null;
|
|
2621
|
+
}, vr = (n, e, t, r, a) => {
|
|
2622
|
+
const s = [], i = /* @__PURE__ */ new Set();
|
|
2623
|
+
let u = n.entryStepId;
|
|
2624
|
+
for (; u && !i.has(u); ) {
|
|
2625
|
+
i.add(u);
|
|
2626
|
+
const o = n.steps[u];
|
|
2627
|
+
if (!o) break;
|
|
2628
|
+
if (o.type !== "action") {
|
|
2629
|
+
if (s.push({ step: o }), u === a) break;
|
|
2630
|
+
u = o.next;
|
|
2631
|
+
continue;
|
|
2632
|
+
}
|
|
2633
|
+
if (o.actionType === "button") {
|
|
2634
|
+
const $ = e.find(
|
|
2635
|
+
(b) => b.chapterId === t && b.sceneId === r && b.stepId === u
|
|
2636
|
+
);
|
|
2637
|
+
if (!$) {
|
|
2638
|
+
s.push({ step: o });
|
|
2639
|
+
break;
|
|
2640
|
+
}
|
|
2641
|
+
const h = o.payload.find(
|
|
2642
|
+
(b) => b.actionId === $.value
|
|
2643
|
+
);
|
|
2644
|
+
if (!h || (s.push({ step: o, selectedAction: h }), u === a)) break;
|
|
2645
|
+
u = h.next;
|
|
2646
|
+
continue;
|
|
2647
|
+
}
|
|
2648
|
+
if (s.push({ step: o }), u === a) break;
|
|
2649
|
+
u = o.payload[0]?.next;
|
|
2650
|
+
}
|
|
2651
|
+
return s;
|
|
2652
|
+
};
|
|
2653
|
+
class Mr extends f {
|
|
2654
|
+
async getCurrentStep(e, t) {
|
|
2655
|
+
const r = await this.get({ user: e, storyId: t });
|
|
2656
|
+
if (!r) return null;
|
|
2657
|
+
const a = await T.get(t);
|
|
2658
|
+
return a ? z(a, r) : null;
|
|
2659
|
+
}
|
|
2660
|
+
async getSceneSteps(e, t, r, a) {
|
|
2661
|
+
const s = await this.get({ user: e, storyId: t });
|
|
2662
|
+
if (!s) return null;
|
|
2663
|
+
const i = await T.get(t);
|
|
2664
|
+
if (!i) return null;
|
|
2665
|
+
const u = i.chapters[r];
|
|
2666
|
+
if (!u) return null;
|
|
2667
|
+
const o = u.scenes[a];
|
|
2668
|
+
if (!o) return null;
|
|
2669
|
+
const m = s.status === "in_progress" && s.currentChapterId === r && s.currentSceneId === a;
|
|
2670
|
+
return vr(
|
|
2671
|
+
o,
|
|
2672
|
+
s.choices,
|
|
2673
|
+
r,
|
|
2674
|
+
a,
|
|
2675
|
+
m ? s.currentStepId : void 0
|
|
2676
|
+
);
|
|
2677
|
+
}
|
|
2678
|
+
async start(e, t) {
|
|
2679
|
+
const r = await T.get(t);
|
|
2680
|
+
if (!r) return null;
|
|
2681
|
+
const a = r.chapters[r.entryChapterId];
|
|
2682
|
+
if (!a) return null;
|
|
2683
|
+
const s = a.scenes[a.entrySceneId];
|
|
2684
|
+
if (!s) return null;
|
|
2685
|
+
await Or(e, t), this.invalidate({ user: e, storyId: t });
|
|
2686
|
+
const i = await Er(
|
|
2687
|
+
e,
|
|
2688
|
+
t,
|
|
2689
|
+
r.entryChapterId,
|
|
2690
|
+
a.entrySceneId,
|
|
2691
|
+
s.entryStepId
|
|
2692
|
+
), u = p(i);
|
|
2693
|
+
return this.cache.set(this.normalizeKey({ user: e, storyId: t }), u), u;
|
|
2694
|
+
}
|
|
2695
|
+
async advanceToNext(e, t) {
|
|
2696
|
+
const r = await this.get({ user: e, storyId: t });
|
|
2697
|
+
if (!r) return { status: "error" };
|
|
2698
|
+
if (r.status === "completed") return { status: "completed" };
|
|
2699
|
+
const a = await T.get(t);
|
|
2700
|
+
if (!a) return { status: "error" };
|
|
2701
|
+
const s = z(a, r);
|
|
2702
|
+
if (!s) return { status: "error" };
|
|
2703
|
+
if (s.type === "action") return { status: "action_required" };
|
|
2704
|
+
if (!s.next) return { status: "scene_ended" };
|
|
2705
|
+
const i = a.chapters[r.currentChapterId];
|
|
2706
|
+
if (!i) return { status: "error" };
|
|
2707
|
+
const u = i.scenes[r.currentSceneId];
|
|
2708
|
+
if (!u) return { status: "error" };
|
|
2709
|
+
if (!u.steps[s.next]) return { status: "scene_ended" };
|
|
2710
|
+
const o = await this.advanceTo(
|
|
2711
|
+
e,
|
|
2712
|
+
t,
|
|
2713
|
+
a,
|
|
2714
|
+
r.currentChapterId,
|
|
2715
|
+
r.currentSceneId,
|
|
2716
|
+
s.next
|
|
2717
|
+
);
|
|
2718
|
+
return o ? { status: "advanced", data: o } : { status: "error" };
|
|
2719
|
+
}
|
|
2720
|
+
async advanceToNextScene(e, t) {
|
|
2721
|
+
const r = await this.get({ user: e, storyId: t });
|
|
2722
|
+
if (!r || r.status === "completed") return null;
|
|
2723
|
+
const a = await T.get(t);
|
|
2724
|
+
if (!a) return null;
|
|
2725
|
+
const s = a.chapters[r.currentChapterId];
|
|
2726
|
+
if (!s) return null;
|
|
2727
|
+
const i = s.scenes[r.currentSceneId];
|
|
2728
|
+
if (!i || !i.next) return null;
|
|
2729
|
+
const u = s.scenes[i.next];
|
|
2730
|
+
return u ? this.update(
|
|
2731
|
+
{ user: e, storyId: t },
|
|
2732
|
+
{
|
|
2733
|
+
$set: {
|
|
2734
|
+
currentSceneId: i.next,
|
|
2735
|
+
currentStepId: u.entryStepId
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
) : null;
|
|
2739
|
+
}
|
|
2740
|
+
async validateCommandAndAdvance(e, t, r) {
|
|
2741
|
+
const a = await this.get({ user: e, storyId: t });
|
|
2742
|
+
if (!a || a.status === "completed") return null;
|
|
2743
|
+
const s = await T.get(t);
|
|
2744
|
+
if (!s) return null;
|
|
2745
|
+
const i = z(s, a);
|
|
2746
|
+
if (!i || i.type !== "action" || i.actionType !== "command")
|
|
2747
|
+
return null;
|
|
2748
|
+
const u = i.payload.find((o) => o.commandId === r);
|
|
2749
|
+
return u ? this.advanceTo(
|
|
2750
|
+
e,
|
|
2751
|
+
t,
|
|
2752
|
+
s,
|
|
2753
|
+
a.currentChapterId,
|
|
2754
|
+
a.currentSceneId,
|
|
2755
|
+
u.next
|
|
2756
|
+
) : null;
|
|
2757
|
+
}
|
|
2758
|
+
async validateActionAndAdvance(e, t, r) {
|
|
2759
|
+
const a = await this.get({ user: e, storyId: t });
|
|
2760
|
+
if (!a || a.status === "completed") return null;
|
|
2761
|
+
const s = await T.get(t);
|
|
2762
|
+
if (!s) return null;
|
|
2763
|
+
const i = z(s, a);
|
|
2764
|
+
if (!i || i.type !== "action") return null;
|
|
2765
|
+
const u = i.payload.find((o) => o.actionId === r);
|
|
2766
|
+
return u ? this.advanceTo(
|
|
2767
|
+
e,
|
|
2768
|
+
t,
|
|
2769
|
+
s,
|
|
2770
|
+
a.currentChapterId,
|
|
2771
|
+
a.currentSceneId,
|
|
2772
|
+
u.next,
|
|
2773
|
+
{
|
|
2774
|
+
chapterId: a.currentChapterId,
|
|
2775
|
+
sceneId: a.currentSceneId,
|
|
2776
|
+
stepId: a.currentStepId,
|
|
2777
|
+
value: r
|
|
2778
|
+
}
|
|
2779
|
+
) : null;
|
|
2780
|
+
}
|
|
2781
|
+
async advanceTo(e, t, r, a, s, i, u) {
|
|
2782
|
+
const o = Dr(r, a, s, i);
|
|
2783
|
+
return o ? this.update(
|
|
2784
|
+
{ user: e, storyId: t },
|
|
2785
|
+
{
|
|
2786
|
+
$set: {
|
|
2787
|
+
currentChapterId: o.chapterId,
|
|
2788
|
+
currentSceneId: o.sceneId,
|
|
2789
|
+
currentStepId: o.stepId
|
|
2790
|
+
},
|
|
2791
|
+
...u && { $push: { choices: u } }
|
|
2792
|
+
}
|
|
2793
|
+
) : this.update(
|
|
2794
|
+
{ user: e, storyId: t },
|
|
2795
|
+
{
|
|
2796
|
+
$set: { status: "completed" },
|
|
2797
|
+
...u && { $push: { choices: u } }
|
|
2798
|
+
}
|
|
2799
|
+
);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
const xr = (n, e = {}) => H.find(n, null, e).lean(), Ar = (n, e) => H.findOne({ user: n, storyId: e }).lean(), qr = (n, e) => H.findOneAndUpdate(n, e, {
|
|
2803
|
+
returnDocument: "after"
|
|
2804
|
+
}).lean();
|
|
2805
|
+
class kr extends Mr {
|
|
2806
|
+
constructor() {
|
|
2807
|
+
super(120);
|
|
2808
|
+
}
|
|
2809
|
+
normalizeKey(e) {
|
|
2810
|
+
return `${e.user.toString()}:${e.storyId}`;
|
|
2811
|
+
}
|
|
2812
|
+
getKey(e) {
|
|
2813
|
+
return { user: e.user, storyId: e.storyId };
|
|
2814
|
+
}
|
|
2815
|
+
fetchFromDb(e) {
|
|
2816
|
+
return Ar(e.user, e.storyId);
|
|
2817
|
+
}
|
|
2818
|
+
fetchManyFromDb(e, t) {
|
|
2819
|
+
return xr(e, t);
|
|
2462
2820
|
}
|
|
2463
2821
|
updateInDb(e, t) {
|
|
2464
|
-
return
|
|
2822
|
+
return qr(e, t);
|
|
2465
2823
|
}
|
|
2466
2824
|
}
|
|
2467
|
-
const
|
|
2468
|
-
class
|
|
2825
|
+
const Va = new kr();
|
|
2826
|
+
class Rr extends y {
|
|
2469
2827
|
async didSevenDoubleAtDoQ(e) {
|
|
2470
2828
|
await this.update(e, {
|
|
2471
2829
|
$inc: { "doubleOrQuit.sevenDoubleInARowCount": 1 }
|
|
@@ -2474,11 +2832,11 @@ class ta extends y {
|
|
|
2474
2832
|
async winWithBlackjack(e) {
|
|
2475
2833
|
await this.update(e, { $inc: { "blackJack.blackJackCount": 1 } });
|
|
2476
2834
|
}
|
|
2477
|
-
async updateLastGames(e, t,
|
|
2835
|
+
async updateLastGames(e, t, r) {
|
|
2478
2836
|
await this.update(e, {
|
|
2479
2837
|
$push: {
|
|
2480
2838
|
lastGames: {
|
|
2481
|
-
$each: [{ gameType: t, endState:
|
|
2839
|
+
$each: [{ gameType: t, endState: r }],
|
|
2482
2840
|
$position: 0,
|
|
2483
2841
|
$slice: 20
|
|
2484
2842
|
}
|
|
@@ -2489,19 +2847,19 @@ class ta extends y {
|
|
|
2489
2847
|
await this.update(e, { $inc: { drawCount: 1 } });
|
|
2490
2848
|
}
|
|
2491
2849
|
async bet666(e) {
|
|
2492
|
-
const t =
|
|
2850
|
+
const t = Y();
|
|
2493
2851
|
t.setHours(0, 0, 0, 0);
|
|
2494
|
-
const
|
|
2495
|
-
|
|
2852
|
+
const r = /* @__PURE__ */ new Date();
|
|
2853
|
+
r.setHours(0, 0, 0, 0), await q.updateOne(
|
|
2496
2854
|
{
|
|
2497
2855
|
user: e,
|
|
2498
2856
|
"bet666.last": {
|
|
2499
2857
|
$gte: t,
|
|
2500
|
-
$lt:
|
|
2858
|
+
$lt: r
|
|
2501
2859
|
}
|
|
2502
2860
|
},
|
|
2503
2861
|
{ $inc: { "bet666.count": 1 }, $set: { "bet666.last": /* @__PURE__ */ new Date() } }
|
|
2504
|
-
), await
|
|
2862
|
+
), await q.updateOne(
|
|
2505
2863
|
{
|
|
2506
2864
|
user: e,
|
|
2507
2865
|
"bet666.last": {
|
|
@@ -2544,18 +2902,18 @@ class ta extends y {
|
|
|
2544
2902
|
await this.update(e, { $inc: { "dice.drawWithDoubleSixCount": 1 } });
|
|
2545
2903
|
}
|
|
2546
2904
|
}
|
|
2547
|
-
const
|
|
2905
|
+
const Cr = async (n) => await q.create({
|
|
2548
2906
|
user: n
|
|
2549
2907
|
});
|
|
2550
|
-
async function
|
|
2551
|
-
const e = await
|
|
2552
|
-
return e || p(await
|
|
2908
|
+
async function Br(n) {
|
|
2909
|
+
const e = await q.findOne({ user: n }).lean();
|
|
2910
|
+
return e || p(await Cr(n));
|
|
2553
2911
|
}
|
|
2554
|
-
const
|
|
2912
|
+
const _r = (n, e) => q.findOneAndUpdate({ user: n }, e, {
|
|
2555
2913
|
upsert: !0,
|
|
2556
2914
|
returnDocument: "after"
|
|
2557
2915
|
}).lean();
|
|
2558
|
-
class
|
|
2916
|
+
class Fr extends Rr {
|
|
2559
2917
|
constructor() {
|
|
2560
2918
|
super(300);
|
|
2561
2919
|
}
|
|
@@ -2566,14 +2924,14 @@ class sa extends ta {
|
|
|
2566
2924
|
return e;
|
|
2567
2925
|
}
|
|
2568
2926
|
fetchFromDb(e) {
|
|
2569
|
-
return
|
|
2927
|
+
return Br(e);
|
|
2570
2928
|
}
|
|
2571
2929
|
updateInDb(e, t) {
|
|
2572
|
-
return
|
|
2930
|
+
return _r(e, t);
|
|
2573
2931
|
}
|
|
2574
2932
|
}
|
|
2575
|
-
const
|
|
2576
|
-
class
|
|
2933
|
+
const Xa = new Fr();
|
|
2934
|
+
class Nr extends y {
|
|
2577
2935
|
async workIncrement(e) {
|
|
2578
2936
|
await this.update(e, { $inc: { workCount: 1 } });
|
|
2579
2937
|
}
|
|
@@ -2585,18 +2943,18 @@ class ia extends y {
|
|
|
2585
2943
|
});
|
|
2586
2944
|
}
|
|
2587
2945
|
}
|
|
2588
|
-
const
|
|
2946
|
+
const Kr = (n) => te.create({
|
|
2589
2947
|
user: n
|
|
2590
2948
|
});
|
|
2591
|
-
async function
|
|
2592
|
-
const e = await
|
|
2593
|
-
return e || p(await
|
|
2949
|
+
async function Hr(n) {
|
|
2950
|
+
const e = await te.findOne({ user: n }).lean();
|
|
2951
|
+
return e || p(await Kr(n));
|
|
2594
2952
|
}
|
|
2595
|
-
const
|
|
2953
|
+
const Pr = (n, e) => te.findOneAndUpdate({ user: n }, e, {
|
|
2596
2954
|
upsert: !0,
|
|
2597
2955
|
returnDocument: "after"
|
|
2598
2956
|
}).lean();
|
|
2599
|
-
class
|
|
2957
|
+
class jr extends Nr {
|
|
2600
2958
|
constructor() {
|
|
2601
2959
|
super(300);
|
|
2602
2960
|
}
|
|
@@ -2607,14 +2965,14 @@ class da extends ia {
|
|
|
2607
2965
|
return e;
|
|
2608
2966
|
}
|
|
2609
2967
|
fetchFromDb(e) {
|
|
2610
|
-
return
|
|
2968
|
+
return Hr(e);
|
|
2611
2969
|
}
|
|
2612
2970
|
updateInDb(e, t) {
|
|
2613
|
-
return
|
|
2971
|
+
return Pr(e, t);
|
|
2614
2972
|
}
|
|
2615
2973
|
}
|
|
2616
|
-
const
|
|
2617
|
-
class
|
|
2974
|
+
const Ja = new jr();
|
|
2975
|
+
class zr extends y {
|
|
2618
2976
|
async hasReportedSomeone(e) {
|
|
2619
2977
|
await this.update(e, { $set: { reportedSomeone: !0 } });
|
|
2620
2978
|
}
|
|
@@ -2645,18 +3003,18 @@ class la extends y {
|
|
|
2645
3003
|
await this.update(e, { $set: { "gamblingFlags.lose10M": !0 } });
|
|
2646
3004
|
}
|
|
2647
3005
|
}
|
|
2648
|
-
const
|
|
3006
|
+
const Lr = async (n) => await re.create({
|
|
2649
3007
|
user: n
|
|
2650
3008
|
});
|
|
2651
|
-
async function
|
|
2652
|
-
const e = await
|
|
2653
|
-
return e || p(await
|
|
3009
|
+
async function Qr(n) {
|
|
3010
|
+
const e = await re.findOne({ user: n }).lean();
|
|
3011
|
+
return e || p(await Lr(n));
|
|
2654
3012
|
}
|
|
2655
|
-
const
|
|
3013
|
+
const Yr = (n, e) => re.findOneAndUpdate({ user: n }, e, {
|
|
2656
3014
|
upsert: !0,
|
|
2657
3015
|
returnDocument: "after"
|
|
2658
3016
|
}).lean();
|
|
2659
|
-
class
|
|
3017
|
+
class Gr extends zr {
|
|
2660
3018
|
constructor() {
|
|
2661
3019
|
super(300);
|
|
2662
3020
|
}
|
|
@@ -2667,17 +3025,17 @@ class ma extends la {
|
|
|
2667
3025
|
return e;
|
|
2668
3026
|
}
|
|
2669
3027
|
fetchFromDb(e) {
|
|
2670
|
-
return
|
|
3028
|
+
return Qr(e);
|
|
2671
3029
|
}
|
|
2672
3030
|
updateInDb(e, t) {
|
|
2673
|
-
return
|
|
3031
|
+
return Yr(e, t);
|
|
2674
3032
|
}
|
|
2675
3033
|
}
|
|
2676
|
-
const
|
|
2677
|
-
class
|
|
3034
|
+
const Za = new Gr();
|
|
3035
|
+
class Wr extends y {
|
|
2678
3036
|
async readEdito(e) {
|
|
2679
3037
|
const t = /* @__PURE__ */ new Date();
|
|
2680
|
-
t.setHours(0, 0, 0, 0), await
|
|
3038
|
+
t.setHours(0, 0, 0, 0), await O.updateOne(
|
|
2681
3039
|
{
|
|
2682
3040
|
user: e,
|
|
2683
3041
|
"edito.lastTimeRead": {
|
|
@@ -2688,7 +3046,7 @@ class ha extends y {
|
|
|
2688
3046
|
$inc: { "edito.readToday": 1 },
|
|
2689
3047
|
$set: { "edito.lastTimeRead": /* @__PURE__ */ new Date() }
|
|
2690
3048
|
}
|
|
2691
|
-
), await
|
|
3049
|
+
), await O.updateOne(
|
|
2692
3050
|
{
|
|
2693
3051
|
user: e,
|
|
2694
3052
|
"edito.lastTimeRead": {
|
|
@@ -2702,7 +3060,7 @@ class ha extends y {
|
|
|
2702
3060
|
}
|
|
2703
3061
|
async getTotalEditoReadToday() {
|
|
2704
3062
|
const e = /* @__PURE__ */ new Date();
|
|
2705
|
-
return e.setHours(0, 0, 0, 0), (await
|
|
3063
|
+
return e.setHours(0, 0, 0, 0), (await O.aggregate([
|
|
2706
3064
|
{
|
|
2707
3065
|
$match: {
|
|
2708
3066
|
"edito.lastTimeRead": { $gte: e },
|
|
@@ -2713,18 +3071,18 @@ class ha extends y {
|
|
|
2713
3071
|
]))[0]?.total ?? 0;
|
|
2714
3072
|
}
|
|
2715
3073
|
}
|
|
2716
|
-
const
|
|
3074
|
+
const Vr = async (n) => await O.create({
|
|
2717
3075
|
user: n
|
|
2718
3076
|
});
|
|
2719
|
-
async function
|
|
2720
|
-
const e = await
|
|
2721
|
-
return e || p(await
|
|
3077
|
+
async function Xr(n) {
|
|
3078
|
+
const e = await O.findOne({ user: n }).lean();
|
|
3079
|
+
return e || p(await Vr(n));
|
|
2722
3080
|
}
|
|
2723
|
-
const
|
|
3081
|
+
const Jr = (n, e) => O.findOneAndUpdate({ user: n }, e, {
|
|
2724
3082
|
upsert: !0,
|
|
2725
3083
|
returnDocument: "after"
|
|
2726
3084
|
}).lean();
|
|
2727
|
-
class
|
|
3085
|
+
class Zr extends Wr {
|
|
2728
3086
|
constructor() {
|
|
2729
3087
|
super(300);
|
|
2730
3088
|
}
|
|
@@ -2735,39 +3093,39 @@ class ba extends ha {
|
|
|
2735
3093
|
return e;
|
|
2736
3094
|
}
|
|
2737
3095
|
fetchFromDb(e) {
|
|
2738
|
-
return
|
|
3096
|
+
return Xr(e);
|
|
2739
3097
|
}
|
|
2740
3098
|
updateInDb(e, t) {
|
|
2741
|
-
return
|
|
3099
|
+
return Jr(e, t);
|
|
2742
3100
|
}
|
|
2743
3101
|
}
|
|
2744
|
-
const
|
|
2745
|
-
class
|
|
2746
|
-
async updateCraftStats(e, t,
|
|
2747
|
-
const
|
|
2748
|
-
!
|
|
3102
|
+
const es = new Zr();
|
|
3103
|
+
class ea extends y {
|
|
3104
|
+
async updateCraftStats(e, t, r) {
|
|
3105
|
+
const a = await U.get(r);
|
|
3106
|
+
!a || !U.isItem(a) || await this.update(e, {
|
|
2749
3107
|
$inc: {
|
|
2750
3108
|
"crafts.totalCrafted": t
|
|
2751
3109
|
}
|
|
2752
3110
|
});
|
|
2753
3111
|
}
|
|
2754
|
-
async incrementAlcoholDrink(e, t,
|
|
3112
|
+
async incrementAlcoholDrink(e, t, r) {
|
|
2755
3113
|
["wine", "beer", "rhum"].includes(t) && await this.update(e, {
|
|
2756
3114
|
$inc: {
|
|
2757
|
-
"alcohols.wines": t === "wine" ?
|
|
2758
|
-
"alcohols.beers": t === "beer" ?
|
|
2759
|
-
"alcohols.rhums": t === "rhum" ?
|
|
2760
|
-
"alcohols.totalConsumed":
|
|
3115
|
+
"alcohols.wines": t === "wine" ? r : 0,
|
|
3116
|
+
"alcohols.beers": t === "beer" ? r : 0,
|
|
3117
|
+
"alcohols.rhums": t === "rhum" ? r : 0,
|
|
3118
|
+
"alcohols.totalConsumed": r
|
|
2761
3119
|
}
|
|
2762
3120
|
});
|
|
2763
3121
|
}
|
|
2764
3122
|
async incrementBottleUsedToday(e, t) {
|
|
2765
|
-
const
|
|
2766
|
-
|
|
3123
|
+
const r = /* @__PURE__ */ new Date();
|
|
3124
|
+
r.setHours(0, 0, 0, 0), await k.updateOne(
|
|
2767
3125
|
{
|
|
2768
3126
|
user: e,
|
|
2769
3127
|
"bottle.lastUsed": {
|
|
2770
|
-
$gte:
|
|
3128
|
+
$gte: r
|
|
2771
3129
|
}
|
|
2772
3130
|
},
|
|
2773
3131
|
{
|
|
@@ -2778,7 +3136,7 @@ class $a extends y {
|
|
|
2778
3136
|
{
|
|
2779
3137
|
user: e,
|
|
2780
3138
|
"bottle.lastUsed": {
|
|
2781
|
-
$lt:
|
|
3139
|
+
$lt: r
|
|
2782
3140
|
}
|
|
2783
3141
|
},
|
|
2784
3142
|
{
|
|
@@ -2800,18 +3158,18 @@ class $a extends y {
|
|
|
2800
3158
|
});
|
|
2801
3159
|
}
|
|
2802
3160
|
}
|
|
2803
|
-
const
|
|
3161
|
+
const ta = async (n) => await k.create({
|
|
2804
3162
|
user: n
|
|
2805
3163
|
});
|
|
2806
|
-
async function
|
|
3164
|
+
async function na(n) {
|
|
2807
3165
|
const e = await k.findOne({ user: n }).lean();
|
|
2808
|
-
return e || p(await
|
|
3166
|
+
return e || p(await ta(n));
|
|
2809
3167
|
}
|
|
2810
|
-
const
|
|
3168
|
+
const ra = (n, e) => k.findOneAndUpdate({ user: n }, e, {
|
|
2811
3169
|
upsert: !0,
|
|
2812
3170
|
returnDocument: "after"
|
|
2813
3171
|
}).lean();
|
|
2814
|
-
class
|
|
3172
|
+
class aa extends ea {
|
|
2815
3173
|
constructor() {
|
|
2816
3174
|
super(300);
|
|
2817
3175
|
}
|
|
@@ -2822,134 +3180,123 @@ class Ia extends $a {
|
|
|
2822
3180
|
return e;
|
|
2823
3181
|
}
|
|
2824
3182
|
fetchFromDb(e) {
|
|
2825
|
-
return
|
|
3183
|
+
return na(e);
|
|
2826
3184
|
}
|
|
2827
3185
|
updateInDb(e, t) {
|
|
2828
|
-
return
|
|
3186
|
+
return ra(e, t);
|
|
2829
3187
|
}
|
|
2830
3188
|
}
|
|
2831
|
-
const
|
|
2832
|
-
class
|
|
3189
|
+
const ts = new aa();
|
|
3190
|
+
class sa extends f {
|
|
2833
3191
|
async maxCraftQuantity(e, t) {
|
|
2834
|
-
const
|
|
2835
|
-
let
|
|
3192
|
+
const r = await M.get(e);
|
|
3193
|
+
let a = 1 / 0;
|
|
2836
3194
|
for (const s of t)
|
|
2837
|
-
|
|
2838
|
-
|
|
3195
|
+
a = Math.min(
|
|
3196
|
+
a,
|
|
2839
3197
|
Math.floor(
|
|
2840
|
-
(
|
|
3198
|
+
(r.itemList[s.entityId] ?? 0) / (s.size ?? 1)
|
|
2841
3199
|
)
|
|
2842
3200
|
);
|
|
2843
|
-
return
|
|
3201
|
+
return a;
|
|
2844
3202
|
}
|
|
2845
|
-
async hasEnoughItemsForRecipe(e, t,
|
|
2846
|
-
const
|
|
3203
|
+
async hasEnoughItemsForRecipe(e, t, r) {
|
|
3204
|
+
const a = await M.get(e);
|
|
2847
3205
|
for (const s of t.entities)
|
|
2848
|
-
if ((
|
|
3206
|
+
if ((a.itemList[s.entityId] ?? 0) < (s.size ?? 1) * r)
|
|
2849
3207
|
return !1;
|
|
2850
3208
|
return !0;
|
|
2851
3209
|
}
|
|
2852
|
-
decodeCraftId(e) {
|
|
2853
|
-
return e.split(";").map((t, a) => ({
|
|
2854
|
-
entityId: t === "null" ? null : t,
|
|
2855
|
-
index: a
|
|
2856
|
-
}));
|
|
2857
|
-
}
|
|
2858
|
-
encodeCraftId(e) {
|
|
2859
|
-
return e.map(({ entityId: t }) => `${t}`).join(";");
|
|
2860
|
-
}
|
|
2861
3210
|
async isValidRecipe(e) {
|
|
2862
|
-
return !!(await this.getAll()).find((
|
|
3211
|
+
return !!(await this.getAll()).find((r) => r.recipeId === e);
|
|
2863
3212
|
}
|
|
2864
3213
|
async getRecipeResult(e, t) {
|
|
2865
|
-
|
|
2866
|
-
([s, i]) => s.panoplyId === "little_blacksmith" && i !== null
|
|
2867
|
-
);
|
|
2868
|
-
return r?.[1] === "full" && t === "chest_3" ? "chest_blacksmith_3" : r?.[1] === "half" && t === "chest_2" ? "chest_blacksmith_2" : r?.[1] === "half" && t === "chest_1" ? "chest_blacksmith_1" : t;
|
|
3214
|
+
return t;
|
|
2869
3215
|
}
|
|
2870
3216
|
}
|
|
2871
|
-
const
|
|
3217
|
+
const ia = new c(
|
|
2872
3218
|
{
|
|
2873
3219
|
entityId: { type: String, required: !0 },
|
|
2874
|
-
size: { type: Number,
|
|
3220
|
+
size: { type: Number, default: 1 }
|
|
2875
3221
|
},
|
|
2876
3222
|
{ _id: !1 }
|
|
2877
|
-
),
|
|
3223
|
+
), ua = new c(
|
|
2878
3224
|
{
|
|
2879
3225
|
entityId: { type: String, required: !0 },
|
|
2880
|
-
size: { type: Number
|
|
3226
|
+
size: { type: Number }
|
|
2881
3227
|
},
|
|
2882
3228
|
{ _id: !1 }
|
|
2883
|
-
),
|
|
3229
|
+
), ca = new c(
|
|
2884
3230
|
{
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
3231
|
+
recipeId: { type: String, unique: !0, required: !0 },
|
|
3232
|
+
rankId: String,
|
|
3233
|
+
type: { type: String, required: !0 },
|
|
3234
|
+
entities: { type: [ia], required: !0 },
|
|
3235
|
+
result: { type: ua, required: !0 }
|
|
2889
3236
|
},
|
|
2890
3237
|
{ minimize: !1 }
|
|
2891
|
-
),
|
|
3238
|
+
), se = d?.Recipes || l("Recipes", ca), oa = async (n) => await se.create({
|
|
2892
3239
|
...n
|
|
2893
|
-
}),
|
|
2894
|
-
async function
|
|
2895
|
-
const e = await
|
|
3240
|
+
}), da = async (n, e) => se.find(n, {}, e).lean();
|
|
3241
|
+
async function la(n) {
|
|
3242
|
+
const e = await se.findOne({ recipeId: n }).lean();
|
|
2896
3243
|
return e || null;
|
|
2897
3244
|
}
|
|
2898
|
-
const
|
|
3245
|
+
const pa = (n, e) => se.findOneAndUpdate(n, e, {
|
|
2899
3246
|
returnDocument: "after"
|
|
2900
3247
|
}).lean();
|
|
2901
|
-
class
|
|
3248
|
+
class ya extends sa {
|
|
2902
3249
|
constructor() {
|
|
2903
3250
|
super(3600);
|
|
2904
3251
|
}
|
|
2905
3252
|
createInDb(e) {
|
|
2906
|
-
return
|
|
3253
|
+
return oa(e);
|
|
2907
3254
|
}
|
|
2908
3255
|
updateInDb(e, t) {
|
|
2909
|
-
return
|
|
3256
|
+
return pa(e, t);
|
|
2910
3257
|
}
|
|
2911
3258
|
fetchFromDb(e) {
|
|
2912
|
-
return
|
|
3259
|
+
return la(e);
|
|
2913
3260
|
}
|
|
2914
3261
|
fetchManyFromDb(e, t) {
|
|
2915
|
-
return
|
|
3262
|
+
return da(e, t);
|
|
2916
3263
|
}
|
|
2917
3264
|
normalizeKey(e) {
|
|
2918
3265
|
return e;
|
|
2919
3266
|
}
|
|
2920
3267
|
getKey(e) {
|
|
2921
|
-
return e.
|
|
3268
|
+
return e.recipeId;
|
|
2922
3269
|
}
|
|
2923
3270
|
}
|
|
2924
|
-
const
|
|
3271
|
+
const ns = new ya(), fa = new c({
|
|
2925
3272
|
bannedUserId: { type: String, index: !0, required: !0 },
|
|
2926
3273
|
authorId: { type: String, required: !0 },
|
|
2927
3274
|
unbannedTimestamp: { type: Date, index: 1 },
|
|
2928
3275
|
reason: { type: String, required: !0 },
|
|
2929
3276
|
guildId: { type: String, required: !0 }
|
|
2930
|
-
}),
|
|
2931
|
-
class
|
|
3277
|
+
}), ie = d?.Bans || l("Bans", fa), ma = (n, e) => ie.deleteOne({ bannedUserId: n, guildId: e });
|
|
3278
|
+
class ha extends f {
|
|
2932
3279
|
async getUnbanUsers() {
|
|
2933
3280
|
return this.getMany({
|
|
2934
3281
|
unbannedTimestamp: { $lte: /* @__PURE__ */ new Date(), $ne: null }
|
|
2935
3282
|
});
|
|
2936
3283
|
}
|
|
2937
|
-
async banUserFromGuild({ bannedUserId: e, guildId: t, ...
|
|
2938
|
-
await this.update({ bannedUserId: e, guildId: t }, { ...
|
|
3284
|
+
async banUserFromGuild({ bannedUserId: e, guildId: t, ...r }) {
|
|
3285
|
+
await this.update({ bannedUserId: e, guildId: t }, { ...r });
|
|
2939
3286
|
}
|
|
2940
3287
|
async isBannedFromGuild(e, t) {
|
|
2941
|
-
const
|
|
2942
|
-
return !!(
|
|
3288
|
+
const r = await this.get({ bannedUserId: e, guildId: t });
|
|
3289
|
+
return !!(r && (!r.unbannedTimestamp || r.unbannedTimestamp > /* @__PURE__ */ new Date()));
|
|
2943
3290
|
}
|
|
2944
3291
|
async deleteBan(e, t) {
|
|
2945
|
-
await
|
|
3292
|
+
await ma(e, t), this.invalidate({ bannedUserId: e, guildId: t });
|
|
2946
3293
|
}
|
|
2947
3294
|
}
|
|
2948
|
-
const
|
|
3295
|
+
const ga = (n) => ie.find(n).lean(), Sa = (n) => ie.findOne(n).lean(), wa = (n, e) => ie.findOneAndUpdate(n, e, {
|
|
2949
3296
|
returnDocument: "after",
|
|
2950
3297
|
upsert: !0
|
|
2951
3298
|
}).lean();
|
|
2952
|
-
class
|
|
3299
|
+
class ba extends ha {
|
|
2953
3300
|
constructor() {
|
|
2954
3301
|
super(3600 * 36);
|
|
2955
3302
|
}
|
|
@@ -2960,23 +3307,23 @@ class Ka extends _a {
|
|
|
2960
3307
|
return { bannedUserId: e, guildId: t };
|
|
2961
3308
|
}
|
|
2962
3309
|
fetchFromDb(e) {
|
|
2963
|
-
return
|
|
3310
|
+
return Sa(e);
|
|
2964
3311
|
}
|
|
2965
3312
|
fetchManyFromDb(e) {
|
|
2966
|
-
return
|
|
3313
|
+
return ga(e);
|
|
2967
3314
|
}
|
|
2968
3315
|
updateInDb(e, t) {
|
|
2969
|
-
return
|
|
3316
|
+
return wa(e, t);
|
|
2970
3317
|
}
|
|
2971
3318
|
}
|
|
2972
|
-
const
|
|
3319
|
+
const rs = new ba(), $a = new c({
|
|
2973
3320
|
senderId: {
|
|
2974
|
-
type:
|
|
3321
|
+
type: c.Types.ObjectId,
|
|
2975
3322
|
required: !0,
|
|
2976
3323
|
ref: "User"
|
|
2977
3324
|
},
|
|
2978
3325
|
receiverId: {
|
|
2979
|
-
type:
|
|
3326
|
+
type: c.Types.ObjectId,
|
|
2980
3327
|
required: !0,
|
|
2981
3328
|
index: !0,
|
|
2982
3329
|
ref: "User"
|
|
@@ -2986,36 +3333,36 @@ const Dr = new Ka(), ja = new u({
|
|
|
2986
3333
|
meta: {
|
|
2987
3334
|
rps: { type: String, default: void 0 }
|
|
2988
3335
|
}
|
|
2989
|
-
}),
|
|
3336
|
+
}), ue = d?.Invitation || l("Invitation", $a), Ia = (n) => ue.create({
|
|
2990
3337
|
...n
|
|
2991
|
-
}),
|
|
2992
|
-
await
|
|
3338
|
+
}), Ua = async (n) => {
|
|
3339
|
+
await ue.deleteMany({
|
|
2993
3340
|
...n
|
|
2994
3341
|
});
|
|
2995
3342
|
};
|
|
2996
|
-
class
|
|
3343
|
+
class Ta extends y {
|
|
2997
3344
|
async sendInvitation({
|
|
2998
3345
|
senderId: e,
|
|
2999
3346
|
receiverId: t,
|
|
3000
|
-
gameMode:
|
|
3001
|
-
...
|
|
3347
|
+
gameMode: r,
|
|
3348
|
+
...a
|
|
3002
3349
|
}) {
|
|
3003
|
-
return await this.get({ senderId: e, gameMode:
|
|
3350
|
+
return await this.get({ senderId: e, gameMode: r, receiverId: t }) ? null : await Ia({ ...a, senderId: e, gameMode: r, receiverId: t });
|
|
3004
3351
|
}
|
|
3005
3352
|
async deleteInvitation({
|
|
3006
3353
|
senderId: e,
|
|
3007
3354
|
receiverId: t,
|
|
3008
|
-
gameMode:
|
|
3355
|
+
gameMode: r
|
|
3009
3356
|
}) {
|
|
3010
|
-
await
|
|
3357
|
+
await Ua({ senderId: e, gameMode: r, receiverId: t }), this.invalidate({ senderId: e, gameMode: r, receiverId: t });
|
|
3011
3358
|
}
|
|
3012
3359
|
}
|
|
3013
|
-
const
|
|
3360
|
+
const Ea = (n) => ue.findOne({
|
|
3014
3361
|
...n
|
|
3015
|
-
}).lean(),
|
|
3362
|
+
}).lean(), Oa = (n, e) => ue.findOneAndUpdate(n, e, {
|
|
3016
3363
|
returnDocument: "after"
|
|
3017
3364
|
}).lean();
|
|
3018
|
-
class
|
|
3365
|
+
class Da extends Ta {
|
|
3019
3366
|
constructor() {
|
|
3020
3367
|
super(3600);
|
|
3021
3368
|
}
|
|
@@ -3025,21 +3372,21 @@ class Wa extends La {
|
|
|
3025
3372
|
getKey({
|
|
3026
3373
|
receiverId: e,
|
|
3027
3374
|
gameMode: t,
|
|
3028
|
-
senderId:
|
|
3375
|
+
senderId: r
|
|
3029
3376
|
}) {
|
|
3030
|
-
return { gameMode: t, receiverId: e, senderId:
|
|
3377
|
+
return { gameMode: t, receiverId: e, senderId: r };
|
|
3031
3378
|
}
|
|
3032
3379
|
fetchFromDb(e) {
|
|
3033
|
-
return
|
|
3380
|
+
return Ea(e);
|
|
3034
3381
|
}
|
|
3035
3382
|
updateInDb(e, t) {
|
|
3036
|
-
return
|
|
3383
|
+
return Oa(e, t);
|
|
3037
3384
|
}
|
|
3038
3385
|
}
|
|
3039
|
-
const
|
|
3040
|
-
class
|
|
3386
|
+
const as = new Da();
|
|
3387
|
+
class va extends y {
|
|
3041
3388
|
async randomizeEditoPrice(e) {
|
|
3042
|
-
const t =
|
|
3389
|
+
const t = Ee(100, 1001);
|
|
3043
3390
|
return await this.update({ guildId: e }, { $set: { "edito.price": t } }), t;
|
|
3044
3391
|
}
|
|
3045
3392
|
async setEditoMessageId(e, t) {
|
|
@@ -3051,11 +3398,11 @@ class Ya extends y {
|
|
|
3051
3398
|
{ $set: { "ranking.messageId": t } }
|
|
3052
3399
|
);
|
|
3053
3400
|
}
|
|
3054
|
-
async addCrewChannelId(e, t,
|
|
3401
|
+
async addCrewChannelId(e, t, r) {
|
|
3055
3402
|
await this.update(
|
|
3056
3403
|
{ guildId: e },
|
|
3057
3404
|
{
|
|
3058
|
-
$push: { "crew.crewChannelIds": { channelId:
|
|
3405
|
+
$push: { "crew.crewChannelIds": { channelId: r, crewId: t } }
|
|
3059
3406
|
}
|
|
3060
3407
|
);
|
|
3061
3408
|
}
|
|
@@ -3064,7 +3411,7 @@ class Ya extends y {
|
|
|
3064
3411
|
{ guildId: e },
|
|
3065
3412
|
{
|
|
3066
3413
|
$set: Object.fromEntries(
|
|
3067
|
-
Object.entries(t).map(([
|
|
3414
|
+
Object.entries(t).map(([r, a]) => [`roles.${r}`, a])
|
|
3068
3415
|
)
|
|
3069
3416
|
}
|
|
3070
3417
|
);
|
|
@@ -3074,16 +3421,16 @@ class Ya extends y {
|
|
|
3074
3421
|
{ guildId: e },
|
|
3075
3422
|
{
|
|
3076
3423
|
$set: Object.fromEntries(
|
|
3077
|
-
Object.entries(t).map(([
|
|
3078
|
-
`channels.${
|
|
3079
|
-
|
|
3424
|
+
Object.entries(t).map(([r, a]) => [
|
|
3425
|
+
`channels.${r}`,
|
|
3426
|
+
a
|
|
3080
3427
|
])
|
|
3081
3428
|
)
|
|
3082
3429
|
}
|
|
3083
3430
|
);
|
|
3084
3431
|
}
|
|
3085
3432
|
}
|
|
3086
|
-
const
|
|
3433
|
+
const Ma = new c({
|
|
3087
3434
|
guildId: { type: String, required: !0, unique: !0 },
|
|
3088
3435
|
ranking: {
|
|
3089
3436
|
messageId: { type: String, default: null }
|
|
@@ -3131,16 +3478,16 @@ const Va = new u({
|
|
|
3131
3478
|
default: []
|
|
3132
3479
|
}
|
|
3133
3480
|
}
|
|
3134
|
-
}),
|
|
3481
|
+
}), me = d?.Settings || l("Settings", Ma), xa = (n) => me.create({
|
|
3135
3482
|
guildId: n
|
|
3136
|
-
}),
|
|
3137
|
-
const e = await
|
|
3138
|
-
return e || p(await
|
|
3139
|
-
},
|
|
3483
|
+
}), Aa = async (n) => {
|
|
3484
|
+
const e = await me.findOne({ guildId: n }).lean();
|
|
3485
|
+
return e || p(await xa(n));
|
|
3486
|
+
}, qa = (n, e) => me.findOneAndUpdate(n, e, {
|
|
3140
3487
|
upsert: !0,
|
|
3141
3488
|
returnDocument: "after"
|
|
3142
3489
|
}).lean();
|
|
3143
|
-
class
|
|
3490
|
+
class ka extends va {
|
|
3144
3491
|
constructor() {
|
|
3145
3492
|
super(3600 * 24 * 30);
|
|
3146
3493
|
}
|
|
@@ -3151,37 +3498,37 @@ class er extends Ya {
|
|
|
3151
3498
|
return e;
|
|
3152
3499
|
}
|
|
3153
3500
|
fetchFromDb(e) {
|
|
3154
|
-
return
|
|
3501
|
+
return Aa(e);
|
|
3155
3502
|
}
|
|
3156
3503
|
updateInDb(e, t) {
|
|
3157
|
-
return
|
|
3504
|
+
return qa(e, t);
|
|
3158
3505
|
}
|
|
3159
3506
|
}
|
|
3160
|
-
const
|
|
3507
|
+
const ss = new ka(), Ra = new c({
|
|
3161
3508
|
warnedUserId: { type: String, required: !0, index: !0 },
|
|
3162
3509
|
authorId: String,
|
|
3163
3510
|
date: { type: Date, default: Date.now() },
|
|
3164
3511
|
reason: { type: String, default: null }
|
|
3165
|
-
}),
|
|
3512
|
+
}), ce = d?.Warn || l("Warn", Ra), Ca = (n) => ce.countDocuments(n), Ba = (n) => ce.create({
|
|
3166
3513
|
...n
|
|
3167
|
-
}),
|
|
3168
|
-
class
|
|
3514
|
+
}), _a = (n) => ce.findByIdAndDelete(n).lean();
|
|
3515
|
+
class Fa extends f {
|
|
3169
3516
|
getUserWarns(e) {
|
|
3170
3517
|
return this.getMany({ warnedUserId: e });
|
|
3171
3518
|
}
|
|
3172
3519
|
getUserWarnCount(e) {
|
|
3173
|
-
return
|
|
3520
|
+
return Ca({ warnedUserId: e });
|
|
3174
3521
|
}
|
|
3175
3522
|
async createWarn(e) {
|
|
3176
|
-
await
|
|
3523
|
+
await Ba(e);
|
|
3177
3524
|
}
|
|
3178
3525
|
async deleteWarn(e) {
|
|
3179
|
-
const t = await
|
|
3526
|
+
const t = await _a(e);
|
|
3180
3527
|
return t && this.invalidate(this.getKey(t)), t;
|
|
3181
3528
|
}
|
|
3182
3529
|
}
|
|
3183
|
-
const
|
|
3184
|
-
class
|
|
3530
|
+
const Na = (n) => ce.find(n).lean();
|
|
3531
|
+
class Ka extends Fa {
|
|
3185
3532
|
constructor() {
|
|
3186
3533
|
super(300);
|
|
3187
3534
|
}
|
|
@@ -3195,48 +3542,49 @@ class ur extends sr {
|
|
|
3195
3542
|
throw new Error("Method not implemented.");
|
|
3196
3543
|
}
|
|
3197
3544
|
fetchManyFromDb(e) {
|
|
3198
|
-
return
|
|
3545
|
+
return Na(e);
|
|
3199
3546
|
}
|
|
3200
3547
|
updateInDb() {
|
|
3201
3548
|
throw new Error("Method not implemented.");
|
|
3202
3549
|
}
|
|
3203
3550
|
}
|
|
3204
|
-
const
|
|
3205
|
-
|
|
3551
|
+
const is = new Ka(), us = (n) => {
|
|
3552
|
+
Qe(n);
|
|
3206
3553
|
};
|
|
3207
|
-
class
|
|
3554
|
+
class cs extends Ye.ObjectId {
|
|
3208
3555
|
}
|
|
3209
3556
|
export {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3557
|
+
cs as ObjectId,
|
|
3558
|
+
S as QUEST_MIDDLEWARE_EVENT_NAME,
|
|
3559
|
+
rs as banService,
|
|
3560
|
+
us as connectToServices,
|
|
3561
|
+
g as emitQuestMiddlewareEvent,
|
|
3562
|
+
U as entityService,
|
|
3563
|
+
as as invitationService,
|
|
3564
|
+
I as ornamentService,
|
|
3565
|
+
_ as panoplyService,
|
|
3566
|
+
ns as recipeService,
|
|
3567
|
+
La as registerQuestMiddlewareEvents,
|
|
3568
|
+
Rt as reminderService,
|
|
3569
|
+
ss as settingsService,
|
|
3570
|
+
T as storyService,
|
|
3571
|
+
Qa as userCooldownService,
|
|
3572
|
+
Ya as userDailyReportService,
|
|
3573
|
+
le as userEncyclopediaService,
|
|
3574
|
+
Ga as userGamesService,
|
|
3575
|
+
M as userInventoryService,
|
|
3229
3576
|
E as userMetaService,
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3577
|
+
we as userOrnamentService,
|
|
3578
|
+
be as userQuestService,
|
|
3579
|
+
Wa as userRankService,
|
|
3580
|
+
Et as userService,
|
|
3581
|
+
Fe as userSettingsService,
|
|
3582
|
+
Xa as userStatsCasinoService,
|
|
3583
|
+
Ja as userStatsEconomyService,
|
|
3584
|
+
$e as userStatsEngagementService,
|
|
3585
|
+
Za as userStatsFlagsService,
|
|
3586
|
+
es as userStatsFrequencyService,
|
|
3587
|
+
ts as userStatsInventoryService,
|
|
3588
|
+
Va as userStoryService,
|
|
3589
|
+
is as warnService
|
|
3242
3590
|
};
|