Example #1
0
function generate_tab_cred($no_of_tchs)
{
    $curr_max = 3700;
    $map_nums = create_map();
    $start = 0;
    $rand_nos = array();
    while ($start <= $curr_max && $start < $no_of_tchs) {
        $rand_index = rand(0, $curr_max);
        array_push($rand_nos, $map_nums[$rand_index]);
        // changing range
        $map_nums[$rand_index] = $map_nums[$curr_max];
        $curr_max -= 1;
        $start++;
    }
    return $rand_nos;
}
Example #2
0
function create_game($bdd2, $name, $id_type, $id_creator)
{
    $name = protect_sql($name, "none");
    $id_type = protect_sql($id_type, "intval");
    $id_creator = protect_sql($id_creator, "intval");
    $sql = "INSERT INTO `games` VALUES ('', '" . $name . "', NOW(), " . $id_type . ", 'En cours')";
    if ($bdd2->query($sql)) {
        $last_id = $bdd2->last_id();
        if ($type = select_tog($bdd2, $id_type)) {
            $sql2 = "INSERT INTO `play_in` VALUES ('" . $id_creator . "', '" . $last_id . "', '" . $type[0]['nbr_points'] . "', '1')";
            if ($bdd2->query($sql2)) {
                if (create_map($bdd2, $last_id)) {
                    if (create_event_table($bdd2, $last_id)) {
                        return $last_id;
                    } else {
                        delete_map($bdd2, $last_id);
                        return 0;
                    }
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        } else {
            return 0;
        }
    } else {
        return 0;
    }
}
Example #3
0
    ?>
</div>
    <p class="small">
        If you are sure there is no error from your side, fill bug at
        <a href="https://github.com/Foxhind/MapCraft/issues?state=open" target="_blank">github.com/Foxhind/MapCraft/issues</a>
        and attach your osm file.
    </p>
    <p>
        Failed to create a file. <br /><a href="javascript:history.back();">Back</a>
    </p>
<?php 
    exit;
}
// Update map
update_kml($pie_id);
create_map($pie_id);
$pie_link = '/pie/' . $pie_id;
?>

Done!<br/>
Please follow <a href="<?php 
echo $pie_link;
?>
">this link</a>, if you have not been forwarded automatically.
<script type="text/javascript">
     window.location = "<?php 
echo $pie_link;
?>
";
</script>
Example #4
0
function create_map($f_width, $f_height, $f_m, $f_x = null, $f_y = null)
{
    $arrMap = array_fill(0, $f_height, array_fill(0, $f_width, 0));
    $iMines = 0;
    while ($iMines < $f_m) {
        $x = rand(0, $f_width - 1);
        $y = rand(0, $f_height - 1);
        if ('m' !== $arrMap[$y][$x]) {
            $arrMap[$y][$x] = 'm';
            surrounders_plus_one($arrMap, $x, $y);
            $iMines++;
        }
    }
    // I clicked something and that must be a 0
    if ($f_x !== null && $f_y !== null && isset($arrMap[$f_y][$f_x])) {
        $tile = $arrMap[$f_y][$f_x];
        if ($tile !== 0) {
            return create_map($f_width, $f_height, $f_m, $f_x, $f_y);
        }
    }
    return $arrMap;
}