Tournaments Module
The Tournaments module provides functionality for interacting with the Gamanza Engage Tournament system. It allows developers to retrieve active tournaments, tournament history, leaderboards, and opt players into tournaments.
Accessing the Module
The Tournaments module is accessible through the Gamanza Engage Web Client SDK:
const sdk = GamanzaEngageWebClientSDK.getInstance();
const tournaments = sdk.Tournaments;
Methods
getPlayerActiveTournaments
Returns the list of Active and Eligible tournaments for the current authenticated player.
Signature:
getPlayerActiveTournaments(): Promise<TournamentType[]>
Returns
Type | Description |
---|---|
Promise<TournamentType[]> | A promise that resolves to an array of active tournaments |
Example
const activeTournaments = await sdk.Tournaments.getPlayerActiveTournaments();
getLeaderboardForTournament
Returns the leaderboard for the given tournament ID. The response always includes the current authenticated Player as part of the response.
- For Active Tournaments: leaderboard always returns the first 25 positions, and if the player is not in the first 25 is added at the end.
- For Ended Tournaments: leaderboard can receive the number of items to be returned with a max of 100 items.
Signature:
getLeaderboardForTournament(tournamentId: string, items = 25): Promise<PlayerLeaderboard[]>
Parameters
Name | Type | Description |
---|---|---|
tournamentId | string | The unique identifier of the tournament |
items | number | The number of leaderboard positions to return (default: 25, max: 100) |
Returns
Type | Description |
---|---|
Promise<PlayerLeaderboard[]> | A promise that resolves to an array of player leaderboard positions |
Example
const leaderboard = await sdk.Tournaments.getLeaderboardForTournament("tournament-id-123", 50);
getPlayerPositionInLeaderboardTournament
Returns the current position and score for the given tournament ID for the authenticated player.
Note: This method is deprecated. This information is propagated in realtime by subscribing to the event EVENTS.TOURNAMENTS.ON_TOURNAMENT_PLAYER_LEADERBOARD_UPDATED, or use the Tournaments.getLeaderboardForTournament and filter by the current authenticated playerId in the response.
Signature:
getPlayerPositionInLeaderboardTournament(tournamentId: string): Promise<{
position: number;
score: number;
} | null>
Parameters
Name | Type | Description |
---|---|---|
tournamentId | string | The unique identifier of the tournament |
Returns
Type | Description |
---|---|
Promise<{ position: number; score: number; } | null> | A promise that resolves to the player's position and score, or null if not found |
Example
const position = await sdk.Tournaments.getPlayerPositionInLeaderboardTournament("tournament-id-123");
if (position) {
console.log(`Current position: ${position.position}, Score: ${position.score}`);
}
getPlayerTournamentsHistory
Returns the recent tournaments participation history for the current authenticated player. The history is based on the last 30 days by default. If you need to change this configuration, please contact your Customer Success Manager and request to adjust the Tournaments.HISTORY_DAYS_COUNT configuration.
Signature:
getPlayerTournamentsHistory(): Promise<TournamentType[]>
Returns
Type | Description |
---|---|
Promise<TournamentType[]> | A promise that resolves to an array of tournament history entries |
Example
const tournamentHistory = await sdk.Tournaments.getPlayerTournamentsHistory();
playerOptInTournament
Sends the request to opt-in the current authenticated player for the given tournament ID.
Signature:
playerOptInTournament(tournamentId: string): Promise<SimpleResponse<null>>
Parameters
Name | Type | Description |
---|---|---|
tournamentId | string | The unique identifier of the tournament |
Returns
Type | Description |
---|---|
Promise<SimpleResponse<null>> | A promise that resolves to a simple response indicating success or failure |
Example
const response = await sdk.Tournaments.playerOptInTournament("tournament-id-123");
if (response.ok) {
console.log("Successfully opted into tournament");
}
Related Interfaces
TournamentType
Represents a tournament in the system.
interface TournamentType {
_id?: string;
internalDetails: {} & Pick<TranslationType, 'name' | 'description'>;
externalDetails: ExternalDetailsEntity[];
optIn: boolean;
buyIn: string;
tags?: string[];
smallImage?: string;
largeImage?: string;
industry: TournamentIndustryTypeEnum;
type: TournamentTypeEnum;
gameCategories?: string[];
gameProviders?: string[];
games?: string[];
sports?: string[];
leagues?: string[];
teams?: string[];
markets?: string[];
minBetAmount: MinAmountCurrencyEntity[];
maxNumberOfBets: number;
timePeriod?: TimePeriodType;
leaderboardRewards: LeaderboardReward[];
eligibility: TournamentEligibilityType;
status: StatusTournamentsEnum;
objectives: TournamentObjective[];
createdBy: string;
updatedBy: string;
}
PlayerLeaderboard
Represents a player's position in a tournament leaderboard.
type PlayerLeaderboard = {
leaderboardRewards: LeaderboardReward[];
playerId: string;
position?: number;
score?: number;
level?: number;
rank?: string;
rankImageUrl?: string;
userName: string;
spinsLeft?: number;
tournamentId: string;
};
LeaderboardReward
Defines rewards for leaderboard positions.
type LeaderboardReward = {
fromPosition: number;
toPosition?: number;
rewards: Reward[];
};
TournamentObjective
Defines objectives for tournaments.
type TournamentObjective = {
conditionQuantity: number;
conditionType: ObjectiveConditionTypeEnum;
gameCategories: string[];
objectiveType: ObjectiveTypeEnum;
pointsAssigned: number;
};
TournamentEligibilityType
Defines eligibility criteria for tournaments.
type TournamentEligibilityType = {
eligibilityType: TournamentEligibilityTypeEnum;
rankId?: string;
segmentId?: string;
};
TimePeriodType
Defines the time period for a tournament.
type TimePeriodType = {
periodType: TimeUnitsEnum;
startDate: string;
endDate: string;
};
MinAmountCurrencyEntity
Defines minimum amount and currency.
type MinAmountCurrencyEntity = {
amount: number;
currency: string;
};
SimpleResponse
A generic interface for simple responses with success/error status.
interface SimpleResponse<T> {
ok: boolean;
error?: ErrorResponse;
data: T | null;
}
TournamentTypeEnum
Enum defining the types of tournaments.
enum TournamentTypeEnum {
MOST_POINTS = 'most_points',
HIGHEST_WIN = 'highest_win_multiplier',
BONUS_BUY = 'bonus_buy_battle',
}
StatusTournamentsEnum
Enum defining the possible statuses of tournaments.
enum StatusTournamentsEnum {
InDesign = 'in_design',
Scheduled = 'scheduled',
Active = 'active',
Ended = 'ended',
Cancelled = 'cancelled',
}
TournamentIndustryTypeEnum
Enum defining the industry types for tournaments.
enum TournamentIndustryTypeEnum {
CASINO = 'casino',
SPORT = 'sport',
}
ObjectiveTypeEnum
Enum defining the types of objectives for tournaments.
enum ObjectiveTypeEnum {
CompletedDeposit = 'completed_deposit',
CasinoWager = 'casino_wager',
CasinoWin = 'casino_win',
CasinoLoss = 'casino_loss',
SportWager = 'sport_wager',
SportWin = 'sport_win',
SportLoss = 'sport_loss',
}
ObjectiveConditionTypeEnum
Enum defining the types of conditions for objectives.
enum ObjectiveConditionTypeEnum {
Quantity = 'quantity',
TotalWinAmount = 'total_win_amount',
SuccessiveQuantity = 'successive_quantity',
TotalBetAmount = 'total_bet_amount',
}
TournamentEligibilityTypeEnum
Enum defining the types of eligibility for tournaments.
enum TournamentEligibilityTypeEnum {
All = 'all',
Ranks = 'ranks',
Segment = 'segment',
}