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

$sql = "SELECT pts,or_lvl,exor_lvl,robo_lvl,or_energie,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); 
$temps1or = (103  / 3 * (bcpow(1.5, ($row[or_lvl]),3)));
if ($row[robo_lvl] =="0") {
$or_destruction = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1or)));
}
else {
$or_destruction = strftime("%Y-%m-%d %H:%M:%S", time()+ (round($temps1or* $siege_temps_evolution * (bcpow(0.9, $row[robo_lvl],3)))));
}

// or
if ($row[or_lvl] =="0") {
$or_lvl = "0";
}
else {
$or_lvl = $row[or_lvl];
}
// exor
if ($row[exor_lvl] =="0") {
$exor_lvl = "0";
}
else {
$exor_lvl = $row[exor_lvl];
}

if($or_lvl == 20) {
if($exor_lvl > 0) {
$valid = "no"; }
else {
$valid = "yes"; }}
else {
$valid = "yes"; }
if($or_lvl > 0 AND $valid == "yes" ) {
if ($evolution < 0) {
$sql = "UPDATE matgraph_users SET  or_destruction='$or_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>';
?>