@gamelobby/common 1.0.372 → 1.0.374
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/build/interfaces/bracketBackend.interface.d.ts +56 -5
- package/build/interfaces/bracketConfig.interface.d.ts +14 -0
- package/build/interfaces/creator.interface.d.ts +10 -0
- package/build/interfaces/gameDay.interface.d.ts +13 -0
- package/build/interfaces/gameDayStatus.interface.d.ts +111 -0
- package/build/interfaces/gameDayStatus.interface.js +56 -0
- package/build/interfaces/index.d.ts +3 -0
- package/build/interfaces/index.js +3 -0
- package/build/interfaces/prizePool.interface.d.ts +123 -0
- package/build/interfaces/prizePool.interface.js +105 -0
- package/build/interfaces/room.interface.d.ts +5 -0
- package/build/interfaces/tournamentRound.interface.d.ts +50 -9
- package/build/topics/matchestopics.d.ts +9 -1
- package/build/topics/matchestopics.js +9 -0
- package/package.json +1 -1
|
@@ -1,11 +1,62 @@
|
|
|
1
|
+
export declare type BracketMatchType = 'winner' | 'loser' | 'grandFinal' | 'grandFinalReset' | 'consolation';
|
|
1
2
|
export interface BracketBackEnd {
|
|
2
|
-
round:
|
|
3
|
-
match:
|
|
4
|
-
player1:
|
|
5
|
-
player2?:
|
|
3
|
+
round: number;
|
|
4
|
+
match: number;
|
|
5
|
+
player1: number | null;
|
|
6
|
+
player2?: number | null;
|
|
6
7
|
win: {
|
|
7
8
|
round: number;
|
|
8
9
|
match: number;
|
|
10
|
+
bracketType?: BracketMatchType;
|
|
9
11
|
};
|
|
10
|
-
|
|
12
|
+
loss?: {
|
|
13
|
+
round: number;
|
|
14
|
+
match: number;
|
|
15
|
+
bracketType?: BracketMatchType;
|
|
16
|
+
} | string;
|
|
17
|
+
bracketType?: BracketMatchType;
|
|
18
|
+
isBye?: boolean;
|
|
19
|
+
byeAdvancesTo?: {
|
|
20
|
+
round: number;
|
|
21
|
+
match: number;
|
|
22
|
+
};
|
|
23
|
+
player1Score?: number;
|
|
24
|
+
player2Score?: number;
|
|
25
|
+
winnerId?: number;
|
|
26
|
+
loserId?: number;
|
|
27
|
+
status?: 'pending' | 'in_progress' | 'completed' | 'forfeited' | 'bye';
|
|
28
|
+
isForfeited?: boolean;
|
|
29
|
+
forfeitedBy?: number;
|
|
30
|
+
forfeitReason?: string;
|
|
31
|
+
player1Raw?: {
|
|
32
|
+
teamId: number;
|
|
33
|
+
teamName: string;
|
|
34
|
+
logo?: string;
|
|
35
|
+
seed?: number;
|
|
36
|
+
};
|
|
37
|
+
player2Raw?: {
|
|
38
|
+
teamId: number;
|
|
39
|
+
teamName: string;
|
|
40
|
+
logo?: string;
|
|
41
|
+
seed?: number;
|
|
42
|
+
};
|
|
43
|
+
scheduledTime?: Date;
|
|
44
|
+
startedAt?: Date;
|
|
45
|
+
completedAt?: Date;
|
|
46
|
+
}
|
|
47
|
+
export interface BracketStructure {
|
|
48
|
+
roomId: number;
|
|
49
|
+
bracketType: 'single' | 'double' | 'swiss' | 'roundRobin';
|
|
50
|
+
totalParticipants: number;
|
|
51
|
+
totalRounds: number;
|
|
52
|
+
winnerBracket: BracketBackEnd[];
|
|
53
|
+
loserBracket?: BracketBackEnd[];
|
|
54
|
+
grandFinal?: BracketBackEnd;
|
|
55
|
+
grandFinalReset?: BracketBackEnd;
|
|
56
|
+
consolation?: BracketBackEnd;
|
|
57
|
+
currentRound: number;
|
|
58
|
+
isComplete: boolean;
|
|
59
|
+
championTeamId?: number;
|
|
60
|
+
runnerUpTeamId?: number;
|
|
61
|
+
thirdPlaceTeamId?: number;
|
|
11
62
|
}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
export declare type TournamentType = 'single' | 'double' | 'swiss' | 'roundRobin';
|
|
1
2
|
export interface BracketConfig {
|
|
2
3
|
_id?: string;
|
|
3
4
|
name?: string;
|
|
4
5
|
total?: number;
|
|
5
6
|
ordered?: boolean;
|
|
6
7
|
generated?: boolean;
|
|
8
|
+
bracketType?: TournamentType;
|
|
9
|
+
enableGrandFinalReset?: boolean;
|
|
10
|
+
enableConsolationBracket?: boolean;
|
|
11
|
+
consolationPlaces?: number;
|
|
12
|
+
swissRounds?: number;
|
|
13
|
+
roundRobinGroups?: number;
|
|
14
|
+
teamsAdvancingPerGroup?: number;
|
|
15
|
+
seedByRanking?: boolean;
|
|
16
|
+
randomSeed?: boolean;
|
|
17
|
+
byeHandling?: 'top_seed' | 'bottom_seed' | 'random';
|
|
18
|
+
bestOf?: number;
|
|
19
|
+
matchDurationMinutes?: number;
|
|
20
|
+
breakBetweenMatchesMinutes?: number;
|
|
7
21
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { ColorsUserInfo } from './colorsUserInfo.interface';
|
|
2
2
|
import { Question } from './question.interface';
|
|
3
3
|
import { UserBanners } from './userBanners.interface';
|
|
4
|
+
export interface CreatorSocialNetwork {
|
|
5
|
+
id: number;
|
|
6
|
+
socialId: number;
|
|
7
|
+
usuario: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
nombre?: string;
|
|
10
|
+
icono?: string;
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
}
|
|
4
13
|
export interface Creator {
|
|
5
14
|
userInfoId: string;
|
|
6
15
|
apellido: string;
|
|
@@ -17,4 +26,5 @@ export interface Creator {
|
|
|
17
26
|
hasCode: boolean;
|
|
18
27
|
codeAnswered: boolean;
|
|
19
28
|
contact: string;
|
|
29
|
+
socialNetworks?: CreatorSocialNetwork[];
|
|
20
30
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GameDayStatus, QualificationRules } from './gameDayStatus.interface';
|
|
1
2
|
export interface GameDay {
|
|
2
3
|
_id?: string;
|
|
3
4
|
id?: number;
|
|
@@ -11,4 +12,16 @@ export interface GameDay {
|
|
|
11
12
|
ranked?: number;
|
|
12
13
|
generated?: boolean;
|
|
13
14
|
createdAt?: string;
|
|
15
|
+
status?: GameDayStatus;
|
|
16
|
+
closedAt?: string;
|
|
17
|
+
closedBy?: string;
|
|
18
|
+
finalizedAt?: string;
|
|
19
|
+
finalizedBy?: string;
|
|
20
|
+
reopenedAt?: string;
|
|
21
|
+
reopenedBy?: string;
|
|
22
|
+
qualificationRules?: QualificationRules;
|
|
23
|
+
totalParticipants?: number;
|
|
24
|
+
qualifiedCount?: number;
|
|
25
|
+
eliminatedCount?: number;
|
|
26
|
+
actionsExecuted?: boolean;
|
|
14
27
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GameDay Status - States for tournament game days
|
|
3
|
+
*/
|
|
4
|
+
export declare enum GameDayStatus {
|
|
5
|
+
DRAFT = "draft",
|
|
6
|
+
OPEN = "open",
|
|
7
|
+
IN_PROGRESS = "in_progress",
|
|
8
|
+
PENDING_CLOSE = "pending_close",
|
|
9
|
+
CLOSED = "closed",
|
|
10
|
+
FINALIZED = "finalized",
|
|
11
|
+
REOPENED = "reopened"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Qualification Action Types
|
|
15
|
+
*/
|
|
16
|
+
export declare enum QualifiedActionType {
|
|
17
|
+
STAY = "stay",
|
|
18
|
+
MOVE_TO_ROOM = "move_to_room",
|
|
19
|
+
EXCLUDE_NEXT = "exclude_next",
|
|
20
|
+
EXCLUDE_BRACKET = "exclude_bracket"
|
|
21
|
+
}
|
|
22
|
+
export declare enum EliminatedActionType {
|
|
23
|
+
ALLOW_REENTRY = "allow_reentry",
|
|
24
|
+
EXCLUDE = "exclude",
|
|
25
|
+
MOVE_TO_ROOM = "move_to_room"
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Qualification Rules Configuration
|
|
29
|
+
*/
|
|
30
|
+
export interface QualificationRules {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
qualifyTop: number;
|
|
33
|
+
qualifyByPoints?: number;
|
|
34
|
+
qualifiedAction: QualifiedActionType;
|
|
35
|
+
qualifiedTargetRoomId?: string;
|
|
36
|
+
qualifiedTargetRoomName?: string;
|
|
37
|
+
eliminatedAction: EliminatedActionType;
|
|
38
|
+
eliminatedTargetRoomId?: string;
|
|
39
|
+
allowReentry: boolean;
|
|
40
|
+
autoExecute: boolean;
|
|
41
|
+
gracePeriodMinutes: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Participant Status per GameDay
|
|
45
|
+
*/
|
|
46
|
+
export declare enum ParticipantGameDayStatus {
|
|
47
|
+
ACTIVE = "active",
|
|
48
|
+
QUALIFIED = "qualified",
|
|
49
|
+
ELIMINATED = "eliminated",
|
|
50
|
+
PROMOTED = "promoted",
|
|
51
|
+
RELEGATED = "relegated",
|
|
52
|
+
PENDING = "pending"
|
|
53
|
+
}
|
|
54
|
+
export interface ParticipantGameDayState {
|
|
55
|
+
participantId: number;
|
|
56
|
+
teamId: number;
|
|
57
|
+
teamName: string;
|
|
58
|
+
roomId: number;
|
|
59
|
+
gameDayId: string;
|
|
60
|
+
status: ParticipantGameDayStatus;
|
|
61
|
+
qualifiedPosition?: number;
|
|
62
|
+
points?: number;
|
|
63
|
+
nextAction?: QualifiedActionType | EliminatedActionType;
|
|
64
|
+
targetRoomId?: string;
|
|
65
|
+
actionExecuted: boolean;
|
|
66
|
+
actionExecutedAt?: Date;
|
|
67
|
+
createdAt: Date;
|
|
68
|
+
updatedAt: Date;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Pending Qualification Action
|
|
72
|
+
*/
|
|
73
|
+
export interface QualificationAction {
|
|
74
|
+
id: number;
|
|
75
|
+
roomId: number;
|
|
76
|
+
gameDayId: string;
|
|
77
|
+
participantId: number;
|
|
78
|
+
teamId: number;
|
|
79
|
+
teamName: string;
|
|
80
|
+
actionType: QualifiedActionType | EliminatedActionType;
|
|
81
|
+
targetRoomId?: string;
|
|
82
|
+
status: 'pending' | 'executed' | 'cancelled' | 'failed';
|
|
83
|
+
position?: number;
|
|
84
|
+
points?: number;
|
|
85
|
+
executedAt?: Date;
|
|
86
|
+
executedBy?: string;
|
|
87
|
+
failureReason?: string;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* GameDay State Transition Result
|
|
92
|
+
*/
|
|
93
|
+
export interface GameDayTransitionResult {
|
|
94
|
+
success: boolean;
|
|
95
|
+
previousStatus: GameDayStatus;
|
|
96
|
+
newStatus: GameDayStatus;
|
|
97
|
+
message: string;
|
|
98
|
+
requiresConfirmation?: boolean;
|
|
99
|
+
dependencies?: {
|
|
100
|
+
hasPromotedPlayers: boolean;
|
|
101
|
+
promotedPlayersCount: number;
|
|
102
|
+
hasNextBracketGenerated: boolean;
|
|
103
|
+
hasPrizesDistributed: boolean;
|
|
104
|
+
};
|
|
105
|
+
affectedParticipants?: ParticipantGameDayState[];
|
|
106
|
+
pendingActions?: QualificationAction[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Default Qualification Rules
|
|
110
|
+
*/
|
|
111
|
+
export declare const DEFAULT_QUALIFICATION_RULES: QualificationRules;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_QUALIFICATION_RULES = exports.ParticipantGameDayStatus = exports.EliminatedActionType = exports.QualifiedActionType = exports.GameDayStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* GameDay Status - States for tournament game days
|
|
6
|
+
*/
|
|
7
|
+
var GameDayStatus;
|
|
8
|
+
(function (GameDayStatus) {
|
|
9
|
+
GameDayStatus["DRAFT"] = "draft";
|
|
10
|
+
GameDayStatus["OPEN"] = "open";
|
|
11
|
+
GameDayStatus["IN_PROGRESS"] = "in_progress";
|
|
12
|
+
GameDayStatus["PENDING_CLOSE"] = "pending_close";
|
|
13
|
+
GameDayStatus["CLOSED"] = "closed";
|
|
14
|
+
GameDayStatus["FINALIZED"] = "finalized";
|
|
15
|
+
GameDayStatus["REOPENED"] = "reopened"; // Reopened (special case)
|
|
16
|
+
})(GameDayStatus = exports.GameDayStatus || (exports.GameDayStatus = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Qualification Action Types
|
|
19
|
+
*/
|
|
20
|
+
var QualifiedActionType;
|
|
21
|
+
(function (QualifiedActionType) {
|
|
22
|
+
QualifiedActionType["STAY"] = "stay";
|
|
23
|
+
QualifiedActionType["MOVE_TO_ROOM"] = "move_to_room";
|
|
24
|
+
QualifiedActionType["EXCLUDE_NEXT"] = "exclude_next";
|
|
25
|
+
QualifiedActionType["EXCLUDE_BRACKET"] = "exclude_bracket"; // Exclude from next bracket generation
|
|
26
|
+
})(QualifiedActionType = exports.QualifiedActionType || (exports.QualifiedActionType = {}));
|
|
27
|
+
var EliminatedActionType;
|
|
28
|
+
(function (EliminatedActionType) {
|
|
29
|
+
EliminatedActionType["ALLOW_REENTRY"] = "allow_reentry";
|
|
30
|
+
EliminatedActionType["EXCLUDE"] = "exclude";
|
|
31
|
+
EliminatedActionType["MOVE_TO_ROOM"] = "move_to_room"; // Move to consolation room
|
|
32
|
+
})(EliminatedActionType = exports.EliminatedActionType || (exports.EliminatedActionType = {}));
|
|
33
|
+
/**
|
|
34
|
+
* Participant Status per GameDay
|
|
35
|
+
*/
|
|
36
|
+
var ParticipantGameDayStatus;
|
|
37
|
+
(function (ParticipantGameDayStatus) {
|
|
38
|
+
ParticipantGameDayStatus["ACTIVE"] = "active";
|
|
39
|
+
ParticipantGameDayStatus["QUALIFIED"] = "qualified";
|
|
40
|
+
ParticipantGameDayStatus["ELIMINATED"] = "eliminated";
|
|
41
|
+
ParticipantGameDayStatus["PROMOTED"] = "promoted";
|
|
42
|
+
ParticipantGameDayStatus["RELEGATED"] = "relegated";
|
|
43
|
+
ParticipantGameDayStatus["PENDING"] = "pending";
|
|
44
|
+
})(ParticipantGameDayStatus = exports.ParticipantGameDayStatus || (exports.ParticipantGameDayStatus = {}));
|
|
45
|
+
/**
|
|
46
|
+
* Default Qualification Rules
|
|
47
|
+
*/
|
|
48
|
+
exports.DEFAULT_QUALIFICATION_RULES = {
|
|
49
|
+
enabled: false,
|
|
50
|
+
qualifyTop: 0,
|
|
51
|
+
qualifiedAction: QualifiedActionType.STAY,
|
|
52
|
+
eliminatedAction: EliminatedActionType.ALLOW_REENTRY,
|
|
53
|
+
allowReentry: true,
|
|
54
|
+
autoExecute: false,
|
|
55
|
+
gracePeriodMinutes: 60
|
|
56
|
+
};
|
|
@@ -71,6 +71,9 @@ export * from './requestStates.enum';
|
|
|
71
71
|
export * from './awardNew.interface';
|
|
72
72
|
export * from './awardType.enum';
|
|
73
73
|
export * from './bracketBackend.interface';
|
|
74
|
+
export * from './bracketConfig.interface';
|
|
74
75
|
export * from './wallet.interface';
|
|
75
76
|
export * from './imageGallery.interface';
|
|
77
|
+
export * from './gameDayStatus.interface';
|
|
76
78
|
export * from './gameDay.interface';
|
|
79
|
+
export * from './prizePool.interface';
|
|
@@ -83,6 +83,9 @@ __exportStar(require("./requestStates.enum"), exports);
|
|
|
83
83
|
__exportStar(require("./awardNew.interface"), exports);
|
|
84
84
|
__exportStar(require("./awardType.enum"), exports);
|
|
85
85
|
__exportStar(require("./bracketBackend.interface"), exports);
|
|
86
|
+
__exportStar(require("./bracketConfig.interface"), exports);
|
|
86
87
|
__exportStar(require("./wallet.interface"), exports);
|
|
87
88
|
__exportStar(require("./imageGallery.interface"), exports);
|
|
89
|
+
__exportStar(require("./gameDayStatus.interface"), exports);
|
|
88
90
|
__exportStar(require("./gameDay.interface"), exports);
|
|
91
|
+
__exportStar(require("./prizePool.interface"), exports);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prize Pool Configuration
|
|
3
|
+
* Defines how coins are collected and distributed in tournaments
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Prize distribution per position
|
|
7
|
+
*/
|
|
8
|
+
export interface PrizePosition {
|
|
9
|
+
position: number;
|
|
10
|
+
percentage: number;
|
|
11
|
+
minAmount?: number;
|
|
12
|
+
label?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Platform fee configuration
|
|
16
|
+
*/
|
|
17
|
+
export interface PlatformFeeConfig {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
percentage: number;
|
|
20
|
+
minFee?: number;
|
|
21
|
+
maxFee?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Prize pool source configuration
|
|
25
|
+
*/
|
|
26
|
+
export declare enum PrizePoolSource {
|
|
27
|
+
ENTRY_FEES = "entry_fees",
|
|
28
|
+
GUARANTEED = "guaranteed",
|
|
29
|
+
MIXED = "mixed"
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Prize pool status
|
|
33
|
+
*/
|
|
34
|
+
export declare enum PrizePoolStatus {
|
|
35
|
+
COLLECTING = "collecting",
|
|
36
|
+
LOCKED = "locked",
|
|
37
|
+
DISTRIBUTING = "distributing",
|
|
38
|
+
DISTRIBUTED = "distributed",
|
|
39
|
+
REFUNDED = "refunded"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Individual escrow hold for a participant
|
|
43
|
+
*/
|
|
44
|
+
export interface ParticipantEscrow {
|
|
45
|
+
participantId: number;
|
|
46
|
+
participantType: 'team' | 'player';
|
|
47
|
+
amount: number;
|
|
48
|
+
currency: string;
|
|
49
|
+
holdId?: string;
|
|
50
|
+
status: 'held' | 'released' | 'refunded';
|
|
51
|
+
heldAt: Date;
|
|
52
|
+
releasedAt?: Date;
|
|
53
|
+
refundedAt?: Date;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Prize distribution record
|
|
57
|
+
*/
|
|
58
|
+
export interface PrizeDistributionRecord {
|
|
59
|
+
participantId: number;
|
|
60
|
+
participantType: 'team' | 'player';
|
|
61
|
+
participantName: string;
|
|
62
|
+
position: number;
|
|
63
|
+
percentage: number;
|
|
64
|
+
amount: number;
|
|
65
|
+
currency: string;
|
|
66
|
+
transactionId?: string;
|
|
67
|
+
distributedAt?: Date;
|
|
68
|
+
status: 'pending' | 'distributed' | 'failed';
|
|
69
|
+
errorMessage?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Complete Prize Pool Configuration for a Room
|
|
73
|
+
*/
|
|
74
|
+
export interface PrizePoolConfig {
|
|
75
|
+
enabled: boolean;
|
|
76
|
+
source: PrizePoolSource;
|
|
77
|
+
currency: string;
|
|
78
|
+
entryFee: number;
|
|
79
|
+
entryFeePerPlayer?: boolean;
|
|
80
|
+
guaranteedAmount?: number;
|
|
81
|
+
distribution: PrizePosition[];
|
|
82
|
+
platformFee: PlatformFeeConfig;
|
|
83
|
+
minParticipantsForPrizes: number;
|
|
84
|
+
insufficientParticipantsAction: 'refund_all' | 'distribute_anyway' | 'cancel';
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Live Prize Pool State (runtime state)
|
|
88
|
+
*/
|
|
89
|
+
export interface PrizePoolState {
|
|
90
|
+
roomId: number;
|
|
91
|
+
gameDayId?: string;
|
|
92
|
+
totalCollected: number;
|
|
93
|
+
guaranteedAmount: number;
|
|
94
|
+
platformFeeAmount: number;
|
|
95
|
+
distributedAmount: number;
|
|
96
|
+
totalPoolAmount: number;
|
|
97
|
+
availableForDistribution: number;
|
|
98
|
+
status: PrizePoolStatus;
|
|
99
|
+
participantCount: number;
|
|
100
|
+
escrows: ParticipantEscrow[];
|
|
101
|
+
distributions: PrizeDistributionRecord[];
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
updatedAt: Date;
|
|
104
|
+
lockedAt?: Date;
|
|
105
|
+
distributedAt?: Date;
|
|
106
|
+
refundedAt?: Date;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Default prize distributions for common tournament sizes
|
|
110
|
+
*/
|
|
111
|
+
export declare const DEFAULT_PRIZE_DISTRIBUTIONS: Record<string, PrizePosition[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Helper to calculate prize amount for a position
|
|
114
|
+
*/
|
|
115
|
+
export declare function calculatePrizeAmount(position: number, totalPool: number, distribution: PrizePosition[]): number;
|
|
116
|
+
/**
|
|
117
|
+
* Validate that distribution percentages sum to 100 (or less)
|
|
118
|
+
*/
|
|
119
|
+
export declare function validateDistribution(distribution: PrizePosition[]): {
|
|
120
|
+
valid: boolean;
|
|
121
|
+
totalPercentage: number;
|
|
122
|
+
message?: string;
|
|
123
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prize Pool Configuration
|
|
4
|
+
* Defines how coins are collected and distributed in tournaments
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.validateDistribution = exports.calculatePrizeAmount = exports.DEFAULT_PRIZE_DISTRIBUTIONS = exports.PrizePoolStatus = exports.PrizePoolSource = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Prize pool source configuration
|
|
10
|
+
*/
|
|
11
|
+
var PrizePoolSource;
|
|
12
|
+
(function (PrizePoolSource) {
|
|
13
|
+
PrizePoolSource["ENTRY_FEES"] = "entry_fees";
|
|
14
|
+
PrizePoolSource["GUARANTEED"] = "guaranteed";
|
|
15
|
+
PrizePoolSource["MIXED"] = "mixed"; // Entry fees + guaranteed minimum
|
|
16
|
+
})(PrizePoolSource = exports.PrizePoolSource || (exports.PrizePoolSource = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Prize pool status
|
|
19
|
+
*/
|
|
20
|
+
var PrizePoolStatus;
|
|
21
|
+
(function (PrizePoolStatus) {
|
|
22
|
+
PrizePoolStatus["COLLECTING"] = "collecting";
|
|
23
|
+
PrizePoolStatus["LOCKED"] = "locked";
|
|
24
|
+
PrizePoolStatus["DISTRIBUTING"] = "distributing";
|
|
25
|
+
PrizePoolStatus["DISTRIBUTED"] = "distributed";
|
|
26
|
+
PrizePoolStatus["REFUNDED"] = "refunded"; // Tournament cancelled, all refunded
|
|
27
|
+
})(PrizePoolStatus = exports.PrizePoolStatus || (exports.PrizePoolStatus = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Default prize distributions for common tournament sizes
|
|
30
|
+
*/
|
|
31
|
+
exports.DEFAULT_PRIZE_DISTRIBUTIONS = {
|
|
32
|
+
// Winner takes all
|
|
33
|
+
'winner_takes_all': [
|
|
34
|
+
{ position: 1, percentage: 100, label: 'Champion' }
|
|
35
|
+
],
|
|
36
|
+
// Top 2
|
|
37
|
+
'top_2': [
|
|
38
|
+
{ position: 1, percentage: 70, label: 'Champion' },
|
|
39
|
+
{ position: 2, percentage: 30, label: 'Runner-up' }
|
|
40
|
+
],
|
|
41
|
+
// Top 3
|
|
42
|
+
'top_3': [
|
|
43
|
+
{ position: 1, percentage: 50, label: 'Champion' },
|
|
44
|
+
{ position: 2, percentage: 30, label: 'Runner-up' },
|
|
45
|
+
{ position: 3, percentage: 20, label: '3rd Place' }
|
|
46
|
+
],
|
|
47
|
+
// Top 4
|
|
48
|
+
'top_4': [
|
|
49
|
+
{ position: 1, percentage: 40, label: 'Champion' },
|
|
50
|
+
{ position: 2, percentage: 25, label: 'Runner-up' },
|
|
51
|
+
{ position: 3, percentage: 20, label: '3rd Place' },
|
|
52
|
+
{ position: 4, percentage: 15, label: '4th Place' }
|
|
53
|
+
],
|
|
54
|
+
// Top 8
|
|
55
|
+
'top_8': [
|
|
56
|
+
{ position: 1, percentage: 30, label: 'Champion' },
|
|
57
|
+
{ position: 2, percentage: 20, label: 'Runner-up' },
|
|
58
|
+
{ position: 3, percentage: 15, label: '3rd Place' },
|
|
59
|
+
{ position: 4, percentage: 10, label: '4th Place' },
|
|
60
|
+
{ position: 5, percentage: 7, label: '5th-8th' },
|
|
61
|
+
{ position: 6, percentage: 7, label: '5th-8th' },
|
|
62
|
+
{ position: 7, percentage: 6, label: '5th-8th' },
|
|
63
|
+
{ position: 8, percentage: 5, label: '5th-8th' }
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Helper to calculate prize amount for a position
|
|
68
|
+
*/
|
|
69
|
+
function calculatePrizeAmount(position, totalPool, distribution) {
|
|
70
|
+
var positionConfig = distribution.find(function (d) { return d.position === position; });
|
|
71
|
+
if (!positionConfig)
|
|
72
|
+
return 0;
|
|
73
|
+
var calculatedAmount = Math.floor((totalPool * positionConfig.percentage) / 100);
|
|
74
|
+
// Apply minimum if configured
|
|
75
|
+
if (positionConfig.minAmount && calculatedAmount < positionConfig.minAmount) {
|
|
76
|
+
return positionConfig.minAmount;
|
|
77
|
+
}
|
|
78
|
+
return calculatedAmount;
|
|
79
|
+
}
|
|
80
|
+
exports.calculatePrizeAmount = calculatePrizeAmount;
|
|
81
|
+
/**
|
|
82
|
+
* Validate that distribution percentages sum to 100 (or less)
|
|
83
|
+
*/
|
|
84
|
+
function validateDistribution(distribution) {
|
|
85
|
+
var totalPercentage = distribution.reduce(function (sum, pos) { return sum + pos.percentage; }, 0);
|
|
86
|
+
if (totalPercentage > 100) {
|
|
87
|
+
return {
|
|
88
|
+
valid: false,
|
|
89
|
+
totalPercentage: totalPercentage,
|
|
90
|
+
message: "Distribution percentages sum to " + totalPercentage + "%, which exceeds 100%"
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (totalPercentage < 100) {
|
|
94
|
+
return {
|
|
95
|
+
valid: true,
|
|
96
|
+
totalPercentage: totalPercentage,
|
|
97
|
+
message: "Distribution uses " + totalPercentage + "%, remaining " + (100 - totalPercentage) + "% goes to platform"
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
valid: true,
|
|
102
|
+
totalPercentage: totalPercentage
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
exports.validateDistribution = validateDistribution;
|
|
@@ -4,7 +4,9 @@ import { BracketConfig } from "./bracketConfig.interface";
|
|
|
4
4
|
import { ConfigRoom } from "./config.interface";
|
|
5
5
|
import { Game } from "./game.interface";
|
|
6
6
|
import { GameDay } from "./gameDay.interface";
|
|
7
|
+
import { QualificationRules } from "./gameDayStatus.interface";
|
|
7
8
|
import { GameMode } from "./gamemode.interface";
|
|
9
|
+
import { PrizePoolConfig } from "./prizePool.interface";
|
|
8
10
|
import { Platform } from "./platform.interface";
|
|
9
11
|
import { Points } from "./points.interface";
|
|
10
12
|
import { RegistrationType } from "./registrationType";
|
|
@@ -81,6 +83,7 @@ export interface Room {
|
|
|
81
83
|
welcomeMsgMatch: string;
|
|
82
84
|
welcomeMsgRoom: string;
|
|
83
85
|
price: number;
|
|
86
|
+
priceCurrency?: string;
|
|
84
87
|
online: boolean;
|
|
85
88
|
userInfo?: UserInfo;
|
|
86
89
|
streaming: Streaming;
|
|
@@ -104,4 +107,6 @@ export interface Room {
|
|
|
104
107
|
gameDay?: GameDay;
|
|
105
108
|
bannerImageUrl?: string;
|
|
106
109
|
showOpponentInInvitation?: boolean;
|
|
110
|
+
qualificationRules?: QualificationRules;
|
|
111
|
+
prizePoolConfig?: PrizePoolConfig;
|
|
107
112
|
}
|
|
@@ -1,18 +1,59 @@
|
|
|
1
1
|
import { GameDay } from "./gameDay.interface";
|
|
2
|
+
import { BracketMatchType } from "./bracketBackend.interface";
|
|
2
3
|
export interface TournamentRound {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
id?: number;
|
|
5
|
+
roomId: string | number;
|
|
6
|
+
round: string | number;
|
|
7
|
+
match: string | number;
|
|
8
|
+
player1: string | number | null;
|
|
9
|
+
player2: string | number | null;
|
|
10
|
+
player1Raw?: {
|
|
11
|
+
teamId: number;
|
|
12
|
+
teamName: string;
|
|
13
|
+
logo?: string;
|
|
14
|
+
seed?: number;
|
|
15
|
+
};
|
|
16
|
+
player2Raw?: {
|
|
17
|
+
teamId: number;
|
|
18
|
+
teamName: string;
|
|
19
|
+
logo?: string;
|
|
20
|
+
seed?: number;
|
|
21
|
+
};
|
|
8
22
|
win: {
|
|
9
|
-
round: string;
|
|
10
|
-
match: string;
|
|
23
|
+
round: string | number;
|
|
24
|
+
match: string | number;
|
|
25
|
+
bracketType?: BracketMatchType;
|
|
11
26
|
};
|
|
12
27
|
loss: {
|
|
13
|
-
round: string;
|
|
14
|
-
match: string;
|
|
28
|
+
round: string | number;
|
|
29
|
+
match: string | number;
|
|
30
|
+
bracketType?: BracketMatchType;
|
|
15
31
|
};
|
|
16
32
|
created: boolean;
|
|
17
33
|
gameDay: GameDay;
|
|
34
|
+
bracketType?: BracketMatchType;
|
|
35
|
+
status?: 'pending' | 'in_progress' | 'completed' | 'forfeited' | 'bye';
|
|
36
|
+
isBye?: boolean;
|
|
37
|
+
isForfeited?: boolean;
|
|
38
|
+
forfeitedBy?: number;
|
|
39
|
+
forfeitReason?: string;
|
|
40
|
+
player1Score?: number;
|
|
41
|
+
player2Score?: number;
|
|
42
|
+
winnerId?: number;
|
|
43
|
+
loserId?: number;
|
|
44
|
+
manualScore1?: number;
|
|
45
|
+
manualScore2?: number;
|
|
46
|
+
isManuallyEdited?: boolean;
|
|
47
|
+
editedBy?: string;
|
|
48
|
+
editedAt?: Date;
|
|
49
|
+
previousResult?: {
|
|
50
|
+
player1Score?: number;
|
|
51
|
+
player2Score?: number;
|
|
52
|
+
winnerId?: number;
|
|
53
|
+
loserId?: number;
|
|
54
|
+
status?: string;
|
|
55
|
+
};
|
|
56
|
+
matchId?: number;
|
|
57
|
+
createdAt?: Date;
|
|
58
|
+
updatedAt?: Date;
|
|
18
59
|
}
|
|
@@ -11,5 +11,13 @@ export declare enum Matchestopics {
|
|
|
11
11
|
matchTournamentDelete = "match.tournament.delete",
|
|
12
12
|
matchTournamentDeleted = "match.tournament.deleted",
|
|
13
13
|
matchTournamentUpdate = "match.tournament.update",
|
|
14
|
-
matchTournamentUpdated = "match.tournament.updated"
|
|
14
|
+
matchTournamentUpdated = "match.tournament.updated",
|
|
15
|
+
bracketGenerated = "bracket.generated",
|
|
16
|
+
bracketUpdated = "bracket.updated",
|
|
17
|
+
bracketMatchCompleted = "bracket.match.completed",
|
|
18
|
+
bracketForfeit = "bracket.forfeit",
|
|
19
|
+
bracketRollback = "bracket.rollback",
|
|
20
|
+
bracketByeAdvanced = "bracket.bye.advanced",
|
|
21
|
+
bracketGrandFinalReset = "bracket.grandfinal.reset",
|
|
22
|
+
bracketCompleted = "bracket.completed"
|
|
15
23
|
}
|
|
@@ -16,4 +16,13 @@ var Matchestopics;
|
|
|
16
16
|
Matchestopics["matchTournamentDeleted"] = "match.tournament.deleted";
|
|
17
17
|
Matchestopics["matchTournamentUpdate"] = "match.tournament.update";
|
|
18
18
|
Matchestopics["matchTournamentUpdated"] = "match.tournament.updated";
|
|
19
|
+
// Bracket events
|
|
20
|
+
Matchestopics["bracketGenerated"] = "bracket.generated";
|
|
21
|
+
Matchestopics["bracketUpdated"] = "bracket.updated";
|
|
22
|
+
Matchestopics["bracketMatchCompleted"] = "bracket.match.completed";
|
|
23
|
+
Matchestopics["bracketForfeit"] = "bracket.forfeit";
|
|
24
|
+
Matchestopics["bracketRollback"] = "bracket.rollback";
|
|
25
|
+
Matchestopics["bracketByeAdvanced"] = "bracket.bye.advanced";
|
|
26
|
+
Matchestopics["bracketGrandFinalReset"] = "bracket.grandfinal.reset";
|
|
27
|
+
Matchestopics["bracketCompleted"] = "bracket.completed";
|
|
19
28
|
})(Matchestopics = exports.Matchestopics || (exports.Matchestopics = {}));
|