113 lines
4.1 KiB
PHP
113 lines
4.1 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if (isset($_POST['cons_def_1']) || isset($_POST['cons_def_2']) || isset($_POST['cons_def_3']) || isset($_POST['cons_def_4']) || isset($_POST['cons_def_5'])) {
|
|
$id=$_SESSION['id'];
|
|
$galaxy=$_SESSION['galaxy'];
|
|
$ss=$_SESSION['ss'];
|
|
$pos=$_SESSION['pos'];
|
|
$race=$_SESSION['race'];
|
|
|
|
require_once('bdd.php');
|
|
require('../connectBDD.php');
|
|
|
|
$id=$_SESSION['id'];
|
|
$galaxy=$_SESSION['galaxy'];
|
|
$ss=$_SESSION['ss'];
|
|
$pos=$_SESSION['pos'];
|
|
$sa=0;
|
|
if (isset($_POST['cons_def_1'])) $sa = floor($_POST['cons_def_1']);
|
|
if (isset($_POST['cons_def_2'])) $sa = floor($_POST['cons_def_2']);
|
|
if (isset($_POST['cons_def_3'])) $sa = floor($_POST['cons_def_3']);
|
|
if (isset($_POST['cons_def_4'])) $sa = floor($_POST['cons_def_4']);
|
|
if (isset($_POST['cons_def_5'])) $sa = floor($_POST['cons_def_5']);
|
|
if ($sa < 0) $sa=0;
|
|
|
|
if (isset($_POST['cons_def_1']) && $sa > 0) {
|
|
if ($metal - ($sa*500) >= 0) {
|
|
if ($cristal - ($sa*200) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(480/pow(1.25,($chantier_terrestre-1)));
|
|
$unit = 9;
|
|
$metal -= ($sa*500);
|
|
$cristal -= ($sa*200);
|
|
|
|
mysql_query("UPDATE planete SET unit_t='$unit', temps_t='$temps_caserne', metal='$metal', cristal='$cristal', hydrogene='$hydrogene', cons_terrestre='$sa' WHERE galaxie='$galaxy' AND ss='$ss' AND position='$pos'") or die ("erreur sql ".mysql_error());
|
|
header("Location: defense.php");
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_def_2']) && $sa > 0) {
|
|
if ($metal - ($sa*4000) >= 0) {
|
|
if ($cristal - ($sa*2000) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(1560/pow(1.25,($chantier_terrestre-3)));
|
|
$unit = 10;
|
|
$metal -= ($sa*4000);
|
|
$cristal -= ($sa*2000);
|
|
|
|
mysql_query("UPDATE planete SET unit_t='$unit', temps_t='$temps_caserne', metal='$metal', cristal='$cristal', hydrogene='$hydrogene', cons_terrestre='$sa' WHERE galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
header("Location: defense.php");
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_def_3']) && $sa > 0) {
|
|
if ($metal - ($sa*4500) >= 0) {
|
|
if ($cristal - ($sa*800) >= 0) {
|
|
if($hydrogene - ($sa*600) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(1800/pow(1.25,($chantier_terrestre-4)));
|
|
$unit = 11;
|
|
$metal -= ($sa*4500);
|
|
$cristal -= ($sa*800);
|
|
$hydrogene -= ($sa*600);
|
|
|
|
mysql_query("UPDATE planete SET unit_t='$unit', temps_t='$temps_caserne', metal='$metal', cristal='$cristal', hydrogene='$hydrogene', cons_terrestre='$sa' WHERE galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
header("Location: defense.php");
|
|
}
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_def_4']) && $sa > 0) {
|
|
if ($metal - ($sa*12000) >= 0) {
|
|
if ($cristal - ($sa*10000) >= 0) {
|
|
if($hydrogene - ($sa*1000) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(6720/pow(1.25,($chantier_terrestre-4)));
|
|
$unit = 12;
|
|
$metal -= ($sa*12000);
|
|
$cristal -= ($sa*10000);
|
|
$hydrogene -= ($sa*1000);
|
|
|
|
mysql_query("UPDATE planete SET unit_t='$unit', temps_t='$temps_caserne', metal='$metal', cristal='$cristal', hydrogene='$hydrogene', cons_terrestre='$sa' WHERE galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
header("Location: defense.php");
|
|
}
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
elseif (isset($_POST['cons_def_5']) && $sa > 0) {
|
|
if ($metal - ($sa*15000) >= 0) {
|
|
if ($cristal - ($sa*9500) >= 0) {
|
|
if($hydrogene - ($sa*1500) >= 0) {
|
|
$temps_caserne = time() + $sa*ceil(12960/pow(1.25,($chantier_terrestre-8)));
|
|
$unit = 13;
|
|
$metal -= ($sa*15000);
|
|
$cristal -= ($sa*9500);
|
|
$hydrogene -= ($sa*1500);
|
|
|
|
mysql_query("UPDATE planete SET unit_t='$unit', temps_t='$temps_caserne', metal='$metal', cristal='$cristal', hydrogene='$hydrogene', cons_terrestre='$sa' WHERE galaxie='$galaxy' AND ss='$ss' AND position='$pos'");
|
|
header("Location: defense.php");
|
|
}
|
|
}
|
|
else echo "Pas assez de cristal !";
|
|
}
|
|
else echo "Pas assez de métal !";
|
|
}
|
|
else header("Location: defense.php");
|
|
}
|
|
mysql_close();
|
|
?>
|