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

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'); 

//////////////////////////////////////////////////// POINTS FLOTTE //////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//joueur ciblé :

$idlogin = 109;


	$req = "SELECT vaisseau, planete, nbre FROM matgraph_nbrevaisseaux WHERE user = '$idlogin'" ;
	$res = db_mysql_Query($req) or die('Erreur SQL! <br>' . $req . '<br>' . mysql_error()) ;
	$num = mysql_num_rows($res) ;
	if ( $num > 0 )
	{
		While ( $row = mysql_fetch_array($res) )
		{
			// Calcul le score des vaisseaux non mobilisés
			$sql2 = "SELECT nom,fer, orr, ada, ura FROM matgraph_vaisseaux WHERE id = '$row[vaisseau]'" ;
			$res2 = db_mysql_Query($sql2) or die('Erreur SQL! <br>' . $sql2 . '<br>' . mysql_error()) ;
			$row2 = mysql_fetch_array($res2) ;
			$Score_vaisseau += ( ( $row2['fer'] + $row2['orr'] + $row2['ada'] + $row2['ura'] ) * $row['nbre'] ) ;

			// Calcul le score des vaisseaux mobilisés
			$sql_6 = "SELECT nombre FROM matgraph_mobil WHERE iddepart = '$row[planete]' AND idvaisseau = '$row[vaisseau]' " ;
			$res_6 = db_mysql_Query($sql_6) or die('erreur sql<br>' . $sql_6 . '<br>' . mysql_error()) ;
			While ($row_6 = mysql_fetch_array($res_6) )
			{
				$Score_vaisseau += ( ( $row2['fer'] + $row2['orr'] + $row2['ada'] + $row2['ura'] ) * $row_6['nombre'] ) ;
			}
			
			$ppptt = ($row2['fer'] + $row2['orr'] + $row2['ada'] + $row2['ura']) / 1000;
			$nnnnbre = $row['nbre'] + $row_6['nombre'];
			echo"<br> $nnnnbre ( $row2[nom] ) à $ppptt ( $row2[fer] + $row2[orr] + $row2[ada] + $row2[ura] )";
		}
	}
	//compte miltaire
	$req = "SELECT mili_nbre FROM matgraph_users WHERE idjoueur = '$idlogin'" ;
	$res = db_mysql_Query($req) or die('Erreur SQL! <br>' . $req . '<br>' . mysql_error()) ;
	$num = mysql_num_rows($res) ;
	if ( $num > 0 )
	{
		While ( $row = mysql_fetch_array($res) )
		{
		$Score_soldats += ($row[mili_nbre]/5) ; // 5.000 mili = 1 pt donc 1000 pt dans la db
		}
	}
	
//////compte spe
	//malp
	$req = "SELECT malp FROM matgraph_users WHERE idjoueur = '$idlogin'" ;
	$res = db_mysql_Query($req) or die('Erreur SQL! <br>' . $req . '<br>' . mysql_error()) ;
	$num = mysql_num_rows($res) ;
	if ( $num > 0 )
	{
		While ( $row = mysql_fetch_array($res) )
		{
		$Score_spe += ($row[malp]*1000) ; 
		}
	}
	//ptremorqueur
	$req = "SELECT ptremorqueur FROM matgraph_users WHERE idjoueur = '$idlogin'" ;
	$res = db_mysql_Query($req) or die('Erreur SQL! <br>' . $req . '<br>' . mysql_error()) ;
	$num = mysql_num_rows($res) ;
	if ( $num > 0 )
	{
		While ( $row = mysql_fetch_array($res) )
		{
		$Score_spe += ($row[ptremorqueur]*3500) ; 
		}
	}
	//gdremorqueur
	$req = "SELECT gdremorqueur FROM matgraph_users WHERE idjoueur = '$idlogin'" ;
	$res = db_mysql_Query($req) or die('Erreur SQL! <br>' . $req . '<br>' . mysql_error()) ;
	$num = mysql_num_rows($res) ;
	if ( $num > 0 )
	{
		While ( $row = mysql_fetch_array($res) )
		{
		$Score_spe += ($row[gdremorqueur]*9000) ; 
		}
	}
	
	
	
//Maj pts
	$pts_flotte = $Score_vaisseau + $Score_soldats + $Score_spe;
	$req_UPDATE = "UPDATE matgraph_users SET pts_flotte = '$pts_flotte' WHERE id = '$idlogin'" ;
	$maj=db_mysql_Query($req_UPDATE) or die('Erreur SQL! <br>' . $req_UPDATE . '<br>' . mysql_error()) ;


$pts_flotte = number_format($pts_flotte/1000 , 0, ',', ' ');
$Score_soldats = number_format($Score_soldats/1000 , 0, ',', ' ');
$Score_spe = number_format($Score_spe/1000 , 0, ',', ' ');

echo'<br>Points flotte : '.$pts_flotte.' (Dont '.$Score_soldats.' points de soldats et '.$Score_spe.' points d\'appareils spécialisés)
';

?>