@stackedapp/utils 2.39.2 → 2.40.1
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.
|
@@ -33,7 +33,7 @@ export declare function evaluateCompletionContext(cond: ICompletionContextCondit
|
|
|
33
33
|
export declare function evaluateBuyItem(cond: IBuyItemCondition, ctx: EvalContext): EvalResult;
|
|
34
34
|
export declare function evaluateSpendCurrency(cond: ISpendCurrencyCondition, ctx: EvalContext): EvalResult;
|
|
35
35
|
export declare function evaluateDepositCurrency(cond: IDepositCurrencyCondition, ctx: EvalContext): EvalResult;
|
|
36
|
-
export declare function evaluateLogin(
|
|
36
|
+
export declare function evaluateLogin(cond: ILoginCondition, ctx: EvalContext): EvalResult;
|
|
37
37
|
export declare function evaluateSocial(cond: ISocialCondition, ctx: EvalContext): EvalResult;
|
|
38
38
|
export declare function evaluateLinkedCompletions(cond: ILinkedCompletionsCondition, ctx: EvalContext): EvalResult;
|
|
39
39
|
export declare function evaluateDynamicTracker(cond: IDynamicTrackerCondition, ctx: EvalContext): EvalResult;
|
|
@@ -31,6 +31,9 @@ const template_1 = require("../template");
|
|
|
31
31
|
const dynamic_1 = require("../dynamic");
|
|
32
32
|
const helpers_1 = require("./helpers");
|
|
33
33
|
const blockchain_utils_1 = require("../blockchain_utils");
|
|
34
|
+
function templateText(cond, vars, fallback) {
|
|
35
|
+
return cond.template ? (0, template_1.renderTemplate)(cond.template, vars) || fallback : fallback;
|
|
36
|
+
}
|
|
34
37
|
// ─── Base Condition Handlers ─────────────────────────────────────────────────
|
|
35
38
|
function evaluateDaysInGame(cond, ctx) {
|
|
36
39
|
const details = [];
|
|
@@ -47,7 +50,7 @@ function evaluateDaysInGame(cond, ctx) {
|
|
|
47
50
|
trackerAmount,
|
|
48
51
|
trackerGoal,
|
|
49
52
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
50
|
-
text: `More than ${trackerGoal} Days in Game
|
|
53
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal }, `More than ${trackerGoal} Days in Game`),
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
if (cond.max) {
|
|
@@ -61,7 +64,7 @@ function evaluateDaysInGame(cond, ctx) {
|
|
|
61
64
|
trackerAmount,
|
|
62
65
|
trackerGoal: cond.max,
|
|
63
66
|
percentCompleted: met ? 100 : 0,
|
|
64
|
-
text: `Less than ${cond.max} Days in Game
|
|
67
|
+
text: templateText(cond, { current: trackerAmount, goal: cond.max }, `Less than ${cond.max} Days in Game`),
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
return { isMet, details };
|
|
@@ -81,7 +84,7 @@ function evaluateTrustScore(cond, ctx) {
|
|
|
81
84
|
trackerAmount,
|
|
82
85
|
trackerGoal,
|
|
83
86
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
84
|
-
text: `More than ${trackerGoal} Rep
|
|
87
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal }, `More than ${trackerGoal} Rep`),
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
if (cond.max) {
|
|
@@ -95,7 +98,7 @@ function evaluateTrustScore(cond, ctx) {
|
|
|
95
98
|
trackerAmount,
|
|
96
99
|
trackerGoal: cond.max,
|
|
97
100
|
percentCompleted: met ? 100 : 0,
|
|
98
|
-
text: `Less than ${cond.max} Rep
|
|
101
|
+
text: templateText(cond, { current: trackerAmount, goal: cond.max }, `Less than ${cond.max} Rep`),
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
return { isMet, details };
|
|
@@ -116,7 +119,7 @@ function evaluateLevel(cond, ctx) {
|
|
|
116
119
|
trackerAmount,
|
|
117
120
|
trackerGoal,
|
|
118
121
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
119
|
-
text: `Be above level ${trackerGoal} ${cond.name}
|
|
122
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Be above level ${trackerGoal} ${cond.name}`),
|
|
120
123
|
});
|
|
121
124
|
}
|
|
122
125
|
if (cond.max) {
|
|
@@ -130,7 +133,7 @@ function evaluateLevel(cond, ctx) {
|
|
|
130
133
|
trackerAmount,
|
|
131
134
|
trackerGoal: cond.max,
|
|
132
135
|
percentCompleted: met ? 100 : 0,
|
|
133
|
-
text: `Be under level ${cond.max} ${cond.name}
|
|
136
|
+
text: templateText(cond, { current: trackerAmount, goal: cond.max, name: cond.name }, `Be under level ${cond.max} ${cond.name}`),
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
return { isMet, details };
|
|
@@ -151,7 +154,7 @@ function evaluateCurrency(cond, ctx) {
|
|
|
151
154
|
trackerAmount,
|
|
152
155
|
trackerGoal,
|
|
153
156
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
154
|
-
text: `Have more than ${trackerGoal} ${cond.name}
|
|
157
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Have more than ${trackerGoal} ${cond.name}`),
|
|
155
158
|
});
|
|
156
159
|
}
|
|
157
160
|
if (cond.max) {
|
|
@@ -165,7 +168,7 @@ function evaluateCurrency(cond, ctx) {
|
|
|
165
168
|
trackerAmount,
|
|
166
169
|
trackerGoal: cond.max,
|
|
167
170
|
percentCompleted: met ? 100 : 0,
|
|
168
|
-
text: `Have less than ${cond.max} ${cond.name}
|
|
171
|
+
text: templateText(cond, { current: trackerAmount, goal: cond.max, name: cond.name }, `Have less than ${cond.max} ${cond.name}`),
|
|
169
172
|
});
|
|
170
173
|
}
|
|
171
174
|
if (cond.in) {
|
|
@@ -180,7 +183,7 @@ function evaluateCurrency(cond, ctx) {
|
|
|
180
183
|
trackerAmount,
|
|
181
184
|
trackerGoal,
|
|
182
185
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
183
|
-
text: `Deposit at least ${trackerGoal} ${cond.name}
|
|
186
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Deposit at least ${trackerGoal} ${cond.name}`),
|
|
184
187
|
});
|
|
185
188
|
}
|
|
186
189
|
if (cond.out) {
|
|
@@ -195,7 +198,7 @@ function evaluateCurrency(cond, ctx) {
|
|
|
195
198
|
trackerAmount,
|
|
196
199
|
trackerGoal,
|
|
197
200
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
198
|
-
text: `Withdraw at least ${trackerGoal} ${cond.name}
|
|
201
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Withdraw at least ${trackerGoal} ${cond.name}`),
|
|
199
202
|
});
|
|
200
203
|
}
|
|
201
204
|
return { isMet, details };
|
|
@@ -216,7 +219,7 @@ function evaluateStakedTokens(cond, ctx) {
|
|
|
216
219
|
trackerAmount,
|
|
217
220
|
trackerGoal,
|
|
218
221
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
219
|
-
text: `Have at least ${trackerGoal} ${cond.name} staked
|
|
222
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Have at least ${trackerGoal} ${cond.name} staked`),
|
|
220
223
|
});
|
|
221
224
|
}
|
|
222
225
|
return { isMet, details };
|
|
@@ -242,7 +245,7 @@ function evaluateLoginStreak(cond, ctx) {
|
|
|
242
245
|
trackerAmount,
|
|
243
246
|
trackerGoal,
|
|
244
247
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, isMet),
|
|
245
|
-
text: `Login streak of ${trackerGoal || 0} days
|
|
248
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal }, `Login streak of ${trackerGoal || 0} days`),
|
|
246
249
|
},
|
|
247
250
|
],
|
|
248
251
|
};
|
|
@@ -259,7 +262,7 @@ function evaluateAchievement(cond, ctx) {
|
|
|
259
262
|
trackerAmount: 0,
|
|
260
263
|
trackerGoal: 1,
|
|
261
264
|
percentCompleted: 0,
|
|
262
|
-
text: `Have the achievement ${cond.name}
|
|
265
|
+
text: templateText(cond, { current: 0, goal: 1, name: cond.name }, `Have the achievement ${cond.name}`),
|
|
263
266
|
});
|
|
264
267
|
}
|
|
265
268
|
if (cond.minCount) {
|
|
@@ -274,7 +277,7 @@ function evaluateAchievement(cond, ctx) {
|
|
|
274
277
|
trackerAmount,
|
|
275
278
|
trackerGoal,
|
|
276
279
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
277
|
-
text: `Have the achievement ${cond.name} more than ${trackerGoal} times
|
|
280
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Have the achievement ${cond.name} more than ${trackerGoal} times`),
|
|
278
281
|
});
|
|
279
282
|
}
|
|
280
283
|
return { isMet, details };
|
|
@@ -295,7 +298,7 @@ function evaluateMembership(cond, ctx) {
|
|
|
295
298
|
trackerAmount,
|
|
296
299
|
trackerGoal,
|
|
297
300
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
298
|
-
text: trackerGoal > 1 ? `Have at least ${trackerGoal} ${cond.name} memberships` : `Have a ${cond.name} membership
|
|
301
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, trackerGoal > 1 ? `Have at least ${trackerGoal} ${cond.name} memberships` : `Have a ${cond.name} membership`),
|
|
299
302
|
});
|
|
300
303
|
}
|
|
301
304
|
if (cond.maxCount) {
|
|
@@ -309,7 +312,7 @@ function evaluateMembership(cond, ctx) {
|
|
|
309
312
|
trackerAmount,
|
|
310
313
|
trackerGoal: cond.maxCount,
|
|
311
314
|
percentCompleted: met ? 100 : 0,
|
|
312
|
-
text: `Have less than ${cond.maxCount} ${cond.name} memberships
|
|
315
|
+
text: templateText(cond, { current: trackerAmount, goal: cond.maxCount, name: cond.name }, `Have less than ${cond.maxCount} ${cond.name} memberships`),
|
|
313
316
|
});
|
|
314
317
|
}
|
|
315
318
|
const timeOwned = (playerData?.expiresAt || 0) - Date.now();
|
|
@@ -325,7 +328,7 @@ function evaluateMembership(cond, ctx) {
|
|
|
325
328
|
trackerAmount,
|
|
326
329
|
trackerGoal,
|
|
327
330
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, met),
|
|
328
|
-
text: `Own ${cond.name} membership for at least ${trackerGoal} days
|
|
331
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, `Own ${cond.name} membership for at least ${trackerGoal} days`),
|
|
329
332
|
});
|
|
330
333
|
}
|
|
331
334
|
if (cond.maxMs) {
|
|
@@ -339,7 +342,7 @@ function evaluateMembership(cond, ctx) {
|
|
|
339
342
|
trackerAmount,
|
|
340
343
|
trackerGoal: Number((cond.maxMs / (1000 * 60 * 60 * 24)).toFixed(1)),
|
|
341
344
|
percentCompleted: met ? 100 : 0,
|
|
342
|
-
text: `Own ${cond.name} membership for less than ${(cond.maxMs / (1000 * 60 * 60 * 24)).toFixed(1)} days
|
|
345
|
+
text: templateText(cond, { current: trackerAmount, goal: Number((cond.maxMs / (1000 * 60 * 60 * 24)).toFixed(1)), name: cond.name }, `Own ${cond.name} membership for less than ${(cond.maxMs / (1000 * 60 * 60 * 24)).toFixed(1)} days`),
|
|
343
346
|
});
|
|
344
347
|
}
|
|
345
348
|
return { isMet, details };
|
|
@@ -358,11 +361,11 @@ function evaluateQuest(cond, ctx) {
|
|
|
358
361
|
trackerAmount,
|
|
359
362
|
trackerGoal,
|
|
360
363
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerAmount, trackerGoal, isMet),
|
|
361
|
-
text: cond.completions === 1
|
|
364
|
+
text: templateText(cond, { current: trackerAmount, goal: trackerGoal, name: cond.name }, cond.completions === 1
|
|
362
365
|
? `Complete the quest ${cond.name}`
|
|
363
366
|
: (cond.completions || 0) < 1
|
|
364
367
|
? `Start the quest ${cond.name}`
|
|
365
|
-
: `Complete the quest ${cond.name} ${cond.completions} times
|
|
368
|
+
: `Complete the quest ${cond.name} ${cond.completions} times`),
|
|
366
369
|
},
|
|
367
370
|
],
|
|
368
371
|
};
|
|
@@ -472,7 +475,8 @@ function evaluateIdentifiers(cond, ctx) {
|
|
|
472
475
|
}
|
|
473
476
|
else {
|
|
474
477
|
isMet = platformsToCheck.some((p) => playerPlatforms.has(p.toLowerCase()));
|
|
475
|
-
displayText =
|
|
478
|
+
displayText =
|
|
479
|
+
platformsToCheck.length > 1 ? `Link any of your ${(0, helpers_1.formatList)(platforms)} accounts` : `Link your ${platforms[0]} account`;
|
|
476
480
|
percentCompleted = isMet ? 100 : 0;
|
|
477
481
|
}
|
|
478
482
|
return {
|
|
@@ -484,7 +488,7 @@ function evaluateIdentifiers(cond, ctx) {
|
|
|
484
488
|
trackerAmount: isMet ? 1 : 0,
|
|
485
489
|
trackerGoal: 1,
|
|
486
490
|
percentCompleted,
|
|
487
|
-
text: displayText,
|
|
491
|
+
text: templateText(cond, { current: metPlatforms.length, goal: platformsToCheck.length }, displayText),
|
|
488
492
|
},
|
|
489
493
|
],
|
|
490
494
|
};
|
|
@@ -509,7 +513,7 @@ function evaluateTokenBalance(cond, ctx) {
|
|
|
509
513
|
trackerAmount: totalBalance,
|
|
510
514
|
trackerGoal: cond.min,
|
|
511
515
|
percentCompleted: (0, helpers_1.calculatePercent)(totalBalance, cond.min, met),
|
|
512
|
-
text: `Have at least ${cond.min} ${cond.name || 'tokens'}
|
|
516
|
+
text: templateText(cond, { current: totalBalance, goal: cond.min, name: cond.name || 'tokens' }, `Have at least ${cond.min} ${cond.name || 'tokens'}`),
|
|
513
517
|
});
|
|
514
518
|
}
|
|
515
519
|
if (cond.max !== undefined) {
|
|
@@ -522,7 +526,7 @@ function evaluateTokenBalance(cond, ctx) {
|
|
|
522
526
|
trackerAmount: totalBalance,
|
|
523
527
|
trackerGoal: cond.max,
|
|
524
528
|
percentCompleted: met ? 100 : 0,
|
|
525
|
-
text: `Have at most ${cond.max} ${cond.name || 'tokens'}
|
|
529
|
+
text: templateText(cond, { current: totalBalance, goal: cond.max, name: cond.name || 'tokens' }, `Have at most ${cond.max} ${cond.name || 'tokens'}`),
|
|
526
530
|
});
|
|
527
531
|
}
|
|
528
532
|
return { isMet, details };
|
|
@@ -541,7 +545,7 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
541
545
|
trackerAmount: playerHasAccount ? 1 : 0,
|
|
542
546
|
trackerGoal: 1,
|
|
543
547
|
percentCompleted: met ? 100 : 0,
|
|
544
|
-
text: cond.hasLinkedAccount ? 'Link a Stacked account' : 'Must not have Stacked account linked',
|
|
548
|
+
text: templateText(cond, { current: playerHasAccount ? 1 : 0, goal: 1 }, cond.hasLinkedAccount ? 'Link a Stacked account' : 'Must not have Stacked account linked'),
|
|
545
549
|
});
|
|
546
550
|
}
|
|
547
551
|
if (cond.cryptoWallets) {
|
|
@@ -556,7 +560,7 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
556
560
|
trackerAmount: walletCount,
|
|
557
561
|
trackerGoal: cond.cryptoWallets.min,
|
|
558
562
|
percentCompleted: (0, helpers_1.calculatePercent)(walletCount, cond.cryptoWallets.min, met),
|
|
559
|
-
text: `Link at least ${cond.cryptoWallets.min} crypto wallet${cond.cryptoWallets.min === 1 ? '' : 's'}
|
|
563
|
+
text: templateText(cond, { current: walletCount, goal: cond.cryptoWallets.min }, `Link at least ${cond.cryptoWallets.min} crypto wallet${cond.cryptoWallets.min === 1 ? '' : 's'}`),
|
|
560
564
|
});
|
|
561
565
|
}
|
|
562
566
|
if (cond.cryptoWallets.max !== undefined) {
|
|
@@ -569,7 +573,7 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
569
573
|
trackerAmount: walletCount,
|
|
570
574
|
trackerGoal: cond.cryptoWallets.max,
|
|
571
575
|
percentCompleted: met ? 100 : 0,
|
|
572
|
-
text: `Have at most ${cond.cryptoWallets.max} crypto wallet${cond.cryptoWallets.max === 1 ? '' : 's'}
|
|
576
|
+
text: templateText(cond, { current: walletCount, goal: cond.cryptoWallets.max }, `Have at most ${cond.cryptoWallets.max} crypto wallet${cond.cryptoWallets.max === 1 ? '' : 's'}`),
|
|
573
577
|
});
|
|
574
578
|
}
|
|
575
579
|
}
|
|
@@ -584,7 +588,7 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
584
588
|
trackerAmount: hasCustomUsername ? 1 : 0,
|
|
585
589
|
trackerGoal: 1,
|
|
586
590
|
percentCompleted: met ? 100 : 0,
|
|
587
|
-
text: cond.hasUsername ? 'Set a custom username' : 'Must not have a custom username',
|
|
591
|
+
text: templateText(cond, { current: hasCustomUsername ? 1 : 0, goal: 1 }, cond.hasUsername ? 'Set a custom username' : 'Must not have a custom username'),
|
|
588
592
|
});
|
|
589
593
|
}
|
|
590
594
|
if (cond.hasProfilePic !== undefined) {
|
|
@@ -598,7 +602,7 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
598
602
|
trackerAmount: hasCustomPic ? 1 : 0,
|
|
599
603
|
trackerGoal: 1,
|
|
600
604
|
percentCompleted: met ? 100 : 0,
|
|
601
|
-
text: cond.hasProfilePic ? 'Set a custom profile picture' : 'Must not have a custom profile picture',
|
|
605
|
+
text: templateText(cond, { current: hasCustomPic ? 1 : 0, goal: 1 }, cond.hasProfilePic ? 'Set a custom profile picture' : 'Must not have a custom profile picture'),
|
|
602
606
|
});
|
|
603
607
|
}
|
|
604
608
|
if (cond.authPlatforms && cond.authPlatforms.platforms.length > 0) {
|
|
@@ -624,7 +628,10 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
624
628
|
}
|
|
625
629
|
else {
|
|
626
630
|
met = platformsToCheck.some((p) => playerPlatforms.has(p.toLowerCase()));
|
|
627
|
-
displayText =
|
|
631
|
+
displayText =
|
|
632
|
+
platformsToCheck.length > 1
|
|
633
|
+
? `Link any of your ${(0, helpers_1.formatList)(platforms)} accounts in Stacked`
|
|
634
|
+
: `Link your ${platforms[0]} account in Stacked`;
|
|
628
635
|
percentCompleted = met ? 100 : 0;
|
|
629
636
|
}
|
|
630
637
|
if (!met)
|
|
@@ -635,7 +642,7 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
635
642
|
trackerAmount: met ? 1 : 0,
|
|
636
643
|
trackerGoal: 1,
|
|
637
644
|
percentCompleted,
|
|
638
|
-
text: displayText,
|
|
645
|
+
text: templateText(cond, { current: met ? 1 : 0, goal: 1 }, displayText),
|
|
639
646
|
});
|
|
640
647
|
}
|
|
641
648
|
return { isMet, details };
|
|
@@ -654,7 +661,7 @@ function evaluateUserSettings(cond, ctx) {
|
|
|
654
661
|
trackerAmount: playerHasNewsletter ? 1 : 0,
|
|
655
662
|
trackerGoal: 1,
|
|
656
663
|
percentCompleted: met ? 100 : 0,
|
|
657
|
-
text: cond.emailNewsletter ? 'Subscribe to email newsletter' : 'Must not be subscribed to email newsletter',
|
|
664
|
+
text: templateText(cond, { current: playerHasNewsletter ? 1 : 0, goal: 1 }, cond.emailNewsletter ? 'Subscribe to email newsletter' : 'Must not be subscribed to email newsletter'),
|
|
658
665
|
});
|
|
659
666
|
}
|
|
660
667
|
return { isMet, details };
|
|
@@ -672,7 +679,7 @@ function evaluateCompletionContext(cond, ctx) {
|
|
|
672
679
|
trackerAmount: isMet ? 1 : 0,
|
|
673
680
|
trackerGoal: 1,
|
|
674
681
|
percentCompleted: isMet ? 100 : 0,
|
|
675
|
-
text: cond.name,
|
|
682
|
+
text: templateText(cond, { current: isMet ? 1 : 0, goal: 1, name: cond.name }, cond.name),
|
|
676
683
|
},
|
|
677
684
|
],
|
|
678
685
|
};
|
|
@@ -691,7 +698,7 @@ function evaluateBuyItem(cond, ctx) {
|
|
|
691
698
|
trackerAmount: trackerValue,
|
|
692
699
|
trackerGoal: scaledAmount,
|
|
693
700
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerValue, scaledAmount, isMet),
|
|
694
|
-
text: `Buy ${scaledAmount} ${cond.name}
|
|
701
|
+
text: templateText(cond, { current: trackerValue, goal: scaledAmount, name: cond.name }, `Buy ${scaledAmount} ${cond.name}`),
|
|
695
702
|
},
|
|
696
703
|
],
|
|
697
704
|
maxClaims: ctx.shouldScale && baseAmount > 0 ? Math.floor(trackerValue / baseAmount) : undefined,
|
|
@@ -711,7 +718,7 @@ function evaluateSpendCurrency(cond, ctx) {
|
|
|
711
718
|
trackerAmount: trackerValue,
|
|
712
719
|
trackerGoal: scaledAmount,
|
|
713
720
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerValue, scaledAmount, isMet),
|
|
714
|
-
text: `Spend ${scaledAmount} ${cond.name}
|
|
721
|
+
text: templateText(cond, { current: trackerValue, goal: scaledAmount, name: cond.name }, `Spend ${scaledAmount} ${cond.name}`),
|
|
715
722
|
},
|
|
716
723
|
],
|
|
717
724
|
maxClaims: ctx.shouldScale && baseAmount > 0 ? Math.floor(trackerValue / baseAmount) : undefined,
|
|
@@ -731,13 +738,13 @@ function evaluateDepositCurrency(cond, ctx) {
|
|
|
731
738
|
trackerAmount: trackerValue,
|
|
732
739
|
trackerGoal: scaledAmount,
|
|
733
740
|
percentCompleted: (0, helpers_1.calculatePercent)(trackerValue, scaledAmount, isMet),
|
|
734
|
-
text: `Deposit ${scaledAmount} ${cond.name}
|
|
741
|
+
text: templateText(cond, { current: trackerValue, goal: scaledAmount, name: cond.name }, `Deposit ${scaledAmount} ${cond.name}`),
|
|
735
742
|
},
|
|
736
743
|
],
|
|
737
744
|
maxClaims: ctx.shouldScale && baseAmount > 0 ? Math.floor(trackerValue / baseAmount) : undefined,
|
|
738
745
|
};
|
|
739
746
|
}
|
|
740
|
-
function evaluateLogin(
|
|
747
|
+
function evaluateLogin(cond, ctx) {
|
|
741
748
|
const isMet = new Date(ctx.snap.snapshotLastUpdated || 0).getTime() > new Date(ctx.offerCreatedAt || 0).getTime();
|
|
742
749
|
return {
|
|
743
750
|
isMet,
|
|
@@ -748,7 +755,7 @@ function evaluateLogin(_cond, ctx) {
|
|
|
748
755
|
trackerAmount: isMet ? 1 : 0,
|
|
749
756
|
trackerGoal: 1,
|
|
750
757
|
percentCompleted: isMet ? 100 : 0,
|
|
751
|
-
text: 'Login to the game',
|
|
758
|
+
text: templateText(cond, { current: isMet ? 1 : 0, goal: 1 }, 'Login to the game'),
|
|
752
759
|
},
|
|
753
760
|
],
|
|
754
761
|
};
|
|
@@ -812,11 +819,11 @@ function evaluateSocial(cond, ctx) {
|
|
|
812
819
|
trackerAmount: matchCount,
|
|
813
820
|
trackerGoal: 1,
|
|
814
821
|
percentCompleted: socialPercent,
|
|
815
|
-
text: hasContent
|
|
822
|
+
text: templateText(cond, { current: matchCount, goal: 1, likes, views, comments, minLikes, minViews, minComments }, hasContent
|
|
816
823
|
? `Found ${matchCount} matching ${platformText} post${matchCount !== 1 ? 's' : ''}`
|
|
817
824
|
: requiredWords.length > 0
|
|
818
825
|
? `Post ${platformText} content with ${requiredWords.map((w) => `"${w}"`).join(', ')}${afterText}`
|
|
819
|
-
: `Post ${platformText} content${afterText}
|
|
826
|
+
: `Post ${platformText} content${afterText}`),
|
|
820
827
|
});
|
|
821
828
|
}
|
|
822
829
|
else {
|
|
@@ -827,11 +834,11 @@ function evaluateSocial(cond, ctx) {
|
|
|
827
834
|
trackerAmount: hasContent ? 1 : 0,
|
|
828
835
|
trackerGoal: 1,
|
|
829
836
|
percentCompleted: socialPercent,
|
|
830
|
-
text: !hasContent
|
|
837
|
+
text: templateText(cond, { current: hasContent ? 1 : 0, goal: 1, likes, views, comments, minLikes, minViews, minComments }, !hasContent
|
|
831
838
|
? requiredWords.length > 0
|
|
832
839
|
? `Attach a ${platformText} post with ${requiredWords.map((w) => `"${w}"`).join(', ')} in the title${afterText}`
|
|
833
840
|
: `Attach a ${platformText} post${afterText}`
|
|
834
|
-
: `Attached: ${title}
|
|
841
|
+
: `Attached: ${title}`),
|
|
835
842
|
});
|
|
836
843
|
}
|
|
837
844
|
if (minLikes > 0) {
|
|
@@ -841,7 +848,7 @@ function evaluateSocial(cond, ctx) {
|
|
|
841
848
|
trackerAmount: likes,
|
|
842
849
|
trackerGoal: minLikes,
|
|
843
850
|
percentCompleted: (0, helpers_1.calculatePercent)(likes, minLikes, hasContent && likes >= minLikes),
|
|
844
|
-
text: mode === 'accumulate' ? `Combined ${minLikes} Likes` : `Reach ${minLikes} Likes
|
|
851
|
+
text: templateText(cond, { current: likes, goal: minLikes }, mode === 'accumulate' ? `Combined ${minLikes} Likes` : `Reach ${minLikes} Likes`),
|
|
845
852
|
});
|
|
846
853
|
}
|
|
847
854
|
if (minViews > 0) {
|
|
@@ -851,7 +858,7 @@ function evaluateSocial(cond, ctx) {
|
|
|
851
858
|
trackerAmount: views,
|
|
852
859
|
trackerGoal: minViews,
|
|
853
860
|
percentCompleted: (0, helpers_1.calculatePercent)(views, minViews, hasContent && views >= minViews),
|
|
854
|
-
text: mode === 'accumulate' ? `Combined ${minViews} Views` : `Reach ${minViews} Views
|
|
861
|
+
text: templateText(cond, { current: views, goal: minViews }, mode === 'accumulate' ? `Combined ${minViews} Views` : `Reach ${minViews} Views`),
|
|
855
862
|
});
|
|
856
863
|
}
|
|
857
864
|
if (minComments > 0) {
|
|
@@ -861,7 +868,7 @@ function evaluateSocial(cond, ctx) {
|
|
|
861
868
|
trackerAmount: comments,
|
|
862
869
|
trackerGoal: minComments,
|
|
863
870
|
percentCompleted: (0, helpers_1.calculatePercent)(comments, minComments, hasContent && comments >= minComments),
|
|
864
|
-
text: mode === 'accumulate' ? `Combined ${minComments} Comments` : `Reach ${minComments} Comments
|
|
871
|
+
text: templateText(cond, { current: comments, goal: minComments }, mode === 'accumulate' ? `Combined ${minComments} Comments` : `Reach ${minComments} Comments`),
|
|
865
872
|
});
|
|
866
873
|
}
|
|
867
874
|
return { isMet, details, maxClaims };
|
|
@@ -1010,7 +1017,7 @@ function evaluateTwitterVerification(cond, ctx) {
|
|
|
1010
1017
|
trackerAmount: isMet ? 1 : 0,
|
|
1011
1018
|
trackerGoal: 1,
|
|
1012
1019
|
percentCompleted: isMet ? 100 : 0,
|
|
1013
|
-
text: actionTextMap[cond.action] || 'Complete action on X',
|
|
1020
|
+
text: templateText(cond, { current: isMet ? 1 : 0, goal: 1 }, actionTextMap[cond.action] || 'Complete action on X'),
|
|
1014
1021
|
},
|
|
1015
1022
|
],
|
|
1016
1023
|
};
|