jp.ms.common.modules 1.0.28 → 1.0.30
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/exception/error-code.enum.d.ts +4 -0
- package/dist/exception/error-code.enum.js +9 -0
- package/dist/exception/error-code.enum.js.map +1 -0
- package/dist/exception/global-exception-filter.d.ts +5 -0
- package/dist/exception/global-exception-filter.js +53 -0
- package/dist/exception/global-exception-filter.js.map +1 -0
- package/dist/exception/http-exception-wth-snackbar.d.ts +12 -0
- package/dist/exception/http-exception-wth-snackbar.js +17 -0
- package/dist/exception/http-exception-wth-snackbar.js.map +1 -0
- package/dist/exception/index.d.ts +4 -0
- package/dist/exception/index.js +12 -0
- package/dist/exception/index.js.map +1 -0
- package/dist/exception/not-enough-money-for-purchase.exception.d.ts +5 -0
- package/dist/exception/not-enough-money-for-purchase.exception.js +12 -0
- package/dist/exception/not-enough-money-for-purchase.exception.js.map +1 -0
- package/dist/exception/not-found-free-room-for-fast-game.exception.d.ts +5 -0
- package/dist/exception/not-found-free-room-for-fast-game.exception.js +12 -0
- package/dist/exception/not-found-free-room-for-fast-game.exception.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/events/events.gateway.js +1 -1
- package/dist/modules/events/events.gateway.js.map +1 -1
- package/dist/modules/main/main-tables-list-screen.view.d.ts +11 -1
- package/dist/modules/main/main-tables-list-screen.view.js +97 -14
- package/dist/modules/main/main-tables-list-screen.view.js.map +1 -1
- package/dist/modules/main/main.controller.d.ts +4 -3
- package/dist/modules/main/main.controller.js +15 -3
- package/dist/modules/main/main.controller.js.map +1 -1
- package/dist/modules/main/main.module.js +2 -2
- package/dist/modules/main/main.module.js.map +1 -1
- package/dist/modules/main/main.service.d.ts +5 -4
- package/dist/modules/main/main.service.js +38 -12
- package/dist/modules/main/main.service.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament-status-screen.view.d.ts +4 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament-status-screen.view.js +56 -4
- package/dist/modules/many-tables-tournament/many-tables-tournament-status-screen.view.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.js +3 -3
- package/dist/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.d.ts +3 -4
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js +5 -17
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.d.ts +3 -4
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js +20 -27
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js.map +1 -1
- package/dist/modules/menu/menu.service.js +1 -2
- package/dist/modules/menu/menu.service.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.d.ts +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.js +18 -5
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.service.js +1 -2
- package/dist/modules/one-table-tournament/one-table-tournament.service.js.map +1 -1
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js.map +1 -1
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.d.ts +3 -1
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.js +14 -3
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.js.map +1 -1
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.d.ts +4 -3
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.js +49 -25
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.js.map +1 -1
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.js +9 -6
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/game-table-result.d.ts +1 -2
- package/dist/utils/game-table-result.js +0 -13
- package/dist/utils/game-table-result.js.map +1 -1
- package/dist/views/tournament-buy-ticket-dialog.view.js +1 -1
- package/dist/views/tournament-buy-ticket-dialog.view.js.map +1 -1
- package/package.json +4 -4
- package/src/exception/error-code.enum.ts +4 -0
- package/src/exception/global-exception-filter.ts +50 -0
- package/src/exception/http-exception-wth-snackbar.ts +23 -0
- package/src/exception/index.ts +4 -0
- package/src/exception/not-enough-money-for-purchase.exception.ts +15 -0
- package/src/exception/not-found-free-room-for-fast-game.exception.ts +15 -0
- package/src/index.ts +1 -0
- package/src/modules/events/events.gateway.ts +1 -1
- package/src/modules/main/main-tables-list-screen.view.ts +177 -55
- package/src/modules/main/main.controller.ts +23 -10
- package/src/modules/main/main.module.ts +2 -2
- package/src/modules/main/main.service.ts +53 -19
- package/src/modules/many-tables-tournament/many-tables-tournament-status-screen.view.ts +97 -31
- package/src/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.ts +25 -17
- package/src/modules/many-tables-tournament/many-tables-tournament.controller.ts +5 -14
- package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +45 -57
- package/src/modules/menu/menu.service.ts +6 -9
- package/src/modules/one-table-tournament/one-table-tournament-status-screen.view.ts +43 -17
- package/src/modules/one-table-tournament/one-table-tournament.controller.ts +0 -1
- package/src/modules/one-table-tournament/one-table-tournament.service.ts +6 -9
- package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +0 -2
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.ts +17 -9
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.ts +57 -26
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.ts +10 -7
- package/src/utils/game-table-result.ts +1 -16
- package/src/views/tournament-buy-ticket-dialog.view.ts +4 -4
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
-
import { AppScreenRoutesEnum, BaseAppScreen, router } from 'jp.common.models';
|
|
3
2
|
import dayjs from 'dayjs';
|
|
4
3
|
import isToday from 'dayjs/plugin/isToday';
|
|
5
4
|
import { ActivityLogRepository, UsersRepository } from 'jp.db.schemas';
|
|
5
|
+
import { SimpleRoom, OneTableTournamentRoom, ManyTablesTournamentRoom } from 'jp.ms.common.engine';
|
|
6
|
+
import { AppScreenRoutesEnum, ErrorSnackbarComponent, AppScreenRouter } from 'jp.common.models';
|
|
6
7
|
|
|
7
8
|
import { BaseAppScreenDto, PlayerCheckStateDto, FindFreeTableDto } from '../../dto';
|
|
8
9
|
import { SimpleRoomsManagerService } from '../simple-rooms-manager';
|
|
@@ -10,6 +11,7 @@ import { PlayersManagerService } from '../players-manager';
|
|
|
10
11
|
import { TournamentOneTableRoomsManagerService } from '../tournament-one-table-rooms-manager';
|
|
11
12
|
import { TournamentManyTablesRoomsManagerService } from '../tournament-many-tables-rooms-manager';
|
|
12
13
|
import { EventsBusMainTablesSubscribeService } from '../event-bus/events-bus.main-tables.subscribe.service';
|
|
14
|
+
import { ErrorCodeEnum, NotEnoughMoneyForPurchaseException, NotFoundFreeRoomForFastGameException } from '../../exception';
|
|
13
15
|
|
|
14
16
|
import { MainFactoryOptions } from './main.interfaces';
|
|
15
17
|
import { MAIN_OPTIONS } from './main.constants';
|
|
@@ -23,24 +25,23 @@ export class MainService {
|
|
|
23
25
|
private readonly manyTablesRoomsManagerService: TournamentManyTablesRoomsManagerService,
|
|
24
26
|
private readonly playersManager: PlayersManagerService,
|
|
25
27
|
private readonly eventsBusMainTablesSubscribeService: EventsBusMainTablesSubscribeService,
|
|
26
|
-
private readonly
|
|
28
|
+
private readonly usersRepository: UsersRepository,
|
|
27
29
|
private readonly activityLogRepository: ActivityLogRepository,
|
|
28
30
|
@Inject(MAIN_OPTIONS) private readonly options: MainFactoryOptions,
|
|
29
31
|
) {
|
|
30
32
|
dayjs.extend(isToday);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
getScreen (lang: string): BaseAppScreenDto {
|
|
35
|
+
getScreen (lang: string, clientAuthToken: string): BaseAppScreenDto {
|
|
34
36
|
return new BaseAppScreenDto(
|
|
35
|
-
new
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
37
|
+
new MainTablesListScreenView(
|
|
38
|
+
this.options.i18n,
|
|
39
|
+
lang,
|
|
40
|
+
this.simpleRoomsManager.getRooms(),
|
|
41
|
+
this.oneTableRoomsManagerService.getRooms(),
|
|
42
|
+
this.manyTablesRoomsManagerService.getRooms(),
|
|
43
|
+
clientAuthToken,
|
|
44
|
+
).buildBS(),
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -68,7 +69,7 @@ export class MainService {
|
|
|
68
69
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
69
70
|
let redirectUrl: string = AppScreenRoutesEnum.MENU;
|
|
70
71
|
|
|
71
|
-
const foundUser = await this.
|
|
72
|
+
const foundUser = await this.usersRepository.findById(clientAuthToken);
|
|
72
73
|
const isNewbie = await this.activityLogRepository.userIsNewbie(clientAuthToken)
|
|
73
74
|
const last7logins = await this.activityLogRepository.findLast7DaysLogins(game, clientAuthToken);
|
|
74
75
|
|
|
@@ -76,8 +77,14 @@ export class MainService {
|
|
|
76
77
|
throw new InternalServerErrorException();
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
if (player
|
|
80
|
-
|
|
80
|
+
if (player && (player.isPlayer() || player.isTableQueuer()) && player.tableId) {
|
|
81
|
+
if (player.room instanceof SimpleRoom) {
|
|
82
|
+
redirectUrl = AppScreenRouter.getSimpleRoomTablePath(player.tableId);
|
|
83
|
+
} else if (player.room instanceof OneTableTournamentRoom) {
|
|
84
|
+
redirectUrl = AppScreenRouter.getOneTableTournamentTablePath(player.tableId);
|
|
85
|
+
} else if (player.room instanceof ManyTablesTournamentRoom) {
|
|
86
|
+
redirectUrl = AppScreenRouter.getManyTablesTournamentTablePath(player.tableId);
|
|
87
|
+
}
|
|
81
88
|
} else if (isNewbie) {
|
|
82
89
|
redirectUrl = AppScreenRoutesEnum.WELCOME;
|
|
83
90
|
} else if (dayjs(last7logins[0].date).isToday() && last7logins[0].count === 1) {
|
|
@@ -92,14 +99,41 @@ export class MainService {
|
|
|
92
99
|
);
|
|
93
100
|
}
|
|
94
101
|
|
|
95
|
-
findFreeTable (clientAuthToken: string): FindFreeTableDto {
|
|
102
|
+
findFreeTable (clientAuthToken: string, lang: string): FindFreeTableDto {
|
|
96
103
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
97
|
-
const tableId = this.simpleRoomsManager.getFreeFastGameRoom()?.getId()
|
|
104
|
+
const tableId = this.simpleRoomsManager.getFreeFastGameRoom()?.getId();
|
|
98
105
|
|
|
106
|
+
if (!player || !tableId) {
|
|
107
|
+
throw new NotFoundFreeRoomForFastGameException(new ErrorSnackbarComponent(
|
|
108
|
+
ErrorCodeEnum.NOT_FOUND_FREE_ROOM_FOR_FAST_GAME,
|
|
109
|
+
this.options.i18n.t('common.server.message.code.4003', { lang })
|
|
110
|
+
));
|
|
111
|
+
}
|
|
99
112
|
|
|
100
113
|
return FindFreeTableDto.fromEntities(
|
|
101
|
-
|
|
102
|
-
player
|
|
114
|
+
AppScreenRouter.getSimpleRoomTablePath(tableId),
|
|
115
|
+
player.id,
|
|
103
116
|
);
|
|
104
117
|
}
|
|
118
|
+
|
|
119
|
+
async manyTablesTournamentbBuyTicket (clientAuthToken: string, lang: string, tournamentId: string): Promise<BaseAppScreenDto> {
|
|
120
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
121
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
122
|
+
const user = await this.usersRepository.findById(player?.id ?? '');
|
|
123
|
+
|
|
124
|
+
if (!player || !tournament || !user) {
|
|
125
|
+
throw new InternalServerErrorException();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (user.balance < tournament.getTicketPrice()) {
|
|
129
|
+
throw new NotEnoughMoneyForPurchaseException(new ErrorSnackbarComponent(
|
|
130
|
+
ErrorCodeEnum.NOT_ENOUGH_MONEY_FOR_PURCHASE,
|
|
131
|
+
this.options.i18n.t('common.server.message.code.4004', { lang })
|
|
132
|
+
));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
await this.manyTablesRoomsManagerService.buyTicket(tournamentId, player);
|
|
136
|
+
|
|
137
|
+
return this.getScreen(lang, clientAuthToken);
|
|
138
|
+
}
|
|
105
139
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
1
2
|
import {
|
|
2
|
-
AppScreen,
|
|
3
|
-
AppScreenAppBar,
|
|
4
3
|
AppScreenIconEnum,
|
|
5
4
|
AppScreenIdEnum,
|
|
6
|
-
AppScreenSection,
|
|
7
|
-
AppScreenSectionButton,
|
|
8
|
-
AppScreenSectionButtons,
|
|
9
|
-
AppScreenSectionImage,
|
|
10
|
-
AppScreenSectionListItem,
|
|
11
5
|
IAppScreen,
|
|
12
6
|
UniversalScreenView,
|
|
13
7
|
ILocaleService,
|
|
8
|
+
StandardScreenComponent,
|
|
9
|
+
StatusAppBarComponent,
|
|
10
|
+
StatusHeaderSectionComponent,
|
|
11
|
+
CardListSectionComponent,
|
|
12
|
+
ArrowBackButtonComponent,
|
|
13
|
+
IconImageComponent,
|
|
14
|
+
MiniCardSectionListItemComponent,
|
|
15
|
+
UrlImageComponent,
|
|
14
16
|
} from "jp.common.models";
|
|
15
|
-
import {
|
|
17
|
+
import { formatChips, formatDate, formatTime, replacePattern } from "jp.common.utils";
|
|
18
|
+
import { ManyTablesTournamentRoom, TournamentMaster } from "jp.ms.common.engine";
|
|
16
19
|
|
|
17
20
|
export class ManyTablesTournamentStatusScreenView extends UniversalScreenView {
|
|
18
21
|
private readonly tournament: ManyTablesTournamentRoom;
|
|
@@ -26,34 +29,97 @@ export class ManyTablesTournamentStatusScreenView extends UniversalScreenView {
|
|
|
26
29
|
this.tournament = tournament;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
build(): IAppScreen {
|
|
30
|
-
return
|
|
32
|
+
build (): IAppScreen {
|
|
33
|
+
return new StandardScreenComponent(AppScreenIdEnum.ROOMS)
|
|
31
34
|
.addAppBar(
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
+
new StatusAppBarComponent(
|
|
36
|
+
this.tournament.getTitle(this.lang),
|
|
37
|
+
new ArrowBackButtonComponent(
|
|
38
|
+
this.localeService.t('common.button.back', { lang: this.lang })
|
|
39
|
+
),
|
|
35
40
|
),
|
|
36
41
|
)
|
|
37
|
-
.addSection((
|
|
38
|
-
AppScreenSection.CreateStatusHeader(
|
|
39
|
-
'status',
|
|
40
|
-
'description',
|
|
41
|
-
AppScreenSectionImage.CreateIconImage(AppScreenIconEnum.EMOJI_EVENTS),
|
|
42
|
-
AppScreenSectionButtons.CreatePrimaryButtonSection(AppScreenSectionButton.CreateTextButton('button')),
|
|
43
|
-
)
|
|
44
|
-
))
|
|
45
42
|
.addSection(
|
|
46
|
-
|
|
43
|
+
this.getStatusHeader()
|
|
44
|
+
)
|
|
45
|
+
.addSection(
|
|
46
|
+
new CardListSectionComponent(
|
|
47
47
|
'id1',
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
item.playerName,
|
|
51
|
-
'',
|
|
52
|
-
AppScreenSectionImage.CreateUrlImage(item.playerAvatarUrl),
|
|
53
|
-
true,
|
|
54
|
-
'',
|
|
55
|
-
))
|
|
56
|
-
),
|
|
48
|
+
this.getPlayersList()
|
|
49
|
+
)
|
|
57
50
|
);
|
|
58
51
|
}
|
|
52
|
+
|
|
53
|
+
private getPlayersList (): Array<MiniCardSectionListItemComponent> {
|
|
54
|
+
if (this.tournament.getRoomMaster<TournamentMaster>().isFinish()) {
|
|
55
|
+
return this.tournament.getWinners().map((item) => (
|
|
56
|
+
new MiniCardSectionListItemComponent(
|
|
57
|
+
item.playerId,
|
|
58
|
+
item.playerName,
|
|
59
|
+
this.localeService.t('common.tournaments.status.screen.finish.description', {
|
|
60
|
+
lang: this.lang,
|
|
61
|
+
args: {
|
|
62
|
+
RANK: item.rank.toString(),
|
|
63
|
+
PRIZE: formatChips(item.profit, this.lang, true),
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
new UrlImageComponent(item.playerAvatarUrl),
|
|
67
|
+
true,
|
|
68
|
+
true,
|
|
69
|
+
'',
|
|
70
|
+
)
|
|
71
|
+
));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return this.tournament.getParticipants().map((item) => (
|
|
75
|
+
new MiniCardSectionListItemComponent(
|
|
76
|
+
item.playerId,
|
|
77
|
+
item.playerName,
|
|
78
|
+
'',
|
|
79
|
+
new UrlImageComponent(item.playerAvatarUrl),
|
|
80
|
+
true,
|
|
81
|
+
true,
|
|
82
|
+
'',
|
|
83
|
+
)
|
|
84
|
+
));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private getStatusHeader (): StatusHeaderSectionComponent {
|
|
88
|
+
return new StatusHeaderSectionComponent(
|
|
89
|
+
'status',
|
|
90
|
+
this.getStatusDescription(),
|
|
91
|
+
new IconImageComponent(this.getStatusIcon())
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private getStatusIcon (): string {
|
|
96
|
+
if (this.tournament.getRoomMaster<TournamentMaster>().isCancelled()) {
|
|
97
|
+
return AppScreenIconEnum.INFO;
|
|
98
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isFinish()) {
|
|
99
|
+
return AppScreenIconEnum.EMOJI_EVENTS;
|
|
100
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isWaiting()) {
|
|
101
|
+
return AppScreenIconEnum.HOURGLASS_EMPTY;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private getStatusDescription (): string {
|
|
108
|
+
if (this.tournament.getRoomMaster<TournamentMaster>().isCancelled()) {
|
|
109
|
+
return this.localeService.t('common.tournaments.status.4', { lang: this.lang });
|
|
110
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isFinish()) {
|
|
111
|
+
return this.localeService.t('common.tournaments.status.3', { lang: this.lang });
|
|
112
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isInProgress()) {
|
|
113
|
+
return this.localeService.t('common.tournaments.status.2', { lang: this.lang });
|
|
114
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isWaiting()) {
|
|
115
|
+
return replacePattern(this.tournament.getSubtitle(this.lang), {
|
|
116
|
+
DATE: dayjs(this.tournament.getScheduleDate()).isToday() ?
|
|
117
|
+
this.localeService.t('common.tournaments.status.today', { lang: this.lang }) :
|
|
118
|
+
formatDate(this.tournament.getScheduleDate() ?? ''),
|
|
119
|
+
SCHEDULE_DATE: formatTime(this.tournament.getScheduleDate() ?? ''),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return '';
|
|
124
|
+
}
|
|
59
125
|
}
|
package/src/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AppScreen,
|
|
3
|
-
AppScreenAppBar,
|
|
4
|
-
AppScreenIconEnum,
|
|
5
2
|
AppScreenIdEnum,
|
|
6
|
-
AppScreenSection,
|
|
7
|
-
AppScreenSectionButton,
|
|
8
|
-
AppScreenSectionImage,
|
|
9
|
-
AppScreenSectionListItem,
|
|
10
3
|
IAppScreen,
|
|
11
4
|
UniversalScreenView,
|
|
12
5
|
ILocaleService,
|
|
13
|
-
|
|
6
|
+
StandardScreenComponent,
|
|
7
|
+
AppScreenRouter,
|
|
8
|
+
StandardAppBarComponent,
|
|
9
|
+
ArrowBackButtonComponent,
|
|
10
|
+
CardListSectionComponent,
|
|
11
|
+
MiniCardSectionListItemComponent,
|
|
12
|
+
UrlImageComponent,
|
|
14
13
|
} from "jp.common.models";
|
|
15
14
|
import { ManyTablesTournamentRoom } from "jp.ms.common.engine";
|
|
16
15
|
|
|
@@ -26,25 +25,34 @@ export class ManyTablesTournamentTablesListScreenView extends UniversalScreenVie
|
|
|
26
25
|
this.tournament = tournament;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
build(): IAppScreen {
|
|
30
|
-
return
|
|
28
|
+
build (): IAppScreen {
|
|
29
|
+
return new StandardScreenComponent(AppScreenIdEnum.ROOMS)
|
|
31
30
|
.addAppBar(
|
|
32
|
-
|
|
31
|
+
new StandardAppBarComponent(
|
|
33
32
|
this.localeService.t('common.rooms.screen.title', { lang: this.lang }),
|
|
34
|
-
|
|
33
|
+
new ArrowBackButtonComponent(
|
|
34
|
+
this.localeService.t(
|
|
35
|
+
'common.button.back',
|
|
36
|
+
{ lang: this.lang },
|
|
37
|
+
)
|
|
38
|
+
),
|
|
35
39
|
),
|
|
36
40
|
)
|
|
37
41
|
.addSection(
|
|
38
|
-
|
|
42
|
+
new CardListSectionComponent(
|
|
39
43
|
'id1',
|
|
40
44
|
this.tournament?.getTables().map((table) =>
|
|
41
|
-
|
|
45
|
+
new MiniCardSectionListItemComponent(
|
|
42
46
|
table.getId(),
|
|
43
47
|
table.getTitle(this.lang),
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
this.localeService.t(
|
|
49
|
+
'common.tournaments.screen.table.title',
|
|
50
|
+
{ lang: this.lang, args: { NUMBER: table.getNumber().toString() } }
|
|
51
|
+
),
|
|
52
|
+
new UrlImageComponent(`${table.getPlayers().length}/${table.getTableSize()}`),
|
|
53
|
+
true,
|
|
46
54
|
true,
|
|
47
|
-
|
|
55
|
+
AppScreenRouter.getManyTablesTournamentTablePath(table.getId()),
|
|
48
56
|
)
|
|
49
57
|
) ?? []
|
|
50
58
|
),
|
|
@@ -25,16 +25,16 @@ export class ManyTablesTournamentController {
|
|
|
25
25
|
subscribeOnStatusScreen(
|
|
26
26
|
@Param('tournamentId') tournamentId: string,
|
|
27
27
|
@Headers() headers: IAppHeaders,
|
|
28
|
-
):
|
|
29
|
-
return this.tournamentService.subscribeOnStatusScreen(tournamentId, headers.
|
|
28
|
+
): void {
|
|
29
|
+
return this.tournamentService.subscribeOnStatusScreen(tournamentId, headers.client_auth_token);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
@Get('status/unsubscribe/:tournamentId')
|
|
33
33
|
unsubscribeFromStatusScreen(
|
|
34
34
|
@Param('tournamentId') tournamentId: string,
|
|
35
35
|
@Headers() headers: IAppHeaders,
|
|
36
|
-
):
|
|
37
|
-
return this.tournamentService.unsubscribeFromStatusScreen(tournamentId, headers.
|
|
36
|
+
): void {
|
|
37
|
+
return this.tournamentService.unsubscribeFromStatusScreen(tournamentId, headers.client_auth_token);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@Get('tables/:tournamentId')
|
|
@@ -78,19 +78,10 @@ export class ManyTablesTournamentController {
|
|
|
78
78
|
leaveTournament(
|
|
79
79
|
@Param('tournamentId') tournamentId: string,
|
|
80
80
|
@Headers() headers: IAppHeaders,
|
|
81
|
-
):
|
|
81
|
+
): void {
|
|
82
82
|
return this.tournamentService.leaveTournament(tournamentId, headers.client_auth_token);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
@Post('buy_ticket/:tournamentId')
|
|
86
|
-
@HttpCode(HttpStatus.OK)
|
|
87
|
-
buyTicket(
|
|
88
|
-
@Param('tournamentId') tournamentId: string,
|
|
89
|
-
@Headers() headers: IAppHeaders,
|
|
90
|
-
): Promise<void> {
|
|
91
|
-
return this.tournamentService.buyTicket(tournamentId, headers.client_auth_token);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
85
|
@Post('create')
|
|
95
86
|
@HttpCode(HttpStatus.OK)
|
|
96
87
|
createTournament(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
2
|
import {
|
|
3
|
-
BaseAppScreen,
|
|
4
3
|
IBaseMoveData,
|
|
5
4
|
IBaseTableGameState,
|
|
6
|
-
|
|
5
|
+
AppScreenRouter,
|
|
7
6
|
} from 'jp.common.models';
|
|
7
|
+
import { ManyTablesTournamentMaster, TournamentMaster } from 'jp.ms.common.engine';
|
|
8
8
|
|
|
9
9
|
import { BaseAppScreenDto } from '../../dto';
|
|
10
10
|
import { TournamentManyTablesRoomsManagerService } from '../tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service';
|
|
@@ -17,7 +17,6 @@ import { ManyTablesTournamentFactoryOptions } from './many-tables-tournament.int
|
|
|
17
17
|
import { MANY_TABLES_TOURNAMENT_OPTIONS } from './many-tables-tournament.constants';
|
|
18
18
|
import { ManyTablesTournamentStatusScreenView } from './many-tables-tournament-status-screen.view';
|
|
19
19
|
import { ManyTablesTournamentTablesListScreenView } from './many-tables-tournament-tables-list-screen.view';
|
|
20
|
-
import { TournamentMaster } from 'jp.ms.common.engine';
|
|
21
20
|
|
|
22
21
|
@Injectable()
|
|
23
22
|
export class ManyTablesTournamentService {
|
|
@@ -28,7 +27,7 @@ export class ManyTablesTournamentService {
|
|
|
28
27
|
) {
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
getStatusScreen(tournamentId: string, lang: string): BaseAppScreenDto {
|
|
30
|
+
getStatusScreen (tournamentId: string, lang: string): BaseAppScreenDto {
|
|
32
31
|
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
33
32
|
|
|
34
33
|
if (!tournament) {
|
|
@@ -36,39 +35,38 @@ export class ManyTablesTournamentService {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
return new BaseAppScreenDto(
|
|
39
|
-
new
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
).build()
|
|
45
|
-
)
|
|
38
|
+
new ManyTablesTournamentStatusScreenView(
|
|
39
|
+
this.options.i18n,
|
|
40
|
+
lang,
|
|
41
|
+
tournament,
|
|
42
|
+
).buildBS()
|
|
46
43
|
);
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
subscribeOnStatusScreen(tournamentId: string, clientAuthToken: string):
|
|
46
|
+
subscribeOnStatusScreen (tournamentId: string, clientAuthToken: string): void {
|
|
50
47
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
51
48
|
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
52
49
|
|
|
53
|
-
if (player
|
|
54
|
-
|
|
50
|
+
if (!player || !tournament) {
|
|
51
|
+
throw new InternalServerErrorException();
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
tournament.addToStatusScreenWatchers(player);
|
|
55
|
+
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
unsubscribeFromStatusScreen(tournamentId: string, clientAuthToken: string):
|
|
58
|
+
unsubscribeFromStatusScreen (tournamentId: string, clientAuthToken: string): void {
|
|
61
59
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
62
60
|
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
63
61
|
|
|
64
|
-
if (player
|
|
65
|
-
|
|
62
|
+
if (!player || !tournament) {
|
|
63
|
+
throw new InternalServerErrorException();
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
|
|
66
|
+
tournament.removeFromStatusScreenWatchers(player);
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
async getTableListScreen(tournamentId: string, lang: string): Promise<BaseAppScreenDto> {
|
|
69
|
+
async getTableListScreen (tournamentId: string, lang: string): Promise<BaseAppScreenDto> {
|
|
72
70
|
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
73
71
|
|
|
74
72
|
if (!tournament) {
|
|
@@ -76,17 +74,15 @@ export class ManyTablesTournamentService {
|
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
return new BaseAppScreenDto(
|
|
79
|
-
new
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
).build()
|
|
85
|
-
)
|
|
77
|
+
new ManyTablesTournamentTablesListScreenView(
|
|
78
|
+
this.options.i18n,
|
|
79
|
+
lang,
|
|
80
|
+
tournament,
|
|
81
|
+
).buildBS()
|
|
86
82
|
);
|
|
87
83
|
}
|
|
88
84
|
|
|
89
|
-
watchTheTable(tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
85
|
+
watchTheTable (tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
90
86
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
91
87
|
const room = this.manyTablesRoomsManagerService.getRoomByTableId(tableId);
|
|
92
88
|
const master = room?.getMasterById(tableId);
|
|
@@ -100,7 +96,7 @@ export class ManyTablesTournamentService {
|
|
|
100
96
|
throw new InternalServerErrorException();
|
|
101
97
|
}
|
|
102
98
|
|
|
103
|
-
moveOnTheTable(tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
99
|
+
moveOnTheTable (tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
104
100
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
105
101
|
const room = this.manyTablesRoomsManagerService.getRoomByTableId(tableId);
|
|
106
102
|
const master = room?.getMasterById(tableId);
|
|
@@ -114,29 +110,36 @@ export class ManyTablesTournamentService {
|
|
|
114
110
|
throw new InternalServerErrorException();
|
|
115
111
|
}
|
|
116
112
|
|
|
117
|
-
joinTournament(tournamentId: string, clientAuthToken: string): JoinTournamentDto {
|
|
113
|
+
joinTournament (tournamentId: string, clientAuthToken: string): JoinTournamentDto {
|
|
118
114
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
119
115
|
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
120
|
-
const master = tournament?.getMasterById(tournamentId);
|
|
121
116
|
|
|
122
|
-
if (player && tournament
|
|
117
|
+
if (player && tournament) {
|
|
123
118
|
tournament.handleJoinTournament(player);
|
|
124
119
|
|
|
125
120
|
if (tournament.getRoomMaster<TournamentMaster>().isInProgress()) {
|
|
126
121
|
if (player.isPlayer() || player.isTableQueuer()) {
|
|
127
122
|
return JoinTournamentDto.fromEntities(
|
|
128
|
-
|
|
123
|
+
AppScreenRouter.getManyTablesTournamentTablePath(player.tableId ?? ''),
|
|
124
|
+
player.id,
|
|
125
|
+
);
|
|
126
|
+
} else if (tournament.isParticipant(player.id)) {
|
|
127
|
+
tournament.getRoomMaster<ManyTablesTournamentMaster>()
|
|
128
|
+
.onTournamentProcessAlonePlayer(tournament.getRoomMaster(), player);
|
|
129
|
+
|
|
130
|
+
return JoinTournamentDto.fromEntities(
|
|
131
|
+
AppScreenRouter.getManyTablesTournamentTablePath(player.tableId ?? ''),
|
|
129
132
|
player.id,
|
|
130
133
|
);
|
|
131
134
|
} else {
|
|
132
135
|
return JoinTournamentDto.fromEntities(
|
|
133
|
-
|
|
136
|
+
AppScreenRouter.getManyTablesTournamentTableListPath(tournamentId),
|
|
134
137
|
player.id,
|
|
135
138
|
);
|
|
136
139
|
}
|
|
137
140
|
} else {
|
|
138
141
|
return JoinTournamentDto.fromEntities(
|
|
139
|
-
|
|
142
|
+
AppScreenRouter.getManyTablesTournamentStatusPath(tournament.getId()),
|
|
140
143
|
player.id,
|
|
141
144
|
);
|
|
142
145
|
}
|
|
@@ -145,41 +148,26 @@ export class ManyTablesTournamentService {
|
|
|
145
148
|
throw new InternalServerErrorException();
|
|
146
149
|
}
|
|
147
150
|
|
|
148
|
-
leaveTournament(tournamentId: string, clientAuthToken: string):
|
|
151
|
+
leaveTournament (tournamentId: string, clientAuthToken: string): void {
|
|
149
152
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
150
153
|
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
151
|
-
const master = tournament?.getMasterById(tournamentId);
|
|
152
154
|
|
|
153
|
-
if (player
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return master.createGameStateDto(player);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
throw new InternalServerErrorException();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async buyTicket(tournamentId: string, clientAuthToken: string) {
|
|
163
|
-
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
164
|
-
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
165
|
-
const master = tournament?.getMasterById(tournamentId);
|
|
166
|
-
|
|
167
|
-
if (player && tournament && master) {
|
|
168
|
-
return this.manyTablesRoomsManagerService.buyTicket(tournamentId, player);
|
|
155
|
+
if (!player || !tournament) {
|
|
156
|
+
throw new InternalServerErrorException();
|
|
169
157
|
}
|
|
170
158
|
|
|
171
|
-
|
|
159
|
+
tournament.handleLeaveTournament(player);
|
|
172
160
|
}
|
|
173
161
|
|
|
174
|
-
async createTournament(createTournamentDto: ManyTablesTournamentCreateDto) {
|
|
162
|
+
async createTournament (createTournamentDto: ManyTablesTournamentCreateDto) {
|
|
175
163
|
return this.manyTablesRoomsManagerService.createTournament(createTournamentDto);
|
|
176
164
|
}
|
|
177
165
|
|
|
178
|
-
async updateTournament(tournamentId: string, updateTournamentDto: ManyTablesTournamentUpdateDto) {
|
|
166
|
+
async updateTournament (tournamentId: string, updateTournamentDto: ManyTablesTournamentUpdateDto) {
|
|
179
167
|
return this.manyTablesRoomsManagerService.updateTournament(tournamentId, updateTournamentDto);
|
|
180
168
|
}
|
|
181
169
|
|
|
182
|
-
async removeTournament(tournamentId: string) {
|
|
170
|
+
async removeTournament (tournamentId: string) {
|
|
183
171
|
return this.manyTablesRoomsManagerService.removeTournament(tournamentId);
|
|
184
172
|
}
|
|
185
173
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { BannersRepository, MenuRepository } from 'jp.db.schemas';
|
|
3
3
|
import {
|
|
4
|
-
BaseAppScreen,
|
|
5
4
|
IAppHeaders,
|
|
6
5
|
} from 'jp.common.models';
|
|
7
6
|
|
|
@@ -25,14 +24,12 @@ export class MenuService {
|
|
|
25
24
|
const enabledBanner = await this.bannersRepository.findEnabledBanner(headers.client_game, headers.client_channel);
|
|
26
25
|
|
|
27
26
|
return new BaseAppScreenDto(
|
|
28
|
-
new
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
).build()
|
|
35
|
-
)
|
|
27
|
+
new MenuScreenView(
|
|
28
|
+
this.options.i18n,
|
|
29
|
+
headers.client_language,
|
|
30
|
+
menuItems,
|
|
31
|
+
enabledBanner,
|
|
32
|
+
).buildBS()
|
|
36
33
|
);
|
|
37
34
|
}
|
|
38
35
|
}
|