<?php
include ('logue.php');
include ('entete2.php');
include ('evolutionbats.php');
include ('siege.php');
include ('ressource.php');
include ('colo3.php');
$sql = "SELECT pts,fer_lvl,fer_energie,fer_evolution,robo_lvl 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[fer_lvl] =="0") {
$Depense_fer_ressource = "60";
$Depense_or_ressource = "15";
}
else {
$Depense_fer_ressource = round((60 * ( bcpow( 1.45, ($row[fer_lvl] + 1),3))),0);
$Depense_or_ressource = round((15 * ( bcpow( 1.45, ($row[fer_lvl] + 1)))),0);
}
$New_fer_ressource = ($new2fer_ressource - $Depense_fer_ressource) ;
$New_or_ressource = ($new2or_ressource - $Depense_or_ressource) ;
$temps1fer = (108 * (bcpow(1.5,($row[fer_lvl] + 1),3)));
if ($row[robo_lvl] =="0") {
$fer_evolution = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1fer)));
}
else {
$fer_evolution = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1fer* $siege_temps_evolution * (bcpow(0.9, $row[robo_lvl],3)))));
}
if ($row[fer_lvl] == "0") {
$besoin_fer_energie2 = "-30" ; }
else {
$besoin_fer_energie2 = round((-30 * (bcpow(1.18, $row[fer_lvl],3))),0);
}
$besoin_fer_energie = -1 * $besoin_fer_energie2 ;

//echo"Temp debug : Depense_fer = $Depense_fer_ressource<br>new2fer : $new2fer_ressource<br>";
//echo"New fer : $New_fer_ressource<br>";
//exit;

if ($new2fer_ressource >= $Depense_fer_ressource && $new2or_ressource >= $Depense_or_ressource && $Total_energie_reste >= $besoin_fer_energie && $evolution < 0) {
$sql = "UPDATE matgraph_users SET fer_evolution='$fer_evolution', fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource WHERE id='$planete' LIMIT 1";
//echo"Sql : $sql<br>";//exit;
$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>';
?>