<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'tasmoybb_dazzaii');
define('DB_PASS', '3XT3RN4l!337');
define('DB_NAME', 'tasmoybb_dazza2');

define('BASE_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/champions-rpg');
define('IMAGE_PATH', $_SERVER['DOCUMENT_ROOT'] . '/champions-rpg/images');
define('IMAGE_URL', BASE_URL . '/images');

// Champion image paths
function getChampionImage($championName, $type = 'flyer') {
    $name = ucfirst(strtolower($championName));
    return IMAGE_URL . "/champions/{$name}/{$name}-{$type}.png";
}

function getChampionImagePath($championName, $type = 'flyer') {
    $name = ucfirst(strtolower($championName));
    return IMAGE_PATH . "/champions/{$name}/{$name}-{$type}.png";
}

// Database connection
function getDB() {
    static $pdo = null;
    if ($pdo === null) {
        try {
            $pdo = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASS);
            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
        } catch (PDOException $e) {
            die("Connection failed: " . $e->getMessage());
        }
    }
    return $pdo;
}
?>


