@extends('layouts.app')
@push('styles')
@endpush
@section('title', 'Lobby - GIGAX ARENA')
@section('page_title', 'Lobby')
@php
$waitingMatches = collect($activeLobbies ?? []);
$runningMatches = collect($liveMatches ?? []);
$lobbyMatches = $runningMatches
->concat($waitingMatches)
->unique(fn ($match) => ($match->status ?? '') . ':' . ($match->id ?? ''))
->values();
$totalMatches = $lobbyMatches->count();
$liveTotal = $runningMatches->count();
$waitingTotal = $waitingMatches->count();
// GIGAX: somente para exibir os comandos administrativos nos cards.
$gxLobbyUserId = (int) (session('user_id') ?? auth()->id() ?? 0);
$gxLobbyUserRole = $gxLobbyUserId
? (string) (\Illuminate\Support\Facades\DB::table('users')->where('id', $gxLobbyUserId)->value('role') ?? '')
: '';
$gxLobbyIsAdmin = $gxLobbyUserRole === 'admin';
$avatarUrl = static function ($player) {
$url = trim((string) ($player->avatar_url ?? ''));
return $url !== '' ? $url : asset('default-avatar.png');
};
// Ranking lateral: usa a mesma base real de XP do projeto.
$gxLobbyRanking = collect();
try {
if (\Illuminate\Support\Facades\Schema::hasTable('gx_player_experience')
&& \Illuminate\Support\Facades\Schema::hasTable('users')) {
$gxLobbyRanking = \Illuminate\Support\Facades\DB::table('gx_player_experience as x')
->join('users as u', 'u.id', '=', 'x.user_id')
->where('x.monthly_xp', '>', 0)
->orderByDesc('x.monthly_xp')
->orderBy('u.nickname')
->limit(10)
->get([
'u.id as user_id',
'u.nickname',
'u.avatar_url',
'x.level',
'x.monthly_xp as xp',
]);
}
} catch (\Throwable $e) {
$gxLobbyRanking = collect();
}
// GIGAX_RANKING_MODALIDADES_V17: ranking fechado, isolado do PUG/Skill.
$gxModeRankings = collect();
$gxModeKeys = ['custom_x1','custom_x2','custom_x3','custom_x4','custom_x5','custom_x6','custom_x7','custom_x8','team_5l','c1s','awp'];
try {
if (\Illuminate\Support\Facades\Schema::hasTable('gigax_player_mode_stats') && \Illuminate\Support\Facades\Schema::hasTable('users')) {
$gxModeRankings = \Illuminate\Support\Facades\DB::table('gigax_player_mode_stats as s')
->join('users as u','u.id','=','s.user_id')
->whereIn('s.mode_code',$gxModeKeys)
->select('s.user_id','s.mode_code as mode_key','s.matches_played','s.wins','s.losses','s.kills','s.deaths','s.headshots','s.points','s.rating','s.current_streak','u.nickname','u.avatar_url')
->orderByDesc('s.points')->orderByDesc('s.wins')->get()->groupBy('mode_key');
}
} catch (\Throwable $e) { $gxModeRankings = collect(); }
$gxPlacementMatches = 0;
$gxCurrentSkill = 1;
try {
if ($gxLobbyUserId > 0) {
$gxCurrentSkill = (int) (\Illuminate\Support\Facades\DB::table('users')->where('id',$gxLobbyUserId)->value('skill_level') ?? 1);
if (\Illuminate\Support\Facades\Schema::hasTable('mix_ranking_modes')) {
$gxPlacementMatches = min(10, (int) (\Illuminate\Support\Facades\DB::table('mix_ranking_modes')->where('user_id',$gxLobbyUserId)->where('game_slug','crossfire')->where('queue_mode','casual')->value('matches_played') ?? 0));
}
}
} catch (\Throwable $e) {}
@endphp
@push('styles')
@endpush
@section('content')
{{-- GIGAX_V53_LIVE_QUEUES_BEGIN --}}
{{-- GIGAX_V53_LIVE_QUEUES_END --}}
@forelse($lobbyMatches as $index => $match)
@php
$isLive = (string) ($match->status ?? '') === 'in_progress';
$currentPlayers = (int) ($match->current_players ?? 0);
$maxPlayers = max(1, (int) ($match->max_players ?? 10));
$gxTeamCapacity = max(1, min(8, (int) ceil(max(2, $maxPlayers) / 2))); // V40: 5v5=5 por time, 8v8=8 por time
$gameSlug = strtoupper((string) ($match->game_slug ?? 'crossfire'));
$statusLabel = match((string) ($match->status ?? 'waiting')) {
'in_progress' => 'Ao vivo',
'ready_check' => 'Confirmação',
'veto' => 'Veto',
default => 'Aguardando',
};
$teamA = collect($match->left_players ?? [])->take(8);
$teamB = collect($match->right_players ?? [])->take(8);
$teamAName = (string) ($match->left_team ?? 'Time A');
$teamBName = (string) ($match->right_team ?? 'Time B');
$modeLabel = strtoupper(str_replace(['_', 'x'], [' ', ' x '], (string) ($match->training_type ?: 'MIX 5V5')));
$gxIsC1s = strtolower(trim((string) ($match->training_type ?? ''))) === 'c1s';
$gxIsHost = (int) ($match->host_id ?? 0) === $gxLobbyUserId;
$gxCanStartC1s = $gxIsC1s
&& !$isLive
&& (string) ($match->status ?? 'waiting') === 'waiting'
&& $gxIsHost
&& $currentPlayers >= 2;
// V78: dados do card em 3 eixos, sem alterar os rankings laterais.
$gxTrainingRaw = strtolower(trim((string) ($match->training_type ?? '')));
$gxCardMode = ($gxTrainingRaw === '5l' || str_contains($gxTrainingRaw, 'misto'))
? '5L • MISTO'
: preg_replace('/\s*5X5\s*$/i', '', $modeLabel);
$gxRegion = mb_strtoupper((string) ($match->server_region ?? $match->region ?? 'BR'));
$gxMap = (string) ($match->map_name ?: 'A definir');
$gxSkillFor = static function ($players) {
$ids = collect($players)->map(function ($p) {
return (int) ($p->user_id ?? $p->id ?? 0);
})->filter()->unique()->values();
if ($ids->isEmpty()) return 0;
$avg = \Illuminate\Support\Facades\DB::table('users')
->whereIn('id', $ids)
->avg('skill_level');
return max(0, min(99, (int) round((float) ($avg ?? 0))));
};
$gxSkillA = $gxSkillFor($teamA);
$gxSkillB = $gxSkillFor($teamB);
@endphp
= 12 ? 'hidden' : '' }}>
{{-- V78: 3 eixos A/B/C. Cada célula cresce a partir do próprio centro. --}}
#{{ $match->id }}
{{ $gxTeamCapacity }}v{{ $gxTeamCapacity }}
{{ $match->title ?? $match->name ?? $gxCardMode }}
{{ $gxMap }}
REGIÃO: {{ $gxRegion }}
TIME ABLSKILL {{ str_pad((string)$gxSkillA, 2, '0', STR_PAD_LEFT) }}
VS
TIME BGRSKILL {{ str_pad((string)$gxSkillB, 2, '0', STR_PAD_LEFT) }}
{{ (int) ($match->team_a_count ?? $teamA->count()) }}/{{ $gxTeamCapacity }}
{{ (int) ($match->team_b_count ?? $teamB->count()) }}/{{ $gxTeamCapacity }}
@foreach($teamA as $player)
@php $name = $player->nickname ?? 'Jogador'; @endphp
{{ $name }}
@endforeach
@for($i = $teamA->count(); $i < $gxTeamCapacity; $i++)
+Vaga
@endfor
@foreach($teamB as $player)
@php $name = $player->nickname ?? 'Jogador'; @endphp
{{ $name }}
@endforeach
@for($i = $teamB->count(); $i < $gxTeamCapacity; $i++)
+Vaga
@endfor
@if($gxLobbyIsAdmin)
@endif
@empty
Nenhuma partida disponível. Use JOGAR AGORA para entrar na Fila MIX.
@endforelse
@if($totalMatches > 12)
@endif
{{-- GIGAX_RANKING_MODALIDADES_V17 --}}
{{-- GIGAX_LOBBY_JOIN_PASSWORD_V8_BEGIN --}}
ENTRAR NA SALA
Esta sala é protegida. Digite a senha definida pelo criador.
{{-- GIGAX_LOBBY_JOIN_PASSWORD_V8_END --}}
{{-- GIGAX_LOBBY_READY_MODAL_BEGIN --}}
GIGAX ARENA
PARTIDA ENCONTRADA
A sala completou. Confirme sua participação sem sair do Lobby.
02:00
Ready-check
0/0 confirmados
A página da sala continua disponível em DETALHES, mas o fluxo principal permanece aqui.
{{-- GIGAX_LOBBY_READY_MODAL_END --}}
{{-- GIGAX_LOBBY_ALIGNED_MENU_V34_BEGIN --}}
{{-- GIGAX_LOBBY_ALIGNED_MENU_V34_END --}}
{{-- GIGAX_LOBBY_CLEAN_V45_BEGIN --}}
{{-- GIGAX_LOBBY_CLEAN_V45_END --}}
{{-- GIGAX_LOBBY_GRID_V52_BEGIN --}}
{{-- GIGAX_LOBBY_GRID_V52_END --}}
{{-- GIGAX_DIRECT_DELETE_V16_SCRIPT --}}
@endsection
@push('scripts')
@endpush
{{-- GIGAX_LOBBY_MODAL_RUNTIME_V3_BEGIN --}}
{{-- GIGAX_LOBBY_MODAL_RUNTIME_V3_END --}}
{{-- GIGAX_OPEN_MATCH_MODAL_CARD_V1_SCRIPT --}}
{{-- GIGAX_RANKING_PUG_GREEN_VISIBLE_V2 --}}
{{-- GIGAX_LOBBY_TOOLBAR_V34_BEGIN --}}
{{-- GIGAX_LOBBY_TOOLBAR_V34_END --}}
{{-- GIGAX_REPORTAR_UI_V21 --}}