@extends('layouts.app') @section('title','Rankings - GIGAX ARENA') @section('page_title','Rankings') @php use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Route; $groups = [ 'fila'=>['open'=>'OPEN','ranked'=>'RANKED','liga'=>'LIGA'], 'modalidades'=>['custom_x1'=>'X1','custom_x2'=>'X2','custom_x3'=>'X3','custom_x4'=>'X4','custom_x5'=>'X5','custom_x6'=>'X6','custom_x7'=>'X7','custom_x8'=>'X8','team_5l'=>'5L','c1s'=>'C1S / DM','awp'=>'AWP','mf'=>'MF'], 'progresso'=>['xp'=>'XP MENSAL'], ]; $all = array_merge(...array_values($groups)); $chosen = strtolower(trim((string) request()->query('rank','open'))); if(!array_key_exists($chosen,$all)) $chosen='open'; $group = in_array($chosen,array_keys($groups['modalidades']),true)?'modalidades':($chosen==='xp'?'progresso':'fila'); $isMode=$group==='modalidades'; $rows=collect(); $error=null; $scoreLabel=$isMode?'PTS':'XP'; try { if (!Schema::hasTable('users')) throw new \RuntimeException('Tabela users indisponível'); if($isMode) { if(!Schema::hasTable('gigax_player_mode_stats')) throw new \RuntimeException('Ranking da modalidade ainda não configurado'); $rows=DB::table('gigax_player_mode_stats as s') ->join('users as u','u.id','=','s.user_id') ->where('s.mode_code',$chosen) ->select('u.id','u.nickname','u.avatar_url','u.skill_level','s.points as score','s.matches_played as matches','s.wins','s.losses','s.kills','s.deaths','s.current_streak') ->orderByDesc('s.points')->orderByDesc('s.wins')->orderBy('u.nickname') ->limit(100)->get(); } else { if(!Schema::hasTable('gx_player_experience')) throw new \RuntimeException('Ranking mensal ainda não configurado'); $rows=DB::table('gx_player_experience as x') ->join('users as u','u.id','=','x.user_id') ->where('x.monthly_xp','>',0) ->select('u.id','u.nickname','u.avatar_url','u.skill_level','x.monthly_xp as score') ->orderByDesc('x.monthly_xp')->orderBy('u.nickname')->limit(100)->get(); } } catch(\Throwable $e) { \Illuminate\Support\Facades\Log::warning('GIGAX Ranking Hub: consulta indisponivel',['rank'=>$chosen,'error'=>$e->getMessage()]); $error='Classificação temporariamente indisponível.'; } $myId=(int)(auth()->id()??0); $myPosition=$rows->search(fn($p)=>(int)$p->id===$myId); $myPlayer=$myPosition!==false?$rows->get($myPosition):null; @endphp @push('styles') @endpush @section('content')

🏆 RANKINGS GIGAX ARENA

Rankings competitivos • selecione uma classificação no topo
@if($group==='fila')
OPEN, RANKED e LIGA compartilham temporariamente o XP mensal do Lobby. Não são classificações independentes até existirem consultas específicas por fila.
@elseif($isMode)
Pontuação exclusiva da modalidade • não altera o XP do PUG.
@endif

RANKING {{ $all[$chosen] }}

{{ $rows->count() }} jogadores retornados • até 100 posições
POS.JOGADORSKILL{{ $isMode?'PARTIDAS':'—' }}{{ $isMode?'VITÓRIAS':'—' }}{{ $scoreLabel }}
@forelse($rows as $index=>$p) @php $pos=$index+1;$name=(string)($p->nickname??'Jogador');$avatar=trim((string)($p->avatar_url??'')); @endphp
{{ $pos===1?'🥇':($pos===2?'🥈':($pos===3?'🥉':$pos.'º')) }} @if($avatar!=='')@else{{ mb_strtoupper(mb_substr($name,0,1)) }}@endif {{ $name }}{{ $myId===(int)$p->id?'VOCÊ • ':'' }}SKILL {{ max(1,(int)($p->skill_level??1)) }} {{ max(1,(int)($p->skill_level??1)) }} {{ $isMode?(int)($p->matches??0):'—' }} {{ $isMode?(int)($p->wins??0):'—' }} {{ number_format((int)($p->score??0),0,',','.') }}
@empty
{{ $error??'Ainda não existem resultados registrados neste ranking.' }}
@endforelse
Sua posição entre os jogadores retornados: {{ $myPosition===false?'—':($myPosition+1).'º' }}. Pontuações exibidas conforme os registros atuais.
@endsection @push('scripts') @endpush