{{-- «Дуэли» on /games.php, for a logged-in student: challenges waiting for them, their recent duels and their win/loss record. $duels: Duels::listFor() — newest first, each with ->status (incoming, waiting, playing, win, loss, draw, declined, expired) $record: Duels::record() — ['wins', 'losses', 'draws'] --}} @push('styles') @endpush @php $statusBadges = [ 'incoming' => ['text-bg-primary', __('Вас вызвали')], 'playing' => ['text-bg-warning', __('Идёт раунд')], 'waiting' => ['text-bg-light border', __('Ждём соперника')], 'win' => ['text-bg-success', __('Победа')], 'loss' => ['text-bg-danger', __('Поражение')], 'draw' => ['text-bg-secondary', __('Ничья')], 'declined' => ['text-bg-light border', __('Отклонён')], 'expired' => ['text-bg-light border', __('Истёк')], ]; @endphp

{{ __('Дуэли') }}

@if ($record !== null && ($record['wins'] + $record['losses'] + $record['draws']) > 0) {{ __('Побед:') }} {{ $record['wins'] }} {{ __('· поражений:') }} {{ $record['losses'] }} {{ __('· ничьих:') }} {{ $record['draws'] }} @endif
@if (! empty($isTeacher))

{{ __('Ученики могут вызвать вас на дуэль в любой игре. Примите вызов — раунд начнётся у вас обоих одновременно, с одинаковыми вопросами. За победу над учителем ученик получает достижение.') }}

@else

{{ __('Откройте любую игру и нажмите «Вызвать на дуэль». Когда соперник примет вызов, раунд начнётся у вас обоих одновременно, с одинаковыми вопросами. Вызвать можно и учителя!') }}

@endif @if (empty($duels))
{{ __('Дуэлей пока нет.') }}
@else
@foreach ($duels as $d) @php([$badgeClass, $badgeLabel] = $statusBadges[$d->status] ?? ['text-bg-light border', $d->status])
{{ $d->is_challenger ? __('Вы').' → ' : '' }}{{ $d->other_name }}{{ $d->is_challenger ? '' : ' → '.__('вы') }}
{{ \App\Services\Duels::GAME_LABELS[$d->game] ?? $d->game }} · {{ \Illuminate\Support\Carbon::parse($d->created_at)->format('d.m H:i') }}
@if ($d->my_score !== null || $d->their_score !== null)
{{ $d->my_score ?? '—' }} : {{ $d->their_score ?? '—' }}
@endif {{ $badgeLabel }} @if ($d->status === 'incoming')
{{ __('Принять') }}
@csrf
@elseif ($d->status === 'playing') {{ __('Вернуться в раунд') }} @endif
@endforeach
@endif