@smartico/public-api 0.0.104 → 0.0.106

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.
@@ -107,6 +107,39 @@ The ribbon of the tournament item. Can be 'sale', 'hot', 'new', 'vip' or URL to
107
107
 
108
108
  ___
109
109
 
110
+ ### priority
111
+
112
+ • **priority**: `number`
113
+
114
+ A number is used to order the tournaments, representing their priority in the list
115
+
116
+ ___
117
+
118
+ ### me
119
+
120
+ • `Optional` **me**: `Object`
121
+
122
+ Info about current player in tournament
123
+
124
+ #### Type declaration
125
+
126
+ | Name | Type | Description |
127
+ | :------ | :------ | :------ |
128
+ | `public_username` | `string` | The username of the participant |
129
+ | `avatar_url` | `string` | The URL to the avatar of the participant |
130
+ | `position` | `number` | The position of the participant in the tournament |
131
+ | `scores` | `number` | The scores of the participant in the tournament |
132
+
133
+ ___
134
+
135
+ ### prizes
136
+
137
+ • `Optional` **prizes**: { `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
138
+
139
+ Prize structure
140
+
141
+ ___
142
+
110
143
  ### start\_time
111
144
 
112
145
  • **start\_time**: `number`
@@ -159,6 +159,18 @@ The ribbon of the tournament item. Can be 'sale', 'hot', 'new', 'vip' or URL to
159
159
 
160
160
  ___
161
161
 
162
+ ### priority
163
+
164
+ • **priority**: `number`
165
+
166
+ A number is used to order the tournaments, representing their priority in the list
167
+
168
+ #### Inherited from
169
+
170
+ [TTournament](TTournament.md).[priority](TTournament.md#priority)
171
+
172
+ ___
173
+
162
174
  ### start\_time
163
175
 
164
176
  • **start\_time**: `number`
@@ -382,8 +394,18 @@ The information about current user in the tournament if he is registered in the
382
394
  | `position` | `number` | The position of the current user in the tournament |
383
395
  | `scores` | `number` | The scores of the current user in the tournament |
384
396
 
397
+ #### Overrides
398
+
399
+ [TTournament](TTournament.md).[me](TTournament.md#me)
400
+
385
401
  ___
386
402
 
387
403
  ### prizes
388
404
 
389
405
  • `Optional` **prizes**: { `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
406
+
407
+ Prize structure
408
+
409
+ #### Overrides
410
+
411
+ [TTournament](TTournament.md).[prizes](TTournament.md#prizes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -4,6 +4,7 @@ import { ProtocolResponse } from "../Base/ProtocolResponse";
4
4
  import { TournamentPrize } from "./TournamentPrize";
5
5
  import { TTournamentDetailed } from "../WSAPI/WSAPITypes";
6
6
  import { ActivityTypeLimited } from "src/Core";
7
+ import { TournamentUtils } from "./TournamentUtils";
7
8
 
8
9
  export interface GetTournamentInfoResponse extends ProtocolResponse {
9
10
 
@@ -23,17 +24,6 @@ export interface GetTournamentInfoResponse extends ProtocolResponse {
23
24
  }
24
25
  }
25
26
 
26
- const tournamentPrizeTypeToPrizeName = (type: ActivityTypeLimited) => {
27
- return {
28
- [ActivityTypeLimited.DoNothing]: 'TANGIBLE',
29
- [ActivityTypeLimited.Points]: 'POINTS_ADD',
30
- [ActivityTypeLimited.DeductPoints]: 'POINTS_DEDUCT',
31
- [ActivityTypeLimited.ResetPoints]: 'POINTS_RESET',
32
- [ActivityTypeLimited.MiniGameAttempt]: "MINI_GAME_ATTEMPT",
33
- [ActivityTypeLimited.Bonus]: 'BONUS',
34
- }[type]
35
- }
36
-
37
27
  export const tournamentInfoItemTransform = (t: GetTournamentInfoResponse): TTournamentDetailed => {
38
28
  const response: TTournamentDetailed = {
39
29
  ...TournamentItemsTransform([t.tournamentInfo.tournamentLobbyInfo])[0],
@@ -48,26 +38,15 @@ export const tournamentInfoItemTransform = (t: GetTournamentInfoResponse): TTour
48
38
  game_provider: g.game_public_meta.game_provider,
49
39
  },
50
40
  })),
