2007-10-27 10:00:00 +00:00
< ? php
session_start ();
$id = $_SESSION [ 'id' ];
$galaxy = $_SESSION [ 'galaxy' ];
$ss = $_SESSION [ 'ss' ];
$pos = $_SESSION [ 'pos' ];
2007-11-20 11:00:00 +00:00
$_SESSION [ 'dernPage' ] = 'defense.php' ;
2007-11-04 11:00:00 +00:00
2008-11-19 11:00:00 +00:00
include_once ( 'common.php' );
2007-11-13 11:00:00 +00:00
require ( '../template.php' );
$template = new Template ( '../templates/' . $templates );
2008-11-19 11:00:00 +00:00
/* Page d<EFBFBD> fenses
*
*/
2007-11-13 11:00:00 +00:00
function verification_des_ress ( $numtec , $metal , $calcium , $nourriture , $ress_ness_metal , $ress_ness_calcium , $ress_ness_nourriture ) {
2008-11-19 11:00:00 +00:00
if ( $metal >= $ress_ness_metal && $calcium >= $ress_ness_calcium && $nourriture >= $ress_ness_nourriture ) return '<form method="post" action="defense_validation.php"><p><input type="text" class="zone_texte" size="4" maxlength="4" name="sa" /><input type="hidden" name="type" value="' . $numtec . '" /><br /><input type="submit" value="Envoyer" class="bouton" /></p></form>' ;
else return '<span style="color: #FF0000;">Vous n\'avez pas suffisament de ressources</span>' ;
}
function verification_des_ressvf ( $numtec , $metal , $calcium , $nourriture , $ress_ness_metal , $ress_ness_calcium , $ress_ness_nourriture ) {
if ( $metal >= $ress_ness_metal && $calcium >= $ress_ness_calcium && $nourriture >= $ress_ness_nourriture ) return true ;
else return false ;
2007-11-13 11:00:00 +00:00
}
2007-10-27 10:00:00 +00:00
2007-11-13 11:00:00 +00:00
function ressources ( $fer , $cristal , $ro , $need_fer , $need_cristal , $need_ro ) {
2008-11-19 11:00:00 +00:00
require 'includes/noms.php' ;
2007-11-13 11:00:00 +00:00
$return = '' ;
if ( $need_fer > 0 ) {
if ( $fer <= $need_fer ) {
$z = floor ( $fer ) - $need_fer ;
2008-11-19 11:00:00 +00:00
$return .= '<span style="color: #FF0000;">' . $ressourc [ 0 ] . ' : <acronym title="Manque : ' . separerNombres ( abs ( $z )) . ' unit<69> s de ' . $ressourc [ 0 ] . '">' . separerNombres ( $need_fer ) . '</acronym></span> ' ;
2007-11-13 11:00:00 +00:00
}
2008-11-19 11:00:00 +00:00
else $return .= $ressourc [ 0 ] . ' : <span class="rc">' . separerNombres ( $need_fer ) . ' </span>' ;
2007-11-13 11:00:00 +00:00
}
if ( $need_cristal > 0 ) {
if ( $cristal <= $need_cristal ) {
$z = floor ( $cristal ) - $need_cristal ;
2008-11-19 11:00:00 +00:00
$return .= '<span style="color: #FF0000;">' . $ressourc [ 1 ] . ' : <acronym title="Manque : ' . separerNombres ( abs ( $z )) . ' unit<69> s de ' . $ressourc [ 0 ] . '">' . separerNombres ( $need_cristal ) . '</acronym></span> ' ;
2007-11-13 11:00:00 +00:00
}
2008-11-19 11:00:00 +00:00
else $return .= $ressourc [ 1 ] . ' : <span class="rc">' . separerNombres ( $need_cristal ) . ' </span>' ;
2007-11-13 11:00:00 +00:00
}
if ( $need_ro > 0 ) {
if ( $ro <= $need_ro ) {
$z = floor ( $ro ) - $need_ro ;
2008-11-19 11:00:00 +00:00
$return .= '<span style="color: #FF0000;">' . $ressourc [ 2 ] . ' : <acronym title="Manque : ' . separerNombres ( abs ( $z )) . ' unit<69> s de ' . $ressourc [ 0 ] . '">' . separerNombres ( $need_ro ) . '</acronym></span>' ;
2007-11-13 11:00:00 +00:00
}
2008-11-19 11:00:00 +00:00
else $return .= $ressourc [ 2 ] . ' : <span class="rc">' . separerNombres ( $need_ro ) . '</span>' ;
2007-11-13 11:00:00 +00:00
}
return $return ;
}
function sec ( $time ) {
2007-10-27 10:00:00 +00:00
$output = '' ;
$tab = array ( 'jour' => '86400' , 'heure' => '3600' , 'minute' => '60' , 'seconde' => '1' );
foreach ( $tab as $key => $value ) {
$compteur = 0 ;
while ( $time > ( $value - 1 )) {
$time = $time - $value ;
$compteur ++ ;
}
if ( $compteur != 0 ) {
$output .= $compteur . ' ' . $key ;
if ( $compteur > 1 ) $output .= 's' ;
if ( $value != 1 ) $output .= ' ' ;
}
}
2007-11-13 11:00:00 +00:00
return $output ;
2007-10-27 10:00:00 +00:00
}
2008-11-19 11:00:00 +00:00
$template -> set_filenames ( array ( 'defense' => 'defense.tpl' ));
2007-10-27 10:00:00 +00:00
2008-11-19 11:00:00 +00:00
$f = ceil ( 1080 / pow ( 1.25 ,( $chantier_spatial - 1 )));
$g = ceil ( 6300 / pow ( 1.25 ,( $chantier_spatial - 5 )));
$h = ceil ( 8280 / pow ( 1.25 ,( $chantier_spatial - 5 )));
$iV = ceil ( 1440 / pow ( 1.25 ,( $chantier_spatial - 3 )));
$j = ceil ( 7380 / pow ( 1.25 ,( $chantier_spatial - 5 )));
$k = ceil ( 1200 / pow ( 1.25 ,( $chantier_spatial - 1 )));
$l = ceil ( 4680 / pow ( 1.25 ,( $chantier_spatial - 3 )));
$m = ceil ( 16800 / pow ( 1.25 ,( $chantier_spatial - 6 )));
$nV = ceil ( 18060 / pow ( 1.25 ,( $chantier_spatial - 6 )));
$p = ceil ( 32400 / pow ( 1.25 ,( $chantier_spatial - 8 )));
$q = ceil ( 117000 / pow ( 1.25 ,( $chantier_spatial - 12 )));
2007-11-04 11:00:00 +00:00
2008-11-19 11:00:00 +00:00
if ( $temps_spatial > 0 ) $unit = $nomvaisa [ -- $unit_s ];
2007-11-04 11:00:00 +00:00
2008-11-19 11:00:00 +00:00
if ( $chantier_spatial > 0 ) {
2007-11-13 11:00:00 +00:00
if ( ! isset ( $_GET [ 'err' ])) $_GET [ 'err' ] = '' ;
$ERREUR = '' ;
if ( $_GET [ 'err' ] == 1 ) $ERREUR = '<div class="centre"><table style="margin-left: auto; margin-right: auto;"><tr><td><font color="#FF0000"><b>Cette technologie est d<> j<EFBFBD> en cours de recherche, vous ne pouvez pas la rajouter dans la file d\'attente</b></font></td></tr></table></div><br />' ;
elseif ( $_GET [ 'err' ] == 2 ) $ERREUR = '<div class="centre"><table style="margin-left: auto; margin-right: auto;"><tr><td><font color="#FFCC00"><b>La production <20> la cha<68> ne a <20> t<EFBFBD> arr<72> t<EFBFBD> e</b></font></td></tr></table></div><br />' ;
2008-11-19 11:00:00 +00:00
elseif ( $_GET [ 'err' ] == 3 ) $ERREUR = '<div class="centre"><table style="margin-left: auto; margin-right: auto;"><tr><td><font color="#FF0000"><b>Vous n\'avez pas assez de ressources pour construire autant de vaisseaux</b></font></td></tr></table></div><br />' ;
2007-11-13 11:00:00 +00:00
2008-11-19 11:00:00 +00:00
$template -> set_filenames ( array ( 'defense' => 'defense.tpl' ));
2007-11-13 11:00:00 +00:00
$a = 0 ; $b = 0 ; $c = 0 ;
// D<> fense n<> 1 : Shade/Tour <20> plasma/Mitrailleuse automatique M247 GP ; planete.def_1
if ( $chantier_spatial >= 1 ) {
$i = 8 ;
2007-11-21 11:00:00 +00:00
$nom_bdd = 'def_' . ( $i - 7 );
2007-11-13 11:00:00 +00:00
if ( ${$nom_bdd} > 0 ) $niveau = '(' . ${$nom_bdd} . ' construit)' ; else $niveau = '' ;
$n = ( ${$nom_bdd} - 1 ); $a = 500 ; $b = 200 ;
if ( $bat == 8 ) $action = 'Le chantier terrestre est en cours d\'<27> volution' ;
else $action = verification_des_ress ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c );
2008-11-19 11:00:00 +00:00
if ( verification_des_ressvf ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c )) { $ACT = '' ; $lien = 'defense_validation.php?type=' . ( $i + 1 ); } else { $ACT = 'none' ; $lien = '' ; }
if ( ! empty ( $nomterrn [ $i ])) $template -> assign_block_vars ( 'defense' , array ( 'IMAGE' => $nomterri [ $i ], 'NOM' => $nomterrn [ $i ], 'NUM' => $i , 'NIVEAU' => $niveau , 'DESCRIPTION' => $nomterde [ $i ], 'BESOIN' => ressources ( $metal , $cristal , $hydrogene , $a , $b , $c , $mine_m , $mine_c , $mine_h ), 'TEMPS' => sec ( $f ), 'ACTION' => $action , 'NEC_METAL' => separerNombres ( $a ), 'NEC_CRISTAL' => separerNombres ( $b ), 'NEC_HYDROGENE' => separerNombres ( $c ), 'ACT' => $ACT , 'NOME' => addslashes ( $nomterrn [ $i ]), 'DESCRIPTIONE' => addslashes ( $nomterde [ $i ]), 'LIEN' => $lien ));
2007-11-13 11:00:00 +00:00
}
// D<> fense n<> 2 : Strong shade/Tour Ion/DCA l<> g<EFBFBD> re ; planete.def_2
if ( $chantier_terrestre >= 3 && $energie_t >= 2 ) {
$i = 9 ;
2007-11-21 11:00:00 +00:00
$nom_bdd = 'def_' . ( $i - 7 );
2007-11-13 11:00:00 +00:00
if ( ${$nom_bdd} > 0 ) $niveau = '(' . ${$nom_bdd} . ' construit)' ; else $niveau = '' ;
$n = ( ${$nom_bdd} - 1 ); $a = 4000 ; $b = 2000 ;
if ( $bat == 8 ) $action = 'Le chantier terrestre est en cours d\'<27> volution' ;
else $action = verification_des_ress ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c );
2008-11-19 11:00:00 +00:00
if ( verification_des_ressvf ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c )) { $ACT = '' ; $lien = 'defense_validation.php?type=' . ( $i + 1 ); } else { $ACT = 'none' ; $lien = '' ; }
if ( ! empty ( $nomterrn [ $i ])) $template -> assign_block_vars ( 'defense' , array ( 'IMAGE' => $nomterri [ $i ], 'NOM' => $nomterrn [ $i ], 'NUM' => $i , 'NIVEAU' => $niveau , 'DESCRIPTION' => $nomterde [ $i ], 'BESOIN' => ressources ( $metal , $cristal , $hydrogene , $a , $b , $c , $mine_m , $mine_c , $mine_h ), 'TEMPS' => sec ( $g ), 'ACTION' => $action , 'NEC_METAL' => separerNombres ( $a ), 'NEC_CRISTAL' => separerNombres ( $b ), 'NEC_HYDROGENE' => separerNombres ( $c ), 'ACT' => $ACT , 'NOME' => addslashes ( $nomterrn [ $i ]), 'DESCRIPTIONE' => addslashes ( $nomterde [ $i ]), 'LIEN' => $lien ));
2007-11-13 11:00:00 +00:00
}
// D<> fense n<> 3 : Tourelle <20> barreau de combustible/Canon Orbital/DCA lourde ; planete.def_3
if ( $chantier_terrestre >= 4 && $armement >= 3 && $energie_t >= 3 ) {
$i = 10 ;
2007-11-21 11:00:00 +00:00
$nom_bdd = 'def_' . ( $i - 7 );
2007-11-13 11:00:00 +00:00
if ( ${$nom_bdd} > 0 ) $niveau = '(' . ${$nom_bdd} . ' construit)' ; else $niveau = '' ;
$n = ( ${$nom_bdd} - 1 ); $a = 4500 ; $b = 800 ; $c = 600 ;
if ( $bat == 8 ) $action = 'Le chantier terrestre est en cours d\'<27> volution' ;
else $action = verification_des_ress ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c );
2008-11-19 11:00:00 +00:00
if ( verification_des_ressvf ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c )) { $ACT = '' ; $lien = 'defense_validation.php?type=' . ( $i + 1 ); } else { $ACT = 'none' ; $lien = '' ; }
if ( ! empty ( $nomterrn [ $i ])) $template -> assign_block_vars ( 'defense' , array ( 'IMAGE' => $nomterri [ $i ], 'NOM' => $nomterrn [ $i ], 'NUM' => $i , 'NIVEAU' => $niveau , 'DESCRIPTION' => $nomterde [ $i ], 'BESOIN' => ressources ( $metal , $cristal , $hydrogene , $a , $b , $c , $mine_m , $mine_c , $mine_h ), 'TEMPS' => sec ( $h ), 'ACTION' => $action , 'NEC_METAL' => separerNombres ( $a ), 'NEC_CRISTAL' => separerNombres ( $b ), 'NEC_HYDROGENE' => separerNombres ( $c ), 'ACT' => $ACT , 'NOME' => addslashes ( $nomterrn [ $i ]), 'DESCRIPTIONE' => addslashes ( $nomterde [ $i ]), 'LIEN' => $lien ));
2007-11-13 11:00:00 +00:00
}
// D<> fense n<> 4 : Canon <20> plasma/Drone/Canon Gauss ; planete.def_4
if ( $chantier_terrestre >= 4 && $armement >= 1 ) {
$i = 11 ;
2007-11-21 11:00:00 +00:00
$nom_bdd = 'def_' . ( $i - 7 );
2007-11-13 11:00:00 +00:00
if ( ${$nom_bdd} > 0 ) $niveau = '(' . ${$nom_bdd} . ' construit)' ; else $niveau = '' ;
$n = ( ${$nom_bdd} - 1 ); $a = 12000 ; $b = 10000 ; $c = 1000 ;
if ( $bat == 8 ) $action = 'Le chantier terrestre est en cours d\'<27> volution' ;
else $action = verification_des_ress ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c );
2008-11-19 11:00:00 +00:00
if ( verification_des_ressvf ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c )) { $ACT = '' ; $lien = 'defense_validation.php?type=' . ( $i + 1 ); } else { $ACT = 'none' ; $lien = '' ; }
if ( ! empty ( $nomterrn [ $i ])) $template -> assign_block_vars ( 'defense' , array ( 'IMAGE' => $nomterri [ $i ], 'NOM' => $nomterrn [ $i ], 'NUM' => $i , 'NIVEAU' => $niveau , 'DESCRIPTION' => $nomterde [ $i ], 'BESOIN' => ressources ( $metal , $cristal , $hydrogene , $a , $b , $c , $mine_m , $mine_c , $mine_h ), 'TEMPS' => sec ( $h ), 'ACTION' => $action , 'NEC_METAL' => separerNombres ( $a ), 'NEC_CRISTAL' => separerNombres ( $b ), 'NEC_HYDROGENE' => separerNombres ( $c ), 'ACT' => $ACT , 'NOME' => addslashes ( $nomterrn [ $i ]), 'DESCRIPTIONE' => addslashes ( $nomterde [ $i ]), 'LIEN' => $lien ));
2007-11-13 11:00:00 +00:00
}
// D<> fense n<> 5 : Lanceur de torpilles plasma/Station de defense/Lanceur de missiles ; planete.def_5
if ( $chantier_terrestre >= 4 && $armement >= 1 ) {
$i = 12 ;
2007-11-21 11:00:00 +00:00
$nom_bdd = 'def_' . ( $i - 7 );
2007-11-13 11:00:00 +00:00
if ( ${$nom_bdd} > 0 ) $niveau = '(' . ${$nom_bdd} . ' construit)' ; else $niveau = '' ;
$n = ( ${$nom_bdd} - 1 ); $a = 15000 ; $b = 9500 ; $c = 1500 ;
if ( $bat == 8 ) $action = 'Le chantier terrestre est en cours d\'<27> volution' ;
else $action = verification_des_ress ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c );
2008-11-19 11:00:00 +00:00
if ( verification_des_ressvf ( $i + 1 , $metal , $cristal , $hydrogene , $a , $b , $c )) { $ACT = '' ; $lien = 'defense_validation.php?type=' . ( $i + 1 ); } else { $ACT = 'none' ; $lien = '' ; }
if ( ! empty ( $nomterrn [ $i ])) $template -> assign_block_vars ( 'defense' , array ( 'IMAGE' => $nomterri [ $i ], 'NOM' => $nomterrn [ $i ], 'NUM' => $i , 'NIVEAU' => $niveau , 'DESCRIPTION' => $nomterde [ $i ], 'BESOIN' => ressources ( $metal , $cristal , $hydrogene , $a , $b , $c , $mine_m , $mine_c , $mine_h ), 'TEMPS' => sec ( $h ), 'ACTION' => $action , 'NEC_METAL' => separerNombres ( $a ), 'NEC_CRISTAL' => separerNombres ( $b ), 'NEC_HYDROGENE' => separerNombres ( $c ), 'ACT' => $ACT , 'NOME' => addslashes ( $nomterrn [ $i ]), 'DESCRIPTIONE' => addslashes ( $nomterde [ $i ]), 'LIEN' => $lien ));
2007-11-13 11:00:00 +00:00
}
2008-11-19 11:00:00 +00:00
$CHAINE = '' ;
$ut = false ;
2007-11-13 11:00:00 +00:00
2008-11-19 11:00:00 +00:00
$tr = $fileTemps_v [ 0 ] + $fileTemps_v [ 1 ] - time ();
if ( ! empty ( $fileVeh [ 0 ])) $RESTE = $action = '<script type="text/javascript">reste(' . $tr . ');</script>' ;
else $RESTE = '' ;
2007-11-04 11:00:00 +00:00
2008-11-19 11:00:00 +00:00
if ( ! empty ( $fileVeh [ 0 ])) {
$comp = 1 ;
for ( $i = 0 ; $i < count ( $fileVeh ) ; $i ++ ) {
if ( $fileVeh [ $i ] != 'e' ) {
if ( $fileVeh [ $i + 1 ] == $fileVeh [ $i ]) $comp ++ ;
else {
if ( $ut == false ) {
$template -> assign_block_vars ( 'file' , array ( 'NOM' => $comp . ' ' . $nomterrn [ $fileVeh [ $i ] - 1 ], 'NUM' => $fileVeh [ $i ], 'I' => $i , 'RESTANT' => 'prochain : <span id="axion"></span><script type="text/javascript">reste(' . $tr . ');</script> - ' ));
$ut = true ;
}
else $template -> assign_block_vars ( 'file' , array ( 'NOM' => $comp . ' ' . $nomterrn [ $fileVeh [ $i ] - 1 ], 'NUM' => $fileVeh [ $i ], 'I' => $i ));
$comp = 1 ;
}
}
//else $CHAINE = ' <br /> <a href="annul_tec.php?tec=e"><i>Arr<72> ter de produire <20> la cha<68> ne</i></a>';
}
$FILETXT = '' ;
//if ($i == 1 && $vai_boucle == false) $CHAINE = ' <br /> <a href="construction.php?tec=e"><i>Produire <20> la cha<68> ne</i></a>';
}
else $FILETXT = 'Aucune d<> fense en attente' ;
$template -> assign_vars ( array ( 'RACE' => $race , 'FILETXT' => $FILETXT , 'CHAINE' => $CHAINE , 'RESTE' => $RESTE , 'ERREUR' => $ERREUR ));
}
else {
$template -> set_filenames ( array ( 'defense' => 'manque.tpl' ));
$template -> assign_vars ( array ( 'TEXTE' => 'Vous devez d\'abord construire un chantier terrestre !' ));
}
/* FIN Page d<EFBFBD> fenses
*
*/
require ( '../connectBDD.php' );
$result = mysql_query ( " SELECT * FROM version ORDER BY temps DESC " );
$data = mysql_fetch_array ( $result );
$version = $data [ 'version' ];
mysql_close ();
$template -> set_filenames ( array ( 'base' => 'base.tpl' ));
$template -> assign_vars ( array ( 'PUB' => $PUB , 'VERSION' => $version , 'RES_IMAGE' => $RES_IMAGE , 'NOM_METAL' => strtolower ( $NOM_METAL ), 'NOM_CRISTAL' => strtolower ( $NOM_CRISTAL ), 'NOM_HYDROGENE' => strtolower ( $NOM_HYDROGENE ), 'NOM_ENERGIE' => strtolower ( $NOM_ENERGIE ), 'RES_METAL' => $RES_METAL , 'RES_CRISTAL' => $RES_CRISTAL , 'RES_HYDROGENE' => $RES_HYDROGENE , 'RES_ENERGIE' => $RES_ENERGIE , 'DATEHEURET' => date ( '/dm/ H:i' ), 'COUNTHUMAINS' => '7500' , 'COUNTCOVENANTS' => '4500' , 'PSEUDO' => $pseudo ));
for ( $i = 0 ; $i < count ( $Aplan_value ) ; $i ++ ) {
$template -> assign_block_vars ( 'planetes' , array ( 'RES_VALUE' => $Aplan_value [ $i ], 'RES_MORE' => $Aplan_more [ $i ], 'RES_IMG' => $Aplan_img [ $i ], 'RES_NOM' => $Aplan_nom [ $i ], 'RES_REF' => $Aplan_ref [ $i ]));
2007-11-13 11:00:00 +00:00
}
2008-11-19 11:00:00 +00:00
$template -> assign_var_from_handle ( 'CONTENU' , 'defense' );
$template -> pparse ( 'base' );
2007-11-13 11:00:00 +00:00
?>