jp.ms.common.modules 1.0.20 → 1.0.21
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/dto/app-screen/app-screen-dialog.dto.d.ts +10 -0
- package/dist/dto/app-screen/app-screen-dialog.dto.js +81 -0
- package/dist/dto/app-screen/app-screen-dialog.dto.js.map +1 -0
- package/dist/dto/app-screen/app-screen.dto.d.ts +3 -0
- package/dist/dto/app-screen/app-screen.dto.js +12 -0
- package/dist/dto/app-screen/app-screen.dto.js.map +1 -1
- package/dist/dto/common/player-check-state.dto.d.ts +2 -2
- package/dist/dto/common/player-check-state.dto.js.map +1 -1
- package/dist/modules/base-achievements/base-achievements.module.d.ts +15 -0
- package/dist/modules/base-achievements/base-achievements.module.js +138 -0
- package/dist/modules/base-achievements/base-achievements.module.js.map +1 -0
- package/dist/modules/base-achievements/index.d.ts +1 -0
- package/dist/modules/base-achievements/index.js +6 -0
- package/dist/modules/base-achievements/index.js.map +1 -0
- package/dist/modules/event-bus/events-bus.app.subscribe.service.d.ts +7 -0
- package/dist/modules/event-bus/events-bus.app.subscribe.service.js +32 -0
- package/dist/modules/event-bus/events-bus.app.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/events-bus.main-tables.subscribe.service.d.ts +11 -0
- package/dist/modules/event-bus/events-bus.main-tables.subscribe.service.js +43 -0
- package/dist/modules/event-bus/events-bus.main-tables.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/events-bus.many-tables-tournament.subscribe.service.d.ts +3 -0
- package/dist/modules/event-bus/events-bus.many-tables-tournament.subscribe.service.js +18 -0
- package/dist/modules/event-bus/events-bus.many-tables-tournament.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/events-bus.module.d.ts +2 -0
- package/dist/modules/event-bus/events-bus.module.js +35 -0
- package/dist/modules/event-bus/events-bus.module.js.map +1 -0
- package/dist/modules/event-bus/events-bus.one-table-tournament.subscribe.service.d.ts +3 -0
- package/dist/modules/event-bus/events-bus.one-table-tournament.subscribe.service.js +18 -0
- package/dist/modules/event-bus/events-bus.one-table-tournament.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/events-bus.tournament.subscribe.service.d.ts +7 -0
- package/dist/modules/event-bus/events-bus.tournament.subscribe.service.js +18 -0
- package/dist/modules/event-bus/events-bus.tournament.subscribe.service.js.map +1 -0
- package/dist/modules/event-bus/index.d.ts +5 -0
- package/dist/modules/event-bus/index.js +14 -0
- package/dist/modules/event-bus/index.js.map +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +6 -1
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/main/main-tables-list-screen.view.d.ts +9 -0
- package/dist/modules/main/main-tables-list-screen.view.js +38 -0
- package/dist/modules/main/main-tables-list-screen.view.js.map +1 -0
- package/dist/modules/main/main.controller.d.ts +4 -2
- package/dist/modules/main/main.controller.js +23 -4
- package/dist/modules/main/main.controller.js.map +1 -1
- package/dist/modules/main/main.module.d.ts +7 -1
- package/dist/modules/main/main.module.js +29 -3
- package/dist/modules/main/main.module.js.map +1 -1
- package/dist/modules/main/main.service.d.ts +10 -3
- package/dist/modules/main/main.service.js +54 -26
- package/dist/modules/main/main.service.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament-status-screen.view.d.ts +7 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament-status-screen.view.js +19 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament-status-screen.view.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.d.ts +7 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.js +18 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.d.ts +4 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js +35 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.d.ts +9 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +22 -2
- 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 +34 -10
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js.map +1 -1
- package/dist/modules/menu/menu-screen.view.d.ts +7 -0
- package/dist/modules/menu/menu-screen.view.js +18 -0
- package/dist/modules/menu/menu-screen.view.js.map +1 -0
- package/dist/modules/menu/menu.service.d.ts +1 -1
- package/dist/modules/menu/menu.service.js +3 -5
- package/dist/modules/menu/menu.service.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.d.ts +7 -0
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.js +19 -0
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.js.map +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.controller.d.ts +3 -1
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js +23 -1
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.d.ts +9 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.js +22 -2
- package/dist/modules/one-table-tournament/one-table-tournament.module.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.service.d.ts +3 -1
- package/dist/modules/one-table-tournament/one-table-tournament.service.js +19 -6
- package/dist/modules/one-table-tournament/one-table-tournament.service.js.map +1 -1
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.d.ts +7 -2
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js +20 -8
- 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.service.d.ts +7 -2
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.js +24 -5
- 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.d.ts +5 -1
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.js +17 -5
- 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/views/index.d.ts +1 -0
- package/dist/views/index.js +6 -0
- package/dist/views/index.js.map +1 -0
- package/dist/views/tournament-buy-ticket-dialog.view.d.ts +4 -0
- package/dist/views/tournament-buy-ticket-dialog.view.js +11 -0
- package/dist/views/tournament-buy-ticket-dialog.view.js.map +1 -0
- package/package.json +7 -7
- package/src/dto/app-screen/app-screen-dialog.dto.ts +57 -0
- package/src/dto/app-screen/app-screen.dto.ts +12 -1
- package/src/dto/common/player-check-state.dto.ts +2 -2
- package/src/modules/base-achievements/base-achievements.module.ts +163 -0
- package/src/modules/base-achievements/index.ts +1 -0
- package/src/modules/event-bus/events-bus.app.subscribe.service.ts +21 -0
- package/src/modules/event-bus/events-bus.main-tables.subscribe.service.ts +34 -0
- package/src/modules/event-bus/events-bus.many-tables-tournament.subscribe.service.ts +6 -0
- package/src/modules/event-bus/events-bus.module.ts +23 -0
- package/src/modules/event-bus/events-bus.one-table-tournament.subscribe.service.ts +6 -0
- package/src/modules/event-bus/events-bus.tournament.subscribe.service.ts +19 -0
- package/src/modules/event-bus/index.ts +5 -0
- package/src/modules/index.ts +2 -1
- package/src/modules/main/main-tables-list-screen.view.ts +107 -0
- package/src/modules/main/main.controller.ts +16 -7
- package/src/modules/main/main.module.ts +30 -5
- package/src/modules/main/main.service.ts +66 -82
- package/src/modules/many-tables-tournament/index.ts +1 -1
- package/src/modules/many-tables-tournament/many-tables-tournament-status-screen.view.ts +59 -0
- package/src/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.ts +53 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.controller.ts +36 -11
- package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +21 -4
- package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +68 -73
- package/src/modules/menu/menu-screen.view.ts +48 -0
- package/src/modules/menu/menu.service.ts +14 -32
- package/src/modules/one-table-tournament/one-table-tournament-status-screen.view.ts +64 -0
- package/src/modules/one-table-tournament/one-table-tournament.controller.ts +23 -7
- package/src/modules/one-table-tournament/one-table-tournament.module.ts +21 -4
- package/src/modules/one-table-tournament/one-table-tournament.service.ts +39 -46
- package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +30 -17
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.ts +39 -16
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.ts +48 -35
- package/src/views/index.ts +1 -0
- package/src/views/tournament-buy-ticket-dialog.view.ts +21 -0
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
2
|
import {
|
|
3
|
-
AppScreen,
|
|
4
|
-
AppScreenAppBar,
|
|
5
|
-
AppScreenIdEnum,
|
|
6
|
-
AppScreenSection,
|
|
7
|
-
AppScreenSectionButton,
|
|
8
|
-
AppScreenSectionImage,
|
|
9
|
-
AppScreenSectionListItem,
|
|
10
3
|
BaseAppScreen,
|
|
11
4
|
IBaseMoveData,
|
|
12
5
|
IBaseTableGameState,
|
|
13
|
-
AppScreenIconEnum,
|
|
14
|
-
AppScreenSectionButtons,
|
|
15
6
|
router,
|
|
16
7
|
} from 'jp.common.models';
|
|
17
8
|
|
|
@@ -24,85 +15,77 @@ import { ManyTablesTournamentUpdateDto } from '../../dto/common/many-tables-tour
|
|
|
24
15
|
|
|
25
16
|
import { ManyTablesTournamentFactoryOptions } from './many-tables-tournament.interfaces';
|
|
26
17
|
import { MANY_TABLES_TOURNAMENT_OPTIONS } from './many-tables-tournament.constants';
|
|
18
|
+
import { ManyTablesTournamentStatusScreenView } from './many-tables-tournament-status-screen.view';
|
|
19
|
+
import { ManyTablesTournamentTablesListScreenView } from './many-tables-tournament-tables-list-screen.view';
|
|
27
20
|
|
|
28
21
|
@Injectable()
|
|
29
22
|
export class ManyTablesTournamentService {
|
|
30
|
-
constructor
|
|
23
|
+
constructor(
|
|
31
24
|
private readonly manyTablesRoomsManagerService: TournamentManyTablesRoomsManagerService,
|
|
32
25
|
private readonly playersManager: PlayersManagerService,
|
|
33
26
|
@Inject(MANY_TABLES_TOURNAMENT_OPTIONS) private readonly options: ManyTablesTournamentFactoryOptions,
|
|
34
27
|
) {
|
|
35
28
|
}
|
|
36
29
|
|
|
37
|
-
|
|
30
|
+
getStatusScreen(tournamentId: string, lang: string): BaseAppScreenDto {
|
|
38
31
|
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
39
32
|
|
|
40
33
|
if (!tournament) {
|
|
41
34
|
throw new InternalServerErrorException();
|
|
42
35
|
}
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
'id1',
|
|
63
|
-
tournament.getParticipants().map((item) => AppScreenSectionListItem.CreateCardListItemMini(
|
|
64
|
-
item.playerId,
|
|
65
|
-
item.playerName,
|
|
66
|
-
'',
|
|
67
|
-
AppScreenSectionImage.CreateUrlImage(item.playerAvatarUrl),
|
|
68
|
-
true,
|
|
69
|
-
'',
|
|
70
|
-
))
|
|
71
|
-
),
|
|
72
|
-
);
|
|
37
|
+
return new BaseAppScreenDto(
|
|
38
|
+
new BaseAppScreen(
|
|
39
|
+
new ManyTablesTournamentStatusScreenView(
|
|
40
|
+
this.options.i18n,
|
|
41
|
+
lang,
|
|
42
|
+
tournament,
|
|
43
|
+
).build()
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
subscribeOnStatusScreen(tournamentId: string, clientAuthToken: string): Promise<void> {
|
|
49
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
50
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
51
|
+
|
|
52
|
+
if (player && tournament) {
|
|
53
|
+
tournament.addToStatusScreenWatchers(player);
|
|
54
|
+
}
|
|
73
55
|
|
|
74
|
-
|
|
56
|
+
throw new InternalServerErrorException();
|
|
75
57
|
}
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
AppScreenSection.CreateCardListSection(
|
|
88
|
-
'id1',
|
|
89
|
-
this.manyTablesRoomsManagerService.getRoomById(tournamentId)?.getTables().map((table) =>
|
|
90
|
-
AppScreenSectionListItem.CreateCardListItemMini(
|
|
91
|
-
table.getId(),
|
|
92
|
-
table.getTitle(lang),
|
|
93
|
-
table.getSubtitle(lang),
|
|
94
|
-
AppScreenSectionImage.CreateIconImage(AppScreenIconEnum.EMOJI_EVENTS),
|
|
95
|
-
true,
|
|
96
|
-
router.getRoomPath(table.getId()),
|
|
97
|
-
)
|
|
98
|
-
) ?? []
|
|
99
|
-
),
|
|
100
|
-
);
|
|
59
|
+
unsubscribeFromStatusScreen(tournamentId: string, clientAuthToken: string): Promise<void> {
|
|
60
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
61
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
62
|
+
|
|
63
|
+
if (player && tournament) {
|
|
64
|
+
tournament.removeFromStatusScreenWatchers(player);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
throw new InternalServerErrorException();
|
|
68
|
+
}
|
|
101
69
|
|
|
102
|
-
|
|
70
|
+
async getTableListScreen(tournamentId: string, lang: string): Promise<BaseAppScreenDto> {
|
|
71
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
72
|
+
|
|
73
|
+
if (!tournament) {
|
|
74
|
+
throw new InternalServerErrorException();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return new BaseAppScreenDto(
|
|
78
|
+
new BaseAppScreen(
|
|
79
|
+
new ManyTablesTournamentTablesListScreenView(
|
|
80
|
+
this.options.i18n,
|
|
81
|
+
lang,
|
|
82
|
+
tournament,
|
|
83
|
+
).build()
|
|
84
|
+
)
|
|
85
|
+
);
|
|
103
86
|
}
|
|
104
87
|
|
|
105
|
-
watchTheTable
|
|
88
|
+
watchTheTable(tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
106
89
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
107
90
|
const room = this.manyTablesRoomsManagerService.getRoomByTableId(tableId);
|
|
108
91
|
const master = room?.getMasterById(tableId);
|
|
@@ -116,7 +99,7 @@ export class ManyTablesTournamentService {
|
|
|
116
99
|
throw new InternalServerErrorException();
|
|
117
100
|
}
|
|
118
101
|
|
|
119
|
-
moveOnTheTable
|
|
102
|
+
moveOnTheTable(tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
120
103
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
121
104
|
const room = this.manyTablesRoomsManagerService.getRoomByTableId(tableId);
|
|
122
105
|
const master = room?.getMasterById(tableId);
|
|
@@ -130,7 +113,7 @@ export class ManyTablesTournamentService {
|
|
|
130
113
|
throw new InternalServerErrorException();
|
|
131
114
|
}
|
|
132
115
|
|
|
133
|
-
joinTournament
|
|
116
|
+
joinTournament(tournamentId: string, clientAuthToken: string): JoinTournamentDto {
|
|
134
117
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
135
118
|
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
136
119
|
const master = tournament?.getMasterById(tournamentId);
|
|
@@ -161,7 +144,7 @@ export class ManyTablesTournamentService {
|
|
|
161
144
|
throw new InternalServerErrorException();
|
|
162
145
|
}
|
|
163
146
|
|
|
164
|
-
leaveTournament
|
|
147
|
+
leaveTournament(tournamentId: string, clientAuthToken: string): IBaseTableGameState {
|
|
165
148
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
166
149
|
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
167
150
|
const master = tournament?.getMasterById(tournamentId);
|
|
@@ -175,15 +158,27 @@ export class ManyTablesTournamentService {
|
|
|
175
158
|
throw new InternalServerErrorException();
|
|
176
159
|
}
|
|
177
160
|
|
|
178
|
-
async
|
|
161
|
+
async buyTicket(tournamentId: string, clientAuthToken: string) {
|
|
162
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
163
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
164
|
+
const master = tournament?.getMasterById(tournamentId);
|
|
165
|
+
|
|
166
|
+
if (player && tournament && master) {
|
|
167
|
+
return this.manyTablesRoomsManagerService.buyTicket(tournamentId, player);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
throw new InternalServerErrorException();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async createTournament(createTournamentDto: ManyTablesTournamentCreateDto) {
|
|
179
174
|
return this.manyTablesRoomsManagerService.createTournament(createTournamentDto);
|
|
180
175
|
}
|
|
181
176
|
|
|
182
|
-
async updateTournament
|
|
177
|
+
async updateTournament(tournamentId: string, updateTournamentDto: ManyTablesTournamentUpdateDto) {
|
|
183
178
|
return this.manyTablesRoomsManagerService.updateTournament(tournamentId, updateTournamentDto);
|
|
184
179
|
}
|
|
185
180
|
|
|
186
|
-
async removeTournament
|
|
181
|
+
async removeTournament(tournamentId: string) {
|
|
187
182
|
return this.manyTablesRoomsManagerService.removeTournament(tournamentId);
|
|
188
183
|
}
|
|
189
184
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppScreenIdEnum,
|
|
3
|
+
IAppScreen,
|
|
4
|
+
UniversalScreenView,
|
|
5
|
+
ILocaleService,
|
|
6
|
+
StandardScreenComponent,
|
|
7
|
+
IconImageComponent,
|
|
8
|
+
MenuHeaderSectionComponent,
|
|
9
|
+
MenuListSectionComponent,
|
|
10
|
+
MenuSectionListItemComponent,
|
|
11
|
+
} from "jp.common.models";
|
|
12
|
+
import { Menu } from "jp.db.schemas";
|
|
13
|
+
|
|
14
|
+
export class MenuScreenView extends UniversalScreenView {
|
|
15
|
+
private readonly menuItems: Array<Menu>;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
localeService: ILocaleService,
|
|
19
|
+
lang: string,
|
|
20
|
+
menuItems: Array<Menu>,
|
|
21
|
+
) {
|
|
22
|
+
super(localeService, lang);
|
|
23
|
+
this.menuItems = menuItems;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
build(): IAppScreen {
|
|
27
|
+
return new StandardScreenComponent(AppScreenIdEnum.MENU)
|
|
28
|
+
.addSection(
|
|
29
|
+
new MenuHeaderSectionComponent(
|
|
30
|
+
'header',
|
|
31
|
+
this.localeService.t('common.menu.header.title', { lang: this.lang }),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
.addSection(
|
|
35
|
+
new MenuListSectionComponent(
|
|
36
|
+
'id1',
|
|
37
|
+
this.menuItems.map((item) => (
|
|
38
|
+
new MenuSectionListItemComponent(
|
|
39
|
+
item.code,
|
|
40
|
+
this.lang === 'ru' ? item.title : item.titleEn,
|
|
41
|
+
new IconImageComponent(item.icon),
|
|
42
|
+
item.url,
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,53 +1,35 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { MenuRepository } from 'jp.db.schemas';
|
|
3
3
|
import {
|
|
4
|
-
AppScreen,
|
|
5
|
-
AppScreenIdEnum,
|
|
6
|
-
AppScreenSection,
|
|
7
|
-
AppScreenSectionImage,
|
|
8
|
-
AppScreenSectionListItem,
|
|
9
4
|
BaseAppScreen,
|
|
10
5
|
IAppHeaders,
|
|
11
6
|
} from 'jp.common.models';
|
|
12
7
|
|
|
8
|
+
import { BaseAppScreenDto } from '../../dto';
|
|
9
|
+
|
|
13
10
|
import { MENU_OPTIONS } from './menu.constants';
|
|
14
11
|
import { MenuFactoryOptions } from './menu.interfaces';
|
|
15
|
-
|
|
16
|
-
import { BaseAppScreenDto } from '../../dto';
|
|
12
|
+
import { MenuScreenView } from './menu-screen.view';
|
|
17
13
|
|
|
18
14
|
@Injectable()
|
|
19
15
|
export class MenuService {
|
|
20
|
-
constructor
|
|
16
|
+
constructor(
|
|
21
17
|
private readonly menuRepository: MenuRepository,
|
|
22
18
|
@Inject(MENU_OPTIONS) private readonly options: MenuFactoryOptions
|
|
23
19
|
) {
|
|
24
20
|
}
|
|
25
21
|
|
|
26
|
-
async getScreen
|
|
22
|
+
async getScreen(headers: IAppHeaders): Promise<BaseAppScreenDto> {
|
|
27
23
|
const menuItems = await this.menuRepository.findMenus('ALL', 'VK') ?? [];
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
AppScreenSection.CreateMenuListSection(
|
|
39
|
-
'id1',
|
|
40
|
-
menuItems.map((item) =>
|
|
41
|
-
AppScreenSectionListItem.CreateMenuListItem(
|
|
42
|
-
item.code,
|
|
43
|
-
headers.client_language === 'ru' ? item.title : item.titleEn,
|
|
44
|
-
AppScreenSectionImage.CreateIconImage(item.icon),
|
|
45
|
-
item.url,
|
|
46
|
-
),
|
|
47
|
-
),
|
|
48
|
-
),
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
return new BaseAppScreenDto(new BaseAppScreen(screen));
|
|
25
|
+
return new BaseAppScreenDto(
|
|
26
|
+
new BaseAppScreen(
|
|
27
|
+
new MenuScreenView(
|
|
28
|
+
this.options.i18n,
|
|
29
|
+
headers.client_language,
|
|
30
|
+
menuItems,
|
|
31
|
+
).build()
|
|
32
|
+
)
|
|
33
|
+
);
|
|
52
34
|
}
|
|
53
35
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppScreenIconEnum,
|
|
3
|
+
AppScreenIdEnum,
|
|
4
|
+
IAppScreen,
|
|
5
|
+
UniversalScreenView,
|
|
6
|
+
ILocaleService,
|
|
7
|
+
StandardScreenComponent,
|
|
8
|
+
StatusAppBarComponent,
|
|
9
|
+
StatusHeaderSectionComponent,
|
|
10
|
+
CardListSectionComponent,
|
|
11
|
+
ArrowBackButtonComponent,
|
|
12
|
+
IconImageComponent,
|
|
13
|
+
PrimaryButtonButtonsComponent,
|
|
14
|
+
TextButtonComponent,
|
|
15
|
+
MiniCardSectionListItemComponent,
|
|
16
|
+
UrlImageComponent,
|
|
17
|
+
} from "jp.common.models";
|
|
18
|
+
import { OneTableTournamentRoom } from "jp.ms.common.engine";
|
|
19
|
+
|
|
20
|
+
export class OneTableTournamentStatusScreenView extends UniversalScreenView {
|
|
21
|
+
private readonly tournament: OneTableTournamentRoom;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
localeService: ILocaleService,
|
|
25
|
+
lang: string,
|
|
26
|
+
tournament: OneTableTournamentRoom,
|
|
27
|
+
) {
|
|
28
|
+
super(localeService, lang);
|
|
29
|
+
this.tournament = tournament;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
build(): IAppScreen {
|
|
33
|
+
return new StandardScreenComponent(AppScreenIdEnum.ROOMS)
|
|
34
|
+
.addAppBar(
|
|
35
|
+
new StatusAppBarComponent(
|
|
36
|
+
this.localeService.t('common.rooms.screen.title', { lang: this.lang }),
|
|
37
|
+
new ArrowBackButtonComponent(this.localeService.t('common.button.back', { lang: this.lang })),
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
.addSection(
|
|
41
|
+
new StatusHeaderSectionComponent(
|
|
42
|
+
'status',
|
|
43
|
+
'description',
|
|
44
|
+
new IconImageComponent(AppScreenIconEnum.EMOJI_EVENTS),
|
|
45
|
+
new PrimaryButtonButtonsComponent(new TextButtonComponent('button')),
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
.addSection(
|
|
49
|
+
new CardListSectionComponent(
|
|
50
|
+
'id1',
|
|
51
|
+
this.tournament.getParticipants().map((item) => (
|
|
52
|
+
new MiniCardSectionListItemComponent(
|
|
53
|
+
item.playerId,
|
|
54
|
+
item.playerName,
|
|
55
|
+
'',
|
|
56
|
+
new UrlImageComponent(item.playerAvatarUrl),
|
|
57
|
+
true,
|
|
58
|
+
'',
|
|
59
|
+
)
|
|
60
|
+
))
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -6,22 +6,38 @@ import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
|
6
6
|
|
|
7
7
|
@Controller('tournament/one_table')
|
|
8
8
|
export class OneTableTournamentController {
|
|
9
|
-
constructor
|
|
9
|
+
constructor(
|
|
10
10
|
private readonly tournamentService: OneTableTournamentService,
|
|
11
11
|
) {
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
@Get('status/:tournamentId')
|
|
15
|
-
getStatusScreen
|
|
15
|
+
getStatusScreen(
|
|
16
16
|
@Param('tournamentId') tournamentId: string,
|
|
17
17
|
@Headers() headers: IAppHeaders,
|
|
18
|
-
):
|
|
18
|
+
): IBaseAppScreen {
|
|
19
19
|
return this.tournamentService.getStatusScreen(tournamentId, headers.client_language);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
@Get('status/subscribe/:tournamentId')
|
|
23
|
+
subscribeOnStatusScreen(
|
|
24
|
+
@Param('tournamentId') tournamentId: string,
|
|
25
|
+
@Headers() headers: IAppHeaders,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
return this.tournamentService.subscribeOnStatusScreen(tournamentId, headers.client_language);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Get('status/unsubscribe/:tournamentId')
|
|
31
|
+
unsubscribeFromStatusScreen(
|
|
32
|
+
@Param('tournamentId') tournamentId: string,
|
|
33
|
+
@Headers() headers: IAppHeaders,
|
|
34
|
+
): Promise<void> {
|
|
35
|
+
return this.tournamentService.unsubscribeFromStatusScreen(tournamentId, headers.client_language);
|
|
36
|
+
}
|
|
37
|
+
|
|
22
38
|
@Post('table/watch/:tableId')
|
|
23
39
|
@HttpCode(HttpStatus.OK)
|
|
24
|
-
watchTheTable
|
|
40
|
+
watchTheTable(
|
|
25
41
|
@Param('tableId') tableId: string,
|
|
26
42
|
@Headers() headers: IAppHeaders,
|
|
27
43
|
): IBaseTableGameState {
|
|
@@ -30,7 +46,7 @@ export class OneTableTournamentController {
|
|
|
30
46
|
|
|
31
47
|
@Post('table/move/:tableId')
|
|
32
48
|
@HttpCode(HttpStatus.OK)
|
|
33
|
-
moveOnTheTable
|
|
49
|
+
moveOnTheTable(
|
|
34
50
|
@Param('tableId') tableId: string,
|
|
35
51
|
@Body() baseMoveData: IBaseMoveData,
|
|
36
52
|
@Headers() headers: IAppHeaders,
|
|
@@ -40,7 +56,7 @@ export class OneTableTournamentController {
|
|
|
40
56
|
|
|
41
57
|
@Post('join/:tournamentId')
|
|
42
58
|
@HttpCode(HttpStatus.OK)
|
|
43
|
-
joinTournament
|
|
59
|
+
joinTournament(
|
|
44
60
|
@Param('tournamentId') tournamentId: string,
|
|
45
61
|
@Headers() headers: IAppHeaders,
|
|
46
62
|
): JoinTournamentDto {
|
|
@@ -49,7 +65,7 @@ export class OneTableTournamentController {
|
|
|
49
65
|
|
|
50
66
|
@Post('leave/:tournamentId')
|
|
51
67
|
@HttpCode(HttpStatus.OK)
|
|
52
|
-
leaveTournament
|
|
68
|
+
leaveTournament(
|
|
53
69
|
@Param('tournamentId') tournamentId: string,
|
|
54
70
|
@Headers() headers: IAppHeaders,
|
|
55
71
|
): IBaseTableGameState {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
2
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
3
3
|
import { TournamentOneTableRoom, TournamentOneTableRoomSchema, TournamentOneTableRoomsRepository } from 'jp.db.schemas';
|
|
4
|
+
import { GamePlayer, OneTableTournamentUpdateStatusWsEvent, RoomUpdateStateEvent } from 'jp.ms.common.engine';
|
|
5
|
+
|
|
6
|
+
import { TournamentOneTableRoomsManagerService } from '../tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service';
|
|
7
|
+
import { EventsBusOneTableTournamentSubscribeService } from '../event-bus';
|
|
4
8
|
|
|
5
9
|
import { OneTableTournamentController } from './one-table-tournament.controller';
|
|
6
10
|
import { OneTableTournamentService } from './one-table-tournament.service';
|
|
@@ -15,11 +19,13 @@ import { OneTableTournamentModuleOptions } from './one-table-tournament.interfac
|
|
|
15
19
|
providers: [OneTableTournamentService, TournamentOneTableRoomsRepository],
|
|
16
20
|
})
|
|
17
21
|
export class OneTableTournamentModule {
|
|
18
|
-
constructor
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly oneTableRoomsManagerService: TournamentOneTableRoomsManagerService,
|
|
24
|
+
private readonly eventsBusOneTableTournamentSubscribeService: EventsBusOneTableTournamentSubscribeService,
|
|
25
|
+
private readonly oneTableTournamentService: OneTableTournamentService,
|
|
26
|
+
) { }
|
|
21
27
|
|
|
22
|
-
static forRootAsync
|
|
28
|
+
static forRootAsync(options: OneTableTournamentModuleOptions): DynamicModule {
|
|
23
29
|
return {
|
|
24
30
|
module: OneTableTournamentModule,
|
|
25
31
|
imports: options.imports ?? [],
|
|
@@ -32,5 +38,16 @@ export class OneTableTournamentModule {
|
|
|
32
38
|
],
|
|
33
39
|
};
|
|
34
40
|
}
|
|
41
|
+
|
|
42
|
+
async onModuleInit() {
|
|
43
|
+
this.eventsBusOneTableTournamentSubscribeService.subscribe(this.onHandleStatusRoomChange);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private onHandleStatusRoomChange = (event: RoomUpdateStateEvent) => {
|
|
47
|
+
this.oneTableRoomsManagerService.getRoomById(event.roomId)?.getStatusScreenWatchers().forEach((subscriber: GamePlayer) => {
|
|
48
|
+
const screen = this.oneTableTournamentService.getStatusScreen(event.roomId, subscriber.language);
|
|
49
|
+
subscriber.sendMessage(new OneTableTournamentUpdateStatusWsEvent(screen.screen));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
35
52
|
}
|
|
36
53
|
|
|
@@ -1,77 +1,70 @@
|
|
|
1
1
|
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
2
|
import {
|
|
3
|
-
AppScreen,
|
|
4
|
-
AppScreenAppBar,
|
|
5
|
-
AppScreenIdEnum,
|
|
6
|
-
AppScreenSection,
|
|
7
|
-
AppScreenSectionButton,
|
|
8
|
-
AppScreenSectionImage,
|
|
9
|
-
AppScreenSectionListItem,
|
|
10
3
|
BaseAppScreen,
|
|
11
4
|
IBaseMoveData,
|
|
12
5
|
IBaseTableGameState,
|
|
13
|
-
|
|
14
|
-
AppScreenSectionButtons, router,
|
|
6
|
+
router,
|
|
15
7
|
} from 'jp.common.models';
|
|
16
8
|
|
|
17
|
-
import { BaseAppScreenDto } from '../../dto';
|
|
9
|
+
import { AppScreenDto, BaseAppScreenDto } from '../../dto';
|
|
18
10
|
import { TournamentOneTableRoomsManagerService } from '../tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service';
|
|
19
11
|
import { PlayersManagerService } from '../players-manager/players-manager.service';
|
|
20
12
|
import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
21
13
|
|
|
22
14
|
import { OneTableTournamentFactoryOptions } from './one-table-tournament.interfaces';
|
|
23
15
|
import { ONE_TABLE_TOURNAMENT_OPTIONS } from './one-table-tournament.constants';
|
|
16
|
+
import { OneTableTournamentStatusScreenView } from './one-table-tournament-status-screen.view';
|
|
24
17
|
|
|
25
18
|
@Injectable()
|
|
26
19
|
export class OneTableTournamentService {
|
|
27
|
-
constructor
|
|
20
|
+
constructor(
|
|
28
21
|
private readonly oneTableRoomsManagerService: TournamentOneTableRoomsManagerService,
|
|
29
22
|
private readonly playersManager: PlayersManagerService,
|
|
30
23
|
@Inject(ONE_TABLE_TOURNAMENT_OPTIONS) private readonly options: OneTableTournamentFactoryOptions,
|
|
31
24
|
) {
|
|
32
25
|
}
|
|
33
26
|
|
|
34
|
-
|
|
27
|
+
getStatusScreen(tournamentId: string, lang: string): BaseAppScreenDto {
|
|
35
28
|
const tournament = this.oneTableRoomsManagerService.getRoomById(tournamentId);
|
|
36
29
|
|
|
37
30
|
if (!tournament) {
|
|
38
31
|
throw new InternalServerErrorException();
|
|
39
32
|
}
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
34
|
+
return new BaseAppScreenDto(
|
|
35
|
+
new BaseAppScreen(
|
|
36
|
+
new OneTableTournamentStatusScreenView(
|
|
37
|
+
this.options.i18n,
|
|
38
|
+
lang,
|
|
39
|
+
tournament,
|
|
40
|
+
).build()
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
subscribeOnStatusScreen(tournamentId: string, clientAuthToken: string): Promise<void> {
|
|
46
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
47
|
+
const tournament = this.oneTableRoomsManagerService.getRoomById(tournamentId);
|
|
48
|
+
|
|
49
|
+
if (player && tournament) {
|
|
50
|
+
tournament.addToStatusScreenWatchers(player);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
throw new InternalServerErrorException();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
unsubscribeFromStatusScreen(tournamentId: string, clientAuthToken: string): Promise<void> {
|
|
57
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
58
|
+
const tournament = this.oneTableRoomsManagerService.getRoomById(tournamentId);
|
|
59
|
+
|
|
60
|
+
if (player && tournament) {
|
|
61
|
+
tournament.removeFromStatusScreenWatchers(player);
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
64
|
+
throw new InternalServerErrorException();
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
watchTheTable
|
|
67
|
+
watchTheTable(tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
75
68
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
76
69
|
const room = this.oneTableRoomsManagerService.getRoomByTableId(tableId);
|
|
77
70
|
const master = room?.getMasterById(tableId);
|
|
@@ -85,7 +78,7 @@ export class OneTableTournamentService {
|
|
|
85
78
|
throw new InternalServerErrorException();
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
moveOnTheTable
|
|
81
|
+
moveOnTheTable(tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
89
82
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
90
83
|
const room = this.oneTableRoomsManagerService.getRoomByTableId(tableId);
|
|
91
84
|
const master = room?.getMasterById(tableId);
|
|
@@ -99,7 +92,7 @@ export class OneTableTournamentService {
|
|
|
99
92
|
throw new InternalServerErrorException();
|
|
100
93
|
}
|
|
101
94
|
|
|
102
|
-
joinTournament
|
|
95
|
+
joinTournament(tournamentId: string, clientAuthToken: string): JoinTournamentDto {
|
|
103
96
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
104
97
|
const tournament = this.oneTableRoomsManagerService.getRoomByTableId(tournamentId);
|
|
105
98
|
const master = tournament?.getMasterById(tournamentId);
|
|
@@ -124,7 +117,7 @@ export class OneTableTournamentService {
|
|
|
124
117
|
throw new InternalServerErrorException();
|
|
125
118
|
}
|
|
126
119
|
|
|
127
|
-
leaveTournament
|
|
120
|
+
leaveTournament(tournamentId: string, clientAuthToken: string): IBaseTableGameState {
|
|
128
121
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
129
122
|
const tournament = this.oneTableRoomsManagerService.getRoomByTableId(tournamentId);
|
|
130
123
|
const master = tournament?.getMasterById(tournamentId);
|