<?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);
Beispiel #2
0
 public static function carregarDB($dados)
 {
     if (!is_null($dados)) {
         //throw new Exception ('Mapa não encontrado!');
         $mapa = unserialize($dados->data);
         //if (is_null($mapa) || !(is_array($mapa)))
         //static::$ ($dados->id_mapa);
         static::setMarginTop($dados->margem_topo);
         static::setMarginLeft($dados->margem_esquerda);
         static::setMapWidth($dados->mapa_largura);
         static::setMapHeight($dados->mapa_altura);
         static::setHexWidth($dados->hex_largura);
         static::setHexHeight($dados->hex_altura);
         static::setHexSide($dados->hex_lado);
         if (is_null($mapa)) {
             static::$mapa = array();
         } elseif ($mapa === false) {
             static::$mapa = array();
         } elseif (!is_array($mapa)) {
             throw new Exception('Dados do mapa estão corrompidos!');
         }
         static::$mapa = $mapa;
         static::$imagem_path = $dados->imagem;
         static::$nome = $dados->nome;
         static::$id_campanha = $dados->id_campanha;
         return true;
     } else {
         Mapa::setHexHeight(70);
         Mapa::setMapWidth(10);
         Mapa::setMapHeight(6);
         Mapa::gerarMapa();
         return false;
     }
 }