jp.ms.common.modules 1.0.42 → 1.0.44
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/common/rooms-manager.service.d.ts +61 -0
- package/dist/common/rooms-manager.service.js +148 -0
- package/dist/common/rooms-manager.service.js.map +1 -0
- package/dist/common/tournament-rooms-manager.service.d.ts +10 -0
- package/dist/common/tournament-rooms-manager.service.js +66 -0
- package/dist/common/tournament-rooms-manager.service.js.map +1 -0
- package/dist/dto/app-table/card.dto.d.ts +1 -0
- package/dist/dto/app-table/card.dto.js +11 -0
- package/dist/dto/app-table/card.dto.js.map +1 -1
- package/dist/dto/app-table/player.dto.d.ts +1 -0
- package/dist/dto/app-table/player.dto.js +11 -0
- package/dist/dto/app-table/player.dto.js.map +1 -1
- package/dist/exception/global-exception-filter.d.ts +2 -0
- package/dist/exception/global-exception-filter.js +23 -17
- package/dist/exception/global-exception-filter.js.map +1 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.d.ts +3 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js +33 -23
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js.map +1 -1
- package/dist/modules/base-achievements/base-achievements.constants.d.ts +1 -0
- package/dist/modules/base-achievements/base-achievements.constants.js +5 -0
- package/dist/modules/base-achievements/base-achievements.constants.js.map +1 -0
- package/dist/modules/base-achievements/base-achievements.interfaces.d.ts +15 -0
- package/dist/modules/base-achievements/base-achievements.interfaces.js +3 -0
- package/dist/modules/base-achievements/base-achievements.interfaces.js.map +1 -0
- package/dist/modules/base-achievements/base-achievements.module.d.ts +29 -7
- package/dist/modules/base-achievements/base-achievements.module.js +166 -76
- package/dist/modules/base-achievements/base-achievements.module.js.map +1 -1
- package/dist/modules/base-achievements/index.d.ts +2 -0
- package/dist/modules/base-achievements/index.js +3 -1
- package/dist/modules/base-achievements/index.js.map +1 -1
- package/dist/modules/event-bus/events-bus.app.subscribe.service.d.ts +3 -3
- package/dist/modules/event-bus/events-bus.app.subscribe.service.js.map +1 -1
- package/dist/modules/events/events.gateway.js +4 -2
- package/dist/modules/events/events.gateway.js.map +1 -1
- package/dist/modules/index.d.ts +1 -1
- package/dist/modules/index.js +4 -3
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/main/main.controller.d.ts +0 -1
- package/dist/modules/main/main.controller.js +0 -12
- package/dist/modules/main/main.controller.js.map +1 -1
- package/dist/modules/main/main.service.d.ts +0 -1
- package/dist/modules/main/main.service.js +8 -19
- package/dist/modules/main/main.service.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.d.ts +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js +12 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +6 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.d.ts +4 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js +18 -2
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js.map +1 -1
- package/dist/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.interfaces.d.ts +1 -0
- package/dist/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.module.js +6 -0
- package/dist/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.module.js.map +1 -1
- package/dist/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service.d.ts +8 -5
- package/dist/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service.js +61 -38
- package/dist/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service.js.map +1 -1
- package/dist/modules/menu/menu-screen.view.d.ts +2 -1
- package/dist/modules/menu/menu-screen.view.js +9 -3
- package/dist/modules/menu/menu-screen.view.js.map +1 -1
- package/dist/modules/menu/menu.interfaces.d.ts +1 -0
- package/dist/modules/menu/menu.service.js +1 -1
- package/dist/modules/menu/menu.service.js.map +1 -1
- package/dist/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.interfaces.d.ts +1 -0
- package/dist/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.module.js +6 -0
- package/dist/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.module.js.map +1 -1
- package/dist/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service.d.ts +8 -5
- package/dist/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service.js +58 -35
- package/dist/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service.js.map +1 -1
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.interfaces.d.ts +1 -0
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.module.js +6 -0
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.module.js.map +1 -1
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.d.ts +8 -5
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js +56 -20
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/views/achievement-snackbar.view.d.ts +8 -0
- package/dist/views/achievement-snackbar.view.js +26 -0
- package/dist/views/achievement-snackbar.view.js.map +1 -0
- package/dist/views/base-table.view.d.ts +13 -0
- package/dist/views/base-table.view.js +34 -0
- package/dist/views/base-table.view.js.map +1 -0
- package/dist/views/index.d.ts +3 -0
- package/dist/views/index.js +7 -1
- package/dist/views/index.js.map +1 -1
- package/dist/views/level-up-snackbar.view.d.ts +7 -0
- package/dist/views/level-up-snackbar.view.js +26 -0
- package/dist/views/level-up-snackbar.view.js.map +1 -0
- package/package.json +5 -5
- package/src/common/rooms-manager.service.ts +250 -0
- package/src/common/tournament-rooms-manager.service.ts +121 -0
- package/src/dto/app-table/card.dto.ts +9 -0
- package/src/dto/app-table/player.dto.ts +9 -0
- package/src/exception/global-exception-filter.ts +34 -20
- package/src/modules/anti-freeze-system/anti-freeze-system.service.ts +48 -35
- package/src/modules/base-achievements/base-achievements.constants.ts +1 -0
- package/src/modules/base-achievements/base-achievements.interfaces.ts +22 -0
- package/src/modules/base-achievements/base-achievements.module.ts +347 -234
- package/src/modules/base-achievements/index.ts +5 -0
- package/src/modules/event-bus/events-bus.app.subscribe.service.ts +5 -5
- package/src/modules/events/events.gateway.ts +4 -2
- package/src/modules/index.ts +6 -1
- package/src/modules/main/main.controller.ts +1 -22
- package/src/modules/main/main.service.ts +7 -34
- package/src/modules/many-tables-tournament/many-tables-tournament.controller.ts +13 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +9 -1
- package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +33 -0
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.interfaces.ts +1 -0
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.module.ts +12 -0
- package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service.ts +92 -42
- package/src/modules/menu/menu-screen.view.ts +9 -2
- package/src/modules/menu/menu.interfaces.ts +1 -0
- package/src/modules/menu/menu.service.ts +1 -0
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.interfaces.ts +1 -0
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.module.ts +12 -0
- package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service.ts +92 -41
- package/src/modules/simple-rooms-manager/simple-rooms-manager.interfaces.ts +1 -0
- package/src/modules/simple-rooms-manager/simple-rooms-manager.module.ts +12 -0
- package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +81 -33
- package/src/views/achievement-snackbar.view.ts +38 -0
- package/src/views/base-table.view.ts +57 -0
- package/src/views/index.ts +3 -0
- package/src/views/level-up-snackbar.view.ts +38 -0
- package/dist/utils/date.d.ts +0 -2
- package/dist/utils/date.js +0 -11
- package/dist/utils/date.js.map +0 -1
- package/dist/utils/game-table-result.d.ts +0 -39
- package/dist/utils/game-table-result.js +0 -102
- package/dist/utils/game-table-result.js.map +0 -1
- package/src/utils/date.ts +0 -7
- package/src/utils/game-table-result.ts +0 -129
|
@@ -40,12 +40,14 @@ export class EventsGateway
|
|
|
40
40
|
if (user) {
|
|
41
41
|
const player = this.options.createPlayer({
|
|
42
42
|
id: user.userId,
|
|
43
|
-
fullName: user.
|
|
44
|
-
avatarUrl: user.
|
|
43
|
+
fullName: user.publicFullName,
|
|
44
|
+
avatarUrl: user.publicAvatarUrl,
|
|
45
|
+
avatarFrame: user.avatarFrame,
|
|
45
46
|
balance: user.balance,
|
|
46
47
|
experience: user.experience,
|
|
47
48
|
level: user.level,
|
|
48
49
|
language: user.normalizedLang,
|
|
50
|
+
cardsSkin: user.cardSkin,
|
|
49
51
|
onSendWsMessage: this.handleSendWsMessage,
|
|
50
52
|
onGotWsMessageClientResponse: this.handleGotWsMessageClientResponse,
|
|
51
53
|
});
|
package/src/modules/index.ts
CHANGED
|
@@ -24,5 +24,10 @@ export {
|
|
|
24
24
|
EventsBusModule,
|
|
25
25
|
EventsBusMainTablesSubscribeService,
|
|
26
26
|
} from './event-bus';
|
|
27
|
-
export {
|
|
27
|
+
export {
|
|
28
|
+
BaseAchievementsModule,
|
|
29
|
+
BaseAchievementsFactoryOptions,
|
|
30
|
+
BASE_ACHIEVEMENTS_OPTIONS,
|
|
31
|
+
BaseAchievementsOptions,
|
|
32
|
+
} from './base-achievements/';
|
|
28
33
|
export { ConfirmationMessageManagerModule } from './confirmation-message-manager/confirmation-message-manager.module';
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Controller,
|
|
3
|
-
Get,
|
|
4
|
-
Headers,
|
|
5
|
-
HttpCode,
|
|
6
|
-
HttpStatus,
|
|
7
|
-
Param,
|
|
8
|
-
Post,
|
|
9
|
-
} from '@nestjs/common';
|
|
1
|
+
import { Controller, Get, Headers } from '@nestjs/common';
|
|
10
2
|
import { IAppHeaders } from 'jp.common.models';
|
|
11
3
|
|
|
12
4
|
import {
|
|
@@ -56,17 +48,4 @@ export class MainController {
|
|
|
56
48
|
headers.client_language,
|
|
57
49
|
);
|
|
58
50
|
}
|
|
59
|
-
|
|
60
|
-
@Post('many_tables_tournament/buy_ticket/:tournamentId')
|
|
61
|
-
@HttpCode(HttpStatus.OK)
|
|
62
|
-
buyTicket(
|
|
63
|
-
@Param('tournamentId') tournamentId: string,
|
|
64
|
-
@Headers() headers: IAppHeaders,
|
|
65
|
-
): Promise<BaseAppScreenDto> {
|
|
66
|
-
return this.mainService.manyTablesTournamentbBuyTicket(
|
|
67
|
-
headers.client_auth_token,
|
|
68
|
-
headers.client_language,
|
|
69
|
-
tournamentId,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
51
|
}
|
|
@@ -29,7 +29,6 @@ import { ManyTablesTournamentRoomsManagerService } from '../many-tables-tourname
|
|
|
29
29
|
import { EventsBusMainTablesSubscribeService } from '../event-bus/events-bus.main-tables.subscribe.service';
|
|
30
30
|
import {
|
|
31
31
|
ErrorCodeEnum,
|
|
32
|
-
NotEnoughMoneyForPurchaseException,
|
|
33
32
|
NotFoundFreeRoomForFastGameException,
|
|
34
33
|
} from '../../exception';
|
|
35
34
|
|
|
@@ -107,18 +106,20 @@ export class MainService {
|
|
|
107
106
|
if (
|
|
108
107
|
player &&
|
|
109
108
|
(player.isPlayer() || player.isTableQueuer()) &&
|
|
110
|
-
player.tableId
|
|
109
|
+
player.tableId &&
|
|
110
|
+
player.room
|
|
111
111
|
) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} else if (player.room instanceof OneTableTournamentRoom) {
|
|
112
|
+
const roomName = player.room.constructor.name;
|
|
113
|
+
if (roomName.includes(OneTableTournamentRoom.name)) {
|
|
115
114
|
redirectUrl = AppScreenRouter.getOneTableTournamentTablePath(
|
|
116
115
|
player.tableId,
|
|
117
116
|
);
|
|
118
|
-
} else if (
|
|
117
|
+
} else if (roomName.includes(ManyTablesTournamentRoom.name)) {
|
|
119
118
|
redirectUrl = AppScreenRouter.getManyTablesTournamentTablePath(
|
|
120
119
|
player.tableId,
|
|
121
120
|
);
|
|
121
|
+
} else if (roomName.includes(SimpleRoom.name)) {
|
|
122
|
+
redirectUrl = AppScreenRouter.getSimpleRoomTablePath(player.tableId);
|
|
122
123
|
}
|
|
123
124
|
} else if (isNewbie) {
|
|
124
125
|
redirectUrl = AppScreenRoutesEnum.WELCOME;
|
|
@@ -152,32 +153,4 @@ export class MainService {
|
|
|
152
153
|
player.id,
|
|
153
154
|
);
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
-
async manyTablesTournamentbBuyTicket(
|
|
157
|
-
clientAuthToken: string,
|
|
158
|
-
lang: string,
|
|
159
|
-
tournamentId: string,
|
|
160
|
-
): Promise<BaseAppScreenDto> {
|
|
161
|
-
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
162
|
-
const tournament =
|
|
163
|
-
this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
164
|
-
const user = await this.usersRepository.findById(player?.id ?? '');
|
|
165
|
-
|
|
166
|
-
if (!player || !tournament || !user) {
|
|
167
|
-
throw new InternalServerErrorException();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (user.balance < tournament.getTicketPrice()) {
|
|
171
|
-
throw new NotEnoughMoneyForPurchaseException(
|
|
172
|
-
new ErrorSnackbarComponent(
|
|
173
|
-
ErrorCodeEnum.NOT_ENOUGH_MONEY_FOR_PURCHASE,
|
|
174
|
-
this.options.i18n.t('common.server.message.code.4004', { lang }),
|
|
175
|
-
),
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
await this.manyTablesRoomsManagerService.buyTicket(tournamentId, player);
|
|
180
|
-
|
|
181
|
-
return this.getScreen(lang, clientAuthToken);
|
|
182
|
-
}
|
|
183
156
|
}
|
|
@@ -148,4 +148,17 @@ export class ManyTablesTournamentController {
|
|
|
148
148
|
removeTournament(@Param('tournamentId') tournamentId: string): Promise<void> {
|
|
149
149
|
return this.tournamentService.removeTournament(tournamentId);
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
@Post('buy_ticket/:tournamentId')
|
|
153
|
+
@HttpCode(HttpStatus.OK)
|
|
154
|
+
buyTicket(
|
|
155
|
+
@Param('tournamentId') tournamentId: string,
|
|
156
|
+
@Headers() headers: IAppHeaders,
|
|
157
|
+
): Promise<void> {
|
|
158
|
+
return this.tournamentService.manyTablesTournamentbBuyTicket(
|
|
159
|
+
headers.client_auth_token,
|
|
160
|
+
headers.client_language,
|
|
161
|
+
tournamentId,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
151
164
|
}
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
ManyTablesTournamentRoom,
|
|
5
5
|
ManyTablesTournamentRoomSchema,
|
|
6
6
|
ManyTablesTournamentRoomsRepository,
|
|
7
|
+
User,
|
|
8
|
+
UserSchema,
|
|
9
|
+
UsersRepository,
|
|
7
10
|
} from 'jp.db.schemas';
|
|
8
11
|
import {
|
|
9
12
|
GamePlayer,
|
|
@@ -27,9 +30,14 @@ import { ManyTablesTournamentModuleOptions } from './many-tables-tournament.inte
|
|
|
27
30
|
schema: ManyTablesTournamentRoomSchema,
|
|
28
31
|
},
|
|
29
32
|
]),
|
|
33
|
+
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
|
|
30
34
|
],
|
|
31
35
|
controllers: [ManyTablesTournamentController],
|
|
32
|
-
providers: [
|
|
36
|
+
providers: [
|
|
37
|
+
ManyTablesTournamentService,
|
|
38
|
+
ManyTablesTournamentRoomsRepository,
|
|
39
|
+
UsersRepository,
|
|
40
|
+
],
|
|
33
41
|
})
|
|
34
42
|
export class ManyTablesTournamentModule {
|
|
35
43
|
constructor(
|
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
IBaseMoveData,
|
|
8
8
|
IAppTableState,
|
|
9
9
|
AppScreenRouter,
|
|
10
|
+
ErrorSnackbarComponent,
|
|
10
11
|
} from 'jp.common.models';
|
|
11
12
|
import {
|
|
12
13
|
ManyTablesTournamentMaster,
|
|
13
14
|
TournamentMaster,
|
|
14
15
|
} from 'jp.ms.common.engine';
|
|
16
|
+
import { UsersRepository } from 'jp.db.schemas';
|
|
15
17
|
|
|
16
18
|
import { BaseAppScreenDto } from '../../dto';
|
|
17
19
|
import { ManyTablesTournamentRoomsManagerService } from '../many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service';
|
|
@@ -19,6 +21,10 @@ import { PlayersManagerService } from '../players-manager/players-manager.servic
|
|
|
19
21
|
import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
20
22
|
import { ManyTablesTournamentCreateDto } from '../../dto/common/many-tables-tournament-create.dto';
|
|
21
23
|
import { ManyTablesTournamentUpdateDto } from '../../dto/common/many-tables-tournament-update.dto';
|
|
24
|
+
import {
|
|
25
|
+
NotEnoughMoneyForPurchaseException,
|
|
26
|
+
ErrorCodeEnum,
|
|
27
|
+
} from '../../exception';
|
|
22
28
|
|
|
23
29
|
import { ManyTablesTournamentFactoryOptions } from './many-tables-tournament.interfaces';
|
|
24
30
|
import { MANY_TABLES_TOURNAMENT_OPTIONS } from './many-tables-tournament.constants';
|
|
@@ -32,6 +38,7 @@ export class ManyTablesTournamentService {
|
|
|
32
38
|
private readonly playersManager: PlayersManagerService,
|
|
33
39
|
@Inject(MANY_TABLES_TOURNAMENT_OPTIONS)
|
|
34
40
|
private readonly options: ManyTablesTournamentFactoryOptions,
|
|
41
|
+
private readonly usersRepository: UsersRepository,
|
|
35
42
|
) {}
|
|
36
43
|
|
|
37
44
|
getStatusScreen(tournamentId: string, lang: string): BaseAppScreenDto {
|
|
@@ -205,4 +212,30 @@ export class ManyTablesTournamentService {
|
|
|
205
212
|
async removeTournament(tournamentId: string) {
|
|
206
213
|
return this.manyTablesRoomsManagerService.removeTournament(tournamentId);
|
|
207
214
|
}
|
|
215
|
+
|
|
216
|
+
async manyTablesTournamentbBuyTicket(
|
|
217
|
+
clientAuthToken: string,
|
|
218
|
+
lang: string,
|
|
219
|
+
tournamentId: string,
|
|
220
|
+
): Promise<void> {
|
|
221
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
222
|
+
const tournament =
|
|
223
|
+
this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
224
|
+
const user = await this.usersRepository.findById(player?.id ?? '');
|
|
225
|
+
|
|
226
|
+
if (!player || !tournament || !user) {
|
|
227
|
+
throw new InternalServerErrorException();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (user.balance < tournament.getTicketPrice()) {
|
|
231
|
+
throw new NotEnoughMoneyForPurchaseException(
|
|
232
|
+
new ErrorSnackbarComponent(
|
|
233
|
+
ErrorCodeEnum.NOT_ENOUGH_MONEY_FOR_PURCHASE,
|
|
234
|
+
this.options.i18n.t('common.server.message.code.4004', { lang }),
|
|
235
|
+
),
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
await this.manyTablesRoomsManagerService.buyTicket(tournamentId, player);
|
|
240
|
+
}
|
|
208
241
|
}
|
|
@@ -19,6 +19,12 @@ import {
|
|
|
19
19
|
Purchase,
|
|
20
20
|
PurchaseSchema,
|
|
21
21
|
PurchaseRepository,
|
|
22
|
+
Rating,
|
|
23
|
+
RatingSchema,
|
|
24
|
+
RatingRepository,
|
|
25
|
+
ActivityLog,
|
|
26
|
+
ActivityLogRepository,
|
|
27
|
+
ActivityLogSchema,
|
|
22
28
|
} from 'jp.db.schemas';
|
|
23
29
|
|
|
24
30
|
import { ManyTablesTournamentRoomsManagerService } from './many-tables-tournament-rooms-manager.service';
|
|
@@ -42,6 +48,10 @@ import { ManyTablesTournamentRoomsFactoryOptions } from './many-tables-tournamen
|
|
|
42
48
|
MongooseModule.forFeature([
|
|
43
49
|
{ name: GameResult.name, schema: GameResultSchema },
|
|
44
50
|
]),
|
|
51
|
+
MongooseModule.forFeature([{ name: Rating.name, schema: RatingSchema }]),
|
|
52
|
+
MongooseModule.forFeature([
|
|
53
|
+
{ name: ActivityLog.name, schema: ActivityLogSchema },
|
|
54
|
+
]),
|
|
45
55
|
],
|
|
46
56
|
providers: [
|
|
47
57
|
ManyTablesTournamentRoomsRepository,
|
|
@@ -49,6 +59,8 @@ import { ManyTablesTournamentRoomsFactoryOptions } from './many-tables-tournamen
|
|
|
49
59
|
ManyTablesTournamentRoomsManagerService,
|
|
50
60
|
GameResultRepository,
|
|
51
61
|
PurchaseRepository,
|
|
62
|
+
RatingRepository,
|
|
63
|
+
ActivityLogRepository,
|
|
52
64
|
],
|
|
53
65
|
exports: [ManyTablesTournamentRoomsManagerService],
|
|
54
66
|
})
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
BaseGameEvent,
|
|
12
12
|
GameMaster,
|
|
13
13
|
GamePlayer,
|
|
14
|
+
GamePlayerMovedOnTheTableEvent,
|
|
14
15
|
GameTableFinishedEvent,
|
|
15
16
|
GameTournamentCancelledEvent,
|
|
16
17
|
GameTournamentFinishedEvent,
|
|
@@ -31,26 +32,26 @@ import {
|
|
|
31
32
|
ManyTablesTournamentRoomDocument,
|
|
32
33
|
ManyTablesTournamentRoomsRepository,
|
|
33
34
|
UsersRepository,
|
|
35
|
+
RatingRepository,
|
|
36
|
+
ActivityLogRepository,
|
|
34
37
|
} from 'jp.db.schemas';
|
|
38
|
+
import { getHours, getMinutes } from 'jp.common.utils';
|
|
35
39
|
|
|
36
|
-
import {
|
|
37
|
-
saveGameTablesResult,
|
|
38
|
-
saveTournamentResult,
|
|
39
|
-
} from '../../utils/game-table-result';
|
|
40
40
|
import { JpLoggerService } from '../logger';
|
|
41
|
-
import { getHours, getMinutes } from '../../utils/date';
|
|
42
41
|
import { ManyTablesTournamentCreateDto } from '../../dto/common/many-tables-tournament-create.dto';
|
|
43
42
|
import { ManyTablesTournamentUpdateDto } from '../../dto/common/many-tables-tournament-update.dto';
|
|
44
43
|
import {
|
|
44
|
+
EventsBusAppSubscribeService,
|
|
45
45
|
EventsBusMainTablesSubscribeService,
|
|
46
46
|
EventsBusManyTablesTournamentSubscribeService,
|
|
47
47
|
} from '../event-bus';
|
|
48
|
+
import { TournamentRoomsManagerService } from '../../common/tournament-rooms-manager.service';
|
|
48
49
|
|
|
49
50
|
import { MANY_TABLES_TOURNAMENT_ROOMS_MANAGER_OPTIONS } from './many-tables-tournament-rooms-manager.constants';
|
|
50
51
|
import { ManyTablesTournamentRoomsFactoryOptions } from './many-tables-tournament-rooms-manager.interfaces';
|
|
51
52
|
|
|
52
53
|
@Injectable()
|
|
53
|
-
export class ManyTablesTournamentRoomsManagerService {
|
|
54
|
+
export class ManyTablesTournamentRoomsManagerService extends TournamentRoomsManagerService {
|
|
54
55
|
private readonly rooms: Map<string, ManyTablesTournamentRoom>;
|
|
55
56
|
private createDailyTournamentJob: Job | null;
|
|
56
57
|
|
|
@@ -59,13 +60,17 @@ export class ManyTablesTournamentRoomsManagerService {
|
|
|
59
60
|
private readonly usersRepository: UsersRepository,
|
|
60
61
|
private readonly gameResultRepository: GameResultRepository,
|
|
61
62
|
private readonly purchaseRepository: PurchaseRepository,
|
|
63
|
+
private readonly ratingRepository: RatingRepository,
|
|
64
|
+
private readonly activityLogRepository: ActivityLogRepository,
|
|
62
65
|
private readonly eventsBusMainTablesSubscribeService: EventsBusMainTablesSubscribeService,
|
|
63
66
|
private readonly eventsBusManyTablesTournamentSubscribeService: EventsBusManyTablesTournamentSubscribeService,
|
|
67
|
+
private readonly eventsBusAppSubscribeService: EventsBusAppSubscribeService,
|
|
64
68
|
@Inject(MANY_TABLES_TOURNAMENT_ROOMS_MANAGER_OPTIONS)
|
|
65
69
|
private readonly options: ManyTablesTournamentRoomsFactoryOptions,
|
|
66
70
|
@InjectConnection() private readonly connection: Connection,
|
|
67
71
|
@Inject() private readonly logger: JpLoggerService,
|
|
68
72
|
) {
|
|
73
|
+
super();
|
|
69
74
|
this.rooms = new Map<string, ManyTablesTournamentRoom>();
|
|
70
75
|
this.createDailyTournamentJob = null;
|
|
71
76
|
}
|
|
@@ -211,6 +216,7 @@ export class ManyTablesTournamentRoomsManagerService {
|
|
|
211
216
|
rulesType: tournamentDocument.rulesType,
|
|
212
217
|
deckType: tournamentDocument.deckType,
|
|
213
218
|
tableSize: tournamentDocument.tableSize,
|
|
219
|
+
tableType: tournamentDocument.tableType,
|
|
214
220
|
bet: tournamentDocument.bet,
|
|
215
221
|
ticketPrice: tournamentDocument.ticketPrice,
|
|
216
222
|
title: tournamentDocument.title,
|
|
@@ -236,58 +242,102 @@ export class ManyTablesTournamentRoomsManagerService {
|
|
|
236
242
|
private handleRoomEvent = (event: BaseGameEvent) => {
|
|
237
243
|
this.logger.log(event.toLog());
|
|
238
244
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
245
|
+
switch (event.constructor.name) {
|
|
246
|
+
case GameTableFinishedEvent.name: {
|
|
247
|
+
void this.handleRoomTableGameFinished(
|
|
248
|
+
event as GameTableFinishedEvent,
|
|
249
|
+
this.connection,
|
|
250
|
+
this.gameResultRepository,
|
|
251
|
+
this.usersRepository,
|
|
252
|
+
this.activityLogRepository,
|
|
253
|
+
this.eventsBusAppSubscribeService,
|
|
254
|
+
this.options.levelUpBonus,
|
|
255
|
+
);
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
case GamePlayerMovedOnTheTableEvent.name: {
|
|
259
|
+
this.handleRoomTableGamePlayerMoved(
|
|
260
|
+
event as GamePlayerMovedOnTheTableEvent,
|
|
261
|
+
this.eventsBusAppSubscribeService,
|
|
262
|
+
);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case GameTournamentStartedEvent.name: {
|
|
266
|
+
void this.handleTournamentRoomStarted(
|
|
267
|
+
event as GameTournamentStartedEvent,
|
|
268
|
+
);
|
|
269
|
+
this.handleRoomStatusUpdated(event as GameTournamentStartedEvent);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
case GameTournamentCancelledEvent.name: {
|
|
273
|
+
void this.handleTournamentRoomCancelled(
|
|
274
|
+
event as GameTournamentCancelledEvent,
|
|
275
|
+
);
|
|
276
|
+
this.handleRoomStatusUpdated(event as GameTournamentCancelledEvent);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case GameTournamentFinishedEvent.name: {
|
|
280
|
+
void this.handleTournamentRoomFinished(
|
|
281
|
+
event as GameTournamentFinishedEvent,
|
|
282
|
+
);
|
|
283
|
+
this.handleRoomStatusUpdated(event as GameTournamentFinishedEvent);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
case GameTournamentPlayerJoinedTheTournamentEvent.name:
|
|
287
|
+
case GameTournamentPlayerLeavedTheTournamentEvent.name:
|
|
288
|
+
case GameTournamentWaitedEvent.name: {
|
|
289
|
+
this.handleRoomStatusUpdated(
|
|
290
|
+
event as
|
|
291
|
+
| GameTournamentPlayerJoinedTheTournamentEvent
|
|
292
|
+
| GameTournamentPlayerLeavedTheTournamentEvent
|
|
293
|
+
| GameTournamentCancelledEvent,
|
|
294
|
+
);
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
258
297
|
}
|
|
259
298
|
};
|
|
260
299
|
|
|
261
|
-
private
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.gameResultRepository,
|
|
266
|
-
this.usersRepository,
|
|
267
|
-
false,
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
private handleTournamentRoomStarted = async (master: TournamentMaster) => {
|
|
300
|
+
private handleTournamentRoomStarted = async (
|
|
301
|
+
event: GameTournamentStartedEvent,
|
|
302
|
+
) => {
|
|
303
|
+
const master = event.room.getRoomMaster<TournamentMaster>();
|
|
272
304
|
await this.tournamentRepository.startTournament(master.getTournamentId());
|
|
273
305
|
};
|
|
274
306
|
|
|
275
|
-
private handleTournamentRoomCancelled = async (
|
|
307
|
+
private handleTournamentRoomCancelled = async (
|
|
308
|
+
event: GameTournamentStartedEvent,
|
|
309
|
+
) => {
|
|
310
|
+
const master = event.room.getRoomMaster<TournamentMaster>();
|
|
276
311
|
await this.tournamentRepository.cancelTournament(master.getTournamentId());
|
|
277
312
|
};
|
|
278
313
|
|
|
279
|
-
private handleTournamentRoomFinished = async (
|
|
280
|
-
|
|
314
|
+
private handleTournamentRoomFinished = async (
|
|
315
|
+
event: GameTournamentFinishedEvent,
|
|
316
|
+
) => {
|
|
317
|
+
const master = event.room.getRoomMaster<TournamentMaster>();
|
|
318
|
+
await this.saveTournamentResult(
|
|
281
319
|
master,
|
|
282
320
|
this.connection,
|
|
283
321
|
this.tournamentRepository,
|
|
284
322
|
this.usersRepository,
|
|
323
|
+
this.ratingRepository,
|
|
285
324
|
);
|
|
286
325
|
};
|
|
287
326
|
|
|
288
|
-
private handleRoomStatusUpdated = (
|
|
289
|
-
|
|
290
|
-
|
|
327
|
+
private handleRoomStatusUpdated = (
|
|
328
|
+
event:
|
|
329
|
+
| GameTournamentPlayerJoinedTheTournamentEvent
|
|
330
|
+
| GameTournamentPlayerLeavedTheTournamentEvent
|
|
331
|
+
| GameTournamentCancelledEvent
|
|
332
|
+
| GameTournamentWaitedEvent
|
|
333
|
+
| GameTournamentStartedEvent
|
|
334
|
+
| GameTournamentFinishedEvent,
|
|
335
|
+
) => {
|
|
336
|
+
const updateEvent = new RoomUpdateStateEvent(event.gameType, event.roomId);
|
|
337
|
+
this.eventsBusMainTablesSubscribeService.pushNewRoomState(updateEvent);
|
|
338
|
+
this.eventsBusManyTablesTournamentSubscribeService.pushNewRoomState(
|
|
339
|
+
updateEvent,
|
|
340
|
+
);
|
|
291
341
|
};
|
|
292
342
|
|
|
293
343
|
private createDailyTournament = async (dailyTournamentTime: string) => {
|
|
@@ -18,16 +18,19 @@ import { Banner, Menu } from 'jp.db.schemas';
|
|
|
18
18
|
export class MenuScreenView extends UniversalScreenView {
|
|
19
19
|
private readonly menuItems: Array<Menu>;
|
|
20
20
|
private readonly banner: Banner | null;
|
|
21
|
+
private gameType: string;
|
|
21
22
|
|
|
22
23
|
constructor(
|
|
23
24
|
localeService: ILocaleService,
|
|
24
25
|
lang: string,
|
|
26
|
+
gameType: string,
|
|
25
27
|
menuItems: Array<Menu>,
|
|
26
28
|
banner: Banner | null,
|
|
27
29
|
) {
|
|
28
30
|
super(localeService, lang);
|
|
29
31
|
this.menuItems = menuItems;
|
|
30
32
|
this.banner = banner;
|
|
33
|
+
this.gameType = gameType;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
build(): IAppScreen {
|
|
@@ -56,7 +59,9 @@ export class MenuScreenView extends UniversalScreenView {
|
|
|
56
59
|
new BannerSectionListItemComponent(
|
|
57
60
|
this.banner.bannerId,
|
|
58
61
|
this.getDbResource(this.banner.title),
|
|
59
|
-
this.localeService.t(
|
|
62
|
+
this.localeService.t(`${this.gameType}.menu.header.title`, {
|
|
63
|
+
lang: this.lang,
|
|
64
|
+
}),
|
|
60
65
|
new UrlImageComponent(this.banner.image),
|
|
61
66
|
this.banner.link,
|
|
62
67
|
),
|
|
@@ -65,7 +70,9 @@ export class MenuScreenView extends UniversalScreenView {
|
|
|
65
70
|
|
|
66
71
|
return new MenuHeaderSectionComponent(
|
|
67
72
|
'header',
|
|
68
|
-
this.localeService.t(
|
|
73
|
+
this.localeService.t(`${this.gameType}.menu.header.title`, {
|
|
74
|
+
lang: this.lang,
|
|
75
|
+
}),
|
|
69
76
|
);
|
|
70
77
|
}
|
|
71
78
|
}
|
package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.module.ts
CHANGED
|
@@ -10,6 +10,12 @@ import {
|
|
|
10
10
|
GameResult,
|
|
11
11
|
GameResultSchema,
|
|
12
12
|
GameResultRepository,
|
|
13
|
+
Rating,
|
|
14
|
+
RatingSchema,
|
|
15
|
+
RatingRepository,
|
|
16
|
+
ActivityLog,
|
|
17
|
+
ActivityLogRepository,
|
|
18
|
+
ActivityLogSchema,
|
|
13
19
|
} from 'jp.db.schemas';
|
|
14
20
|
|
|
15
21
|
import { OneTableTournamentRoomsManagerService } from './one-table-tournament-rooms-manager.service';
|
|
@@ -29,12 +35,18 @@ import { ONE_TABLE_TOURNAMENT_ROOMS_MANAGER_OPTIONS } from './one-table-tourname
|
|
|
29
35
|
MongooseModule.forFeature([
|
|
30
36
|
{ name: GameResult.name, schema: GameResultSchema },
|
|
31
37
|
]),
|
|
38
|
+
MongooseModule.forFeature([{ name: Rating.name, schema: RatingSchema }]),
|
|
39
|
+
MongooseModule.forFeature([
|
|
40
|
+
{ name: ActivityLog.name, schema: ActivityLogSchema },
|
|
41
|
+
]),
|
|
32
42
|
],
|
|
33
43
|
providers: [
|
|
34
44
|
OneTableTournamentRoomsRepository,
|
|
35
45
|
UsersRepository,
|
|
36
46
|
OneTableTournamentRoomsManagerService,
|
|
37
47
|
GameResultRepository,
|
|
48
|
+
RatingRepository,
|
|
49
|
+
ActivityLogRepository,
|
|
38
50
|
],
|
|
39
51
|
exports: [OneTableTournamentRoomsManagerService],
|
|
40
52
|
})
|