<?	
include ('logue.php'); 
include ('entete2.php');
include ('ressource.php');
include ('entete.php');

$sql2 = "SELECT hangarfer_lvl,hangarfer_evolution,hangaror_lvl,hangaror_evolution,hangarada_lvl,hangarada_evolution,hangaror_lvl,hangarura_lvl,hangarura_evolution FROM matgraph_users WHERE id='$planete' ";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2); 

$pts = floor(($row[pts] / 1000)) ;
$Total_energie_consom = $row2[fer_energie] + $row2[or_energie] + $row2[exfer_energie] + $row2[exor_energie] + $row2[ada_energie] + $row2[ura_energie] ;
$Total_energie_reste =  round(($New_central_energie + $New_fission_energie + $Total_energie_consom),0);
$Total_energie_prod = round(($New_central_energie + $New_fission_energie),0);

echo"<style>
input {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
textarea {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
select, option {
background-color:#000000;
color:white;
}
</style>
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
</STYLE>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"_parent\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">
         <input name=\"page\" value=\"" . $PHP_SELF . "\" type=\"hidden\" id=\"page\">
         <select name=\"idcolo\" onchange=submit()>";
include ('colo2.php'); 
$sql = "SELECT defense_lvl,robo_lvl FROM matgraph_users WHERE id='$planete'";
$res = db_mysql_Query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 
// defense
if ($row[defense_lvl] =="0") {
$defense_lvl = "0";
}
else {
$defense_lvl = $row[defense_lvl];
}

echo"<table width=\"618\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td colspan=\"4\" style =\"background-color:#222222;\"><div align=\"center\"><b>Centre Militaire de Défense Interplanétaire </b>(Niveau $defense_lvl)</div></td>
  </tr>
  <tr>
    <td width=\"72\" height=\"120\"><img src=\"imgs/centredef.gif\" width=\"120\" height=\"120\"></td>
    <td width=\"1119\" colspan=\"2\">Ce centre permet de développer, à partir des technologies d'armement, un système de défense contre ce type d'arme. Le centre militaire de défense interplanétaire developpe des tours de protection armées de différents systémes et plus ou moins résistants. Plus la recherche est poussée et plus le centre militaire est grand, plus des tours efficaces pourront être construites.

</td>
  </tr>
</table>";
// robo
if ($row[robo_lvl] =="0") {
$robo_lvl = "0";
}
else {
$robo_lvl = $row[robo_lvl];
}
if ($row[defense_lvl] =="0") {
$besoin_defense_fer = number_format((75/3), 0, ',', ' ');
$besoin_defense_or = number_format((150/3), 0, ',', ' ');
$besoin_defense_ada = number_format((75/3), 0, ',', ' ');
}
else {
$besoin_defense_fer = number_format(round(((75/3) * ( bcpow( 1.9, $defense_lvl,3))),0), 0, ',', ' ');
$besoin_defense_or = number_format(round(((150/3) * ( bcpow( 1.9, $defense_lvl))),0), 0, ',', ' ');
$besoin_defense_ada = number_format(round(((75/3) * ( bcpow( 1.9, $defense_lvl))),0), 0, ',', ' ');
}
include ('siege.php');
//defense 
$temps1defense = (650/3 * $siege_temps_evolution * (bcpow(1.35, $defense_lvl,3)));
if ($robo_lvl == "0") {
$stimedefense = (round($temps1defense));
}
else {
$stimedefense = (round($temps1defense*(bcpow(0.9, $robo_lvl,3))));
} 
$etimedefense = $stimedefense;
$emindefense = $etimedefense / 60;

if ( floor($emindefense) != $emindefense )
  $esecdefense = floor( ($emindefense - floor( $emindefense )) * 60);

  if ( $emindefense > 60 ) {

    $ehourdefense = floor( $emindefense / 60 );
    $emindefense = $emindefense - ( 60 * $ehourdefense );

    if ( $ehourdefense > 24 ) {
      $edaydefense = floor( $ehourdefense / 24);
      $ehourdefense = $ehourdefense - ( 24 * $edaydefense );
    }

  }

$etimedefense ="";

if (!empty($edaydefense) )
  $etimedefense.="$edaydefense j ";

if (!empty($ehourdefense) )
  $etimedefense.="$ehourdefense h ";

if ($emindefense != 0)
  $etimedefense.= floor($emindefense)." min. ";

if (!empty($esecdefense) ) 
  $etimedefense.="$esecdefense sec. ";
if($defense_lvl > 0) {
echo"<br><table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td style =\"background-color:#222222;\"><div align=\"center\">Destruction de batiment : </div></td>
  </tr>
  <tr>
    <td><div align=\"center\">Gain : Fer : <b>$besoin_defense_fer</b> ; Or : <b>$besoin_defense_or</b> ; Cristal : <b>$besoin_defense_ada</b> ; Temps : <b>$etimedefense</b> </div></td>
  </tr>
  <tr>
    <td style =\"background-color:#111111;\"><div align=\"center\"><a href=\"Destructiondefense.php\" target=\"_parent\">Détruire le niveau $defense_lvl</a></div></td>
  </tr>
</table>";	}	
?>

