<?php
include ('logue.php'); 
include ('entete2.php');
include ('evolutiontech.php');
include ('siege.php');
$sql = "SELECT pts,technaqua_lvl,labo_lvl,or_ressource,ura_ressource,fer_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); 
$sql2 = "SELECT technaqua_lvl FROM matgraph_users WHERE id='$idlogin' ";
$res2 = mysql_query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2);
if ($row2[technaqua_lvl] == "0") {
$Depense_technaqua_fer = "4000";
$Depense_technaqua_ura = "2500";
}
else {
$Depense_technaqua_fer = round((2000 * ( bcpow( 2, ($row2[technaqua_lvl] + 1),3))),0);
$Depense_technaqua_ura = round((1250 * ( bcpow( 2, ($row2[technaqua_lvl] + 1),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] - $Depense_technaqua_fer) ;
$New_ura_ressource = ($row[ura_ressource] - $Depense_technaqua_ura) ;
$temps1technaqua = (86400 * (bcpow(2, ($row2[technaqua_lvl] + 1),3)));
$technaqua_evolution =  strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1technaqua* $siege_temps_evolution * (bcpow(0.9, $row[labo_lvl],3)))));
if ($row[fer_ressource] >= $Depense_technaqua_fer && $row[ura_ressource] >= $Depense_technaqua_ura && $evolution < 0) {
$sql = "UPDATE matgraph_users SET fer_ressource=$New_fer_ressource, ura_ressource=$New_ura_ressource WHERE id='$planete'";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET technaqua_evolution='$technaqua_evolution' , labo_util = '$planete' WHERE id='$idlogin'";
$res2 = mysql_query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());   }
echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("labo.php");
-->
</script>';
?>