<?php
include ('logue.php'); 
include ('entete2.php');
include ('evolutionbats.php');
include ('siege.php');
include ('ressource.php');
include ('colo3.php');
$sql = "SELECT pts,exor_lvl,exor_energie,exor_evolution,robo_lvl,fer_ressource,or_ressource,ada_ressource FROM matgraph_users WHERE id='$planete' ";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 
if ($row[exor_lvl] =="0") {
$Depense_fer_ressource = "32000";
$Depense_or_ressource = "20000";
$Depense_ada_ressource = "1500";
}
else {
$Depense_fer_ressource = round((32000 * ( bcpow( 1.3, ($row[exor_lvl] + 1),3))),0);
$Depense_or_ressource = round((20000 * ( bcpow( 1.3, ($row[exor_lvl] + 1),3))),0);
$Depense_ada_ressource = round((1500 * ( bcpow( 1.3, ($row[exor_lvl] + 1),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] - $Depense_fer_ressource) ;
$New_or_ressource = ($row[or_ressource] - $Depense_or_ressource) ;
$New_ada_ressource = ($row[ada_ressource] - $Depense_ada_ressource) ;
$temps1exor = (43200 * (bcpow(1.35, ($row[exor_lvl] + 1),3)));
if ($row[robo_lvl] == "0") {
$exor_evolution = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1exor)));
}
else {
$exor_evolution = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1exor* $siege_temps_evolution * (bcpow(0.9, $row[robo_lvl],3)))));
} 
if ($row[exor_lvl] == "0") {
$besoin_exor_energie2 = "-150" ; }
else {
$besoin_exor_energie2 = round((-150 * (bcpow(1.16, $row[exor_lvl],3))),0);
}
$besoin_exor_energie = -1 * $besoin_exor_energie2 ;
if ($row[fer_ressource] >= $Depense_fer_ressource && $row[or_ressource] >= $Depense_or_ressource && $row[ada_ressource] >= $Depense_ada_ressource && $Total_energie_reste >= $besoin_exor_energie && $evolution < 0) {
$sql = "UPDATE matgraph_users SET exor_evolution='$exor_evolution',fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource WHERE id='$planete'";
$res = db_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>';
?>