jp.ms.common.modules 1.0.24 → 1.0.25
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/adapter/base-table-game-state-adapter.d.ts +3 -1
- package/dist/adapter/base-table-game-state-adapter.js +11 -0
- package/dist/adapter/base-table-game-state-adapter.js.map +1 -1
- package/dist/adapter/card-table-game-state-adapter.d.ts +4 -2
- package/dist/adapter/card-table-game-state-adapter.js +15 -4
- package/dist/adapter/card-table-game-state-adapter.js.map +1 -1
- package/dist/config/cert.js +35 -2
- package/dist/config/cert.js.map +1 -1
- package/dist/config/cors.js +34 -1
- package/dist/config/cors.js.map +1 -1
- package/dist/dto/common/find-free-table.dto.d.ts +3 -0
- package/dist/dto/common/find-free-table.dto.js +8 -0
- package/dist/dto/common/find-free-table.dto.js.map +1 -0
- package/dist/dto/common/index.d.ts +1 -0
- package/dist/dto/common/index.js +3 -1
- package/dist/dto/common/index.js.map +1 -1
- package/dist/dto/table-game/base/base-table-game-state.dto.d.ts +3 -0
- package/dist/dto/table-game/base/base-table-game-state.dto.js +19 -0
- package/dist/dto/table-game/base/base-table-game-state.dto.js.map +1 -1
- package/dist/dto/table-game/cards/cards-panel.dto.d.ts +2 -1
- package/dist/dto/table-game/cards/cards-panel.dto.js +14 -3
- package/dist/dto/table-game/cards/cards-panel.dto.js.map +1 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js +4 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js.map +1 -1
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js +2 -2
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js.map +1 -1
- package/dist/modules/base-achievements/base-achievements.module.d.ts +1 -1
- package/dist/modules/base-achievements/base-achievements.module.js +12 -12
- package/dist/modules/base-achievements/base-achievements.module.js.map +1 -1
- package/dist/modules/event-bus/events-bus.main-tables.subscribe.service.d.ts +1 -1
- package/dist/modules/event-bus/events-bus.main-tables.subscribe.service.js.map +1 -1
- package/dist/modules/logger/jp-logger.service.js +34 -1
- package/dist/modules/logger/jp-logger.service.js.map +1 -1
- package/dist/modules/main/main-tables-list-screen.view.js +1 -1
- package/dist/modules/main/main-tables-list-screen.view.js.map +1 -1
- package/dist/modules/main/main.controller.d.ts +2 -2
- package/dist/modules/main/main.controller.js +4 -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 +2 -2
- package/dist/modules/main/main.service.js +11 -5
- package/dist/modules/main/main.service.js.map +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +1 -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.js +1 -1
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js.map +1 -1
- package/dist/modules/menu/menu-screen.view.d.ts +5 -3
- package/dist/modules/menu/menu-screen.view.js +10 -2
- package/dist/modules/menu/menu-screen.view.js.map +1 -1
- package/dist/modules/menu/menu.module.js +2 -1
- package/dist/modules/menu/menu.module.js.map +1 -1
- package/dist/modules/menu/menu.service.d.ts +3 -2
- package/dist/modules/menu/menu.service.js +8 -4
- package/dist/modules/menu/menu.service.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.d.ts +6 -1
- package/dist/modules/one-table-tournament/one-table-tournament-status-screen.view.js +52 -3
- 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.d.ts +4 -5
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js +8 -9
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js.map +1 -1
- package/dist/modules/one-table-tournament/one-table-tournament.module.js +2 -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 +6 -7
- package/dist/modules/one-table-tournament/one-table-tournament.service.js +10 -17
- 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 +2 -1
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js +30 -5
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js.map +1 -1
- package/dist/modules/support/dump.service.js +4 -1
- package/dist/modules/support/dump.service.js.map +1 -1
- package/dist/modules/support/metric.service.js +34 -1
- package/dist/modules/support/metric.service.js.map +1 -1
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.js +33 -10
- 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 +21 -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/utils/game-table-result.d.ts +3 -2
- package/dist/utils/game-table-result.js +14 -1
- package/dist/utils/game-table-result.js.map +1 -1
- package/dist/views/index.d.ts +1 -0
- package/dist/views/index.js +3 -1
- package/dist/views/index.js.map +1 -1
- package/dist/views/simple-room-conifrm-exit-dialog.view.d.ts +4 -0
- package/dist/views/simple-room-conifrm-exit-dialog.view.js +11 -0
- package/dist/views/simple-room-conifrm-exit-dialog.view.js.map +1 -0
- package/dist/views/tournament-buy-ticket-dialog.view.d.ts +2 -2
- 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/adapter/base-table-game-state-adapter.ts +23 -5
- package/src/adapter/card-table-game-state-adapter.ts +28 -4
- package/src/dto/common/find-free-table.dto.ts +3 -0
- package/src/dto/common/index.ts +1 -0
- package/src/dto/table-game/base/base-table-game-state.dto.ts +16 -0
- package/src/dto/table-game/cards/cards-panel.dto.ts +12 -3
- package/src/modules/anti-freeze-system/anti-freeze-system.service.ts +3 -3
- package/src/modules/base-achievements/base-achievements.module.ts +12 -10
- package/src/modules/event-bus/events-bus.main-tables.subscribe.service.ts +1 -1
- package/src/modules/main/main-tables-list-screen.view.ts +2 -2
- package/src/modules/main/main.controller.ts +4 -4
- package/src/modules/main/main.module.ts +5 -5
- package/src/modules/main/main.service.ts +20 -10
- package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +1 -1
- package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +2 -1
- package/src/modules/menu/menu-screen.view.ts +33 -11
- package/src/modules/menu/menu.module.ts +3 -2
- package/src/modules/menu/menu.service.ts +5 -2
- package/src/modules/one-table-tournament/one-table-tournament-status-screen.view.ts +76 -10
- package/src/modules/one-table-tournament/one-table-tournament.controller.ts +8 -8
- package/src/modules/one-table-tournament/one-table-tournament.module.ts +2 -2
- package/src/modules/one-table-tournament/one-table-tournament.service.ts +20 -28
- package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +64 -14
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.ts +42 -17
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.ts +37 -15
- package/src/utils/game-table-result.ts +18 -3
- package/src/views/index.ts +2 -1
- package/src/views/simple-room-conifrm-exit-dialog.view.ts +21 -0
- package/src/views/tournament-buy-ticket-dialog.view.ts +11 -11
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
2
|
import { AppScreenRoutesEnum, BaseAppScreen, router } from 'jp.common.models';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import isToday from 'dayjs/plugin/isToday';
|
|
5
5
|
import { ActivityLogRepository, UsersRepository } from 'jp.db.schemas';
|
|
6
6
|
|
|
7
|
-
import { BaseAppScreenDto, PlayerCheckStateDto } from '../../dto';
|
|
7
|
+
import { BaseAppScreenDto, PlayerCheckStateDto, FindFreeTableDto } from '../../dto';
|
|
8
8
|
import { SimpleRoomsManagerService } from '../simple-rooms-manager';
|
|
9
9
|
import { PlayersManagerService } from '../players-manager';
|
|
10
10
|
import { TournamentOneTableRoomsManagerService } from '../tournament-one-table-rooms-manager';
|
|
@@ -17,7 +17,6 @@ import { MainTablesListScreenView } from './main-tables-list-screen.view';
|
|
|
17
17
|
|
|
18
18
|
@Injectable()
|
|
19
19
|
export class MainService {
|
|
20
|
-
|
|
21
20
|
constructor(
|
|
22
21
|
private readonly simpleRoomsManager: SimpleRoomsManagerService,
|
|
23
22
|
private readonly oneTableRoomsManagerService: TournamentOneTableRoomsManagerService,
|
|
@@ -31,7 +30,7 @@ export class MainService {
|
|
|
31
30
|
dayjs.extend(isToday);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
getScreen(lang: string): BaseAppScreenDto {
|
|
33
|
+
getScreen (lang: string): BaseAppScreenDto {
|
|
35
34
|
return new BaseAppScreenDto(
|
|
36
35
|
new BaseAppScreen(
|
|
37
36
|
new MainTablesListScreenView(
|
|
@@ -45,7 +44,7 @@ export class MainService {
|
|
|
45
44
|
);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
subscribeOnTablesScreen(clientAuthToken: string): Promise<void> {
|
|
47
|
+
subscribeOnTablesScreen (clientAuthToken: string): Promise<void> {
|
|
49
48
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
50
49
|
|
|
51
50
|
if (player) {
|
|
@@ -55,7 +54,7 @@ export class MainService {
|
|
|
55
54
|
throw new InternalServerErrorException();
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
unsubscribeFromTablesScreen(clientAuthToken: string): Promise<void> {
|
|
57
|
+
unsubscribeFromTablesScreen (clientAuthToken: string): Promise<void> {
|
|
59
58
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
60
59
|
|
|
61
60
|
if (player) {
|
|
@@ -65,7 +64,7 @@ export class MainService {
|
|
|
65
64
|
throw new InternalServerErrorException();
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
async playerCheckState(clientAuthToken: string, game: string): Promise<PlayerCheckStateDto> {
|
|
67
|
+
async playerCheckState (clientAuthToken: string, game: string): Promise<PlayerCheckStateDto> {
|
|
69
68
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
70
69
|
let redirectUrl: string = AppScreenRoutesEnum.MENU;
|
|
71
70
|
|
|
@@ -87,9 +86,20 @@ export class MainService {
|
|
|
87
86
|
redirectUrl = AppScreenRoutesEnum.PREMIUM;
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
return PlayerCheckStateDto.fromEntities(
|
|
89
|
+
return PlayerCheckStateDto.fromEntities(
|
|
90
|
+
redirectUrl,
|
|
91
|
+
player?.id ?? '',
|
|
92
|
+
);
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
findFreeTable(clientAuthToken: string) {
|
|
95
|
+
findFreeTable (clientAuthToken: string): FindFreeTableDto {
|
|
96
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
97
|
+
const tableId = this.simpleRoomsManager.getFreeFastGameRoom()?.getId() ?? '';
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
return FindFreeTableDto.fromEntities(
|
|
101
|
+
tableId ? router.getRoomPath(tableId) : '',
|
|
102
|
+
player?.id ?? '',
|
|
103
|
+
);
|
|
94
104
|
}
|
|
95
105
|
}
|
|
@@ -46,7 +46,7 @@ export class ManyTablesTournamentModule {
|
|
|
46
46
|
private onHandleStatusRoomChange = (event: RoomUpdateStateEvent) => {
|
|
47
47
|
this.manyTablesRoomsManagerService.getRoomById(event.roomId)?.getStatusScreenWatchers().forEach((subscriber: GamePlayer) => {
|
|
48
48
|
const screen = this.manyTablesTournamentService.getStatusScreen(event.roomId, subscriber.language);
|
|
49
|
-
subscriber.sendMessage(new ManyTablesTournamentUpdateStatusWsEvent(screen.screen));
|
|
49
|
+
subscriber.sendMessage(new ManyTablesTournamentUpdateStatusWsEvent(event.game, screen.screen));
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -17,6 +17,7 @@ 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';
|
|
20
21
|
|
|
21
22
|
@Injectable()
|
|
22
23
|
export class ManyTablesTournamentService {
|
|
@@ -121,7 +122,7 @@ export class ManyTablesTournamentService {
|
|
|
121
122
|
if (player && tournament && master) {
|
|
122
123
|
tournament.handleJoinTournament(player);
|
|
123
124
|
|
|
124
|
-
if (tournament.
|
|
125
|
+
if (tournament.getRoomMaster<TournamentMaster>().isInProgress()) {
|
|
125
126
|
if (player.isPlayer() || player.isTableQueuer()) {
|
|
126
127
|
return JoinTournamentDto.fromEntities(
|
|
127
128
|
router.getManyTablesTournamentTablePath(player.tableId ?? ''),
|
|
@@ -8,29 +8,31 @@ import {
|
|
|
8
8
|
MenuHeaderSectionComponent,
|
|
9
9
|
MenuListSectionComponent,
|
|
10
10
|
MenuSectionListItemComponent,
|
|
11
|
+
OneBannerSectionComponent,
|
|
12
|
+
BannerSectionListItemComponent,
|
|
13
|
+
UrlImageComponent,
|
|
14
|
+
BaseSectionComponent,
|
|
11
15
|
} from "jp.common.models";
|
|
12
|
-
import { Menu } from "jp.db.schemas";
|
|
16
|
+
import { Banner, Menu } from "jp.db.schemas";
|
|
13
17
|
|
|
14
18
|
export class MenuScreenView extends UniversalScreenView {
|
|
15
19
|
private readonly menuItems: Array<Menu>;
|
|
20
|
+
private readonly banner: Banner | null
|
|
16
21
|
|
|
17
22
|
constructor(
|
|
18
23
|
localeService: ILocaleService,
|
|
19
24
|
lang: string,
|
|
20
25
|
menuItems: Array<Menu>,
|
|
26
|
+
banner: Banner | null
|
|
21
27
|
) {
|
|
22
28
|
super(localeService, lang);
|
|
23
29
|
this.menuItems = menuItems;
|
|
30
|
+
this.banner = banner;
|
|
24
31
|
}
|
|
25
32
|
|
|
26
|
-
build(): IAppScreen {
|
|
33
|
+
build (): IAppScreen {
|
|
27
34
|
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
|
-
)
|
|
35
|
+
.addSection(this.getHeaderSection())
|
|
34
36
|
.addSection(
|
|
35
37
|
new MenuListSectionComponent(
|
|
36
38
|
'id1',
|
|
@@ -41,8 +43,28 @@ export class MenuScreenView extends UniversalScreenView {
|
|
|
41
43
|
new IconImageComponent(item.icon),
|
|
42
44
|
item.url,
|
|
43
45
|
)
|
|
44
|
-
)
|
|
45
|
-
)
|
|
46
|
-
)
|
|
46
|
+
)),
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getHeaderSection (): BaseSectionComponent {
|
|
52
|
+
if (this.banner) {
|
|
53
|
+
return new OneBannerSectionComponent(
|
|
54
|
+
'banner',
|
|
55
|
+
new BannerSectionListItemComponent(
|
|
56
|
+
this.banner.bannerId,
|
|
57
|
+
this.banner.titleRu,
|
|
58
|
+
this.localeService.t('common.menu.header.title', { lang: this.lang }),
|
|
59
|
+
new UrlImageComponent(this.banner.image),
|
|
60
|
+
this.banner.link,
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return new MenuHeaderSectionComponent(
|
|
66
|
+
'header',
|
|
67
|
+
this.localeService.t('common.menu.header.title', { lang: this.lang }),
|
|
68
|
+
);
|
|
47
69
|
}
|
|
48
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
2
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
3
|
-
import { Menu, MenuSchema, MenuRepository } from 'jp.db.schemas';
|
|
3
|
+
import { Menu, MenuSchema, MenuRepository, Banner, BannerSchema, BannersRepository } from 'jp.db.schemas';
|
|
4
4
|
|
|
5
5
|
import { MenuController } from './menu.controller';
|
|
6
6
|
import { MenuService } from './menu.service';
|
|
@@ -10,9 +10,10 @@ import { MenuModuleOptions } from './menu.interfaces';
|
|
|
10
10
|
@Module({
|
|
11
11
|
imports: [
|
|
12
12
|
MongooseModule.forFeature([{ name: Menu.name, schema: MenuSchema }]),
|
|
13
|
+
MongooseModule.forFeature([{ name: Banner.name, schema: BannerSchema }]),
|
|
13
14
|
],
|
|
14
15
|
controllers: [MenuController],
|
|
15
|
-
providers: [MenuRepository, MenuService],
|
|
16
|
+
providers: [MenuRepository, MenuService, BannersRepository],
|
|
16
17
|
})
|
|
17
18
|
export class MenuModule {
|
|
18
19
|
static forRootAsync(options: MenuModuleOptions): DynamicModule {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
2
|
-
import { MenuRepository } from 'jp.db.schemas';
|
|
2
|
+
import { BannersRepository, MenuRepository } from 'jp.db.schemas';
|
|
3
3
|
import {
|
|
4
4
|
BaseAppScreen,
|
|
5
5
|
IAppHeaders,
|
|
@@ -15,12 +15,14 @@ import { MenuScreenView } from './menu-screen.view';
|
|
|
15
15
|
export class MenuService {
|
|
16
16
|
constructor(
|
|
17
17
|
private readonly menuRepository: MenuRepository,
|
|
18
|
+
private readonly bannersRepository: BannersRepository,
|
|
18
19
|
@Inject(MENU_OPTIONS) private readonly options: MenuFactoryOptions
|
|
19
20
|
) {
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
async getScreen(headers: IAppHeaders): Promise<BaseAppScreenDto> {
|
|
23
|
+
async getScreen (headers: IAppHeaders): Promise<BaseAppScreenDto> {
|
|
23
24
|
const menuItems = await this.menuRepository.findMenus('ALL', 'VK') ?? [];
|
|
25
|
+
const enabledBanner = await this.bannersRepository.findEnabledBanner(headers.client_game, headers.client_channel);
|
|
24
26
|
|
|
25
27
|
return new BaseAppScreenDto(
|
|
26
28
|
new BaseAppScreen(
|
|
@@ -28,6 +30,7 @@ export class MenuService {
|
|
|
28
30
|
this.options.i18n,
|
|
29
31
|
headers.client_language,
|
|
30
32
|
menuItems,
|
|
33
|
+
enabledBanner,
|
|
31
34
|
).build()
|
|
32
35
|
)
|
|
33
36
|
);
|
|
@@ -15,35 +15,35 @@ import {
|
|
|
15
15
|
MiniCardSectionListItemComponent,
|
|
16
16
|
UrlImageComponent,
|
|
17
17
|
} from "jp.common.models";
|
|
18
|
-
import { OneTableTournamentRoom } from "jp.ms.common.engine";
|
|
18
|
+
import { OneTableTournamentRoom, TournamentMaster } from "jp.ms.common.engine";
|
|
19
19
|
|
|
20
20
|
export class OneTableTournamentStatusScreenView extends UniversalScreenView {
|
|
21
21
|
private readonly tournament: OneTableTournamentRoom;
|
|
22
|
+
private readonly playerId: string;
|
|
22
23
|
|
|
23
24
|
constructor(
|
|
24
25
|
localeService: ILocaleService,
|
|
25
26
|
lang: string,
|
|
26
27
|
tournament: OneTableTournamentRoom,
|
|
28
|
+
playerId: string,
|
|
27
29
|
) {
|
|
28
30
|
super(localeService, lang);
|
|
29
31
|
this.tournament = tournament;
|
|
32
|
+
this.playerId = playerId;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
build(): IAppScreen {
|
|
35
|
+
build (): IAppScreen {
|
|
33
36
|
return new StandardScreenComponent(AppScreenIdEnum.ROOMS)
|
|
34
37
|
.addAppBar(
|
|
35
38
|
new StatusAppBarComponent(
|
|
36
|
-
this.
|
|
37
|
-
new ArrowBackButtonComponent(
|
|
39
|
+
this.tournament.getTitle(this.lang),
|
|
40
|
+
new ArrowBackButtonComponent(
|
|
41
|
+
this.localeService.t('common.button.back', { lang: this.lang })
|
|
42
|
+
),
|
|
38
43
|
),
|
|
39
44
|
)
|
|
40
45
|
.addSection(
|
|
41
|
-
|
|
42
|
-
'status',
|
|
43
|
-
'description',
|
|
44
|
-
new IconImageComponent(AppScreenIconEnum.EMOJI_EVENTS),
|
|
45
|
-
new PrimaryButtonButtonsComponent(new TextButtonComponent('button')),
|
|
46
|
-
)
|
|
46
|
+
this.getStatusHeader()
|
|
47
47
|
)
|
|
48
48
|
.addSection(
|
|
49
49
|
new CardListSectionComponent(
|
|
@@ -62,4 +62,70 @@ export class OneTableTournamentStatusScreenView extends UniversalScreenView {
|
|
|
62
62
|
),
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
private getStatusHeader (): StatusHeaderSectionComponent {
|
|
67
|
+
// TODO разобраться с участниками для туринар
|
|
68
|
+
const foundPlayer = this.tournament.getParticipants().find((item) => item.playerId === this.playerId);
|
|
69
|
+
|
|
70
|
+
return new StatusHeaderSectionComponent(
|
|
71
|
+
'status',
|
|
72
|
+
this.getStatusDescription(),
|
|
73
|
+
new IconImageComponent(this.getStatusIcon()),
|
|
74
|
+
!foundPlayer ?
|
|
75
|
+
new PrimaryButtonButtonsComponent(
|
|
76
|
+
new TextButtonComponent('Join tournament')
|
|
77
|
+
) : undefined,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private getStatusIcon (): string {
|
|
82
|
+
if (this.tournament.getRoomMaster<TournamentMaster>().isCancelled()) {
|
|
83
|
+
return AppScreenIconEnum.INFO;
|
|
84
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isFinish()) {
|
|
85
|
+
return AppScreenIconEnum.EMOJI_EVENTS;
|
|
86
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isWaiting()) {
|
|
87
|
+
return AppScreenIconEnum.HOURGLASS_EMPTY;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private getStatusDescription (): string {
|
|
94
|
+
if (this.tournament.getRoomMaster<TournamentMaster>().isCancelled()) {
|
|
95
|
+
return this.localeService.t('common.tournaments.status.2', { lang: this.lang });
|
|
96
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isFinish()) {
|
|
97
|
+
return this.localeService.t('common.tournaments.status.3', { lang: this.lang });
|
|
98
|
+
} else if (this.tournament.getRoomMaster<TournamentMaster>().isWaiting()) {
|
|
99
|
+
return this.getStatusDescriptionWaiting();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private getStatusDescriptionWaiting (): string {
|
|
106
|
+
const players = this.tournament.getParticipants().length;
|
|
107
|
+
const maxPlayers = this.tournament.getTableSize();
|
|
108
|
+
|
|
109
|
+
if (players === 0) {
|
|
110
|
+
return this.localeService.t(
|
|
111
|
+
'common.room.screen.seat.and.go.waiting.for.the.players',
|
|
112
|
+
{
|
|
113
|
+
lang: this.lang,
|
|
114
|
+
args: {
|
|
115
|
+
MAX_PLAYERS: this.tournament.getTableSize().toString(),
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return this.localeService.t(
|
|
122
|
+
'common.room.screen.seat.and.go.more.waiting.for.the.players',
|
|
123
|
+
{
|
|
124
|
+
lang: this.lang,
|
|
125
|
+
args: {
|
|
126
|
+
PLAYERS: (maxPlayers - players).toString(),
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
}
|
|
65
131
|
}
|
|
@@ -16,23 +16,23 @@ export class OneTableTournamentController {
|
|
|
16
16
|
@Param('tournamentId') tournamentId: string,
|
|
17
17
|
@Headers() headers: IAppHeaders,
|
|
18
18
|
): IBaseAppScreen {
|
|
19
|
-
return this.tournamentService.getStatusScreen(tournamentId, headers.client_language);
|
|
19
|
+
return this.tournamentService.getStatusScreen(tournamentId, headers.client_language, headers.client_auth_token);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
@Get('status/subscribe/:tournamentId')
|
|
23
23
|
subscribeOnStatusScreen(
|
|
24
24
|
@Param('tournamentId') tournamentId: string,
|
|
25
25
|
@Headers() headers: IAppHeaders,
|
|
26
|
-
):
|
|
27
|
-
return this.tournamentService.subscribeOnStatusScreen(tournamentId, headers.
|
|
26
|
+
): void {
|
|
27
|
+
return this.tournamentService.subscribeOnStatusScreen(tournamentId, headers.client_auth_token);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
@Get('status/unsubscribe/:tournamentId')
|
|
31
31
|
unsubscribeFromStatusScreen(
|
|
32
32
|
@Param('tournamentId') tournamentId: string,
|
|
33
33
|
@Headers() headers: IAppHeaders,
|
|
34
|
-
):
|
|
35
|
-
return this.tournamentService.unsubscribeFromStatusScreen(tournamentId, headers.
|
|
34
|
+
): void {
|
|
35
|
+
return this.tournamentService.unsubscribeFromStatusScreen(tournamentId, headers.client_auth_token);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
@Post('table/watch/:tableId')
|
|
@@ -59,8 +59,8 @@ export class OneTableTournamentController {
|
|
|
59
59
|
joinTournament(
|
|
60
60
|
@Param('tournamentId') tournamentId: string,
|
|
61
61
|
@Headers() headers: IAppHeaders,
|
|
62
|
-
):
|
|
63
|
-
return this.tournamentService.joinTournament(tournamentId, headers
|
|
62
|
+
): IBaseAppScreen {
|
|
63
|
+
return this.tournamentService.joinTournament(tournamentId, headers);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
@Post('leave/:tournamentId')
|
|
@@ -68,7 +68,7 @@ export class OneTableTournamentController {
|
|
|
68
68
|
leaveTournament(
|
|
69
69
|
@Param('tournamentId') tournamentId: string,
|
|
70
70
|
@Headers() headers: IAppHeaders,
|
|
71
|
-
):
|
|
71
|
+
): void {
|
|
72
72
|
return this.tournamentService.leaveTournament(tournamentId, headers.client_auth_token);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -45,8 +45,8 @@ export class OneTableTournamentModule {
|
|
|
45
45
|
|
|
46
46
|
private onHandleStatusRoomChange = (event: RoomUpdateStateEvent) => {
|
|
47
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));
|
|
48
|
+
const screen = this.oneTableTournamentService.getStatusScreen(event.roomId, subscriber.language, subscriber.id);
|
|
49
|
+
subscriber.sendMessage(new OneTableTournamentUpdateStatusWsEvent(event.game, screen.screen));
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
2
|
import {
|
|
3
3
|
BaseAppScreen,
|
|
4
|
+
IAppHeaders,
|
|
5
|
+
IBaseAppScreen,
|
|
4
6
|
IBaseMoveData,
|
|
5
7
|
IBaseTableGameState,
|
|
6
|
-
router,
|
|
7
8
|
} from 'jp.common.models';
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { BaseAppScreenDto } from '../../dto';
|
|
10
11
|
import { TournamentOneTableRoomsManagerService } from '../tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service';
|
|
11
12
|
import { PlayersManagerService } from '../players-manager/players-manager.service';
|
|
12
|
-
import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
13
13
|
|
|
14
14
|
import { OneTableTournamentFactoryOptions } from './one-table-tournament.interfaces';
|
|
15
15
|
import { ONE_TABLE_TOURNAMENT_OPTIONS } from './one-table-tournament.constants';
|
|
@@ -24,7 +24,7 @@ export class OneTableTournamentService {
|
|
|
24
24
|
) {
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
getStatusScreen(tournamentId: string, lang: string): BaseAppScreenDto {
|
|
27
|
+
getStatusScreen (tournamentId: string, lang: string, playerId: string): BaseAppScreenDto {
|
|
28
28
|
const tournament = this.oneTableRoomsManagerService.getRoomById(tournamentId);
|
|
29
29
|
|
|
30
30
|
if (!tournament) {
|
|
@@ -37,34 +37,39 @@ export class OneTableTournamentService {
|
|
|
37
37
|
this.options.i18n,
|
|
38
38
|
lang,
|
|
39
39
|
tournament,
|
|
40
|
+
playerId,
|
|
40
41
|
).build()
|
|
41
42
|
)
|
|
42
43
|
);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
subscribeOnStatusScreen(tournamentId: string, clientAuthToken: string):
|
|
46
|
+
subscribeOnStatusScreen (tournamentId: string, clientAuthToken: string): void {
|
|
46
47
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
47
48
|
const tournament = this.oneTableRoomsManagerService.getRoomById(tournamentId);
|
|
48
49
|
|
|
49
50
|
if (player && tournament) {
|
|
50
51
|
tournament.addToStatusScreenWatchers(player);
|
|
52
|
+
|
|
53
|
+
return;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
throw new InternalServerErrorException();
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
unsubscribeFromStatusScreen(tournamentId: string, clientAuthToken: string):
|
|
59
|
+
unsubscribeFromStatusScreen (tournamentId: string, clientAuthToken: string): void {
|
|
57
60
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
58
61
|
const tournament = this.oneTableRoomsManagerService.getRoomById(tournamentId);
|
|
59
62
|
|
|
60
63
|
if (player && tournament) {
|
|
61
64
|
tournament.removeFromStatusScreenWatchers(player);
|
|
65
|
+
|
|
66
|
+
return;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
throw new InternalServerErrorException();
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
watchTheTable(tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
72
|
+
watchTheTable (tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
68
73
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
69
74
|
const room = this.oneTableRoomsManagerService.getRoomByTableId(tableId);
|
|
70
75
|
const master = room?.getMasterById(tableId);
|
|
@@ -78,7 +83,7 @@ export class OneTableTournamentService {
|
|
|
78
83
|
throw new InternalServerErrorException();
|
|
79
84
|
}
|
|
80
85
|
|
|
81
|
-
moveOnTheTable(tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
86
|
+
moveOnTheTable (tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
82
87
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
83
88
|
const room = this.oneTableRoomsManagerService.getRoomByTableId(tableId);
|
|
84
89
|
const master = room?.getMasterById(tableId);
|
|
@@ -92,40 +97,27 @@ export class OneTableTournamentService {
|
|
|
92
97
|
throw new InternalServerErrorException();
|
|
93
98
|
}
|
|
94
99
|
|
|
95
|
-
joinTournament(tournamentId: string,
|
|
96
|
-
const player = this.playersManager.getPlayerById(
|
|
100
|
+
joinTournament (tournamentId: string, headers: IAppHeaders): IBaseAppScreen {
|
|
101
|
+
const player = this.playersManager.getPlayerById(headers.client_auth_token);
|
|
97
102
|
const tournament = this.oneTableRoomsManagerService.getRoomByTableId(tournamentId);
|
|
98
|
-
const master = tournament?.getMasterById(tournamentId);
|
|
99
103
|
|
|
100
|
-
if (player && tournament
|
|
104
|
+
if (player && tournament) {
|
|
101
105
|
tournament.handleJoinTournament(player);
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
const onlyTableId = tournament.getFirstMaster()?.getTable()?.getId() ?? '';
|
|
105
|
-
return JoinTournamentDto.fromEntities(
|
|
106
|
-
router.getOneTableTournamentTablePath(onlyTableId),
|
|
107
|
-
player.id,
|
|
108
|
-
);
|
|
109
|
-
} else {
|
|
110
|
-
return JoinTournamentDto.fromEntities(
|
|
111
|
-
router.getOneTableTournamentStatusPath(tournament.getId()),
|
|
112
|
-
player.id,
|
|
113
|
-
);
|
|
114
|
-
}
|
|
107
|
+
return this.getStatusScreen(tournamentId, headers.client_language, headers.client_auth_token);
|
|
115
108
|
}
|
|
116
109
|
|
|
117
110
|
throw new InternalServerErrorException();
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
leaveTournament(tournamentId: string, clientAuthToken: string):
|
|
113
|
+
leaveTournament (tournamentId: string, clientAuthToken: string): void {
|
|
121
114
|
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
122
115
|
const tournament = this.oneTableRoomsManagerService.getRoomByTableId(tournamentId);
|
|
123
|
-
const master = tournament?.getMasterById(tournamentId);
|
|
124
116
|
|
|
125
|
-
if (player && tournament
|
|
117
|
+
if (player && tournament) {
|
|
126
118
|
tournament.handleLeaveTournament(player);
|
|
127
119
|
|
|
128
|
-
return
|
|
120
|
+
return;
|
|
129
121
|
}
|
|
130
122
|
|
|
131
123
|
throw new InternalServerErrorException();
|