Skip to main content

Calculate Tournament Score Request

Schema for calculating tournament scores via POST /api/v2/tournament/:id/calculateScore.

Description

This schema defines the request payload for calculating tournament scores based on raw game points and NFT drop ownership. The system applies multipliers based on owned NFTs to calculate the final tournament score.

Class Validator Schema

import { Type } from "class-transformer";
import { IsArray, IsNumber, IsString, ValidateNested } from "class-validator";

export class DropCounts {
@IsString()
dropId: string;

@IsArray()
@IsNumber({ allowNaN: false }, { each: true })
counts: number[];
}

export class CalculateTournamentScoreRequestPayload {
@IsNumber()
rawGamePoint: number;

@IsArray()
@ValidateNested({ each: true })
@Type(() => DropCounts)
drops: DropCounts[];
}

TypeScript Type

interface DropCounts {
dropId: string;
counts: number[];
}

interface CalculateTournamentScoreRequestPayload {
rawGamePoint: number;
drops: DropCounts[];
}

Example Request

{
"rawGamePoint": 1500,
"drops": [
{
"dropId": "drop-123",
"counts": [2, 1, 0, 0, 0]
},
{
"dropId": "drop-456",
"counts": [1, 0, 0, 0, 0]
}
]
}

Field Descriptions

FieldTypeRequiredDescription
rawGamePointnumberYesRaw game score/points earned
dropsDropCounts[]YesArray of drop counts by rarity tier
drops[].dropIdstringYesUnique identifier for the drop
drops[].countsnumber[]YesArray of counts for each rarity tier (0-4)

Drop Counts Structure

The counts array represents the number of NFTs owned for each rarity tier:

  • counts[0]: Common tier count
  • counts[1]: Uncommon tier count
  • counts[2]: Rare tier count
  • counts[3]: Epic tier count
  • counts[4]: Legendary tier count

Usage Example

// Calculate tournament score
const response = await fetch("https://api.intraverse.io//v2/tournament/tournament-123/calculateScore", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"x-game-key": "your-game-client-key",
},
body: JSON.stringify({
rawGamePoint: 1500,
drops: [
{
dropId: "drop-123",
counts: [2, 1, 0, 0, 0], // 2 common, 1 uncommon
},
{
dropId: "drop-456",
counts: [1, 0, 0, 0, 0], // 1 common
},
],
}),
});

const result = await response.json();

if (result.finalScore) {
console.log("Final tournament score:", result.finalScore);
console.log("Rank:", result.rank);
}

API Endpoint

This schema is used by the following endpoint:

  • POST /v2/tournament/:id/calculateScore - Calculate tournament score

Authentication

This endpoint requires dual authentication:

User Authentication

  • JWT Bearer Token: Authorization: Bearer <jwt_token>
  • Purpose: Identifies the authenticated user
  • Scope: User must have valid authentication

Game Authentication

  • Game Key Header: x-game-key: <client_key> or x-game-server-key: <server_key>
  • Purpose: Identifies the game/application making the request
  • Validation: Game key must be valid and active

Example Request Headers

headers: {
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"x-game-key": "your-game-client-key"
}

Response Format

The endpoint returns a response with the following structure:

interface CalculateTournamentScoreResponsePayload {
finalScore: number; // Calculated final tournament score
rank?: number; // User's rank in the tournament
eligibility?: boolean; // Whether user is eligible for rewards
// Additional fields may be present
}

Validation Rules

  • rawGamePoint: Must be a valid number
  • drops: Must be a non-empty array
  • dropId: Must be a valid string
  • counts: Must be an array of numbers (0-4 elements)
  • counts values: Must be non-negative integers

Next Steps