<?php
include ('logue.php'); 
include ('entete2.php');
include ('evolutionbats.php');
include ('siege.php');

$sql = "SELECT pts,fer_lvl,exfer_lvl,fer_energie,fer_destruction,robo_lvl,fer_ressource,or_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); 
// exfer
if ($row[exfer_lvl] =="0") {
$exfer_lvl = "0";
}
else {
$exfer_lvl = $row[exfer_lvl];
}
// fer
if ($row[fer_lvl] =="0") {
$fer_lvl = "0";
}
else {
$fer_lvl = $row[fer_lvl];
}
$temps1fer = (108 / 3  * (bcpow(1.5,($row[fer_lvl]),3)));
if ($row[robo_lvl] =="0") {
$fer_destruction = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1fer)));
}
else {
$fer_destruction = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1fer* $siege_temps_evolution * (bcpow(0.9, $row[robo_lvl],3)))));
$fer22 = strftime("%Y-%m-%d %H:%M:%S", time());
} 
if($fer_lvl == 20) {
if($exfer_lvl > 0) {
$valid = "no"; }
else {
$valid = "yes"; }}
else {
$valid = "yes"; }
if($fer_lvl > 0 AND $valid == "yes" ) {
if ($evolution < 0) {
$sql = "UPDATE matgraph_users SET fer_destruction='$fer_destruction' 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>';

?>