<?php
namespace App\Modules\Gamification\Controllers;

use Core\Controller;
use Core\Services\GamificationEngine;

class GamificationController extends Controller {

    public function index() {
        if (!isset($_SESSION['user_id'])) {
            header("Location: " . BASE_URL . "/auth/login");
            exit;
        }

        $userId = $_SESSION['user_id'];
        $engine = GamificationEngine::getInstance();
        
        $profile = $engine->getProfile($userId);
        $badges = $engine->getUserBadges($userId);

        $this->render('Gamification/Views/index', [
            'title' => 'مسار الإنجازات - OTIS',
            'profile' => $profile,
            'badges' => $badges,
            'userName' => $_SESSION['username'] ?? 'البطل'
        ]);
    }
}
