<?php
include ('logue.php'); 
include ('entete2.php');
include ('evolutiontech.php');
include ('siege.php');
$sql = "SELECT pts,techBouclier_lvl,labo_lvl,or_ressource,ada_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 techBouclier_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[techBouclier_lvl] == "0") {
$Depense_techBouclier_fer = "400";
$Depense_techBouclier_or = "300";
$Depense_techBouclier_ada = "75";
}
else {
$Depense_techBouclier_fer = round((200 * ( bcpow( 2, ($row2[techBouclier_lvl] + 1),3))),0);
$Depense_techBouclier_or = round((150 * ( bcpow( 2, ($row2[techBouclier_lvl] + 1),3))),0);
$Depense_techBouclier_ada = round((37.5 * ( bcpow( 2, ($row2[techBouclier_lvl] + 1),3))),0);
}
$New_or_ressource = ($row[or_ressource] - $Depense_techBouclier_or) ;
$New_fer_ressource = ($row[fer_ressource] - $Depense_techBouclier_fer) ;
$New_ada_ressource = ($row[ada_ressource] - $Depense_techBouclier_ada) ;
$temps1techBouclier = (1000 * (bcpow(2, ($row2[techBouclier_lvl] + 1),3)));
$techBouclier_evolution =  strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1techBouclier* $siege_temps_evolution * (bcpow(0.9, $row[labo_lvl],3)))));
if ($row[or_ressource] >= $Depense_techBouclier_or && $row[fer_ressource] >= $Depense_techBouclier_fer && $row[ada_ressource] >= $Depense_techBouclier_ada && $evolution < 0) {
$sql = "UPDATE matgraph_users SET or_ressource=$New_or_ressource, fer_ressource=$New_fer_ressource , ada_ressource=$New_ada_ressource WHERE id='$planete'";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET techBouclier_evolution='$techBouclier_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>';
?>