<?	
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 mili_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); 
// mili
if ($row[mili_lvl] =="0") {
$mili_lvl = "0";
}
else {
$mili_lvl = $row[mili_lvl];
}
$mili_lvl22 = $mili_lvl+1;
$mili_lvl23 = $mili_lvl+2;
$mili_lvl24 = $mili_lvl+3;
$mili_lvl25 = $mili_lvl+4;
//prod energie 
if ($row[mili_lvl] == "0") {
$besoin_mili_energie2 = "0" ; }
else {
$besoin_mili_energie2 = round(((2.5) * (bcpow(2, ($row[mili_lvl]),3))),0);
}
$besoin_mili_energie = 1 * $besoin_mili_energie2 ;
$besoin_mili_energie22 = round(((2.5) * (bcpow(2, ($row[mili_lvl] + 1),3))),0);
$besoin_mili_energie23 = round(((2.5) * (bcpow(2, ($row[mili_lvl] + 2),3))),0);
$besoin_mili_energie24 = round(((2.5) * (bcpow(2, ($row[mili_lvl] + 3),3))),0);
$besoin_mili_energie25 = round(((2.5) * (bcpow(2, ($row[mili_lvl] + 4),3))),0);
echo"<table width=\"618\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td colspan=\"4\" style =\"background-color:#222222;\"><div align=\"center\"><b>Caserne Militaire</b>(Niveau $mili_lvl)</div></td>
  </tr>
  <tr>
    <td width=\"72\" height=\"120\"><img src=\"imgs/mili.gif\" width=\"120\" height=\"120\"></td>
    <td width=\"1119\" colspan=\"2\">La caserne militaire permet de former des hommes aux combats. Ils seront en première ligne lors de combats mais servent, aussi, pour explorer de nouvelles planètes. Les soldats sont généralement les premiers à passer la porte des étoiles. Chaque niveau de ce bâtiment permet de former plus d'hommes. En développant parallèlement les technologies d'armes et de boucliers, vos soldats deviennent plus puissants et plus résistants.
</td>
  </tr>
</table>
<br>
<table width=\"323\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr style =\"background-color:#222222;\">
    <td width=\"93\" height=\"21\" align=\"center\">Niveau : </td>
    <td>Production de soldats par heure : </td>
  </tr>
  <tr style =\"background-color:#000000;\">
    <td width=\"93\" height=\"21\" align=\"center\">$mili_lvl</td>
    <td width=\"210\">$besoin_mili_energie</td>
  </tr>
  <tr style =\"background-color:#111111;\">
    <td width=\"93\" height=\"21\" align=\"center\">$mili_lvl22</td>
    <td width=\"210\">$besoin_mili_energie22</td>
  </tr>
  <tr style =\"background-color:#000000;\">
    <td width=\"93\" height=\"21\" align=\"center\">$mili_lvl23</td>
    <td width=210>$besoin_mili_energie23</td>
  </tr>
  <tr style =\"background-color:#111111;\">
    <td width=\"93\" height=\"21\" align=\"center\">$mili_lvl24</td>
    <td width=\"210\">$besoin_mili_energie24</td>
  </tr>
  <tr style =\"background-color:#000000;\">
    <td width=\"93\" height=\"21\" align=\"center\">$mili_lvl25</td>
    <td width=\"210\">$besoin_mili_energie25</td>
  </tr>
</table>";	
// robo
if ($row[robo_lvl] =="0") {
$robo_lvl = "0";
}
else {
$robo_lvl = $row[robo_lvl];
}
if ($row[mili_lvl] =="0") {
$besoin_mili_fer = number_format((500/3), 0, ',', ' ');
$besoin_mili_or = number_format((500/3), 0, ',', ' ');
}
else {
$besoin_mili_fer = number_format(round(((250/3) * ( bcpow( 2, $mili_lvl,3))),0), 0, ',', ' ');
$besoin_mili_or = number_format(round(((250/3) * ( bcpow( 2, $mili_lvl))),0), 0, ',', ' ');
}
include ('siege.php');
//mili 
$temps1mili = (600/3 * $siege_temps_evolution * (bcpow(2, $mili_lvl,3)));
if ($robo_lvl == "0") {
$stimemili = (round($temps1mili));
}
else {
$stimemili = (round($temps1mili*(bcpow(0.9, $robo_lvl,3))));
} 
$etimemili = $stimemili;
$eminmili = $etimemili / 60;

if ( floor($eminmili) != $eminmili )
  $esecmili = floor( ($eminmili - floor( $eminmili )) * 60);

  if ( $eminmili > 60 ) {

    $ehourmili = floor( $eminmili / 60 );
    $eminmili = $eminmili - ( 60 * $ehourmili );

    if ( $ehourmili > 24 ) {
      $edaymili = floor( $ehourmili / 24);
      $ehourmili = $ehourmili - ( 24 * $edaymili );
    }

  }

$etimemili ="";

if (!empty($edaymili) )
  $etimemili.="$edaymili j ";

if (!empty($ehourmili) )
  $etimemili.="$ehourmili h ";

if ($eminmili != 0)
  $etimemili.= floor($eminmili)." min. ";

if (!empty($esecmili) ) 
  $etimemili.="$esecmili sec. ";
if($mili_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_mili_fer</b> ; Or : <b>$besoin_mili_or</b> ; Temps : <b>$etimemili</b> </div></td>
  </tr>
  <tr>
    <td style =\"background-color:#111111;\"><div align=\"center\"><a href=\"Destructionmili.php\" target=\"_parent\">Détruire le niveau $mili_lvl</a></div></td>
  </tr>
</table>";	}
?>

