jp.db.schemas 2.1.13 → 2.1.15
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/models/activity-log-user-login.interface copy.d.ts +11 -0
- package/dist/models/activity-log-user-login.interface copy.d.ts.map +1 -0
- package/dist/models/activity-log-user-login.interface copy.js +3 -0
- package/dist/models/activity-log-user-login.interface copy.js.map +1 -0
- package/dist/repositories/premium.repository.d.ts +1 -1
- package/dist/repositories/premium.repository.d.ts.map +1 -1
- package/dist/repositories/premium.repository.js +2 -5
- package/dist/repositories/premium.repository.js.map +1 -1
- package/dist/repositories/purchase.repository.d.ts +1 -1
- package/dist/repositories/purchase.repository.js +1 -1
- package/dist/repositories/rule.repository.d.ts +1 -1
- package/dist/repositories/rule.repository.d.ts.map +1 -1
- package/dist/repositories/rule.repository.js +2 -5
- package/dist/repositories/rule.repository.js.map +1 -1
- package/dist/repositories/welcome.repository.d.ts +1 -1
- package/dist/repositories/welcome.repository.d.ts.map +1 -1
- package/dist/repositories/welcome.repository.js +2 -5
- package/dist/repositories/welcome.repository.js.map +1 -1
- package/package.json +31 -31
- package/readme.md +3 -3
- package/src/index.ts +251 -251
- package/src/models/activity-log-user-login.interface copy.ts +10 -0
- package/src/models/activity-log-user-login.interface.ts +9 -9
- package/src/models/activity-log.enum.ts +7 -7
- package/src/models/currency.enum.ts +4 -4
- package/src/models/rating-add-bulk-item.interface.ts +6 -6
- package/src/models/rating-monthly-result.interface.ts +10 -10
- package/src/models/tournament-participant.interface.ts +5 -5
- package/src/models/tournament-status.enum.ts +6 -6
- package/src/models/tournament-template.enum.ts +3 -3
- package/src/models/tournament-winner.interface.ts +7 -7
- package/src/repositories/achievement.repository.ts +18 -18
- package/src/repositories/activity-log.repository.ts +110 -110
- package/src/repositories/admin.repository.ts +23 -23
- package/src/repositories/article.repository.ts +33 -33
- package/src/repositories/balance-history.repository.ts +15 -15
- package/src/repositories/banners.repository.ts +54 -54
- package/src/repositories/complains.repository.ts +30 -30
- package/src/repositories/daily-bonus.repository.ts +25 -25
- package/src/repositories/friend.repository.ts +19 -19
- package/src/repositories/game-result.repository.ts +15 -15
- package/src/repositories/game-statistic.repository.ts +21 -21
- package/src/repositories/index.ts +57 -57
- package/src/repositories/menu.repository.ts +21 -21
- package/src/repositories/notification.repository.ts +54 -54
- package/src/repositories/premium.repository.ts +17 -19
- package/src/repositories/products.repository.ts +29 -29
- package/src/repositories/purchase.repository.ts +95 -95
- package/src/repositories/rating.repository.ts +83 -83
- package/src/repositories/rooms.repository.ts +17 -17
- package/src/repositories/rule.repository.ts +17 -19
- package/src/repositories/scheduled-tournaments.repository.ts +30 -30
- package/src/repositories/servers.repository.ts +18 -18
- package/src/repositories/setting.repository.ts +19 -19
- package/src/repositories/simple-rooms.repository.ts +17 -17
- package/src/repositories/tournament-many-tables-rooms.repository.ts +132 -132
- package/src/repositories/tournament-one-table-rooms.repository.ts +106 -106
- package/src/repositories/users.repository.ts +151 -151
- package/src/repositories/welcome.repository.ts +17 -19
- package/src/schemas/achievement.schema.ts +40 -40
- package/src/schemas/activity_log.schema.ts +37 -37
- package/src/schemas/admin.schema.ts +22 -22
- package/src/schemas/article.schema.ts +37 -37
- package/src/schemas/balance_history.schema.ts +37 -37
- package/src/schemas/banner.schema.ts +40 -40
- package/src/schemas/channel_message.schema.ts +31 -31
- package/src/schemas/complain.schema.ts +46 -46
- package/src/schemas/daily_bonus.schema.ts +56 -56
- package/src/schemas/feature.schema.ts +28 -28
- package/src/schemas/friend.schema.ts +50 -50
- package/src/schemas/game_result.schema.ts +68 -68
- package/src/schemas/game_statistic.schema.ts +40 -40
- package/src/schemas/menu.schema.ts +40 -40
- package/src/schemas/notification.schema.ts +61 -61
- package/src/schemas/premium.schema.ts +45 -45
- package/src/schemas/product.schema.ts +123 -123
- package/src/schemas/purchase.schema.ts +58 -58
- package/src/schemas/purchase_channel.schema.ts +31 -31
- package/src/schemas/rating.schema.ts +37 -37
- package/src/schemas/rooms.schema.ts +63 -63
- package/src/schemas/rule.schema.ts +45 -45
- package/src/schemas/scheduled_tournament.schema.ts +93 -93
- package/src/schemas/server.schema.ts +22 -22
- package/src/schemas/setting.schema.ts +55 -55
- package/src/schemas/simple_rooms.schema.ts +46 -46
- package/src/schemas/tournament_many_tables_rooms.schema.ts +84 -84
- package/src/schemas/tournament_one_table_rooms.schema.ts +81 -81
- package/src/schemas/user.fb.schema.ts +33 -33
- package/src/schemas/user.google.schema.ts +24 -24
- package/src/schemas/user.ok.schema.ts +52 -52
- package/src/schemas/user.schema.ts +182 -182
- package/src/schemas/user.tg.schema.ts +30 -30
- package/src/schemas/user.vk.schema.ts +70 -70
- package/src/schemas/user.ya.schema.ts +24 -24
- package/src/schemas/welcome.schema.ts +45 -45
- package/src/utils.ts +3 -3
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
TournamentManyTablesRoom,
|
|
7
|
-
TournamentManyTablesRoomDocument,
|
|
8
|
-
TournamentOneTableRoomDocument,
|
|
9
|
-
} from '../';
|
|
10
|
-
import { TournamentStatusEnum } from '../models/tournament-status.enum';
|
|
11
|
-
import { ITournamentWinner } from '../models/tournament-winner.interface';
|
|
12
|
-
import { TournamentTemplateEnum } from '../models/tournament-template.enum';
|
|
13
|
-
import { ITournamentParticipant } from '../models/tournament-participant.interface';
|
|
14
|
-
|
|
15
|
-
@Injectable()
|
|
16
|
-
export class TournamentManyTablesRoomsRepository {
|
|
17
|
-
constructor (@InjectModel(TournamentManyTablesRoom.name) private tournamentModel: Model<TournamentManyTablesRoomDocument>) {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async findTournamentById (tournamentId: string): Promise<TournamentManyTablesRoomDocument | null> {
|
|
21
|
-
return this.tournamentModel
|
|
22
|
-
.findById(tournamentId)
|
|
23
|
-
.exec();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async findTemplateById (templateId: string, gameType: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
27
|
-
return this.tournamentModel
|
|
28
|
-
.findOne({ templateId, gameType })
|
|
29
|
-
.exec();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async findTournaments (gameType: string): Promise<Array<TournamentManyTablesRoomDocument>> {
|
|
33
|
-
return this.tournamentModel
|
|
34
|
-
.find({ gameType, isTemplate: false })
|
|
35
|
-
.exec();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async findWaitingTournamentByDate (gameType: string, startDate: Date, endDate: Date): Promise<TournamentOneTableRoomDocument | null> {
|
|
39
|
-
return this.tournamentModel
|
|
40
|
-
.findOne({
|
|
41
|
-
gameType,
|
|
42
|
-
status: TournamentStatusEnum.STATE_WAITING_FOR_START,
|
|
43
|
-
isTemplate: false,
|
|
44
|
-
scheduleDate: { $gte: startDate, $lt: endDate },
|
|
45
|
-
})
|
|
46
|
-
.exec();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async createTournament (tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
|
|
50
|
-
return this.tournamentModel.create(tournament)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async scheduleTournamentFromMasterTemplate (gameType: string, scheduleDate: Date): Promise<TournamentManyTablesRoomDocument> {
|
|
54
|
-
const masterTemplate = await this.findTemplateById(TournamentTemplateEnum.MASTER, gameType);
|
|
55
|
-
|
|
56
|
-
return this.createTournament({
|
|
57
|
-
title: masterTemplate.title,
|
|
58
|
-
subtitle: masterTemplate.subtitle,
|
|
59
|
-
description: masterTemplate.description,
|
|
60
|
-
tableSize: masterTemplate.tableSize,
|
|
61
|
-
bet: masterTemplate.bet,
|
|
62
|
-
ticketPrice: masterTemplate.ticketPrice,
|
|
63
|
-
roomType: masterTemplate.roomType,
|
|
64
|
-
gameType: masterTemplate.gameType,
|
|
65
|
-
rulesType: masterTemplate.rulesType,
|
|
66
|
-
deckType: masterTemplate.deckType,
|
|
67
|
-
maxParticipants: masterTemplate.maxParticipants,
|
|
68
|
-
participants: masterTemplate.participants,
|
|
69
|
-
status: masterTemplate.status,
|
|
70
|
-
winners: masterTemplate.winners,
|
|
71
|
-
createDate: new Date(),
|
|
72
|
-
isTemplate: false,
|
|
73
|
-
templateId: undefined,
|
|
74
|
-
scheduleDate,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async updateTournament (tournamentId: string, tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
|
|
79
|
-
return this.tournamentModel.findByIdAndUpdate(
|
|
80
|
-
tournamentId,
|
|
81
|
-
{
|
|
82
|
-
$set: {
|
|
83
|
-
...tournament,
|
|
84
|
-
},
|
|
85
|
-
}).exec();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async removeTournament (tournamentId: string): Promise<void> {
|
|
89
|
-
await this.tournamentModel.findByIdAndDelete(tournamentId);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async startTournament (tournamentId: string): Promise<void> {
|
|
93
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
94
|
-
tournamentId,
|
|
95
|
-
{
|
|
96
|
-
$set: {
|
|
97
|
-
startDate: new Date(),
|
|
98
|
-
status: TournamentStatusEnum.STATE_IN_PROGRESS,
|
|
99
|
-
},
|
|
100
|
-
}).exec();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async cancelTournament (tournamentId: string): Promise<void> {
|
|
104
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
105
|
-
tournamentId,
|
|
106
|
-
{
|
|
107
|
-
$set: {
|
|
108
|
-
finishDate: new Date(),
|
|
109
|
-
status: TournamentStatusEnum.STATE_CANCELLED,
|
|
110
|
-
},
|
|
111
|
-
}).exec();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async finishTournament (tournamentId: string, winners: Array<ITournamentWinner>): Promise<void> {
|
|
115
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
116
|
-
tournamentId,
|
|
117
|
-
{
|
|
118
|
-
$set: {
|
|
119
|
-
finishDate: new Date(),
|
|
120
|
-
status: TournamentStatusEnum.STATE_FINISHED,
|
|
121
|
-
winners,
|
|
122
|
-
},
|
|
123
|
-
}).exec();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async addPlayerToParticipants (tournamentId: string, player: ITournamentParticipant): Promise<void> {
|
|
127
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
128
|
-
tournamentId,
|
|
129
|
-
{ $push: { participants: player } })
|
|
130
|
-
.exec();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
TournamentManyTablesRoom,
|
|
7
|
+
TournamentManyTablesRoomDocument,
|
|
8
|
+
TournamentOneTableRoomDocument,
|
|
9
|
+
} from '../';
|
|
10
|
+
import { TournamentStatusEnum } from '../models/tournament-status.enum';
|
|
11
|
+
import { ITournamentWinner } from '../models/tournament-winner.interface';
|
|
12
|
+
import { TournamentTemplateEnum } from '../models/tournament-template.enum';
|
|
13
|
+
import { ITournamentParticipant } from '../models/tournament-participant.interface';
|
|
14
|
+
|
|
15
|
+
@Injectable()
|
|
16
|
+
export class TournamentManyTablesRoomsRepository {
|
|
17
|
+
constructor (@InjectModel(TournamentManyTablesRoom.name) private tournamentModel: Model<TournamentManyTablesRoomDocument>) {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async findTournamentById (tournamentId: string): Promise<TournamentManyTablesRoomDocument | null> {
|
|
21
|
+
return this.tournamentModel
|
|
22
|
+
.findById(tournamentId)
|
|
23
|
+
.exec();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async findTemplateById (templateId: string, gameType: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
27
|
+
return this.tournamentModel
|
|
28
|
+
.findOne({ templateId, gameType })
|
|
29
|
+
.exec();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async findTournaments (gameType: string): Promise<Array<TournamentManyTablesRoomDocument>> {
|
|
33
|
+
return this.tournamentModel
|
|
34
|
+
.find({ gameType, isTemplate: false })
|
|
35
|
+
.exec();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async findWaitingTournamentByDate (gameType: string, startDate: Date, endDate: Date): Promise<TournamentOneTableRoomDocument | null> {
|
|
39
|
+
return this.tournamentModel
|
|
40
|
+
.findOne({
|
|
41
|
+
gameType,
|
|
42
|
+
status: TournamentStatusEnum.STATE_WAITING_FOR_START,
|
|
43
|
+
isTemplate: false,
|
|
44
|
+
scheduleDate: { $gte: startDate, $lt: endDate },
|
|
45
|
+
})
|
|
46
|
+
.exec();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async createTournament (tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
|
|
50
|
+
return this.tournamentModel.create(tournament)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async scheduleTournamentFromMasterTemplate (gameType: string, scheduleDate: Date): Promise<TournamentManyTablesRoomDocument> {
|
|
54
|
+
const masterTemplate = await this.findTemplateById(TournamentTemplateEnum.MASTER, gameType);
|
|
55
|
+
|
|
56
|
+
return this.createTournament({
|
|
57
|
+
title: masterTemplate.title,
|
|
58
|
+
subtitle: masterTemplate.subtitle,
|
|
59
|
+
description: masterTemplate.description,
|
|
60
|
+
tableSize: masterTemplate.tableSize,
|
|
61
|
+
bet: masterTemplate.bet,
|
|
62
|
+
ticketPrice: masterTemplate.ticketPrice,
|
|
63
|
+
roomType: masterTemplate.roomType,
|
|
64
|
+
gameType: masterTemplate.gameType,
|
|
65
|
+
rulesType: masterTemplate.rulesType,
|
|
66
|
+
deckType: masterTemplate.deckType,
|
|
67
|
+
maxParticipants: masterTemplate.maxParticipants,
|
|
68
|
+
participants: masterTemplate.participants,
|
|
69
|
+
status: masterTemplate.status,
|
|
70
|
+
winners: masterTemplate.winners,
|
|
71
|
+
createDate: new Date(),
|
|
72
|
+
isTemplate: false,
|
|
73
|
+
templateId: undefined,
|
|
74
|
+
scheduleDate,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async updateTournament (tournamentId: string, tournament: Partial<TournamentManyTablesRoom>): Promise<TournamentManyTablesRoomDocument> {
|
|
79
|
+
return this.tournamentModel.findByIdAndUpdate(
|
|
80
|
+
tournamentId,
|
|
81
|
+
{
|
|
82
|
+
$set: {
|
|
83
|
+
...tournament,
|
|
84
|
+
},
|
|
85
|
+
}).exec();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async removeTournament (tournamentId: string): Promise<void> {
|
|
89
|
+
await this.tournamentModel.findByIdAndDelete(tournamentId);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async startTournament (tournamentId: string): Promise<void> {
|
|
93
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
94
|
+
tournamentId,
|
|
95
|
+
{
|
|
96
|
+
$set: {
|
|
97
|
+
startDate: new Date(),
|
|
98
|
+
status: TournamentStatusEnum.STATE_IN_PROGRESS,
|
|
99
|
+
},
|
|
100
|
+
}).exec();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async cancelTournament (tournamentId: string): Promise<void> {
|
|
104
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
105
|
+
tournamentId,
|
|
106
|
+
{
|
|
107
|
+
$set: {
|
|
108
|
+
finishDate: new Date(),
|
|
109
|
+
status: TournamentStatusEnum.STATE_CANCELLED,
|
|
110
|
+
},
|
|
111
|
+
}).exec();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async finishTournament (tournamentId: string, winners: Array<ITournamentWinner>): Promise<void> {
|
|
115
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
116
|
+
tournamentId,
|
|
117
|
+
{
|
|
118
|
+
$set: {
|
|
119
|
+
finishDate: new Date(),
|
|
120
|
+
status: TournamentStatusEnum.STATE_FINISHED,
|
|
121
|
+
winners,
|
|
122
|
+
},
|
|
123
|
+
}).exec();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async addPlayerToParticipants (tournamentId: string, player: ITournamentParticipant): Promise<void> {
|
|
127
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
128
|
+
tournamentId,
|
|
129
|
+
{ $push: { participants: player } })
|
|
130
|
+
.exec();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { TournamentOneTableRoom, TournamentOneTableRoomDocument } from '../';
|
|
6
|
-
import { ITournamentParticipant } from '../models/tournament-participant.interface';
|
|
7
|
-
import { TournamentStatusEnum } from '../models/tournament-status.enum';
|
|
8
|
-
import { ITournamentWinner } from '../models/tournament-winner.interface';
|
|
9
|
-
import { TournamentTemplateEnum } from '../models/tournament-template.enum';
|
|
10
|
-
|
|
11
|
-
@Injectable()
|
|
12
|
-
export class TournamentOneTableRoomsRepository {
|
|
13
|
-
constructor (@InjectModel(TournamentOneTableRoom.name) private tournamentModel: Model<TournamentOneTableRoomDocument>) {
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async findTournamentById (tournamentId: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
17
|
-
return this.tournamentModel
|
|
18
|
-
.findById(tournamentId)
|
|
19
|
-
.exec();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async findTemplateById (templateId: string, gameType: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
23
|
-
return this.tournamentModel
|
|
24
|
-
.findOne({ isTemplate: true, templateId, gameType })
|
|
25
|
-
.exec();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async findTournaments (gameType: string): Promise<Array<TournamentOneTableRoomDocument>> {
|
|
29
|
-
return this.tournamentModel
|
|
30
|
-
.find({ gameType, isTemplate: false })
|
|
31
|
-
.exec();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async findWaitingTournament (gameType: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
35
|
-
return this.tournamentModel
|
|
36
|
-
.findOne({
|
|
37
|
-
gameType,
|
|
38
|
-
status: TournamentStatusEnum.STATE_WAITING_FOR_START,
|
|
39
|
-
isTemplate: false,
|
|
40
|
-
})
|
|
41
|
-
.exec();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async createTournament (tournament: Partial<TournamentOneTableRoom>): Promise<TournamentOneTableRoomDocument> {
|
|
45
|
-
return this.tournamentModel.create(tournament);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async createTournamentFromMasterTemplate (gameType: string): Promise<TournamentOneTableRoomDocument> {
|
|
49
|
-
const masterTemplate = await this.findTemplateById(TournamentTemplateEnum.MASTER, gameType);
|
|
50
|
-
|
|
51
|
-
return this.createTournament({
|
|
52
|
-
title: masterTemplate.title,
|
|
53
|
-
subtitle: masterTemplate.subtitle,
|
|
54
|
-
description: masterTemplate.description,
|
|
55
|
-
tableSize: masterTemplate.tableSize,
|
|
56
|
-
bet: masterTemplate.bet,
|
|
57
|
-
ticketPrice: masterTemplate.ticketPrice,
|
|
58
|
-
roomType: masterTemplate.roomType,
|
|
59
|
-
gameType: masterTemplate.gameType,
|
|
60
|
-
rulesType: masterTemplate.rulesType,
|
|
61
|
-
deckType: masterTemplate.deckType,
|
|
62
|
-
maxParticipants: masterTemplate.maxParticipants,
|
|
63
|
-
participants: masterTemplate.participants,
|
|
64
|
-
status: masterTemplate.status,
|
|
65
|
-
winners: masterTemplate.winners,
|
|
66
|
-
createDate: new Date(),
|
|
67
|
-
isTemplate: false,
|
|
68
|
-
templateId: undefined,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async startTournament (tournamentId: string, participants: Array<ITournamentParticipant>): Promise<void> {
|
|
73
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
74
|
-
tournamentId,
|
|
75
|
-
{
|
|
76
|
-
$set: {
|
|
77
|
-
startDate: new Date(),
|
|
78
|
-
status: TournamentStatusEnum.STATE_IN_PROGRESS,
|
|
79
|
-
participants,
|
|
80
|
-
},
|
|
81
|
-
}).exec();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async cancelTournament (tournamentId: string): Promise<void> {
|
|
85
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
86
|
-
tournamentId,
|
|
87
|
-
{
|
|
88
|
-
$set: {
|
|
89
|
-
finishDate: new Date(),
|
|
90
|
-
status: TournamentStatusEnum.STATE_CANCELLED,
|
|
91
|
-
},
|
|
92
|
-
}).exec();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async finishTournament (tournamentId: string, winners: Array<ITournamentWinner>): Promise<void> {
|
|
96
|
-
await this.tournamentModel.findByIdAndUpdate(
|
|
97
|
-
tournamentId,
|
|
98
|
-
{
|
|
99
|
-
$set: {
|
|
100
|
-
finishDate: new Date(),
|
|
101
|
-
status: TournamentStatusEnum.STATE_FINISHED,
|
|
102
|
-
winners,
|
|
103
|
-
},
|
|
104
|
-
}).exec();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { TournamentOneTableRoom, TournamentOneTableRoomDocument } from '../';
|
|
6
|
+
import { ITournamentParticipant } from '../models/tournament-participant.interface';
|
|
7
|
+
import { TournamentStatusEnum } from '../models/tournament-status.enum';
|
|
8
|
+
import { ITournamentWinner } from '../models/tournament-winner.interface';
|
|
9
|
+
import { TournamentTemplateEnum } from '../models/tournament-template.enum';
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class TournamentOneTableRoomsRepository {
|
|
13
|
+
constructor (@InjectModel(TournamentOneTableRoom.name) private tournamentModel: Model<TournamentOneTableRoomDocument>) {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async findTournamentById (tournamentId: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
17
|
+
return this.tournamentModel
|
|
18
|
+
.findById(tournamentId)
|
|
19
|
+
.exec();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async findTemplateById (templateId: string, gameType: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
23
|
+
return this.tournamentModel
|
|
24
|
+
.findOne({ isTemplate: true, templateId, gameType })
|
|
25
|
+
.exec();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async findTournaments (gameType: string): Promise<Array<TournamentOneTableRoomDocument>> {
|
|
29
|
+
return this.tournamentModel
|
|
30
|
+
.find({ gameType, isTemplate: false })
|
|
31
|
+
.exec();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async findWaitingTournament (gameType: string): Promise<TournamentOneTableRoomDocument | null> {
|
|
35
|
+
return this.tournamentModel
|
|
36
|
+
.findOne({
|
|
37
|
+
gameType,
|
|
38
|
+
status: TournamentStatusEnum.STATE_WAITING_FOR_START,
|
|
39
|
+
isTemplate: false,
|
|
40
|
+
})
|
|
41
|
+
.exec();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async createTournament (tournament: Partial<TournamentOneTableRoom>): Promise<TournamentOneTableRoomDocument> {
|
|
45
|
+
return this.tournamentModel.create(tournament);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async createTournamentFromMasterTemplate (gameType: string): Promise<TournamentOneTableRoomDocument> {
|
|
49
|
+
const masterTemplate = await this.findTemplateById(TournamentTemplateEnum.MASTER, gameType);
|
|
50
|
+
|
|
51
|
+
return this.createTournament({
|
|
52
|
+
title: masterTemplate.title,
|
|
53
|
+
subtitle: masterTemplate.subtitle,
|
|
54
|
+
description: masterTemplate.description,
|
|
55
|
+
tableSize: masterTemplate.tableSize,
|
|
56
|
+
bet: masterTemplate.bet,
|
|
57
|
+
ticketPrice: masterTemplate.ticketPrice,
|
|
58
|
+
roomType: masterTemplate.roomType,
|
|
59
|
+
gameType: masterTemplate.gameType,
|
|
60
|
+
rulesType: masterTemplate.rulesType,
|
|
61
|
+
deckType: masterTemplate.deckType,
|
|
62
|
+
maxParticipants: masterTemplate.maxParticipants,
|
|
63
|
+
participants: masterTemplate.participants,
|
|
64
|
+
status: masterTemplate.status,
|
|
65
|
+
winners: masterTemplate.winners,
|
|
66
|
+
createDate: new Date(),
|
|
67
|
+
isTemplate: false,
|
|
68
|
+
templateId: undefined,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async startTournament (tournamentId: string, participants: Array<ITournamentParticipant>): Promise<void> {
|
|
73
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
74
|
+
tournamentId,
|
|
75
|
+
{
|
|
76
|
+
$set: {
|
|
77
|
+
startDate: new Date(),
|
|
78
|
+
status: TournamentStatusEnum.STATE_IN_PROGRESS,
|
|
79
|
+
participants,
|
|
80
|
+
},
|
|
81
|
+
}).exec();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async cancelTournament (tournamentId: string): Promise<void> {
|
|
85
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
86
|
+
tournamentId,
|
|
87
|
+
{
|
|
88
|
+
$set: {
|
|
89
|
+
finishDate: new Date(),
|
|
90
|
+
status: TournamentStatusEnum.STATE_CANCELLED,
|
|
91
|
+
},
|
|
92
|
+
}).exec();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async finishTournament (tournamentId: string, winners: Array<ITournamentWinner>): Promise<void> {
|
|
96
|
+
await this.tournamentModel.findByIdAndUpdate(
|
|
97
|
+
tournamentId,
|
|
98
|
+
{
|
|
99
|
+
$set: {
|
|
100
|
+
finishDate: new Date(),
|
|
101
|
+
status: TournamentStatusEnum.STATE_FINISHED,
|
|
102
|
+
winners,
|
|
103
|
+
},
|
|
104
|
+
}).exec();
|
|
105
|
+
}
|
|
106
|
+
}
|