Commit d6ec628c authored by Mahmoud Aglan's avatar Mahmoud Aglan

feat: tournaments hub — full tab with filters, registration, match launch

Replace shop tab with tournaments hub. Players can browse all tournaments,
filter by status, register, and launch pending matches directly from the hub.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 3fc863bf
......@@ -18,9 +18,9 @@ if ($method === 'GET') {
if ($action === 'list') {
$tournaments = $db->get('el3ab_tournaments', [
'select' => 'id,name,game_key,format,time_control,status,max_players,starts_at,ends_at,prize_pool,entry_fee',
'order' => 'starts_at.desc',
'limit' => 20
'select' => 'id,name,game_key,format,time_control,status,max_players,swiss_rounds,starts_at,ends_at,prize_pool_coins,entry_fee_coins',
'order' => 'created_at.desc',
'limit' => 50
]);
if (!is_array($tournaments) || isset($tournaments['error'])) {
......@@ -48,6 +48,17 @@ if ($method === 'GET') {
jsonResponse($tournament);
}
if ($action === 'my-registrations') {
$token = requireAuth();
$userId = getUserId($token);
$regs = $db->get('tournament_registrations', [
'player_id' => 'eq.' . $userId,
'status' => 'eq.registered',
'select' => 'tournament_id'
]);
jsonResponse(['registrations' => is_array($regs) && !isset($regs['error']) ? $regs : []]);
}
}
if ($method === 'POST') {
......
......@@ -151,17 +151,17 @@ function formatNum(n) {
}
function updateTournamentBadge(pending) {
const rankTab = tabBar?.querySelector('[data-world="rank"]');
if (!rankTab) return;
let badge = rankTab.querySelector('.tour-badge');
const tourTab = tabBar?.querySelector('[data-world="tournaments"]');
if (!tourTab) return;
let badge = tourTab.querySelector('.tour-badge');
const count = Array.isArray(pending) ? pending.length : 0;
if (count > 0) {
if (!badge) {
badge = document.createElement('div');
badge.className = 'tour-badge';
badge.style.cssText = 'position:absolute;top:2px;right:8px;width:8px;height:8px;background:#E4AC38;border-radius:50%;';
rankTab.style.position = 'relative';
rankTab.appendChild(badge);
tourTab.style.position = 'relative';
tourTab.appendChild(badge);
}
} else if (badge) {
badge.remove();
......
import * as scene from '../../core/scene.js';
import { mountLeaderboard } from './scenes/leaderboard.js';
import { mountTournaments } from './scenes/tournaments.js';
import { mountTournamentDetail } from './scenes/tournament-detail.js';
import { mountTournamentBracket } from './scenes/tournament-bracket.js';
import { mountTournamentArena } from './scenes/tournament-arena.js';
import { mountTournamentLobby } from './scenes/tournament-lobby.js';
import { mountTournamentLive } from './scenes/tournament-live.js';
scene.register('leaderboard', mountLeaderboard);
scene.register('tournaments', mountTournaments);
scene.register('tournament-detail', mountTournamentDetail);
scene.register('tournament-bracket', mountTournamentBracket);
scene.register('tournament-arena', mountTournamentArena);
scene.register('tournament-lobby', mountTournamentLobby);
scene.register('tournament-live', mountTournamentLive);
export { mountTournamentArena } from '../../rank/scenes/tournament-arena.js';
export { mountTournamentBracket } from '../../rank/scenes/tournament-bracket.js';
export { mountTournamentDetail } from '../../rank/scenes/tournament-detail.js';
This diff is collapsed.
export { mountTournamentLive } from '../../rank/scenes/tournament-live.js';
export { mountTournamentLobby } from '../../rank/scenes/tournament-lobby.js';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment