<?php 
    require "../includes/config.php";

    if (!isset($_SESSION["data"])) {
        header("Location: signin");
        exit;
    }

    // Get money
    $stmt = $conn->prepare("SELECT money FROM users WHERE uid = ?");
    $stmt->bind_param("i", $_SESSION['data']['uid']);
    $stmt->execute();
    $result = $stmt->get_result();
    $user = $result->fetch_assoc();
    $stmt->close();

    // Update session 
    $_SESSION['data']['money'] = $user['money'];
?>

<!doctype html>
<html lang="id">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>Hit & Run</title>
        <link rel="stylesheet" href="assets/css/style.css">
    </head>

    <body>
    <div style="padding-right: 32px;">
        <div class="gamename card">
            Hit & Run <br> 
            Hit or you Lose.
        </div>
        <div style="padding-top: 32px; display:flex; flex-direction:column; align-items:center;">
            <div class="num-box">
                <button class="btn minus">-</button>
                <input min="1000" max="<?php echo $_SESSION['data']['money']; ?>"type="number" value="1000" style="margin-bottom: -1px;">
                <button class="btn plus">+</button>
            </div>
            <button class="btn btn-primary" id="playBtn">▶️ MAINKAN</button>
        </div>
    </div>

    <div>
        <div class="userbox">
            <div class="avatar">P</div>

            <div class="info">
                <div class="name"><?php echo $_SESSION['data']["username"]; ?></div>
                <div class="saldo">Saldo: <span><?php echo $_SESSION['data']["money"]; ?></span></div>
                <div class="status">Status: Masih Pemula Banghh....</div>
            </div>
        </div>

    </div>

        <script>
            const playBtn = document.getElementById('playBtn');
            console.log("Startgame");
        </script>
    </body>
    <script src="assets/js/menu.js"></script>
</html>
