jp.ms.common.modules 1.0.41 → 1.0.42

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.
Files changed (189) hide show
  1. package/dist/modules/anti-freeze-system/anti-freeze-system.module.d.ts +3 -1
  2. package/dist/modules/anti-freeze-system/anti-freeze-system.module.js +8 -4
  3. package/dist/modules/anti-freeze-system/anti-freeze-system.module.js.map +1 -1
  4. package/dist/modules/anti-freeze-system/anti-freeze-system.service.d.ts +6 -2
  5. package/dist/modules/anti-freeze-system/anti-freeze-system.service.js +37 -10
  6. package/dist/modules/anti-freeze-system/anti-freeze-system.service.js.map +1 -1
  7. package/dist/modules/base-achievements/base-achievements.module.js +2 -2
  8. package/dist/modules/base-achievements/base-achievements.module.js.map +1 -1
  9. package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.d.ts +1 -0
  10. package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.js +5 -0
  11. package/dist/modules/confirmation-message-manager/confirmation-message-manager.constants.js.map +1 -0
  12. package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.d.ts +13 -0
  13. package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.js +3 -0
  14. package/dist/modules/confirmation-message-manager/confirmation-message-manager.interfaces.js.map +1 -0
  15. package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.d.ts +15 -0
  16. package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.js +77 -0
  17. package/dist/modules/confirmation-message-manager/confirmation-message-manager.module.js.map +1 -0
  18. package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.d.ts +19 -0
  19. package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.js +83 -0
  20. package/dist/modules/confirmation-message-manager/confirmation-message-manager.service.js.map +1 -0
  21. package/dist/modules/event-bus/events-bus.module.js +3 -0
  22. package/dist/modules/event-bus/events-bus.module.js.map +1 -1
  23. package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.d.ts +10 -0
  24. package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.js +26 -0
  25. package/dist/modules/event-bus/events-bus.player-ws-message.subscribe.service.js.map +1 -0
  26. package/dist/modules/event-bus/index.d.ts +1 -0
  27. package/dist/modules/event-bus/index.js +3 -1
  28. package/dist/modules/event-bus/index.js.map +1 -1
  29. package/dist/modules/events/events.gateway.d.ts +6 -1
  30. package/dist/modules/events/events.gateway.js +15 -3
  31. package/dist/modules/events/events.gateway.js.map +1 -1
  32. package/dist/modules/index.d.ts +1 -0
  33. package/dist/modules/index.js +3 -1
  34. package/dist/modules/index.js.map +1 -1
  35. package/dist/modules/main/main.module.js +1 -1
  36. package/dist/modules/main/main.module.js.map +1 -1
  37. package/dist/modules/many-tables-tournament/many-tables-tournament.module.js +1 -1
  38. package/dist/modules/many-tables-tournament/many-tables-tournament.module.js.map +1 -1
  39. package/dist/modules/one-table-tournament/one-table-tournament.module.js +1 -1
  40. package/dist/modules/one-table-tournament/one-table-tournament.module.js.map +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +57 -57
  43. package/src/dto/app-screen/app-screen-app-bar.dto.ts +36 -36
  44. package/src/dto/app-screen/app-screen-dialog.dto.ts +64 -64
  45. package/src/dto/app-screen/app-screen-field-list-item.dto.ts +42 -42
  46. package/src/dto/app-screen/app-screen-field.dto.ts +59 -59
  47. package/src/dto/app-screen/app-screen-section-button.dto.ts +60 -60
  48. package/src/dto/app-screen/app-screen-section-buttons.dto.ts +14 -14
  49. package/src/dto/app-screen/app-screen-section-image.dto.ts +33 -33
  50. package/src/dto/app-screen/app-screen-section-list-item.dto.ts +105 -105
  51. package/src/dto/app-screen/app-screen-section-req.dto.ts +33 -33
  52. package/src/dto/app-screen/app-screen-section.dto.ts +76 -76
  53. package/src/dto/app-screen/app-screen.dto.ts +50 -50
  54. package/src/dto/app-screen/base-app-screen.dto.ts +16 -16
  55. package/src/dto/app-screen/index.ts +10 -10
  56. package/src/dto/app-table/bids-panel-item.dto.ts +33 -33
  57. package/src/dto/app-table/bids-panel.dto.ts +32 -32
  58. package/src/dto/app-table/card.dto.ts +54 -54
  59. package/src/dto/app-table/cards-deck.dto.ts +22 -22
  60. package/src/dto/app-table/cards-pair-slots-item.dto.ts +45 -45
  61. package/src/dto/app-table/cards-pair-slots.dto.ts +13 -13
  62. package/src/dto/app-table/cards-panel.dto.ts +48 -48
  63. package/src/dto/app-table/cards-player.dto.ts +14 -14
  64. package/src/dto/app-table/cards-slots-item.dto.ts +40 -40
  65. package/src/dto/app-table/cards-slots.dto.ts +13 -13
  66. package/src/dto/app-table/index.ts +15 -15
  67. package/src/dto/app-table/moves-panel-button.dto.ts +24 -24
  68. package/src/dto/app-table/moves-panel.dto.ts +23 -23
  69. package/src/dto/app-table/player.dto.ts +69 -69
  70. package/src/dto/app-table/summary-item.dto.ts +51 -51
  71. package/src/dto/app-table/summary.dto.ts +13 -13
  72. package/src/dto/common/find-free-table.dto.ts +3 -3
  73. package/src/dto/common/index.ts +2 -2
  74. package/src/dto/common/join-tournament.dto.ts +33 -33
  75. package/src/dto/common/log.dto.ts +9 -9
  76. package/src/dto/common/many-tables-tournament-create.dto.ts +125 -125
  77. package/src/dto/common/many-tables-tournament-update.dto.ts +3 -3
  78. package/src/dto/common/player-check-state.dto.ts +33 -33
  79. package/src/dto/common/player-connected.dto.ts +58 -58
  80. package/src/dto/games/fool/fool-player.dto.ts +3 -3
  81. package/src/dto/games/fool/fool-table.dto.ts +81 -81
  82. package/src/dto/games/index.ts +2 -2
  83. package/src/dto/games/poker/poker-player.dto.ts +3 -3
  84. package/src/dto/games/poker/poker-table.dto.ts +81 -81
  85. package/src/dto/index.ts +4 -4
  86. package/src/exception/error-code.enum.ts +4 -4
  87. package/src/exception/global-exception-filter.ts +53 -53
  88. package/src/exception/http-exception-wth-snackbar.ts +27 -27
  89. package/src/exception/index.ts +4 -4
  90. package/src/exception/not-enough-money-for-purchase.exception.ts +14 -14
  91. package/src/exception/not-found-free-room-for-fast-game.exception.ts +14 -14
  92. package/src/index.ts +4 -4
  93. package/src/modules/anti-freeze-system/anti-freeze-system.constants.ts +1 -1
  94. package/src/modules/anti-freeze-system/anti-freeze-system.interfaces.ts +20 -20
  95. package/src/modules/anti-freeze-system/anti-freeze-system.module.ts +59 -55
  96. package/src/modules/anti-freeze-system/anti-freeze-system.service.ts +136 -105
  97. package/src/modules/anti-freeze-system/index.ts +1 -1
  98. package/src/modules/base-achievements/base-achievements.module.ts +324 -322
  99. package/src/modules/base-achievements/index.ts +1 -1
  100. package/src/modules/confirmation-message-manager/confirmation-message-manager.constants.ts +3 -0
  101. package/src/modules/confirmation-message-manager/confirmation-message-manager.interfaces.ts +20 -0
  102. package/src/modules/confirmation-message-manager/confirmation-message-manager.module.ts +77 -0
  103. package/src/modules/confirmation-message-manager/confirmation-message-manager.service.ts +91 -0
  104. package/src/modules/event-bus/events-bus.app.subscribe.service.ts +20 -20
  105. package/src/modules/event-bus/events-bus.main-tables.subscribe.service.ts +34 -34
  106. package/src/modules/event-bus/events-bus.many-tables-tournament.subscribe.service.ts +6 -6
  107. package/src/modules/event-bus/events-bus.module.ts +26 -23
  108. package/src/modules/event-bus/events-bus.one-table-tournament.subscribe.service.ts +6 -6
  109. package/src/modules/event-bus/events-bus.player-ws-message.subscribe.service.ts +30 -0
  110. package/src/modules/event-bus/events-bus.tournament.subscribe.service.ts +18 -18
  111. package/src/modules/event-bus/index.ts +6 -5
  112. package/src/modules/events/events.constants.ts +1 -1
  113. package/src/modules/events/events.gateway.ts +82 -70
  114. package/src/modules/events/events.interfaces.ts +17 -17
  115. package/src/modules/events/events.module.ts +32 -32
  116. package/src/modules/events/index.ts +1 -1
  117. package/src/modules/index.ts +28 -27
  118. package/src/modules/logger/index.ts +2 -2
  119. package/src/modules/logger/jp-logger.module.ts +10 -10
  120. package/src/modules/logger/jp-logger.service.ts +38 -38
  121. package/src/modules/main/index.ts +1 -1
  122. package/src/modules/main/main-tables-list-screen.view.ts +275 -275
  123. package/src/modules/main/main.constants.ts +1 -1
  124. package/src/modules/main/main.controller.ts +72 -72
  125. package/src/modules/main/main.interfaces.ts +17 -17
  126. package/src/modules/main/main.module.ts +73 -73
  127. package/src/modules/main/main.service.ts +183 -183
  128. package/src/modules/many-tables-tournament/index.ts +1 -1
  129. package/src/modules/many-tables-tournament/many-tables-tournament-status-screen.view.ts +143 -143
  130. package/src/modules/many-tables-tournament/many-tables-tournament-tables-list-screen.view.ts +63 -63
  131. package/src/modules/many-tables-tournament/many-tables-tournament.constants.ts +3 -3
  132. package/src/modules/many-tables-tournament/many-tables-tournament.controller.ts +151 -151
  133. package/src/modules/many-tables-tournament/many-tables-tournament.interfaces.ts +20 -20
  134. package/src/modules/many-tables-tournament/many-tables-tournament.module.ts +81 -80
  135. package/src/modules/many-tables-tournament/many-tables-tournament.service.ts +208 -208
  136. package/src/modules/many-tables-tournament-rooms-manager/index.ts +2 -2
  137. package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.constants.ts +3 -3
  138. package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.interfaces.ts +37 -37
  139. package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.module.ts +84 -84
  140. package/src/modules/many-tables-tournament-rooms-manager/many-tables-tournament-rooms-manager.service.ts +331 -331
  141. package/src/modules/menu/index.ts +1 -1
  142. package/src/modules/menu/menu-screen.view.ts +71 -71
  143. package/src/modules/menu/menu.constants.ts +1 -1
  144. package/src/modules/menu/menu.controller.ts +16 -16
  145. package/src/modules/menu/menu.interfaces.ts +17 -17
  146. package/src/modules/menu/menu.module.ts +39 -39
  147. package/src/modules/menu/menu.service.ts +39 -39
  148. package/src/modules/one-table-tournament/index.ts +1 -1
  149. package/src/modules/one-table-tournament/one-table-tournament-status-screen.view.ts +166 -166
  150. package/src/modules/one-table-tournament/one-table-tournament.constants.ts +3 -3
  151. package/src/modules/one-table-tournament/one-table-tournament.controller.ts +104 -104
  152. package/src/modules/one-table-tournament/one-table-tournament.interfaces.ts +20 -20
  153. package/src/modules/one-table-tournament/one-table-tournament.module.ts +80 -76
  154. package/src/modules/one-table-tournament/one-table-tournament.service.ts +146 -146
  155. package/src/modules/one-table-tournament-rooms-manager/index.ts +2 -2
  156. package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.constants.ts +3 -3
  157. package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.interfaces.ts +31 -31
  158. package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.module.ts +66 -66
  159. package/src/modules/one-table-tournament-rooms-manager/one-table-tournament-rooms-manager.service.ts +220 -220
  160. package/src/modules/players-manager/index.ts +2 -2
  161. package/src/modules/players-manager/players-manager.module.ts +9 -9
  162. package/src/modules/players-manager/players-manager.service.ts +27 -27
  163. package/src/modules/simple-rooms/index.ts +1 -1
  164. package/src/modules/simple-rooms/simple-rooms.constants.ts +1 -1
  165. package/src/modules/simple-rooms/simple-rooms.controller.ts +63 -63
  166. package/src/modules/simple-rooms/simple-rooms.interfaces.ts +20 -20
  167. package/src/modules/simple-rooms/simple-rooms.module.ts +39 -39
  168. package/src/modules/simple-rooms/simple-rooms.service.ts +95 -95
  169. package/src/modules/simple-rooms-manager/index.ts +2 -2
  170. package/src/modules/simple-rooms-manager/simple-rooms-manager.constants.ts +3 -3
  171. package/src/modules/simple-rooms-manager/simple-rooms-manager.interfaces.ts +26 -26
  172. package/src/modules/simple-rooms-manager/simple-rooms-manager.module.ts +60 -60
  173. package/src/modules/simple-rooms-manager/simple-rooms-manager.service.ts +190 -190
  174. package/src/modules/support/dump.service.ts +11 -11
  175. package/src/modules/support/index.ts +1 -1
  176. package/src/modules/support/metric.service.ts +41 -41
  177. package/src/modules/support/support.constants.ts +1 -1
  178. package/src/modules/support/support.controller.ts +79 -79
  179. package/src/modules/support/support.interfaces.ts +16 -16
  180. package/src/modules/support/support.module.ts +35 -35
  181. package/src/modules/support/support.service.ts +27 -27
  182. package/src/utils/date.ts +7 -7
  183. package/src/utils/game-table-result.ts +129 -129
  184. package/src/views/index.ts +5 -5
  185. package/src/views/many-tables-tournament-conifrm-exit-dialog.view.ts +37 -37
  186. package/src/views/one-table-tournament-conifrm-exit-dialog.view.ts +37 -37
  187. package/src/views/simple-room-conifrm-exit-dialog.view.ts +37 -37
  188. package/src/views/table-summary.view.ts +104 -104
  189. package/src/views/tournament-buy-ticket-dialog.view.ts +34 -34