51
- players: t.tournamentInfo.players.map( p => ({
52
- public_username: p.userAltName,
53
- avatar_url: p.avatar_url,
54
- position: p.position,
55
- scores: p.scores,
56
- is_me: p.isMe,
57
- })),
41
+ players: t.tournamentInfo.players.map( p => TournamentUtils.getPlayerTransformed(p)),
58
42
  };
59
43
 
60
44
  if (t.prizeStructure) {
61
- response.prizes = t.prizeStructure.prizes.map(p => ({...p, type: tournamentPrizeTypeToPrizeName(p.type)}))
45
+ response.prizes = t.prizeStructure.prizes.map(p => TournamentUtils.getPrizeTransformed(p));
62
46
  }
63
47
 
64
48
  if (t.userPosition) {
65
- response.me = {
66
- public_username: t.userPosition.userAltName,
67
- avatar_url: t.userPosition.avatar_url,
68
- position: t.userPosition.position,
69
- scores: t.userPosition.scores,
70
- }
49
+ response.me = TournamentUtils.getPlayerTransformed(t.userPosition, true)
71
50
  }
72
51
 
73
52
  return response;
@@ -4,7 +4,7 @@ import { TournamentRegistrationStatus, TournamentRegistrationStatusName, Tournam
4
4
  import { TournamentType } from "./TournamentType";
5
5
  import { TournamentPublicMeta } from "./TournamentPublicMeta";
6
6
  import { TTournament } from "../WSAPI/WSAPITypes";
7
- import { TournamentUtils } from ".";
7
+ import { TournamentPlayer, TournamentPrize, TournamentUtils } from ".";
8
8
  import { IntUtils } from "../IntUtils";
9
9
  import { AchRelatedGame } from "../Base/AchRelatedGame";
10
10
 
@@ -50,6 +50,12 @@ export interface Tournament {
50
50
  playersMaxCount?: number;
51
51
  /** Tournament duration in millisecnnds */
52
52
  durationMs?: number;
53
+ /** prizes structure */
54
+ prizeStructure?: {
55
+ prizes: TournamentPrize[],
56
+ }
57
+ /** Information about current user */
58
+ tournamentPlayer?: TournamentPlayer
53
59
 
54
60
  /** List of casino games (or other types of entities) related to the tournament */
55
61
  related_games?: AchRelatedGame[];
@@ -58,9 +64,8 @@ export interface Tournament {
58
64
 
59
65
  export const TournamentItemsTransform = (items: Tournament[]): TTournament[] => {
60
66
 
61
- return items.filter( r => r.tournamentId >= 1).map( r => {
62
-
63
- const x: TTournament = {
67
+ return items.filter(r => r.tournamentId >= 1).map(r => {
68
+ const x: TTournament = {
64
69
  instance_id: r.tournamentInstanceId,
65
70
  tournament_id: r.tournamentId,
66
71
  name: r.publicMeta.name,
@@ -74,6 +79,8 @@ export const TournamentItemsTransform = (items: Tournament[]): TTournament[] =>
74
79
  custom_data: IntUtils.JsonOrText(r.publicMeta.custom_data),
75
80
  is_featured: r.publicMeta.featured,
76
81
  ribbon: r.publicMeta.label_tag,
82
+ priority: r.publicMeta.position,
83
+
77
84
 
78
85
  start_time: r.startTimeTs,
79
86
  end_time: r.endTimeTs,
@@ -96,6 +103,14 @@ export const TournamentItemsTransform = (items: Tournament[]): TTournament[] =>
96
103
 
97
104
  }
98
105
 
106
+ if (r.prizeStructure) {
107
+ x.prizes = r.prizeStructure.prizes.map(p => TournamentUtils.getPrizeTransformed(p));
108
+ }
109
+
110
+ if (r.tournamentPlayer) {
111
+ x.me = TournamentUtils.getPlayerTransformed(r.tournamentPlayer, true)
112
+ }
113
+
99
114
  return x;
100
115
  });
101
116
 
@@ -1,8 +1,22 @@
1
+ import { ActivityTypeLimited } from "src/Core";
1
2
  import { Tournament } from "./Tournament";
2
3
  import { TournamentInstanceStatus } from "./TournamentInstanceStatus";
4
+ import { TournamentPlayer } from "./TournamentPlayer";
5
+ import { TournamentPrize } from "./TournamentPrize";
3
6
  import { TournamentRegistrationStatus } from "./TournamentRegistrationStatus";
4
7
  import { TournamentRegistrationType } from "./TournamentRegistrationType";
5
8
 
9
+ const tournamentPrizeTypeToPrizeName = (type: ActivityTypeLimited) => {
10
+ return {
11
+ [ActivityTypeLimited.DoNothing]: 'TANGIBLE',
12
+ [ActivityTypeLimited.Points]: 'POINTS_ADD',
13
+ [ActivityTypeLimited.DeductPoints]: 'POINTS_DEDUCT',
14
+ [ActivityTypeLimited.ResetPoints]: 'POINTS_RESET',
15
+ [ActivityTypeLimited.MiniGameAttempt]: "MINI_GAME_ATTEMPT",
16
+ [ActivityTypeLimited.Bonus]: 'BONUS',
17
+ }[type]
18
+ }
19
+
6
20
  export class TournamentUtils {
7
21
 
8
22
  public static isCanRegister = (tournament: Tournament): boolean => {
@@ -61,4 +75,32 @@ export class TournamentUtils {
61
75
  return false;
62
76
  }
63
77
 
78
+ public static getPlayerTransformed = (player: TournamentPlayer, isMe?: boolean) => {
79
+ if (player) {
80
+ const playerTransformed = {
81
+ public_username: player.userAltName,
82
+ avatar_url: player.avatar_url,
83
+ position: player.position,
84
+ scores: player.scores,
85
+ is_me: player.isMe,
86
+ }
87
+
88
+ if (isMe) {
89
+ delete playerTransformed.is_me;
90
+ }
91
+
92
+ return playerTransformed;
93
+ }
94
+
95
+ return null;
96
+ }
97
+
98
+ public static getPrizeTransformed = (prize: TournamentPrize) => {
99
+ if (prize) {
100
+ return ({...prize, type: tournamentPrizeTypeToPrizeName(prize.type)})
101
+ }
102
+
103
+ return null;
104
+ }
105
+
64
106
  }
@@ -205,6 +205,36 @@ export interface TTournament {
205
205
  /** The ribbon of the tournament item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon */
206
206
  ribbon: TRibbon;
207
207
 
208
+ /** A number is used to order the tournaments, representing their priority in the list */
209
+ priority: number;
210
+ /** Info about current player in tournament */
211
+ me?: {
212
+ /** The username of the participant */
213
+ public_username: string;
214
+ /** The URL to the avatar of the participant */
215
+ avatar_url: string;
216
+ /** The position of the participant in the tournament */
217
+ position: number;
218
+ /** The scores of the participant in the tournament */
219
+ scores: number;
220
+ },
221
+ /** Prize structure */
222
+ prizes?: {
223
+ /** The name of the prize */
224
+ name: string;
225
+ /** The description of the prize */
226
+ description: string;
227
+ /** The image of the prize */
228
+ image_url: string;
229
+ /** from-to range of the places to which this prize */
230
+ place_from: number;
231
+ place_to: number;
232
+ /** type of the prize: TANGIBLE, POINTS_ADD, POINTS_DEDUCT, POINTS_RESET, MINI_GAME_ATTEMPT, BONUS */
233
+ type: string;
234
+ /** if the prize is points related, indicates amount of points */
235
+ points?: number;
236
+ }[]
237
+
208
238
  /** The time when tournament is going to start, epoch with milliseconds */
209
239
  start_time: number;
210
240
  /** The time when tournament is going to finish, epoch with milliseconds */
@@ -240,6 +270,7 @@ export interface TTournament {
240
270
  is_in_progress: boolean;
241
271
  /** Indicator if tournament instance is upcoming (status PUBLISHED or REGISTER) */
242
272
  is_upcoming: boolean;
273
+
243
274
  }
244
275
 
245
276
  /**