<?php
include ('logue.php');
include ('entete2.php');
$sql = "SELECT pts,techhypernav_lvl,labo_lvl,or_ressource,ada_ressource,fer_ressource,ura_ressource,techhypernav_evolution 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 techhypernav_lvl, techhypernav_evolution,labo_util FROM matgraph_users WHERE id='$idlogin' ";
$res2 = mysql_query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2);
$sql3 = "SELECT fer_ressource, or_ressource,ada_ressource, ura_ressource FROM matgraph_users WHERE id='$row2[labo_util]' ";
$res3 = mysql_query($sql3)or die('erreur sql<br>'.$sql3.'<br>'.mysql_error());
$row3 = mysql_fetch_array($res3);
if ($row2[techhypernav_lvl] == "0") {
	$Depense_techhypernav_fer = "100000";
	$Depense_techhypernav_or = "50000";
	$Depense_techhypernav_ada = "50000";
	$Depense_techhypernav_ura = "40000";
}else{
	$Depense_techhypernav_fer = round((50000 * ( bcpow( 2, ($row2[techhypernav_lvl] + 1),3))),0);
	$Depense_techhypernav_or = round((25000 * ( bcpow( 2, ($row2[techhypernav_lvl] + 1),3))),0);
	$Depense_techhypernav_ada = round((25000 * ( bcpow( 2, ($row2[techhypernav_lvl] + 1),3))),0);
	$Depense_techhypernav_ura = round((20000 * ( bcpow( 2, ($row2[techhypernav_lvl] + 1),3))),0);
}
$New_fer_ressource = ($row[fer_ressource] + $Depense_techhypernav_fer) ;
$New_or_ressource = ($row[or_ressource] + $Depense_techhypernav_or) ;
$New_ada_ressource = ($row[ada_ressource] + $Depense_techhypernav_ada) ;
$New_ura_ressource = ($row[ura_ressource] + $Depense_techhypernav_ura) ;
if ($row2[techhypernav_evolution] != "0000-00-00 00:00:00" ) {
$sql = "UPDATE matgraph_users SET fer_ressource=$New_fer_ressource, or_ressource=$New_or_ressource, ada_ressource=$New_ada_ressource, ura_ressource=$New_ura_ressource, labo_util = '0' WHERE id='$row2[labo_util]'";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$sql2 = "UPDATE matgraph_users SET techhypernav_evolution=\"0000-00-00 00:00:00\" , labo_util = '0' 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>';
?>