@@ -1,16 +1,16 @@
1
- import { ModuleMetadata } from '@nestjs/common';
2
- import { Type } from '@nestjs/common/interfaces/type.interface';
3
- import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
4
- import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
5
-
6
- export interface SupportOptions extends Pick<ModuleMetadata, 'imports'> {
7
- imports?: Array<
8
- Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
9
- >;
10
- inject?: any[];
11
- useFactory?: (...args: any[]) => SupportFactoryOptions;
12
- }
13
-
14
- export interface SupportFactoryOptions {
15
- prometheusNameApp: string;
16
- }
1
+ import { ModuleMetadata } from '@nestjs/common';
2
+ import { Type } from '@nestjs/common/interfaces/type.interface';
3
+ import { DynamicModule } from '@nestjs/common/interfaces/modules/dynamic-module.interface';
4
+ import { ForwardReference } from '@nestjs/common/interfaces/modules/forward-reference.interface';
5
+
6
+ export interface SupportOptions extends Pick<ModuleMetadata, 'imports'> {
7
+ imports?: Array<
8
+ Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
9
+ >;
10
+ inject?: any[];
11
+ useFactory?: (...args: any[]) => SupportFactoryOptions;
12
+ }
13
+
14
+ export interface SupportFactoryOptions {
15
+ prometheusNameApp: string;
16
+ }
@@ -1,35 +1,35 @@
1
- import { DynamicModule, Module, Provider } from '@nestjs/common';
2
-
3
- import { SupportController } from './support.controller';
4
- import { SupportService } from './support.service';
5
- import { SupportOptions } from './support.interfaces';
6
- import { SUPPORT_OPTIONS } from './support.constants';
7
- import { MetricService } from './metric.service';
8
- import { DumpService } from './dump.service';
9
-
10
- @Module({
11
- controllers: [SupportController],
12
- providers: [SupportService, MetricService, DumpService],
13
- })
14
- export class SupportModule {
15
- public static forRoot(options: SupportOptions): DynamicModule {
16
- return {
17
- module: SupportModule,
18
- providers: [{ provide: SUPPORT_OPTIONS, useValue: options }],
19
- };
20
- }
21
-
22
- static forRootAsync(options: SupportOptions): DynamicModule {
23
- return {
24
- module: SupportModule,
25
- imports: options.imports ?? [],
26
- providers: [
27
- {
28
- provide: SUPPORT_OPTIONS,
29
- useFactory: options.useFactory,
30
- inject: options.inject || [],
31
- } as Provider,
32
- ],
33
- };
34
- }
35
- }
1
+ import { DynamicModule, Module, Provider } from '@nestjs/common';
2
+
3
+ import { SupportController } from './support.controller';
4
+ import { SupportService } from './support.service';
5
+ import { SupportOptions } from './support.interfaces';
6
+ import { SUPPORT_OPTIONS } from './support.constants';
7
+ import { MetricService } from './metric.service';
8
+ import { DumpService } from './dump.service';
9
+
10
+ @Module({
11
+ controllers: [SupportController],
12
+ providers: [SupportService, MetricService, DumpService],
13
+ })
14
+ export class SupportModule {
15
+ public static forRoot(options: SupportOptions): DynamicModule {
16
+ return {
17
+ module: SupportModule,
18
+ providers: [{ provide: SUPPORT_OPTIONS, useValue: options }],
19
+ };
20
+ }
21
+
22
+ static forRootAsync(options: SupportOptions): DynamicModule {
23
+ return {
24
+ module: SupportModule,
25
+ imports: options.imports ?? [],
26
+ providers: [
27
+ {
28
+ provide: SUPPORT_OPTIONS,
29
+ useFactory: options.useFactory,
30
+ inject: options.inject || [],
31
+ } as Provider,
32
+ ],
33
+ };
34
+ }
35
+ }
@@ -1,27 +1,27 @@
1
- import { Injectable } from '@nestjs/common';
2
-
3
- import { PlayersManagerService } from '../players-manager/players-manager.service';
4
- import { PlayerConnectedDto } from '../../dto/common/player-connected.dto';
5
- import { SimpleRoomsManagerService } from '../simple-rooms-manager/simple-rooms-manager.service';
6
-
7
- @Injectable()
8
- export class SupportService {
9
- constructor(
10
- private readonly playersManager: PlayersManagerService,
11
- private readonly simpleRoomsManager: SimpleRoomsManagerService,
12
- ) {}
13
-
14
- getUsers(): Array<PlayerConnectedDto> {
15
- return this.playersManager
16
- .getPlayers()
17
- .map((item) => PlayerConnectedDto.fromEntities(item));
18
- }
19
-
20
- techBreakOn(): boolean {
21
- this.simpleRoomsManager
22
- .getRooms()
23
- .forEach((item) => item.handleTechBreakOn());
24
-
25
- return true;
26
- }
27
- }
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ import { PlayersManagerService } from '../players-manager/players-manager.service';
4
+ import { PlayerConnectedDto } from '../../dto/common/player-connected.dto';
5
+ import { SimpleRoomsManagerService } from '../simple-rooms-manager/simple-rooms-manager.service';
6
+
7
+ @Injectable()
8
+ export class SupportService {
9
+ constructor(
10
+ private readonly playersManager: PlayersManagerService,
11
+ private readonly simpleRoomsManager: SimpleRoomsManagerService,
12
+ ) {}
13
+
14
+ getUsers(): Array<PlayerConnectedDto> {
15
+ return this.playersManager
16
+ .getPlayers()
17
+ .map((item) => PlayerConnectedDto.fromEntities(item));
18
+ }
19
+
20
+ techBreakOn(): boolean {
21
+ this.simpleRoomsManager
22
+ .getRooms()
23
+ .forEach((item) => item.handleTechBreakOn());
24
+
25
+ return true;
26
+ }
27
+ }
package/src/utils/date.ts CHANGED
@@ -1,7 +1,7 @@
1
- export function getHours(timeStr: string) {
2
- return parseInt(timeStr.substring(0, 2), 10);
3
- }
4
-
5
- export function getMinutes(timeStr: string) {
6
- return parseInt(timeStr.substring(3, 5), 10);
7
- }
1
+ export function getHours(timeStr: string) {
2
+ return parseInt(timeStr.substring(0, 2), 10);
3
+ }
4
+
5
+ export function getMinutes(timeStr: string) {
6
+ return parseInt(timeStr.substring(3, 5), 10);
7
+ }
@@ -1,129 +1,129 @@
1
- import { Connection } from 'mongoose';
2
- import {
3
- GameResultRepository,
4
- OneTableTournamentRoomsRepository,
5
- ManyTablesTournamentRoomsRepository,
6
- UsersRepository,
7
- } from 'jp.db.schemas';
8
- import { GameMaster, TournamentMaster } from 'jp.ms.common.engine';
9
-
10
- export function getGameTableResults(master: GameMaster) {
11
- return {
12
- gameType: master.getRoom().getGameType(),
13
- gameId: master.getGameRound()?.getId() ?? '',
14
- roomId: master.getRoom().getId(),
15
- date: new Date(),
16
- pot: master.getGameRound()?.getPot() ?? 0,
17
- players: master
18
- .getTable()
19
- .getPlayers()
20
- .map((item) => ({
21
- userId: item.id,
22
- fullName: item.fullName,
23
- profit: item.profit,
24
- figures: [],
25
- })),
26
- winners: master
27
- .getGameResultHelper()
28
- .getWinners()
29
- .map((item) => ({
30
- userId: item.id,
31
- fullName: item.fullName,
32
- profit: item.profit,
33
- figures: [],
34
- })),
35
- history:
36
- master
37
- .getGameRound()
38
- ?.getHistory()
39
- .map((item) => ({
40
- userId: item.userId,
41
- fullName: item.fullName,
42
- date: item.date,
43
- actionType: item.actionType,
44
- state: item.state,
45
- turnNumber: item.turnNumber,
46
- moveAction: item.move?.action,
47
- moveData: item.move ?? undefined,
48
- figures:
49
- item.figures?.map((item) => ({
50
- figureId: item.id,
51
- type: item.type,
52
- name: item.getName(),
53
- })) ?? [],
54
- })) ?? [],
55
- };
56
- }
57
-
58
- export async function saveGameTablesResult(
59
- master: GameMaster,
60
- connection: Connection,
61
- gameResultRepository: GameResultRepository,
62
- usersRepository: UsersRepository,
63
- saveNewBalance: boolean,
64
- ) {
65
- const userGameResult = master
66
- .getTable()
67
- .getPlayers()
68
- .map((player) => {
69
- return {
70
- userId: player.id,
71
- balanceAdding: saveNewBalance ? player.profit : 0,
72
- experienceAdding: master.levelHelper.getNewExperienceAmount(player),
73
- levelAdding: master.levelHelper.getNewLevelAdding(
74
- player.level,
75
- player.experience,
76
- ),
77
- };
78
- });
79
-
80
- const session = await connection.startSession();
81
- session.startTransaction();
82
-
83
- try {
84
- await gameResultRepository.createGameResult(getGameTableResults(master));
85
- await usersRepository.saveGameResult(userGameResult);
86
-
87
- await session.commitTransaction();
88
- } catch (error) {
89
- await session.abortTransaction();
90
- throw error;
91
- } finally {
92
- await session.endSession();
93
- }
94
- }
95
-
96
- export async function saveTournamentResult(
97
- master: TournamentMaster,
98
- connection: Connection,
99
- tournamentRepository:
100
- | OneTableTournamentRoomsRepository
101
- | ManyTablesTournamentRoomsRepository,
102
- usersRepository: UsersRepository,
103
- ) {
104
- const userTournamentResult = master.getTournamentResult().map((player) => {
105
- return {
106
- userId: player.playerId,
107
- balanceAdding: player.profit,
108
- experienceAdding: 0,
109
- levelAdding: 0,
110
- };
111
- });
112
-
113
- const session = await connection.startSession();
114
- session.startTransaction();
115
-
116
- try {
117
- await usersRepository.saveGameResult(userTournamentResult);
118
- await tournamentRepository.finishTournament(
119
- master.getTournamentId(),
120
- master.getTournamentResult(),
121
- );
122
- await session.commitTransaction();
123
- } catch (error) {
124
- await session.abortTransaction();
125
- throw error;
126
- } finally {
127
- await session.endSession();
128
- }
129
- }
1
+ import { Connection } from 'mongoose';
2
+ import {
3
+ GameResultRepository,
4
+ OneTableTournamentRoomsRepository,
5
+ ManyTablesTournamentRoomsRepository,
6
+ UsersRepository,
7
+ } from 'jp.db.schemas';
8
+ import { GameMaster, TournamentMaster } from 'jp.ms.common.engine';
9
+
10
+ export function getGameTableResults(master: GameMaster) {
11
+ return {
12
+ gameType: master.getRoom().getGameType(),
13
+ gameId: master.getGameRound()?.getId() ?? '',
14
+ roomId: master.getRoom().getId(),
15
+ date: new Date(),
16
+ pot: master.getGameRound()?.getPot() ?? 0,
17
+ players: master
18
+ .getTable()
19
+ .getPlayers()
20
+ .map((item) => ({
21
+ userId: item.id,
22
+ fullName: item.fullName,
23
+ profit: item.profit,
24
+ figures: [],
25
+ })),
26
+ winners: master
27
+ .getGameResultHelper()
28
+ .getWinners()
29
+ .map((item) => ({
30
+ userId: item.id,
31
+ fullName: item.fullName,
32
+ profit: item.profit,
33
+ figures: [],
34
+ })),
35
+ history:
36
+ master
37
+ .getGameRound()
38
+ ?.getHistory()
39
+ .map((item) => ({
40
+ userId: item.userId,
41
+ fullName: item.fullName,
42
+ date: item.date,
43
+ actionType: item.actionType,
44
+ state: item.state,
45
+ turnNumber: item.turnNumber,
46
+ moveAction: item.move?.action,
47
+ moveData: item.move ?? undefined,
48
+ figures:
49
+ item.figures?.map((item) => ({
50
+ figureId: item.id,
51
+ type: item.type,
52
+ name: item.getName(),
53
+ })) ?? [],
54
+ })) ?? [],
55
+ };
56
+ }
57
+
58
+ export async function saveGameTablesResult(
59
+ master: GameMaster,
60
+ connection: Connection,
61
+ gameResultRepository: GameResultRepository,
62
+ usersRepository: UsersRepository,
63
+ saveNewBalance: boolean,
64
+ ) {
65
+ const userGameResult = master
66
+ .getTable()
67
+ .getPlayers()
68
+ .map((player) => {
69
+ return {
70
+ userId: player.id,
71
+ balanceAdding: saveNewBalance ? player.profit : 0,
72
+ experienceAdding: master.levelHelper.getNewExperienceAmount(player),
73
+ levelAdding: master.levelHelper.getNewLevelAdding(
74
+ player.level,
75
+ player.experience,
76
+ ),
77
+ };
78
+ });
79
+
80
+ const session = await connection.startSession();
81
+ session.startTransaction();
82
+
83
+ try {
84
+ await gameResultRepository.createGameResult(getGameTableResults(master));
85
+ await usersRepository.saveGameResult(userGameResult);
86
+
87
+ await session.commitTransaction();
88
+ } catch (error) {
89
+ await session.abortTransaction();
90
+ throw error;
91
+ } finally {
92
+ await session.endSession();
93
+ }
94
+ }
95
+
96
+ export async function saveTournamentResult(
97
+ master: TournamentMaster,
98
+ connection: Connection,
99
+ tournamentRepository:
100
+ | OneTableTournamentRoomsRepository
101
+ | ManyTablesTournamentRoomsRepository,
102
+ usersRepository: UsersRepository,
103
+ ) {
104
+ const userTournamentResult = master.getTournamentResult().map((player) => {
105
+ return {
106
+ userId: player.playerId,
107
+ balanceAdding: player.profit,
108
+ experienceAdding: 0,
109
+ levelAdding: 0,
110
+ };
111
+ });
112
+
113
+ const session = await connection.startSession();
114
+ session.startTransaction();
115
+
116
+ try {
117
+ await usersRepository.saveGameResult(userTournamentResult);
118
+ await tournamentRepository.finishTournament(
119
+ master.getTournamentId(),
120
+ master.getTournamentResult(),
121
+ );
122
+ await session.commitTransaction();
123
+ } catch (error) {
124
+ await session.abortTransaction();
125
+ throw error;
126
+ } finally {
127
+ await session.endSession();
128
+ }
129
+ }
@@ -1,5 +1,5 @@
1
- export { TournamentBuyTicketDialogView } from './tournament-buy-ticket-dialog.view';
2
- export { SimpleRoomConfirmExitDialogView } from './simple-room-conifrm-exit-dialog.view';
3
- export { ManyTablesTournamentConfirmExitDialogView } from './many-tables-tournament-conifrm-exit-dialog.view';
4
- export { OneTableTournamentConfirmExitDialogView } from './one-table-tournament-conifrm-exit-dialog.view';
5
- export { TableSummaryView } from './table-summary.view';
1
+ export { TournamentBuyTicketDialogView } from './tournament-buy-ticket-dialog.view';
2
+ export { SimpleRoomConfirmExitDialogView } from './simple-room-conifrm-exit-dialog.view';
3
+ export { ManyTablesTournamentConfirmExitDialogView } from './many-tables-tournament-conifrm-exit-dialog.view';
4
+ export { OneTableTournamentConfirmExitDialogView } from './one-table-tournament-conifrm-exit-dialog.view';
5
+ export { TableSummaryView } from './table-summary.view';
@@ -1,37 +1,37 @@
1
- import {
2
- UniversalScreenDialogView,
3
- AppScreenDialogIdEnum,
4
- StandardDialogComponent,
5
- FullButtonsButtonsComponent,
6
- TextButtonComponent,
7
- } from 'jp.common.models';
8
-
9
- export class ManyTablesTournamentConfirmExitDialogView extends UniversalScreenDialogView {
10
- build() {
11
- return new StandardDialogComponent(
12
- AppScreenDialogIdEnum.DIALOG_MANY_TABLES_TOURNAMENT_CONFIRM_EXIT,
13
- this.localeService.t(
14
- 'common.many.tables.tournament.screen.dialog.confirm.exit.game.title',
15
- { lang: this.lang },
16
- ),
17
- this.localeService.t(
18
- 'common.many.tables.tournament.screen.dialog.confirm.exit.game.message',
19
- { lang: this.lang },
20
- ),
21
- new FullButtonsButtonsComponent(
22
- new TextButtonComponent(
23
- this.localeService.t(
24
- 'common.many.tables.tournament.screen.dialog.confirm.exit.game.ok',
25
- { lang: this.lang },
26
- ),
27
- ),
28
- new TextButtonComponent(
29
- this.localeService.t(
30
- 'common.many.tables.tournament.screen.dialog.confirm.exit.game.cancel',
31
- { lang: this.lang },
32
- ),
33
- ),
34
- ),
35
- );
36
- }
37
- }
1
+ import {
2
+ UniversalScreenDialogView,
3
+ AppScreenDialogIdEnum,
4
+ StandardDialogComponent,
5
+ FullButtonsButtonsComponent,
6
+ TextButtonComponent,
7
+ } from 'jp.common.models';
8
+
9
+ export class ManyTablesTournamentConfirmExitDialogView extends UniversalScreenDialogView {
10
+ build() {
11
+ return new StandardDialogComponent(
12
+ AppScreenDialogIdEnum.DIALOG_MANY_TABLES_TOURNAMENT_CONFIRM_EXIT,
13
+ this.localeService.t(
14
+ 'common.many.tables.tournament.screen.dialog.confirm.exit.game.title',
15
+ { lang: this.lang },
16
+ ),
17
+ this.localeService.t(
18
+ 'common.many.tables.tournament.screen.dialog.confirm.exit.game.message',
19
+ { lang: this.lang },
20
+ ),
21
+ new FullButtonsButtonsComponent(
22
+ new TextButtonComponent(
23
+ this.localeService.t(
24
+ 'common.many.tables.tournament.screen.dialog.confirm.exit.game.ok',
25
+ { lang: this.lang },
26
+ ),
27
+ ),
28
+ new TextButtonComponent(
29
+ this.localeService.t(
30
+ 'common.many.tables.tournament.screen.dialog.confirm.exit.game.cancel',
31
+ { lang: this.lang },
32
+ ),
33
+ ),
34
+ ),
35
+ );
36
+ }
37
+ }
@@ -1,37 +1,37 @@
1
- import {
2
- UniversalScreenDialogView,
3
- AppScreenDialogIdEnum,
4
- StandardDialogComponent,
5
- FullButtonsButtonsComponent,
6
- TextButtonComponent,
7
- } from 'jp.common.models';
8
-
9
- export class OneTableTournamentConfirmExitDialogView extends UniversalScreenDialogView {
10
- build() {
11
- return new StandardDialogComponent(
12
- AppScreenDialogIdEnum.DIALOG_ONE_TABLE_TOURNAMENT_CONFIRM_EXIT,
13
- this.localeService.t(
14
- 'common.one.table.tournament.screen.dialog.confirm.exit.game.title',
15
- { lang: this.lang },
16
- ),
17
- this.localeService.t(
18
- 'common.one.table.tournament.screen.dialog.confirm.exit.game.message',
19
- { lang: this.lang },
20
- ),
21
- new FullButtonsButtonsComponent(
22
- new TextButtonComponent(
23
- this.localeService.t(
24
- 'common.one.table.tournament.screen.dialog.confirm.exit.game.ok',
25
- { lang: this.lang },
26
- ),
27
- ),
28
- new TextButtonComponent(
29
- this.localeService.t(
30
- 'common.one.table.tournament.screen.dialog.confirm.exit.game.cancel',
31
- { lang: this.lang },
32
- ),
33
- ),
34
- ),
35
- );
36
- }
37
- }
1
+ import {
2
+ UniversalScreenDialogView,
3
+ AppScreenDialogIdEnum,
4
+ StandardDialogComponent,
5
+ FullButtonsButtonsComponent,
6
+ TextButtonComponent,
7
+ } from 'jp.common.models';
8
+
9
+ export class OneTableTournamentConfirmExitDialogView extends UniversalScreenDialogView {
10
+ build() {
11
+ return new StandardDialogComponent(
12
+ AppScreenDialogIdEnum.DIALOG_ONE_TABLE_TOURNAMENT_CONFIRM_EXIT,
13
+ this.localeService.t(
14
+ 'common.one.table.tournament.screen.dialog.confirm.exit.game.title',
15
+ { lang: this.lang },
16
+ ),
17
+ this.localeService.t(
18
+ 'common.one.table.tournament.screen.dialog.confirm.exit.game.message',
19
+ { lang: this.lang },
20
+ ),
21
+ new FullButtonsButtonsComponent(
22
+ new TextButtonComponent(
23
+ this.localeService.t(
24
+ 'common.one.table.tournament.screen.dialog.confirm.exit.game.ok',
25
+ { lang: this.lang },
26
+ ),
27
+ ),
28
+ new TextButtonComponent(
29
+ this.localeService.t(
30
+ 'common.one.table.tournament.screen.dialog.confirm.exit.game.cancel',
31
+ { lang: this.lang },
32
+ ),
33
+ ),
34
+ ),
35
+ );
36
+ }
37
+ }
@@ -1,37 +1,37 @@
1
- import {
2
- UniversalScreenDialogView,
3
- AppScreenDialogIdEnum,
4
- StandardDialogComponent,
5
- FullButtonsButtonsComponent,
6
- TextButtonComponent,
7
- } from 'jp.common.models';
8
-
9
- export class SimpleRoomConfirmExitDialogView extends UniversalScreenDialogView {
10
- build() {
11
- return new StandardDialogComponent(
12
- AppScreenDialogIdEnum.DIALOG_SIMPLE_ROOM_CONFIRM_EXIT,
13
- this.localeService.t(
14
- 'common.simple.room.screen.dialog.confirm.exit.game.title',
15
- { lang: this.lang },
16
- ),
17
- this.localeService.t(
18
- 'common.simple.room.screen.dialog.confirm.exit.game.message',
19
- { lang: this.lang },
20
- ),
21
- new FullButtonsButtonsComponent(
22
- new TextButtonComponent(
23
- this.localeService.t(
24
- 'common.simple.room.screen.dialog.confirm.exit.game.ok',
25
- { lang: this.lang },
26
- ),
27
- ),
28
- new TextButtonComponent(
29
- this.localeService.t(
30
- 'common.simple.room.screen.dialog.confirm.exit.game.cancel',
31
- { lang: this.lang },
32
- ),
33
- ),
34
- ),
35
- );
36
- }
37
- }
1
+ import {
2
+ UniversalScreenDialogView,
3
+ AppScreenDialogIdEnum,
4
+ StandardDialogComponent,
5
+ FullButtonsButtonsComponent,
6
+ TextButtonComponent,
7
+ } from 'jp.common.models';
8
+
9
+ export class SimpleRoomConfirmExitDialogView extends UniversalScreenDialogView {
10
+ build() {
11
+ return new StandardDialogComponent(
12
+ AppScreenDialogIdEnum.DIALOG_SIMPLE_ROOM_CONFIRM_EXIT,
13
+ this.localeService.t(
14
+ 'common.simple.room.screen.dialog.confirm.exit.game.title',
15
+ { lang: this.lang },
16
+ ),
17
+ this.localeService.t(
18
+ 'common.simple.room.screen.dialog.confirm.exit.game.message',
19
+ { lang: this.lang },
20
+ ),
21
+ new FullButtonsButtonsComponent(
22
+ new TextButtonComponent(
23
+ this.localeService.t(
24
+ 'common.simple.room.screen.dialog.confirm.exit.game.ok',
25
+ { lang: this.lang },
26
+ ),
27
+ ),
28
+ new TextButtonComponent(
29
+ this.localeService.t(
30
+ 'common.simple.room.screen.dialog.confirm.exit.game.cancel',
31
+ { lang: this.lang },
32
+ ),
33
+ ),
34
+ ),
35
+ );
36
+ }
37
+ }