jp.ms.common.modules 1.0.18 → 1.0.20
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/common/join-tournament.dto.d.ts +5 -0
- package/dist/dto/common/join-tournament.dto.js +47 -0
- package/dist/dto/common/join-tournament.dto.js.map +1 -0
- package/dist/dto/common/many-tables-tournament-create.dto.d.ts +20 -0
- package/dist/dto/common/many-tables-tournament-create.dto.js +167 -0
- package/dist/dto/common/many-tables-tournament-create.dto.js.map +1 -0
- package/dist/dto/common/many-tables-tournament-update.dto.d.ts +3 -0
- package/dist/dto/common/many-tables-tournament-update.dto.js +8 -0
- package/dist/dto/common/many-tables-tournament-update.dto.js.map +1 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.constants.d.ts +1 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.constants.js +5 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.constants.js.map +1 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.interfaces.d.ts +13 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.interfaces.js +3 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.interfaces.js.map +1 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.d.ts +13 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js +65 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.module.js.map +1 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.d.ts +21 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js +99 -0
- package/dist/modules/anti-freeze-system/anti-freeze-system.service.js.map +1 -0
- package/dist/modules/anti-freeze-system/index.d.ts +1 -0
- package/dist/modules/anti-freeze-system/index.js +6 -0
- package/dist/modules/anti-freeze-system/index.js.map +1 -0
- package/dist/modules/events/events.module.js +2 -2
- package/dist/modules/events/events.module.js.map +1 -1
- package/dist/modules/events/index.d.ts +1 -0
- package/dist/modules/events/index.js +6 -0
- package/dist/modules/events/index.js.map +1 -0
- package/dist/modules/index.d.ts +13 -13
- package/dist/modules/index.js +32 -25
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/logger/index.d.ts +2 -0
- package/dist/modules/logger/index.js +8 -0
- package/dist/modules/logger/index.js.map +1 -0
- package/dist/modules/main/index.d.ts +1 -0
- package/dist/modules/main/index.js +6 -0
- package/dist/modules/main/index.js.map +1 -0
- package/dist/modules/main/main.constants.d.ts +1 -0
- package/dist/modules/main/main.constants.js +5 -0
- package/dist/modules/main/main.constants.js.map +1 -0
- package/dist/modules/main/main.controller.d.ts +10 -0
- package/dist/modules/main/main.controller.js +60 -0
- package/dist/modules/main/main.controller.js.map +1 -0
- package/dist/modules/{rooms/rooms.interfaces.d.ts → main/main.interfaces.d.ts} +2 -4
- package/dist/modules/{rooms/rooms.interfaces.js → main/main.interfaces.js} +1 -1
- package/dist/modules/main/main.interfaces.js.map +1 -0
- package/dist/modules/main/main.module.d.ts +6 -0
- package/dist/modules/main/main.module.js +43 -0
- package/dist/modules/main/main.module.js.map +1 -0
- package/dist/modules/main/main.service.d.ts +17 -0
- package/dist/modules/main/main.service.js +76 -0
- package/dist/modules/main/main.service.js.map +1 -0
- package/dist/modules/many-tables-tournament/index.d.ts +1 -0
- package/dist/modules/many-tables-tournament/index.js +6 -0
- package/dist/modules/many-tables-tournament/index.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.constants.d.ts +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.constants.js +5 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.constants.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.d.ts +18 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js +140 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.controller.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.interfaces.d.ts +13 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.interfaces.js +3 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.interfaces.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.d.ts +6 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +48 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.module.js.map +1 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.d.ts +23 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js +116 -0
- package/dist/modules/many-tables-tournament/many-tables-tournament.service.js.map +1 -0
- package/dist/modules/menu/index.d.ts +1 -0
- package/dist/modules/menu/index.js +6 -0
- package/dist/modules/menu/index.js.map +1 -0
- package/dist/modules/one-table-tournament/index.d.ts +1 -0
- package/dist/modules/one-table-tournament/index.js +6 -0
- package/dist/modules/one-table-tournament/index.js.map +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.constants.d.ts +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.constants.js +5 -0
- package/dist/modules/one-table-tournament/one-table-tournament.constants.js.map +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.controller.d.ts +12 -0
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js +90 -0
- package/dist/modules/one-table-tournament/one-table-tournament.controller.js.map +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.interfaces.d.ts +13 -0
- package/dist/modules/one-table-tournament/one-table-tournament.interfaces.js +3 -0
- package/dist/modules/one-table-tournament/one-table-tournament.interfaces.js.map +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.module.d.ts +6 -0
- package/dist/modules/one-table-tournament/one-table-tournament.module.js +48 -0
- package/dist/modules/one-table-tournament/one-table-tournament.module.js.map +1 -0
- package/dist/modules/one-table-tournament/one-table-tournament.service.d.ts +17 -0
- package/dist/modules/one-table-tournament/one-table-tournament.service.js +97 -0
- package/dist/modules/one-table-tournament/one-table-tournament.service.js.map +1 -0
- package/dist/modules/players-manager/index.d.ts +2 -0
- package/dist/modules/players-manager/index.js +8 -0
- package/dist/modules/players-manager/index.js.map +1 -0
- package/dist/modules/simple-rooms/index.d.ts +1 -0
- package/dist/modules/simple-rooms/index.js +6 -0
- package/dist/modules/simple-rooms/index.js.map +1 -0
- package/dist/modules/simple-rooms/simple-rooms.constants.d.ts +1 -0
- package/dist/modules/simple-rooms/simple-rooms.constants.js +5 -0
- package/dist/modules/simple-rooms/simple-rooms.constants.js.map +1 -0
- package/dist/modules/simple-rooms/simple-rooms.controller.d.ts +11 -0
- package/dist/modules/{rooms/rooms.controller.js → simple-rooms/simple-rooms.controller.js} +14 -45
- package/dist/modules/simple-rooms/simple-rooms.controller.js.map +1 -0
- package/dist/modules/simple-rooms/simple-rooms.interfaces.d.ts +13 -0
- package/dist/modules/simple-rooms/simple-rooms.interfaces.js +3 -0
- package/dist/modules/simple-rooms/simple-rooms.interfaces.js.map +1 -0
- package/dist/modules/simple-rooms/simple-rooms.module.d.ts +6 -0
- package/dist/modules/{rooms/rooms.module.js → simple-rooms/simple-rooms.module.js} +15 -15
- package/dist/modules/simple-rooms/simple-rooms.module.js.map +1 -0
- package/dist/modules/{rooms/rooms.service.d.ts → simple-rooms/simple-rooms.service.d.ts} +5 -9
- package/dist/modules/{rooms/rooms.service.js → simple-rooms/simple-rooms.service.js} +12 -38
- package/dist/modules/simple-rooms/simple-rooms.service.js.map +1 -0
- package/dist/modules/simple-rooms-manager/index.d.ts +2 -0
- package/dist/modules/simple-rooms-manager/index.js +8 -0
- package/dist/modules/simple-rooms-manager/index.js.map +1 -0
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.module.d.ts +2 -13
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.module.js +5 -117
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.module.js.map +1 -1
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.d.ts +18 -2
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js +74 -2
- package/dist/modules/simple-rooms-manager/simple-rooms-manager.service.js.map +1 -1
- package/dist/modules/support/index.d.ts +1 -0
- package/dist/modules/support/index.js +6 -0
- package/dist/modules/support/index.js.map +1 -0
- package/dist/modules/support/support.controller.d.ts +1 -0
- package/dist/modules/support/support.controller.js +10 -0
- package/dist/modules/support/support.controller.js.map +1 -1
- package/dist/modules/support/support.service.d.ts +4 -1
- package/dist/modules/support/support.service.js +10 -2
- package/dist/modules/support/support.service.js.map +1 -1
- package/dist/modules/tournament-many-tables-rooms-manager/index.d.ts +2 -0
- package/dist/modules/tournament-many-tables-rooms-manager/index.js +8 -0
- package/dist/modules/tournament-many-tables-rooms-manager/index.js.map +1 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.constants.d.ts +1 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.constants.js +5 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.constants.js.map +1 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.interfaces.d.ts +18 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.interfaces.js +3 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.interfaces.js.map +1 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.d.ts +9 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.js +61 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.js.map +1 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.d.ts +36 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.js +167 -0
- package/dist/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.js.map +1 -0
- package/dist/modules/tournament-one-table-rooms-manager/index.d.ts +2 -0
- package/dist/modules/tournament-one-table-rooms-manager/index.js +8 -0
- package/dist/modules/tournament-one-table-rooms-manager/index.js.map +1 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.constants.d.ts +1 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.constants.js +5 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.constants.js.map +1 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.interfaces.d.ts +18 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.interfaces.js +3 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.interfaces.js.map +1 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.module.d.ts +9 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.module.js +61 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.module.js.map +1 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.d.ts +29 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.js +143 -0
- package/dist/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/date.d.ts +2 -0
- package/dist/utils/date.js +11 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/game-table-result.d.ts +39 -0
- package/dist/utils/game-table-result.js +90 -0
- package/dist/utils/game-table-result.js.map +1 -0
- package/package.json +7 -4
- package/src/dto/common/join-tournament.dto.ts +30 -0
- package/src/dto/common/many-tables-tournament-create.dto.ts +123 -0
- package/src/dto/common/many-tables-tournament-update.dto.ts +3 -0
- package/src/modules/anti-freeze-system/anti-freeze-system.constants.ts +1 -0
- package/src/modules/anti-freeze-system/anti-freeze-system.interfaces.ts +15 -0
- package/src/modules/anti-freeze-system/anti-freeze-system.module.ts +55 -0
- package/src/modules/anti-freeze-system/anti-freeze-system.service.ts +94 -0
- package/src/modules/anti-freeze-system/index.ts +1 -0
- package/src/modules/events/events.module.ts +1 -1
- package/src/modules/events/index.ts +1 -0
- package/src/modules/index.ts +19 -26
- package/src/modules/logger/index.ts +2 -0
- package/src/modules/main/index.ts +1 -0
- package/src/modules/main/main.constants.ts +1 -0
- package/src/modules/main/main.controller.ts +29 -0
- package/src/modules/{rooms/rooms.interfaces.ts → main/main.interfaces.ts} +2 -4
- package/src/modules/main/main.module.ts +31 -0
- package/src/modules/main/main.service.ts +111 -0
- package/src/modules/many-tables-tournament/index.ts +1 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.constants.ts +1 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.controller.ts +96 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.interfaces.ts +15 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +36 -0
- package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +189 -0
- package/src/modules/menu/index.ts +1 -0
- package/src/modules/one-table-tournament/index.ts +1 -0
- package/src/modules/one-table-tournament/one-table-tournament.constants.ts +1 -0
- package/src/modules/one-table-tournament/one-table-tournament.controller.ts +58 -0
- package/src/modules/one-table-tournament/one-table-tournament.interfaces.ts +15 -0
- package/src/modules/one-table-tournament/one-table-tournament.module.ts +36 -0
- package/src/modules/one-table-tournament/one-table-tournament.service.ts +140 -0
- package/src/modules/players-manager/index.ts +2 -0
- package/src/modules/simple-rooms/index.ts +1 -0
- package/src/modules/simple-rooms/simple-rooms.constants.ts +1 -0
- package/src/modules/{rooms/rooms.controller.ts → simple-rooms/simple-rooms.controller.ts} +6 -25
- package/src/modules/simple-rooms/simple-rooms.interfaces.ts +15 -0
- package/src/modules/simple-rooms/simple-rooms.module.ts +36 -0
- package/src/modules/simple-rooms/simple-rooms.service.ts +90 -0
- package/src/modules/simple-rooms-manager/index.ts +2 -0
- package/src/modules/simple-rooms-manager/simple-rooms-manager.module.ts +11 -116
- package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +108 -19
- package/src/modules/support/index.ts +1 -0
- package/src/modules/support/support.controller.ts +6 -0
- package/src/modules/support/support.service.ts +8 -0
- package/src/modules/tournament-many-tables-rooms-manager/index.ts +2 -0
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.constants.ts +1 -0
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.interfaces.ts +20 -0
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.module.ts +61 -0
- package/src/modules/tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service.ts +216 -0
- package/src/modules/tournament-one-table-rooms-manager/index.ts +2 -0
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.constants.ts +1 -0
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.interfaces.ts +20 -0
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.module.ts +59 -0
- package/src/modules/tournament-one-table-rooms-manager/tournament-one-table-rooms-manager.service.ts +165 -0
- package/src/utils/date.ts +7 -0
- package/src/utils/game-table-result.ts +110 -0
- package/dist/modules/rooms/rooms.constants.d.ts +0 -1
- package/dist/modules/rooms/rooms.constants.js +0 -5
- package/dist/modules/rooms/rooms.constants.js.map +0 -1
- package/dist/modules/rooms/rooms.controller.d.ts +0 -15
- package/dist/modules/rooms/rooms.controller.js.map +0 -1
- package/dist/modules/rooms/rooms.interfaces.js.map +0 -1
- package/dist/modules/rooms/rooms.module.d.ts +0 -6
- package/dist/modules/rooms/rooms.module.js.map +0 -1
- package/dist/modules/rooms/rooms.service.js.map +0 -1
- package/src/modules/rooms/rooms.constants.ts +0 -1
- package/src/modules/rooms/rooms.module.ts +0 -36
- package/src/modules/rooms/rooms.service.ts +0 -150
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
import { MainController } from './main.controller';
|
|
4
|
+
import { MainService } from './main.service';
|
|
5
|
+
import { MAIN_OPTIONS } from './main.constants';
|
|
6
|
+
import { MainModuleOptions } from './main.interfaces';
|
|
7
|
+
|
|
8
|
+
@Module({
|
|
9
|
+
controllers: [MainController],
|
|
10
|
+
providers: [MainService],
|
|
11
|
+
})
|
|
12
|
+
export class MainModule {
|
|
13
|
+
constructor () {
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static forRootAsync (options: MainModuleOptions): DynamicModule {
|
|
18
|
+
return {
|
|
19
|
+
module: MainModule,
|
|
20
|
+
imports: options.imports ?? [],
|
|
21
|
+
providers: [
|
|
22
|
+
{
|
|
23
|
+
provide: MAIN_OPTIONS,
|
|
24
|
+
useFactory: options.useFactory,
|
|
25
|
+
inject: options.inject || [],
|
|
26
|
+
} as Provider,
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
AppScreen,
|
|
4
|
+
AppScreenAppBar,
|
|
5
|
+
AppScreenIdEnum,
|
|
6
|
+
AppScreenRoutesEnum,
|
|
7
|
+
AppScreenSection,
|
|
8
|
+
AppScreenSectionButton,
|
|
9
|
+
AppScreenSectionImage,
|
|
10
|
+
AppScreenSectionListItem,
|
|
11
|
+
BaseAppScreen,
|
|
12
|
+
router,
|
|
13
|
+
AppScreenIconEnum,
|
|
14
|
+
AppScreenSectionButtons,
|
|
15
|
+
} from 'jp.common.models';
|
|
16
|
+
import { replacePattern } from 'jp.common.utils';
|
|
17
|
+
|
|
18
|
+
import { BaseAppScreenDto, PlayerCheckStateDto } from '../../dto';
|
|
19
|
+
import { SimpleRoomsManagerService } from '../simple-rooms-manager';
|
|
20
|
+
import { PlayersManagerService } from '../players-manager';
|
|
21
|
+
import { TournamentOneTableRoomsManagerService } from '../tournament-one-table-rooms-manager';
|
|
22
|
+
import { TournamentManyTablesRoomsManagerService } from '../tournament-many-tables-rooms-manager';
|
|
23
|
+
|
|
24
|
+
import { MainFactoryOptions } from './main.interfaces';
|
|
25
|
+
import { MAIN_OPTIONS } from './main.constants';
|
|
26
|
+
|
|
27
|
+
@Injectable()
|
|
28
|
+
export class MainService {
|
|
29
|
+
constructor (
|
|
30
|
+
private readonly simpleRoomsManager: SimpleRoomsManagerService,
|
|
31
|
+
private readonly oneTableRoomsManagerService: TournamentOneTableRoomsManagerService,
|
|
32
|
+
private readonly manyTablesRoomsManagerService: TournamentManyTablesRoomsManagerService,
|
|
33
|
+
private readonly playersManager: PlayersManagerService,
|
|
34
|
+
@Inject(MAIN_OPTIONS) private readonly options: MainFactoryOptions,
|
|
35
|
+
) {
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async getScreen (lang: string): Promise<BaseAppScreenDto> {
|
|
39
|
+
const oneTableTournamentsCardList = this.oneTableRoomsManagerService.getRooms().map((room) =>
|
|
40
|
+
AppScreenSectionListItem.CreateCardListItemMini(
|
|
41
|
+
room.getId(),
|
|
42
|
+
room.getTitle(lang),
|
|
43
|
+
room.getSubtitle(lang),
|
|
44
|
+
AppScreenSectionImage.CreateIconImage(AppScreenIconEnum.EMOJI_EVENTS),
|
|
45
|
+
true,
|
|
46
|
+
router.getRoomPath(room.getFirstMaster()?.getId() ?? ''),
|
|
47
|
+
));
|
|
48
|
+
|
|
49
|
+
const manyTablesTournamentsCardList = this.manyTablesRoomsManagerService.getRooms().map((room) =>
|
|
50
|
+
AppScreenSectionListItem.CreateCardListItemExtended(
|
|
51
|
+
room.getId(),
|
|
52
|
+
room.getTitle(lang),
|
|
53
|
+
room.getSubtitle(lang),
|
|
54
|
+
AppScreenSectionImage.CreateIconImage(AppScreenIconEnum.EMOJI_EVENTS),
|
|
55
|
+
true,
|
|
56
|
+
true,
|
|
57
|
+
AppScreenSectionImage.CreateIconImage(AppScreenIconEnum.EMOJI_EVENTS),
|
|
58
|
+
room.getDescription(lang),
|
|
59
|
+
AppScreenSectionButtons.CreatePrimaryButtonSection(AppScreenSectionButton.CreateTextButton('button')),
|
|
60
|
+
));
|
|
61
|
+
|
|
62
|
+
const simpleRoomsTableCardList = this.simpleRoomsManager.getRooms().reduce<Array<AppScreenSectionListItem>>((result, room) => {
|
|
63
|
+
const list = room.getTables().map((table) => AppScreenSectionListItem.CreateCardListItemMini(
|
|
64
|
+
table.getId(),
|
|
65
|
+
replacePattern(table.getTitle(lang), { NUMBER: table.getNumber().toString() }),
|
|
66
|
+
replacePattern(table.getSubtitle(lang), {
|
|
67
|
+
HALF_BET: table.getHalfBet().toString(),
|
|
68
|
+
BET: table.getBet().toString()
|
|
69
|
+
}),
|
|
70
|
+
AppScreenSectionImage.CreateUrlImage(`${table.getPlayers().length}/${table.getTableSize()}`),
|
|
71
|
+
true,
|
|
72
|
+
router.getRoomPath(table.getId()),
|
|
73
|
+
));
|
|
74
|
+
|
|
75
|
+
return [...result, ...list];
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const screen =
|
|
79
|
+
AppScreen.CreateStandardScreen(AppScreenIdEnum.ROOMS)
|
|
80
|
+
.addAppBar(
|
|
81
|
+
AppScreenAppBar.CreateStandardAppBar(
|
|
82
|
+
this.options.i18n.t('common.rooms.screen.title', { lang }),
|
|
83
|
+
AppScreenSectionButton.CreateArrowBackButton(this.options.i18n.t('common.button.back', { lang })),
|
|
84
|
+
),
|
|
85
|
+
)
|
|
86
|
+
.addSection(
|
|
87
|
+
AppScreenSection.CreateCardListSection(
|
|
88
|
+
'id1',
|
|
89
|
+
[
|
|
90
|
+
...manyTablesTournamentsCardList,
|
|
91
|
+
...oneTableTournamentsCardList,
|
|
92
|
+
...simpleRoomsTableCardList
|
|
93
|
+
]
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return new BaseAppScreenDto(new BaseAppScreen(screen));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
playerCheckState (clientAuthToken: string): PlayerCheckStateDto {
|
|
101
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
102
|
+
if (player && player.isPlayer() && player.tableId) {
|
|
103
|
+
return PlayerCheckStateDto.fromEntities(router.getRoomPath(player.tableId), player.id);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return PlayerCheckStateDto.fromEntities(AppScreenRoutesEnum.MENU);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
findFreeTable (clientAuthToken: string) {
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ManyTablesTournamentModule } from './many-tables-tournament.module';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MANY_TABLES_TOURNAMENT_OPTIONS = Symbol('MANY_TABLES_TOURNAMENT_OPTIONS');
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Body, Controller, Get, Param, Post, Headers, HttpStatus, HttpCode, Patch, Delete } from '@nestjs/common';
|
|
2
|
+
import { IAppHeaders, IBaseAppScreen, IBaseMoveData, IBaseTableGameState } from 'jp.common.models';
|
|
3
|
+
|
|
4
|
+
import { ManyTablesTournamentService } from './many-tables-tournament.service';
|
|
5
|
+
import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
6
|
+
import { ManyTablesTournamentCreateDto } from '../../dto/common/many-tables-tournament-create.dto';
|
|
7
|
+
import { ManyTablesTournamentUpdateDto } from '../../dto/common/many-tables-tournament-update.dto';
|
|
8
|
+
|
|
9
|
+
@Controller('tournament/many_tables')
|
|
10
|
+
export class ManyTablesTournamentController {
|
|
11
|
+
constructor (
|
|
12
|
+
private readonly tournamentService: ManyTablesTournamentService,
|
|
13
|
+
) {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Get('status/:tournamentId')
|
|
17
|
+
getStatusScreen (
|
|
18
|
+
@Param('tournamentId') tournamentId: string,
|
|
19
|
+
@Headers() headers: IAppHeaders,
|
|
20
|
+
): Promise<IBaseAppScreen> {
|
|
21
|
+
return this.tournamentService.getStatusScreen(tournamentId, headers.client_language);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Get('tables/:tournamentId')
|
|
25
|
+
getTableListScreen (
|
|
26
|
+
@Param('tournamentId') tournamentId: string,
|
|
27
|
+
@Headers() headers: IAppHeaders,
|
|
28
|
+
): Promise<IBaseAppScreen> {
|
|
29
|
+
return this.tournamentService.getTableListScreen(tournamentId, headers.client_language);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Post('table/watch/:tableId')
|
|
33
|
+
@HttpCode(HttpStatus.OK)
|
|
34
|
+
watchTheTable (
|
|
35
|
+
@Param('tableId') tableId: string,
|
|
36
|
+
@Headers() headers: IAppHeaders,
|
|
37
|
+
): IBaseTableGameState {
|
|
38
|
+
return this.tournamentService.watchTheTable(tableId, headers.client_auth_token);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Post('table/move/:tableId')
|
|
42
|
+
@HttpCode(HttpStatus.OK)
|
|
43
|
+
moveOnTheTable (
|
|
44
|
+
@Param('tableId') tableId: string,
|
|
45
|
+
@Body() baseMoveData: IBaseMoveData,
|
|
46
|
+
@Headers() headers: IAppHeaders,
|
|
47
|
+
): IBaseTableGameState {
|
|
48
|
+
return this.tournamentService.moveOnTheTable(tableId, headers.client_auth_token, baseMoveData);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Post('join/:tournamentId')
|
|
52
|
+
@HttpCode(HttpStatus.OK)
|
|
53
|
+
joinTournament (
|
|
54
|
+
@Param('tournamentId') tournamentId: string,
|
|
55
|
+
@Headers() headers: IAppHeaders,
|
|
56
|
+
): JoinTournamentDto {
|
|
57
|
+
return this.tournamentService.joinTournament(tournamentId, headers.client_auth_token);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Post('leave/:tournamentId')
|
|
61
|
+
@HttpCode(HttpStatus.OK)
|
|
62
|
+
leaveTournament (
|
|
63
|
+
@Param('tournamentId') tournamentId: string,
|
|
64
|
+
@Headers() headers: IAppHeaders,
|
|
65
|
+
): IBaseTableGameState {
|
|
66
|
+
return this.tournamentService.leaveTournament(tournamentId, headers.client_auth_token);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Post('create')
|
|
70
|
+
@HttpCode(HttpStatus.OK)
|
|
71
|
+
createTournament (
|
|
72
|
+
@Headers() headers: IAppHeaders,
|
|
73
|
+
@Body() createTournamentDto: ManyTablesTournamentCreateDto,
|
|
74
|
+
): Promise<void> {
|
|
75
|
+
return this.tournamentService.createTournament(createTournamentDto);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Patch('update/:tournamentId')
|
|
79
|
+
@HttpCode(HttpStatus.OK)
|
|
80
|
+
updateTournament (
|
|
81
|
+
@Param('tournamentId') tournamentId: string,
|
|
82
|
+
@Body() updateTournamentDto: ManyTablesTournamentUpdateDto,
|
|
83
|
+
@Headers() headers: IAppHeaders,
|
|
84
|
+
): Promise<void> {
|
|
85
|
+
return this.tournamentService.updateTournament(tournamentId, updateTournamentDto);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Delete('remove/:tournamentId')
|
|
89
|
+
@HttpCode(HttpStatus.OK)
|
|
90
|
+
removeTournament (
|
|
91
|
+
@Param('tournamentId') tournamentId: string,
|
|
92
|
+
@Headers() headers: IAppHeaders,
|
|
93
|
+
): Promise<void> {
|
|
94
|
+
return this.tournamentService.removeTournament(tournamentId);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { I18nService } from 'nestjs-i18n';
|
|
3
|
+
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
4
|
+
import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
|
|
5
|
+
import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
|
|
6
|
+
|
|
7
|
+
export interface ManyTablesTournamentModuleOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
8
|
+
imports?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
9
|
+
inject?: any[];
|
|
10
|
+
useFactory?: (...args: any[]) => Promise<any> | any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ManyTablesTournamentFactoryOptions {
|
|
14
|
+
i18n: I18nService
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
|
+
import { MongooseModule } from '@nestjs/mongoose';
|
|
3
|
+
import { TournamentManyTablesRoom, TournamentManyTablesRoomSchema, TournamentManyTablesRoomsRepository } from 'jp.db.schemas';
|
|
4
|
+
|
|
5
|
+
import { ManyTablesTournamentController } from './many-tables-tournament.controller';
|
|
6
|
+
import { ManyTablesTournamentService } from './many-tables-tournament.service';
|
|
7
|
+
import { MANY_TABLES_TOURNAMENT_OPTIONS } from './many-tables-tournament.constants';
|
|
8
|
+
import { ManyTablesTournamentModuleOptions } from './many-tables-tournament.interfaces';
|
|
9
|
+
|
|
10
|
+
@Module({
|
|
11
|
+
imports: [
|
|
12
|
+
MongooseModule.forFeature([{ name: TournamentManyTablesRoom.name, schema: TournamentManyTablesRoomSchema }]),
|
|
13
|
+
],
|
|
14
|
+
controllers: [ManyTablesTournamentController],
|
|
15
|
+
providers: [ManyTablesTournamentService, TournamentManyTablesRoomsRepository],
|
|
16
|
+
})
|
|
17
|
+
export class ManyTablesTournamentModule {
|
|
18
|
+
constructor () {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static forRootAsync (options: ManyTablesTournamentModuleOptions): DynamicModule {
|
|
23
|
+
return {
|
|
24
|
+
module: ManyTablesTournamentModule,
|
|
25
|
+
imports: options.imports ?? [],
|
|
26
|
+
providers: [
|
|
27
|
+
{
|
|
28
|
+
provide: MANY_TABLES_TOURNAMENT_OPTIONS,
|
|
29
|
+
useFactory: options.useFactory,
|
|
30
|
+
inject: options.inject || [],
|
|
31
|
+
} as Provider,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { Inject, Injectable, InternalServerErrorException } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
AppScreen,
|
|
4
|
+
AppScreenAppBar,
|
|
5
|
+
AppScreenIdEnum,
|
|
6
|
+
AppScreenSection,
|
|
7
|
+
AppScreenSectionButton,
|
|
8
|
+
AppScreenSectionImage,
|
|
9
|
+
AppScreenSectionListItem,
|
|
10
|
+
BaseAppScreen,
|
|
11
|
+
IBaseMoveData,
|
|
12
|
+
IBaseTableGameState,
|
|
13
|
+
AppScreenIconEnum,
|
|
14
|
+
AppScreenSectionButtons,
|
|
15
|
+
router,
|
|
16
|
+
} from 'jp.common.models';
|
|
17
|
+
|
|
18
|
+
import { BaseAppScreenDto } from '../../dto';
|
|
19
|
+
import { TournamentManyTablesRoomsManagerService } from '../tournament-many-tables-rooms-manager/tournament-many-tables-rooms-manager.service';
|
|
20
|
+
import { PlayersManagerService } from '../players-manager/players-manager.service';
|
|
21
|
+
import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
22
|
+
import { ManyTablesTournamentCreateDto } from '../../dto/common/many-tables-tournament-create.dto';
|
|
23
|
+
import { ManyTablesTournamentUpdateDto } from '../../dto/common/many-tables-tournament-update.dto';
|
|
24
|
+
|
|
25
|
+
import { ManyTablesTournamentFactoryOptions } from './many-tables-tournament.interfaces';
|
|
26
|
+
import { MANY_TABLES_TOURNAMENT_OPTIONS } from './many-tables-tournament.constants';
|
|
27
|
+
|
|
28
|
+
@Injectable()
|
|
29
|
+
export class ManyTablesTournamentService {
|
|
30
|
+
constructor (
|
|
31
|
+
private readonly manyTablesRoomsManagerService: TournamentManyTablesRoomsManagerService,
|
|
32
|
+
private readonly playersManager: PlayersManagerService,
|
|
33
|
+
@Inject(MANY_TABLES_TOURNAMENT_OPTIONS) private readonly options: ManyTablesTournamentFactoryOptions,
|
|
34
|
+
) {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getStatusScreen (tournamentId: string, lang: string): Promise<BaseAppScreenDto> {
|
|
38
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomById(tournamentId);
|
|
39
|
+
|
|
40
|
+
if (!tournament) {
|
|
41
|
+
throw new InternalServerErrorException();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const screen =
|
|
45
|
+
AppScreen.CreateStatusScreen(AppScreenIdEnum.ROOMS)
|
|
46
|
+
.addAppBar(
|
|
47
|
+
AppScreenAppBar.CreateStatusAppBar(
|
|
48
|
+
this.options.i18n.t('common.rooms.screen.title', { lang }),
|
|
49
|
+
AppScreenSectionButton.CreateArrowBackButton(this.options.i18n.t('common.button.back', { lang })),
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
.addSection((
|
|
53
|
+
AppScreenSection.CreateStatusHeader(
|
|
54
|
+
'status',
|
|
55
|
+
'description',
|
|
56
|
+
AppScreenSectionImage.CreateIconImage(AppScreenIconEnum.EMOJI_EVENTS),
|
|
57
|
+
AppScreenSectionButtons.CreatePrimaryButtonSection(AppScreenSectionButton.CreateTextButton('button')),
|
|
58
|
+
)
|
|
59
|
+
))
|
|
60
|
+
.addSection(
|
|
61
|
+
AppScreenSection.CreateCardListSection(
|
|
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
|
+
);
|
|
73
|
+
|
|
74
|
+
return new BaseAppScreenDto(new BaseAppScreen(screen));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async getTableListScreen (tournamentId: string, lang: string): Promise<BaseAppScreenDto> {
|
|
78
|
+
const screen =
|
|
79
|
+
AppScreen.CreateStandardScreen(AppScreenIdEnum.ROOMS)
|
|
80
|
+
.addAppBar(
|
|
81
|
+
AppScreenAppBar.CreateStandardAppBar(
|
|
82
|
+
this.options.i18n.t('common.rooms.screen.title', { lang }),
|
|
83
|
+
AppScreenSectionButton.CreateArrowBackButton(this.options.i18n.t('common.button.back', { lang })),
|
|
84
|
+
),
|
|
85
|
+
)
|
|
86
|
+
.addSection(
|
|
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
|
+
);
|
|
101
|
+
|
|
102
|
+
return new BaseAppScreenDto(new BaseAppScreen(screen));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
watchTheTable (tableId: string, clientAuthToken: string): IBaseTableGameState {
|
|
106
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
107
|
+
const room = this.manyTablesRoomsManagerService.getRoomByTableId(tableId);
|
|
108
|
+
const master = room?.getMasterById(tableId);
|
|
109
|
+
|
|
110
|
+
if (player && room && master) {
|
|
111
|
+
room.handleWatchTheTable(player, tableId);
|
|
112
|
+
|
|
113
|
+
return master.createGameStateDto(player);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
throw new InternalServerErrorException();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
moveOnTheTable (tableId: string, clientAuthToken: string, moveDto: IBaseMoveData): IBaseTableGameState {
|
|
120
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
121
|
+
const room = this.manyTablesRoomsManagerService.getRoomByTableId(tableId);
|
|
122
|
+
const master = room?.getMasterById(tableId);
|
|
123
|
+
|
|
124
|
+
if (player && room && master) {
|
|
125
|
+
room.handleMoveOnTheTable(player, tableId, moveDto);
|
|
126
|
+
|
|
127
|
+
return master.createGameStateDto(player);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
throw new InternalServerErrorException();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
joinTournament (tournamentId: string, clientAuthToken: string): JoinTournamentDto {
|
|
134
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
135
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
136
|
+
const master = tournament?.getMasterById(tournamentId);
|
|
137
|
+
|
|
138
|
+
if (player && tournament && master) {
|
|
139
|
+
tournament.handleJoinTournament(player);
|
|
140
|
+
|
|
141
|
+
if (tournament.getTournamentMaster().isInProgress()) {
|
|
142
|
+
if (player.isPlayer() || player.isTableQueuer()) {
|
|
143
|
+
return JoinTournamentDto.fromEntities(
|
|
144
|
+
router.getManyTablesTournamentTablePath(player.tableId ?? ''),
|
|
145
|
+
player.id,
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
return JoinTournamentDto.fromEntities(
|
|
149
|
+
router.getManyTablesTournamentTableListPath(),
|
|
150
|
+
player.id,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
return JoinTournamentDto.fromEntities(
|
|
155
|
+
router.getManyTablesTournamentStatusPath(tournament.getId()),
|
|
156
|
+
player.id,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
throw new InternalServerErrorException();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
leaveTournament (tournamentId: string, clientAuthToken: string): IBaseTableGameState {
|
|
165
|
+
const player = this.playersManager.getPlayerById(clientAuthToken);
|
|
166
|
+
const tournament = this.manyTablesRoomsManagerService.getRoomByTableId(tournamentId);
|
|
167
|
+
const master = tournament?.getMasterById(tournamentId);
|
|
168
|
+
|
|
169
|
+
if (player && tournament && master) {
|
|
170
|
+
tournament.handleLeaveTournament(player);
|
|
171
|
+
|
|
172
|
+
return master.createGameStateDto(player);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
throw new InternalServerErrorException();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async createTournament (createTournamentDto: ManyTablesTournamentCreateDto) {
|
|
179
|
+
return this.manyTablesRoomsManagerService.createTournament(createTournamentDto);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async updateTournament (tournamentId: string, updateTournamentDto: ManyTablesTournamentUpdateDto) {
|
|
183
|
+
return this.manyTablesRoomsManagerService.updateTournament(tournamentId, updateTournamentDto);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async removeTournament (tournamentId: string) {
|
|
187
|
+
return this.manyTablesRoomsManagerService.removeTournament(tournamentId);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MenuModule } from './menu.module';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { OneTableTournamentModule } from './one-table-tournament.module';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ONE_TABLE_TOURNAMENT_OPTIONS = Symbol('ONE_TABLE_TOURNAMENT_OPTIONS');
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Body, Controller, Get, Param, Post, Headers, HttpStatus, HttpCode } from '@nestjs/common';
|
|
2
|
+
import { IAppHeaders, IBaseAppScreen, IBaseMoveData, IBaseTableGameState } from 'jp.common.models';
|
|
3
|
+
|
|
4
|
+
import { OneTableTournamentService } from './one-table-tournament.service';
|
|
5
|
+
import { JoinTournamentDto } from '../../dto/common/join-tournament.dto';
|
|
6
|
+
|
|
7
|
+
@Controller('tournament/one_table')
|
|
8
|
+
export class OneTableTournamentController {
|
|
9
|
+
constructor (
|
|
10
|
+
private readonly tournamentService: OneTableTournamentService,
|
|
11
|
+
) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Get('status/:tournamentId')
|
|
15
|
+
getStatusScreen (
|
|
16
|
+
@Param('tournamentId') tournamentId: string,
|
|
17
|
+
@Headers() headers: IAppHeaders,
|
|
18
|
+
): Promise<IBaseAppScreen> {
|
|
19
|
+
return this.tournamentService.getStatusScreen(tournamentId, headers.client_language);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Post('table/watch/:tableId')
|
|
23
|
+
@HttpCode(HttpStatus.OK)
|
|
24
|
+
watchTheTable (
|
|
25
|
+
@Param('tableId') tableId: string,
|
|
26
|
+
@Headers() headers: IAppHeaders,
|
|
27
|
+
): IBaseTableGameState {
|
|
28
|
+
return this.tournamentService.watchTheTable(tableId, headers.client_auth_token);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Post('table/move/:tableId')
|
|
32
|
+
@HttpCode(HttpStatus.OK)
|
|
33
|
+
moveOnTheTable (
|
|
34
|
+
@Param('tableId') tableId: string,
|
|
35
|
+
@Body() baseMoveData: IBaseMoveData,
|
|
36
|
+
@Headers() headers: IAppHeaders,
|
|
37
|
+
): IBaseTableGameState {
|
|
38
|
+
return this.tournamentService.moveOnTheTable(tableId, headers.client_auth_token, baseMoveData);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Post('join/:tournamentId')
|
|
42
|
+
@HttpCode(HttpStatus.OK)
|
|
43
|
+
joinTournament (
|
|
44
|
+
@Param('tournamentId') tournamentId: string,
|
|
45
|
+
@Headers() headers: IAppHeaders,
|
|
46
|
+
): JoinTournamentDto {
|
|
47
|
+
return this.tournamentService.joinTournament(tournamentId, headers.client_auth_token);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Post('leave/:tournamentId')
|
|
51
|
+
@HttpCode(HttpStatus.OK)
|
|
52
|
+
leaveTournament (
|
|
53
|
+
@Param('tournamentId') tournamentId: string,
|
|
54
|
+
@Headers() headers: IAppHeaders,
|
|
55
|
+
): IBaseTableGameState {
|
|
56
|
+
return this.tournamentService.leaveTournament(tournamentId, headers.client_auth_token);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { I18nService } from 'nestjs-i18n';
|
|
3
|
+
import { Type } from '@nestjs/common/interfaces/type.interface';
|
|
4
|
+
import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
|
|
5
|
+
import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
|
|
6
|
+
|
|
7
|
+
export interface OneTableTournamentModuleOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
8
|
+
imports?: Array<Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
9
|
+
inject?: any[];
|
|
10
|
+
useFactory?: (...args: any[]) => Promise<any> | any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface OneTableTournamentFactoryOptions {
|
|
14
|
+
i18n: I18nService
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
|
2
|
+
import { MongooseModule } from '@nestjs/mongoose';
|
|
3
|
+
import { TournamentOneTableRoom, TournamentOneTableRoomSchema, TournamentOneTableRoomsRepository } from 'jp.db.schemas';
|
|
4
|
+
|
|
5
|
+
import { OneTableTournamentController } from './one-table-tournament.controller';
|
|
6
|
+
import { OneTableTournamentService } from './one-table-tournament.service';
|
|
7
|
+
import { ONE_TABLE_TOURNAMENT_OPTIONS } from './one-table-tournament.constants';
|
|
8
|
+
import { OneTableTournamentModuleOptions } from './one-table-tournament.interfaces';
|
|
9
|
+
|
|
10
|
+
@Module({
|
|
11
|
+
imports: [
|
|
12
|
+
MongooseModule.forFeature([{ name: TournamentOneTableRoom.name, schema: TournamentOneTableRoomSchema }]),
|
|
13
|
+
],
|
|
14
|
+
controllers: [OneTableTournamentController],
|
|
15
|
+
providers: [OneTableTournamentService, TournamentOneTableRoomsRepository],
|
|
16
|
+
})
|
|
17
|
+
export class OneTableTournamentModule {
|
|
18
|
+
constructor () {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static forRootAsync (options: OneTableTournamentModuleOptions): DynamicModule {
|
|
23
|
+
return {
|
|
24
|
+
module: OneTableTournamentModule,
|
|
25
|
+
imports: options.imports ?? [],
|
|
26
|
+
providers: [
|
|
27
|
+
{
|
|
28
|
+
provide: ONE_TABLE_TOURNAMENT_OPTIONS,
|
|
29
|
+
useFactory: options.useFactory,
|
|
30
|
+
inject: options.inject || [],
|
|
31
|
+
} as Provider,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|