@extends('layouts.app') @section('title', __('ui.challenge_title').' — Coaster World') @section('content') @php $scopeIcons = ['personal' => '🎯', 'friends' => '🤝', 'group' => '👥', 'community' => '🌍']; $typeIcons = ['rides' => '🎡', 'coasters' => '🎢', 'new_coasters' => '✨', 'parks' => '🏰', 'manufacturers' => '⚙️']; @endphp
{{ __('ui.challenge_kicker') }}

{{ __('ui.challenge_title') }}

{{ __('ui.challenge_intro') }}

🔥{{ $activeCount }}{{ __('ui.challenge_stat_active') }}
{{ $completedCount }}{{ __('ui.challenge_stat_completed') }}
🏆{{ $officialCompleted }}{{ __('ui.challenge_stat_official') }}
@if(session('challenge_status'))
{{ session('challenge_status') }}
@endif @if($errors->any())
{{ $errors->first() }}
@endif
{{ __('ui.challenge_filter_scope') }}
@foreach(['all', 'personal', 'friends', 'group', 'community'] as $scopeKey) {{ $scopeKey === 'all' ? '✦' : $scopeIcons[$scopeKey] }} {{ __('ui.challenge_scope_'.$scopeKey) }} @endforeach
{{ __('ui.challenge_filter_period') }}
@foreach(['all', 'week', 'month', 'custom'] as $periodKey) {{ __('ui.challenge_period_'.$periodKey) }} @endforeach
{{ __('ui.challenge_live_kicker') }}

{{ __('ui.challenge_live_title') }}

{{ __('ui.challenge_live_intro') }}

@forelse($items as $challenge) @php $participant = $myParticipants->get($challenge->id); $target = max(1, (int) data_get($challenge->rules, 'target_score', 1)); $score = (int) ($participant?->score ?? 0); $progress = min(100, (int) round(($score / $target) * 100)); $joined = $participant && in_array($participant->status, ['accepted', 'active', 'completed'], true); $completed = $participant?->status === 'completed'; $ended = $challenge->status === 'completed' || $challenge->ends_at?->isPast(); $systemTitleKey = 'challenge_official_'.$challenge->period_kind.'_'.$challenge->challenge_type.'_title'; $systemTextKey = 'challenge_official_'.$challenge->period_kind.'_'.$challenge->challenge_type.'_text'; $title = $challenge->is_system && __($systemTitleKey) !== $systemTitleKey ? __($systemTitleKey) : $challenge->name; $description = $challenge->is_system && __($systemTextKey) !== $systemTextKey ? __($systemTextKey) : $challenge->description; $ranking = $challenge->participants->sortByDesc('score')->values(); @endphp
{{ $typeIcons[$challenge->challenge_type] ?? '⚡' }}
{{ $scopeIcons[$challenge->scope] ?? '🎯' }} {{ __('ui.challenge_scope_'.$challenge->scope) }} {{ __('ui.challenge_period_'.$challenge->period_kind) }} @if($challenge->is_system)✓ {{ __('ui.challenge_official') }}@endif

{{ $title }}

@if($description)

{{ $description }}

@endif
{{ __('ui.challenge_goal') }}{{ $target }} {{ __('ui.challenge_type_'.$challenge->challenge_type) }}
{{ __('ui.challenge_ends') }}{{ $challenge->ends_at?->locale(app()->getLocale())->diffForHumans() ?: '—' }}
@if($challenge->group)
{{ __('ui.challenge_scope_group') }}{{ $challenge->group->name }}
@endif
@if($challenge->is_system)
✦ {{ (int) $challenge->reward_xp }} XP @if($challenge->reward_badge_key)🏆 {{ __('ui.challenge_reward_badge') }}@endif
@endif @if($joined)
{{ __('ui.challenge_your_progress') }}{{ $score }} / {{ $target }}
@if($completed)🏆 {{ __('ui.challenge_completed') }}@endif
@endif @if($ranking->isNotEmpty())
{{ __('ui.challenge_leaders') }}
@foreach($ranking->take(3) as $ranked) {{ ['🥇','🥈','🥉'][$loop->index] }} {{ $ranked->user?->username ? '@'.$ranked->user->username : ($ranked->user?->name ?: '—') }} {{ $ranked->score }} @endforeach
@endif
@if(!$ended && !$joined)
@csrf
@elseif(!$ended && $joined && !$completed && $challenge->scope !== 'personal')
@csrf @method('DELETE')
@endif @if(!$challenge->is_system && !$ended && (int) $challenge->created_by_user_id === (int) auth()->id())
@csrf
@endif
@empty

{{ __('ui.challenge_empty_title') }}

{{ __('ui.challenge_empty_text') }}

@endforelse
{{ __('ui.challenge_create_kicker') }}

{{ __('ui.challenge_create_title') }}

{{ __('ui.challenge_create_intro') }}

🛡️ {{ __('ui.challenge_custom_reward_note') }}
@csrf
@endsection