216 lines
9.4 KiB
PHP
216 lines
9.4 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (isset($_POST['cons_sto']) || isset($_POST['cons_sonde']) || isset($_POST['cons_vcolo']) || isset($_POST['cons_transporteur']) || isset($_POST['cons_gtransporteur']) || isset($_POST['cons_chasseur']) || isset($_POST['cons_fregate']) || isset($_POST['cons_croiseur2']) || isset($_POST['cons_croiseur'])) {
|
|
$id=$_SESSION['id'];
|
|
$galaxy=$_SESSION['galaxy'];
|
|
$ss=$_SESSION['ss'];
|
|
$pos=$_SESSION['pos'];
|
|
$race=$_SESSION['race'];
|
|
|
|
require_once('bdd.php');
|
|
require('../connectBDD.php');
|
|
|
|
$sa=0;
|
|
if (isset($_POST['cons_transporteur'])) $sa = floor($_POST['cons_transporteur']);
|
|
if (isset($_POST['cons_vcolo'])) $sa = floor($_POST['cons_vcolo']);
|
|
if (isset($_POST['cons_sonde'])) $sa = floor($_POST['cons_sonde']);
|
|
if (isset($_POST['cons_chasseur'])) $sa = floor($_POST['cons_chasseur']);
|
|
if (isset($_POST['cons_croiseur'])) $sa = floor($_POST['cons_croiseur']);
|
|
if (isset($_POST['cons_croiseur2'])) $sa = floor($_POST['cons_croiseur2']);
|
|
if (isset($_POST['cons_fregate'])) $sa = floor($_POST['cons_fregate']);
|
|
if (isset($_POST['cons_gtransporteur'])) $sa = floor($_POST['cons_gtransporteur']);
|
|
if (isset($_POST['cons_sto'])) $sa = floor($_POST['cons_sto']);
|
|
|
|
if ($sa < 0) $sa=0;
|
|
if (isset($_POST['cons_transporteur']) && $sa != 0) {
|
|
if ($metal - ($sa*1000) >= 0) {
|
|
if ($cristal - ($sa*800) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(1080/pow(1.25,$chantier_spatial));
|
|
$unit = 1;
|
|
$metal -= ($sa*1000);
|
|
$cristal -= ($sa*800);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_close();
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_gtransporteur']) && $sa != 0) {
|
|
if ($metal - ($sa*4000) >= 0) {
|
|
if ($cristal - ($sa*3000) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(6300/pow(1.25,$chantier_spatial));
|
|
$unit = 2;
|
|
$metal -= ($sa*4000);
|
|
$cristal -= ($sa*3000);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_close();
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_vcolo']) && $sa != 0) {
|
|
if ($metal - ($sa*9000) >= 0) {
|
|
if ($cristal - ($sa*9000) >= 0) {
|
|
if($hydrogene - ($sa*1000) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(8280/pow(1.25,$chantier_spatial));
|
|
$unit = 3;
|
|
$metal -= ($sa*9000);
|
|
$cristal -= ($sa*9000);
|
|
$hydrogene -= ($sa*1000);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal', hydrogene='$hydrogene' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez d'hydrogène !";
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_gtransporteur']) && $sa != 0) {
|
|
if ($metal - ($sa*15000) >= 0) {
|
|
if ($cristal - ($sa*9000) >= 0) {
|
|
if($hydrogene - ($sa*1000) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(7380/pow(1.25,$chantier_spatial));
|
|
$unit = 5;
|
|
$metal -= ($sa*15000);
|
|
$cristal -= ($sa*9000);
|
|
$hydrogene -= ($sa*1000);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal', hydrogene='$hydrogene' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez d'hydrogène !";
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_chasseur']) && $sa != 0) {
|
|
if ($metal - ($sa*1700) >= 0) {
|
|
if ($cristal - ($sa*1220) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(1200/pow(1.25,$chantier_spatial));
|
|
$unit = 6;
|
|
$metal -= ($sa*1700);
|
|
$cristal -= ($sa*1220);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_fregate']) && $sa != 0) {
|
|
if ($metal - ($sa*5800) >= 0) {
|
|
if ($cristal - ($sa*1400) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(4680/pow(1.25,$chantier_spatial));
|
|
$unit = 7;
|
|
$metal -= ($sa*5800);
|
|
$cristal -= ($sa*1400);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'") or die ("erreur sql ".mysql_error());
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'") or die ("erreur sql ".mysql_error());
|
|
mysql_close();
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_croiseur']) && $sa != 0) {
|
|
if ($metal - ($sa*20000) >= 0) {
|
|
if ($cristal - ($sa*16000) >= 0) {
|
|
if($hydrogene - ($sa*1600) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(16800/pow(1.25,$chantier_spatial));
|
|
$unit = 8;
|
|
$metal -= ($sa*20000);
|
|
$cristal -= ($sa*16000);
|
|
$hydrogene -= ($sa*1600);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal', hydrogene='$hydrogene' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez d'hydrogène !";
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_croiseur2']) && $sa != 0) {
|
|
if ($metal - ($sa*26000) >= 0) {
|
|
if ($cristal - ($sa*16400) >= 0) {
|
|
if($hydrogene - ($sa*1600) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(18060/pow(1.25,$chantier_spatial));
|
|
$unit = 9;
|
|
$metal -= ($sa*26000);
|
|
$cristal -= ($sa*16400);
|
|
$hydrogene -= ($sa*1600);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal', hydrogene='$hydrogene' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez d'hydrogène !";
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_sonde']) && $sa != 0) {
|
|
if ($metal - ($sa*1000) >= 0) {
|
|
if ($cristal - ($sa*1200) >= 0) {
|
|
if($hydrogene - ($sa*100) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(1440/pow(1.25,$chantier_spatial));
|
|
$unit = 4;
|
|
$metal -= ($sa*1000);
|
|
$cristal -= ($sa*1200);
|
|
$hydrogene -= ($sa*100);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal', hydrogene='$hydrogene' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez d'hydrogène !";
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_sto']) && $sa != 0) {
|
|
if ($metal - ($sa*500000) >= 0) {
|
|
if ($cristal - ($sa*400000) >= 0) {
|
|
if($hydrogene - ($sa*250000) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(117000/pow(1.25,$chantier_spatial));
|
|
$unit = 11;
|
|
$metal -= ($sa*500000);
|
|
$cristal -= ($sa*400000);
|
|
$hydrogene -= ($sa*250000);
|
|
|
|
mysql_query("UPDATE planete SET unit_s='$unit', metal='$metal', cristal='$cristal', hydrogene='$hydrogene' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
mysql_query("UPDATE planete SET cons_spatial='$sa', temps_spatial='$temps_caserne' WHERE id_user='$id' AND galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
@header("Location: chantier_spatial.php");
|
|
}
|
|
else echo "Pas assez d'hydrogène !";
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
else @header("Location: chantier_spatial.php");
|
|
mysql_close();
|
|
}
|
|
?>
|