<?php
require_once __DIR__ . '/config.php';

$pdo->exec("
CREATE TABLE IF NOT EXISTS games (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    categories VARCHAR(255) DEFAULT '',
    image_url TEXT NOT NULL,
    link VARCHAR(255) NOT NULL,
    rtp DECIMAL(5,2) DEFAULT 98.00,
    sort_order INT DEFAULT 0,
    is_popular TINYINT(1) DEFAULT 0,
    is_top_rated TINYINT(1) DEFAULT 0,
    is_best_choice TINYINT(1) DEFAULT 0,
    badge_text VARCHAR(20) DEFAULT '',
    badge_color VARCHAR(50) DEFAULT 'badge-tb',
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
");

$existing = $pdo->query("SELECT count(*) FROM games")->fetchColumn();
if ($existing == 0) {
    $games = [
        ['WinGo', 'Lottery,Popular', 'https://pakclub.bet/img/6004/gamelogo/ARLottery/053839317-30101-file_20260407053839311.webp', '/WinGo/WinGo_30S.php', 98.27, 1, 1, 1, 1, 'Top1', 'badge-top'],
        ['Aviator', 'Popular,Top Rated', 'https://pakclub.bet/img/0/gamelogo/SPRIBE/aviator.png', 'javascript:showToast(\'Not aviliable\')', 97.02, 2, 1, 1, 0, 'Top2', 'badge-top'],
        ['Aviator (Alt)', 'Top Rated', 'https://pakclub.bet/img/0/gamelogo/TB_Chess/043300184-22935-file_20260114043300150.webp', 'javascript:showToast(\'Not aviliable\')', 98.09, 3, 0, 1, 0, 'Top3', 'badge-top'],
        ['Chicken Road 2', 'Games,Popular', 'https://pakclub.bet/img/0/gamelogo/TB_Chess/043259069-22911-file_20260114043259027.webp', 'javascript:showToast(\'Not aviliable\')', 98.60, 4, 1, 0, 0, 'TB', 'badge-tb'],
        ['Wildfire Wins', 'Games', 'https://pakclub.bet/img/0/gamelogo/MG/SMG_wildfireWins.png', 'javascript:showToast(\'Not aviliable\')', 99.23, 5, 0, 0, 0, 'MG', 'badge-mg'],
        ['Fortune Gems 2', 'Games,Best Choice', 'https://pakclub.bet/img/0/gamelogo/JILI/121851683-9353-223.png', 'javascript:showToast(\'Not aviliable\')', 97.52, 6, 0, 0, 1, 'JILI', 'badge-jili']
    ];
    $stmt = $pdo->prepare("INSERT INTO games (name, categories, image_url, link, rtp, sort_order, is_popular, is_top_rated, is_best_choice, badge_text, badge_color) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    foreach ($games as $g) {
        $stmt->execute($g);
    }
}
echo "Done";
