@smartico/public-api 0.0.287 → 0.0.289
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/SmarticoLib/index.d.ts +2 -0
- package/dist/Tournaments/TournamentPlayer.d.ts +2 -0
- package/dist/Tournaments/TournamentUtils.d.ts +3 -0
- package/dist/WSAPI/WSAPITypes.d.ts +22 -0
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +18 -9
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +2 -0
- package/docs/enums/SAWGameDifficultyType.md +19 -0
- package/docs/enums/SAWGameDifficultyTypeName.md +19 -0
- package/docs/interfaces/SAWTemplateUI.md +8 -0
- package/docs/interfaces/TTournament.md +3 -0
- package/docs/interfaces/TTournamentDetailed.md +4 -1
- package/docs/interfaces/TUserProfile.md +16 -0
- package/package.json +1 -1
- package/src/SmarticoAPI.ts +15 -10
- package/src/SmarticoLib/index.ts +2 -0
- package/src/Tournaments/TournamentPlayer.ts +2 -0
- package/src/Tournaments/TournamentUtils.ts +3 -0
- package/src/WSAPI/WSAPITypes.ts +22 -0
|
@@ -101,6 +101,8 @@ declare enum ClientActivityRequestId {
|
|
|
101
101
|
export interface PublicProperties {
|
|
102
102
|
core_user_language?: string;
|
|
103
103
|
ach_points_balance?: number;
|
|
104
|
+
ach_gems_balance?: number;
|
|
105
|
+
ach_diamonds_balance?: number;
|
|
104
106
|
ach_points_ever?: number;
|
|
105
107
|
core_public_tags?: string[];
|
|
106
108
|
ach_level_current_id?: number;
|
|
@@ -185,6 +185,10 @@ export interface TUserProfile {
|
|
|
185
185
|
ach_points_balance: number;
|
|
186
186
|
/** The amount of points that user collected in total */
|
|
187
187
|
ach_points_ever: number;
|
|
188
|
+
/** The current gems balance */
|
|
189
|
+
ach_gems_balance: number;
|
|
190
|
+
/** The current diamonds balance */
|
|
191
|
+
ach_diamonds_balance: number;
|
|
188
192
|
/**
|
|
189
193
|
* The array of the public tags set on the user object.
|
|
190
194
|
* They can be treated as server-based cookies.
|
|
@@ -299,6 +303,12 @@ export interface TTournament {
|
|
|
299
303
|
position: number;
|
|
300
304
|
/** The scores of the participant in the tournament */
|
|
301
305
|
scores: number;
|
|
306
|
+
/** The external user id of the participant */
|
|
307
|
+
user_ext_id: string;
|
|
308
|
+
/** The crm brand id of the participant */
|
|
309
|
+
crm_brand_id: number;
|
|
310
|
+
/** The user id of the participant */
|
|
311
|
+
user_id: number;
|
|
302
312
|
};
|
|
303
313
|
/** Prize structure */
|
|
304
314
|
prizes?: {
|
|
@@ -375,6 +385,12 @@ export interface TTournamentDetailed extends TTournament {
|
|
|
375
385
|
scores: number;
|
|
376
386
|
/** The indicator if the participant is current user */
|
|
377
387
|
is_me: boolean;
|
|
388
|
+
/** The external user id of the participant */
|
|
389
|
+
user_ext_id: string;
|
|
390
|
+
/** The crm brand id of the participant */
|
|
391
|
+
crm_brand_id: number;
|
|
392
|
+
/** The user id of the participant */
|
|
393
|
+
user_id: number;
|
|
378
394
|
}[];
|
|
379
395
|
/** The information about current user in the tournament if he is registered in the tournamnet */
|
|
380
396
|
me?: {
|
|
@@ -386,6 +402,12 @@ export interface TTournamentDetailed extends TTournament {
|
|
|
386
402
|
position: number;
|
|
387
403
|
/** The scores of the current user in the tournament */
|
|
388
404
|
scores: number;
|
|
405
|
+
/** The external user id of the current user */
|
|
406
|
+
user_ext_id: string;
|
|
407
|
+
/** The crm brand id of the current user */
|
|
408
|
+
crm_brand_id: number;
|
|
409
|
+
/** The user id of the current user */
|
|
410
|
+
user_id: number;
|
|
389
411
|
};
|
|
390
412
|
prizes?: {
|
|
391
413
|
/** The name of the prize */
|
package/dist/index.js
CHANGED
|
@@ -1488,7 +1488,10 @@ TournamentUtils.getPlayerTransformed = function (player, isMe) {
|
|
|
1488
1488
|
avatar_url: player.avatar_url,
|
|
1489
1489
|
position: player.position,
|
|
1490
1490
|
scores: player.scores,
|
|
1491
|
-
is_me: player.isMe
|
|
1491
|
+
is_me: player.isMe,
|
|
1492
|
+
user_ext_id: player.cleanExtUserId,
|
|
1493
|
+
crm_brand_id: player.crmBrandId,
|
|
1494
|
+
user_id: player.userId
|
|
1492
1495
|
};
|
|
1493
1496
|
if (isMe) {
|
|
1494
1497
|
delete playerTransformed.is_me;
|
|
@@ -4429,21 +4432,29 @@ var SmarticoAPI = /*#__PURE__*/function () {
|
|
|
4429
4432
|
var _this54 = this;
|
|
4430
4433
|
return Promise.resolve(_this54.levelsGetT(user_ext_id)).then(function (levels) {
|
|
4431
4434
|
return Promise.resolve(_this54.getUserGamificationInfo(user_ext_id)).then(function (userInfo) {
|
|
4435
|
+
var _userInfo$points_ever2;
|
|
4432
4436
|
if (!levels || levels.length === 0) return null;
|
|
4433
|
-
var
|
|
4434
|
-
var sortedLevels = levels.sort(function (a, b) {
|
|
4437
|
+
var sortedLevels = [].concat(levels).sort(function (a, b) {
|
|
4435
4438
|
return a.required_points - b.required_points;
|
|
4436
4439
|
});
|
|
4437
|
-
var currentLevelIndex = sortedLevels.findIndex(function (level
|
|
4438
|
-
|
|
4439
|
-
return userPoints >= level.required_points && (!nextLevel || userPoints < nextLevel.required_points);
|
|
4440
|
+
var currentLevelIndex = sortedLevels.findIndex(function (level) {
|
|
4441
|
+
return level.id === userInfo.current_level;
|
|
4440
4442
|
});
|
|
4441
4443
|
if (currentLevelIndex === -1) {
|
|
4442
|
-
|
|
4444
|
+
var _userInfo$points_ever;
|
|
4445
|
+
var _userPointsEver = (_userInfo$points_ever = userInfo.points_ever) != null ? _userInfo$points_ever : 0;
|
|
4446
|
+
currentLevelIndex = sortedLevels.findIndex(function (level, index) {
|
|
4447
|
+
var nextLevel = sortedLevels[index + 1];
|
|
4448
|
+
return _userPointsEver >= level.required_points && (!nextLevel || _userPointsEver < nextLevel.required_points);
|
|
4449
|
+
});
|
|
4450
|
+
if (currentLevelIndex === -1) {
|
|
4451
|
+
currentLevelIndex = sortedLevels.length - 1;
|
|
4452
|
+
}
|
|
4443
4453
|
}
|
|
4444
4454
|
var currentLevel = sortedLevels[currentLevelIndex];
|
|
4445
4455
|
var nextLevel = sortedLevels[currentLevelIndex + 1];
|
|
4446
|
-
var
|
|
4456
|
+
var userPointsEver = (_userInfo$points_ever2 = userInfo.points_ever) != null ? _userInfo$points_ever2 : 0;
|
|
4457
|
+
var progress = nextLevel ? (userPointsEver - currentLevel.required_points) / (nextLevel.required_points - currentLevel.required_points) * 100 : 100;
|
|
4447
4458
|
return _extends({}, currentLevel, {
|
|
4448
4459
|
ordinal_position: currentLevelIndex + 1,
|
|
4449
4460
|
progress: Math.min(Math.max(progress, 0), 100)
|