Exemplo n.º 1
0
$msgsuccess = null;
if (array_key_exists('arte', $_GET)) {
    $gerar = $_POST['acao'] == 'Gerar Token';
    $altura = intval($_POST['altura']);
    $margin_left = intval($_POST['margin_left']);
    $margin_top = intval($_POST['margin_top']);
    $rotate = intval($_POST['rotate']);
    if ($altura <= 0) {
        $altura = 140;
    }
    $id_arte = intval($_GET['arte']);
    $arte = new Arte($id_arte);
    Mapa::setHexWidth(160);
    Mapa::setHexHeight(140);
    Mapa::setHexSide(80);
    Mapa::setMapWidth(5);
    Mapa::setMapHeight(5);
    Mapa::gerarMapa();
    Mapa::getArea(0, 0)->setTipo(AREA_FORA);
    Mapa::getArea(4, 0)->setTipo(AREA_FORA);
    Mapa::getArea(0, 4)->setTipo(AREA_FORA);
    Mapa::getArea(1, 4)->setTipo(AREA_FORA);
    Mapa::getArea(3, 4)->setTipo(AREA_FORA);
    Mapa::getArea(4, 4)->setTipo(AREA_FORA);
    if ($gerar) {
        $width = Mapa::getTileAreaWidth();
        $height = Mapa::getTileAreaHeight();
        $height -= floor(Mapa::getHexWidth() / 2);
        $image2 = imagecreatetruecolor($width, $height);
        imagealphablending($image2, false);
        imagesavealpha($image2, true);
Exemplo n.º 2
0
<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
require 'common.php';
if (!is_null(Mapa::getId())) {
    if (!Mapa::carregarEstrutura(Mapa::getId())) {
        Mapa::setHexHeight(70);
        Mapa::setMapWidth(10);
        Mapa::setMapHeight(6);
        Mapa::gerarMapa();
        Mapa::gravarEstrutura(Mapa::getId());
    }
} else {
    $id_mapa = Mapa::novoIdMapa();
    header('Location: mapa-creator.php?map=' . $id_mapa);
    exit;
}
if (count($_POST) > 0) {
    $x = intval($_POST['x']);
    $y = intval($_POST['y']);
    $queda = intval($_POST['queda']);
    $luz = intval($_POST['luz']);
    $area = Mapa::getArea($x, $y);
    $area->setTipo($_POST['tipo']);
    $area->setImagem($_POST['imagem']);
    $area->setDesnivel(intval($_POST['desnivel']));
    $area->setQueda(intval($_POST['queda']));
    $area->setLuz(intval($_POST['luz']));
    Mapa::gravarEstrutura(Mapa::getId());
    header('content-type: application/json');
    echo Mapa::getAreaJson($area);
Exemplo n.º 3
0
 public static function carregarDoPost()
 {
     $margin_top = intval($_POST['margin_top']);
     $margin_left = intval($_POST['margin_left']);
     $map_width = intval($_POST['map_width']);
     $map_height = intval($_POST['map_height']);
     $hex_width = intval($_POST['hex_width']);
     $hex_height = intval($_POST['hex_height']);
     $hex_side = intval($_POST['hex_side']);
     if (trim($_POST['nome']) == '') {
         throw new Exception("Preencha o nome do mapa.");
     }
     if ($map_width <= 0) {
         throw new Exception("A largura do mapa precisa ser maior que zero.");
     }
     if ($map_height <= 0) {
         throw new Exception("A altura do mapa precisa ser maior que zero.");
     }
     if ($hex_width <= 0) {
         throw new Exception("A largura do hex precisa ser maior que zero.");
     }
     if ($hex_height <= 0) {
         throw new Exception("A algura do hex precisa ser maior que zero.");
     }
     if ($hex_side <= 0) {
         throw new Exception("O tamanho do lado de hex precisa ser maior que zero e menor que a largura.");
     }
     Mapa::setNome($_POST['nome']);
     Mapa::setMarginTop($margin_top);
     Mapa::setMarginLeft($margin_left);
     Mapa::setMapWidth($map_width);
     Mapa::setMapHeight($map_height);
     Mapa::setHexWidth($hex_width);
     Mapa::setHexHeight($hex_height);
     Mapa::setHexSide($hex_side);
 }