<?php

// Connect to the database
require_once('pdo.php');
require_once('get_provider_translit.php');
require('create_images.php');

$id = 52;
$provider_translit = getProviderTranslit($id);

$url = 'https://mrpacho.com/en/api/v2/game/list?page=1&category=all-games&count=10000';
$data = file_get_contents($url);
$games = json_decode($data, true)["result"];

$insertedGames = [];

foreach ($games as $game) {

        $amatic = $game["brand"];
        if($amatic != "Amatic"){continue;}

        $link = "";
        
        $provider_id = $id;

        $name = $game["name"];
        
        $translit = str_replace(" ", "-", $name);
        $translit = str_replace("&#039;", "-", $translit);
        $translit = str_replace("&#39;", "-", $translit);
        $translit = preg_replace("/[^a-zA-Z0-9\-]/", "", $translit);
        $translit = str_replace("---", "-", $translit);
        $translit = str_replace("--", "-", $translit);

        $gameId = $game["launch_code"];

        $demo_desk = "https://cdn02.cdn.amatic.com/gmsl/amanet/game.html?game=".$gameId."&hash=&wallet=w13&currency=USD&config=14720&isFreeplay=true&language=en&exit=&type=desktop";
        
        $demo_mob = "https://cdn02.cdn.amatic.com/gmsl/amanet/game.html?game=".$gameId."&hash=&wallet=w13&currency=USD&config=14720&isFreeplay=true&language=en&exit=&type=mobile";
        
        $volatility = 0;

        $rtp = 0.0;

        $rtp_low = 0.0;
        
        $rtp_high = 0.0;
        
        $max_win = 0.0;
        
        $img = $game["image"];
        $img = "https://mrpacho834643.com".$img;

        createImage($provider_translit, $translit, $img);

        require ('insert_values.php');

        require ('inserted_games.php');
        
}

// echo json_encode(['insertedGames' => $insertedGames]);
?>
