<!------------------------------[DEV ZER00IB]-------------------------------------->
<main id="main-route">
    <div class="main-content slot-game">
        <div class="container">
            <nav class="breadcrumb-container">
                <ul class="breadcrumb-list">
                    <li class="breadcrumb-item" text="MPOSLOT" url="<?php echo $urlweb ?>">
                        <a href="<?php echo $urlweb ?>" class="breadcrumb-link" target="_self"><?php echo $judul; ?></a>
                    </li>
                    <li class="breadcrumb-item" text="Slot" url="?page=arcade">
                        <a href="?page=arcade" class="breadcrumb-link" target="_self">Arcade</a>
                    </li>
                    <li class="breadcrumb-item" text="JDB" url="?page=arcade_jdb">
                        <a href="?page=arcade_jdb" class="breadcrumb-link" target="_self">JDB</a>
                    </li>
                </ul>
            </nav>
        </div>
        <div class="container">
            <div class="slot-game__container">
                <div class="slot-game-header">
                    <h3>JDB</h3>
                    <div class="slot-game__search-cont">
                        <div class="game-search">
                            <input class="form-control-sm" type="text" onkeyup="searchGames(this)" placeholder="Cari ...">
                            <a href="#" class="search-btn">
                                <i class="fas fa-search"></i>
                            </a>
                        </div>
                    </div>
                </div>
                <div class="component-pills-tab" id="game-filter">
                    <a href="javascript:void(0);" class="filter-tab" onclick="changeCategory('OT')">All Games</a>
                    <a href="javascript:void(0);" class="filter-tab" onclick="changeCategory('FH')">Fishing</a>
                </div>
                <div class="slot-game-list" id="game-list">
                    <?php
                    $categories = isset($_POST['category']) ? $_POST['category'] : 'OT';

                    $id_provider = 'JD';
                    $user = $_SESSION['username'];
                    $getUser = mysqli_query($koneksi, "SELECT * FROM tb_user WHERE username = '$user'");
                    $infouser = mysqli_fetch_array($getUser);
                    $extplayer = $infouser['extplayer'];
                    $query = mysqli_query($koneksi, "SELECT * FROM tb_games WHERE game_provider = '$id_provider' AND game_type = '$categories'");
                    function generateRandomRTP()
                    {
                        $minRTP = 80;
                        $maxRTP = 96;
                        return rand($minRTP, $maxRTP);
                    }
                    $randomRTP = generateRandomRTP();
                    while ($row = mysqli_fetch_array($query)) {
                        if (isset($_SESSION['username'])) {
                            $que = mysqli_query($koneksi, "SELECT * FROM tb_user WHERE extplayer = '$extplayer' AND status_game = 'offgame'");
                            $cek = mysqli_num_rows($que);

                            if ($cek > 0) {
                                $link_url = 'index.php?pesan=22';
                            } else {
                                $link_url = $urlweb . "/main/PlayGame.php?p=" . $extplayer . "&id=" . $row['game_code'];
                            }
                        } else {
                            // Mengganti dengan fungsi gameAlert
                            $link_url = 'javascript:void(0);';
                        }
                    ?>
<!------------------------------[DEV ZER00IB]-------------------------------------->
                        <div class="slot-game-item slot-tg xbonus-buy-slot-games show" style="">
                            <a class="main sekarang main-sekarang-alert" href="<?php echo $link_url ?>" <?php if (!isset($_SESSION['username'])) echo 'onclick="gameAlert()"'; ?>>
                                <div class="slot-game-tag hot">
                                    <div class="info"><i class="fab fa-hotjar"></i> Permainan Baru</div>
                                </div>
                                <div class="slot-game-img">
                                    <img src="<?php echo $row['game_image'] ?>" style="height: 100px;" loading="lazy">
                                </div>
                                <div class="hover-play">
                                    <i class="fas fa-play"></i>
                                </div>

                                <?php if (!isset($_SESSION['username'])) { ?>
                                    <!-- Progress Bar ditampilkan jika user belum login -->
                                    <div class="progress baradjust rounded-0">
                                        <div class="progress-bar progress-bar-striped progress-bar-animated bg-info" id="progress-rtp" role="progressbar" style="width:<?= $row['rtp'] ?>%;" aria-valuenow="81" aria-valuemin="0" aria-valuemax="100">
                                            RTP <?= $randomRTP ?>%
                                        </div>
                                    </div>
                                <?php } ?>

                                <div class="games-bottom">
                                    <div class="bottom-info">
                                        <div class="name"><?= $row['game_name'] ?></div>
                                    </div>
                                </div>
                            </a>
                        </div>
                    <?php } ?>
                </div>

                <div class="game mt-5">
                    <div class="game__seo">
                        <div hidden id="title-seo"><?php echo $urlweb ?>: JDB</div>
                        <div class="seo-content showFooter"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function changeCategory(category) {
            $.ajax({
                url: '?page=arcade_jdb',
                type: 'POST',
                data: { category: category },
                success: function(response) {
                    $('#game-list').html($(response).find('#game-list').html());
                }
            });
        }
        function searchGames(_this) {
            let value = $(_this).val().toLowerCase();
            $(".slot-game-list .slot-game-item").filter(function () {
                $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
            });
        }
    </script>
</main>
<!------------------------------[DEV ZER00IB]-------------------------------------->
