<?php
include ('logue.php'); 
include ('entete2.php');
include ('evolutionbats.php');
include ('siege.php');
include ('ressource.php');
include ('colo3.php');
$sql = "SELECT pts,exfer_lvl,exfer_energie,exfer_evolution,robo_lvl,fer_ressource,or_ressource,ada_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[exfer_lvl] =="0") {
$Depense_fer_ressource = "35000";
$Depense_or_ressource = "15000";
$Depense_ada_ressource = "1000";
}
else {
$Depense_fer_ressource = round((30000 * ( bcpow( 1.2, ($row[exfer_lvl] + 1),3))),0);
$Depense_or_ressource = round((20000 * ( bcpow( 1.2, ($row[exfer_lvl] + 1)))),0);
$Depense_ada_ressource = round((1000 * ( bcpow( 1.2, ($row[exfer_lvl] + 1)))),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) ;
$temps1exfer = (43200 * (bcpow(1.7, ($row[exfer_lvl] + 1),3)));
if ($row[robo_lvl] == "0") {
$exfer_evolution = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1exfer)));
}
else {
$exfer_evolution = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1exfer* $siege_temps_evolution * (bcpow(0.9, $row[robo_lvl],3)))));
} 
if ($row[exfer_lvl] == "0") {
$besoin_exfer_energie2 = "-200" ;}
else {
$besoin_exfer_energie2 = round((-200 * (bcpow(1.2, $row[exfer_lvl],3))),0);
}
$besoin_exfer_energie = -1 * $besoin_exfer_energie2 ;
if ($row[fer_ressource] >= $Depense_fer_ressource && $row[or_ressource] >= $Depense_or_ressource && $row[ada_ressource] >= $Depense_ada_ressource && $Total_energie_reste >= $besoin_fer_energie && $evolution < 0) {
$sql = "UPDATE matgraph_users SET exfer_evolution='$exfer_evolution', fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_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>';
?>