<?php
include ('logue.php'); 
include ('entete2.php');
include ('evolutionbats.php');
include ('siege.php');
include ('ressource.php');
include ('colo3.php');
$sql = "SELECT pts,ada_lvl,ada_energie,robo_lvl,fer_ressource,or_ressource FROM matgraph_users WHERE id='$planete' ";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 
if ($row[ada_lvl] =="0") {
$Depense_fer_ressource = "500";
$Depense_or_ressource = "160";
}
else {
$Depense_fer_ressource = round((500 * ( bcpow( 1.45, ($row[ada_lvl] + 1),3))),0);
$Depense_or_ressource = round((160 * ( bcpow( 1.45, ($row[ada_lvl] + 1),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] - $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] - $Depense_or_ressource) ;

$temps1ada = (432 * (bcpow(1.4, ($row[ada_lvl] + 1),3)));
if ($row[robo_lvl] == "0") {
$ada_evolution =  strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1ada)));
}
else {
$ada_evolution =  strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1ada* $siege_temps_evolution * (bcpow(0.9, $row[robo_lvl],3)))));
} 

if ($row[fer_ressource] >= $Depense_fer_ressource && $row[or_ressource] >= $Depense_or_ressource && $Total_energie_reste >= $besoin_ada_energie && $evolution < 0) {
$sql = "UPDATE matgraph_users SET ada_evolution='$ada_evolution', fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete'";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error()); }
echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("batiments.php");
-->
</script>';
?>