@extends('layouts.app') @push('styles') @endpush @push('styles') @endpush @section('title','Partidas - GIGAX ARENA') @section('page_title','Minhas Partidas') @section('content') @php $user = auth()->user(); $level = (int) (data_get($user,'level') ?: data_get($user,'skill_level') ?: 1); @endphp @php $gxHistory = collect(); $gxSummary = ['matches'=>0,'wins'=>0,'kills'=>0,'deaths'=>0,'assists'=>0,'kd'=>0]; $gxHistoryError = null; $gxUid = (int) (auth()->id() ?: session('user_id',0)); try { if ($gxUid <= 0) { $gxHistoryError = 'Sessão do jogador não identificada.'; } elseif (!\Illuminate\Support\Facades\Schema::hasTable('mix_training_history') || !\Illuminate\Support\Facades\Schema::hasTable('mix_training_player_stats')) { $gxHistoryError = 'As tabelas do histórico MIX não foram encontradas.'; } else { $gxHistory = \Illuminate\Support\Facades\DB::table('mix_training_history as th') ->join('mix_training_player_stats as ps','ps.match_id','=','th.match_id') ->where('ps.user_id',$gxUid) ->select('th.match_id','th.map_played','th.completed_at','th.winning_team','ps.team','ps.kills','ps.deaths','ps.assists','ps.rating') ->orderByDesc('th.completed_at')->limit(100)->get(); $gxAgg = \Illuminate\Support\Facades\DB::table('mix_training_history as th') ->join('mix_training_player_stats as ps','ps.match_id','=','th.match_id') ->where('ps.user_id',$gxUid) ->selectRaw('COUNT(*) as matches, SUM(CASE WHEN th.winning_team = ps.team THEN 1 ELSE 0 END) as wins, SUM(ISNULL(ps.kills,0)) as kills, SUM(ISNULL(ps.deaths,0)) as deaths, SUM(ISNULL(ps.assists,0)) as assists')->first(); foreach (['matches','wins','kills','deaths','assists'] as $gxKey) $gxSummary[$gxKey]=(int)($gxAgg->$gxKey ?? 0); $gxSummary['kd']=$gxSummary['deaths'] ? $gxSummary['kills']/$gxSummary['deaths'] : $gxSummary['kills']; } } catch (\Throwable $gxEx) { \Illuminate\Support\Facades\Log::warning('GIGAX_PARTIDAS_V2_HISTORY', ['user_id'=>$gxUid,'error'=>$gxEx->getMessage()]); $gxHistoryError = 'Erro ao consultar histórico. Verifique storage/logs/laravel.log.'; } $gxWinRate = $gxSummary['matches'] ? round(100*$gxSummary['wins']/$gxSummary['matches'],1) : 0; @endphp
Partidas jogadas{{ $gxSummary['matches'] }}Partidas finalizadas registradas
Vitórias{{ $gxSummary['wins'] }}{{ $gxWinRate }}% aproveitamento
Kills{{ $gxSummary['kills'] }}Média {{ $gxSummary['matches'] ? number_format($gxSummary['kills']/$gxSummary['matches'],1,',','.') : 0 }} / partida
Mortes{{ $gxSummary['deaths'] }}Média {{ $gxSummary['matches'] ? number_format($gxSummary['deaths']/$gxSummary['matches'],1,',','.') : 0 }} / partida
K/D Ratio{{ number_format($gxSummary['kd'],2,'.','') }}Kills / mortes
@forelse($gxHistory as $gxMatch) @php $gxWon = (string)$gxMatch->winning_team === (string)$gxMatch->team; @endphp @empty @endforelse
DataModoMapaResultadoK/D/APontuaçãoDuraçãoAções
{{ $gxMatch->completed_at ? \Illuminate\Support\Carbon::parse($gxMatch->completed_at)->format('d/m/Y H:i') : '—' }} MIX{{ $gxMatch->map_played ?: '—' }} {{ $gxWon ? 'Vitória' : 'Derrota' }} {{ (int)$gxMatch->kills }}/{{ (int)$gxMatch->deaths }}/{{ (int)$gxMatch->assists }} {{ number_format((float)$gxMatch->rating,2,',','.') }}— #{{ $gxMatch->match_id }}
{{ $gxHistoryError ?: 'Nenhuma partida encontrada no histórico MIX' }}Esta página mostra somente partidas finalizadas vinculadas ao seu usuário nas tabelas de treinamento MIX.
@forelse($gxHistory as $gxMatch)
#{{ $gxMatch->match_id }} · {{ $gxMatch->map_played ?: 'Mapa não informado' }}{{ $gxMatch->completed_at ? \Illuminate\Support\Carbon::parse($gxMatch->completed_at)->format('d/m/Y H:i') : '—' }}
@empty
{{ $gxHistoryError ?: 'Histórico vazio' }}Nenhuma partida MIX finalizada vinculada a este usuário.
@endforelse
Partidas{{ $gxSummary['matches'] }}Total
Vitórias{{ $gxSummary['wins'] }}Total
Derrotas{{ $gxSummary['matches']-$gxSummary['wins'] }}Total
Kills{{ $gxSummary['kills'] }}Total
K/D{{ number_format($gxSummary['kd'],2,'.','') }}Total
Sem dados de desempenhoJogue partidas para gerar comparativos de desempenho.
Sem companheiros registradosOs jogadores aparecerão aqui após partidas concluídas.
@push('scripts') @endpush @endsection