Exemplo n.º 1
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);
 }