@extends('layouts.app') @section('title','Rankings - GIGAX ARENA') @section('page_title','Rankings') @section('content') @php use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Schema; $user = Auth::user(); $go = static fn(string $route, string $fallback) => Route::has($route) ? route($route) : url($fallback); $name = $user->nickname ?? $user->name ?? 'Jogador'; $myId = (int)($user->id ?? 0); $myLevel = (int)($user->skill_level ?? $user->level ?? 1); $myMatches = (int)($user->total_matches ?? $user->matches ?? 0); $myWins = (int)($user->wins ?? 0); $myLosses = (int)($user->losses ?? max(0,$myMatches-$myWins)); $myKills = (int)($user->kills ?? 0); $myDeaths = (int)($user->deaths ?? 0); $myHeadshots = (int)($user->headshots ?? 0); $myKD = $myDeaths > 0 ? number_format($myKills/$myDeaths,2,'.','') : number_format($myKills,2,'.',''); $myWinRate = $myMatches > 0 ? number_format(($myWins/$myMatches)*100,1,',','.') : '0,0'; $myHsRate = $myKills > 0 ? number_format(($myHeadshots/$myKills)*100,1,',','.') : '0,0'; $scoreColumn = null; $players = collect(); try { if (Schema::hasTable('users')) { foreach (['rank_points','ranking_points','mix_points','points','xp'] as $candidate) { if (Schema::hasColumn('users',$candidate)) { $scoreColumn=$candidate; break; } } $select = ['id']; foreach (['nickname','name','avatar_url','skill_level','level','total_matches','matches','wins','losses','kills','deaths','headshots'] as $c) { if (Schema::hasColumn('users',$c)) $select[]=$c; } if ($scoreColumn) $select[]=$scoreColumn; $q=DB::table('users')->select(array_unique($select)); $players = $scoreColumn ? $q->orderByDesc($scoreColumn)->limit(100)->get() : $q->orderByDesc('id')->limit(100)->get(); } } catch (\Throwable $e) {} $normalize = function($p,$position) use ($scoreColumn) { $matches=(int)(data_get($p,'total_matches',data_get($p,'matches',0))); $wins=(int)data_get($p,'wins',0); $kills=(int)data_get($p,'kills',0); $deaths=(int)data_get($p,'deaths',0); return (object)[ 'id'=>(int)data_get($p,'id',0), 'name'=>data_get($p,'nickname',data_get($p,'name','Jogador')), 'avatar'=>data_get($p,'avatar_url'), 'level'=>(int)data_get($p,'skill_level',data_get($p,'level',1)), 'matches'=>$matches, 'wins'=>$wins, 'winrate'=>$matches>0 ? ($wins/$matches)*100 : 0, 'kd'=>$deaths>0 ? $kills/$deaths : $kills, 'score'=>$scoreColumn ? (int)data_get($p,$scoreColumn,0) : 0, 'position'=>$position, ]; }; $ranking = $players->values()->map(fn($p,$i)=>$normalize($p,$i+1)); $myRank = optional($ranking->firstWhere('id',$myId))->position ?? null; $myScore = optional($ranking->firstWhere('id',$myId))->score ?? (int)($scoreColumn ? ($user->{$scoreColumn} ?? 0) : 0); $top10Target = max(3000,(int)(optional($ranking->get(9))->score ?? 3000)); $progress = min(100,max(0,$top10Target > 0 ? ($myScore/$top10Target)*100 : 0)); $onlineCount = 0; try { if (Schema::hasTable('sessions') && Schema::hasColumn('sessions','user_id')) $onlineCount=(int)DB::table('sessions')->whereNotNull('user_id')->distinct()->count('user_id'); } catch (\Throwable $e) {} @endphp
●STATUSOnline{{ $onlineCount }} jogadores ativos
⚔PARTIDAS{{ $myMatches }}Jogadas
🏆VITÓRIAS{{ $myWins }}Vitórias
✣TAXA DE VITÓRIAS{{ $myWinRate }}%Aproveitamento
◈POSIÇÃO{{ $myRank ? '#'.$myRank : '—' }}Sua posição
POSIÇÃOJOGADORNÍVELPARTIDASVITÓRIASTAXA WINK/DPONTOSAÇÃO
@forelse($ranking as $p)
@if($p->position===1)♛@elseif($p->position===2)♛@elseif($p->position===3)♛@endif {{ $p->position }} @if($p->avatar)@else{{ mb_strtoupper(mb_substr($p->name,0,1)) }}@endif {{ $p->name }}GIGAX Anti-Cheat {{ $p->level }} {{ $p->matches }} {{ $p->wins }} {{ number_format($p->winrate,1,',','.') }}% {{ number_format($p->kd,2,'.','') }} {{ number_format($p->score,0,',','.') }} Ver perfil
@empty
O ranking ainda não possui jogadores para exibir.
@endforelse
…
@endsection @push('styles') @endpush @push('scripts') @endpush