2008-11-16 11:00:00 +00:00
< ? php
if ( ! defined ( 'INDEX' )) { header ( 'Location: ../' ); exit ; }
$page = 'laboratoire' ;
$titre = 'Laboratoire' ;
$TEMP_recherches = array ();
$nbstop = count ( $technolo );
if ( empty ( $queryPlanete [ 'file_tech' ])) $fileT = new gererFile ( $queryUser [ 'prodfile' ] + 2 );
else {
$fileT = unserialize ( $queryPlanete [ 'file_tech' ]);
$fileT -> limite = $queryUser [ 'prodfile' ] + 2 ;
}
if ( $queryPlanete [ 'labo' ] == 0 ) {
$template -> assign ( 'message' , 'Vous devez d\'abord construire un ' . strtolower ( $batiment [ 6 ]));
$template -> assign ( 'script' , '<script type="text/javascript">setTimeout(\'document.location.href="?p=batiments";\', 4000);</script>' );
$template -> assign ( 'couleur' , 'red' );
$template -> display ( 'game/erreur.tpl' );
exit ;
}
//Lancement d'une nouvelle construction
if ( isset ( $_GET [ 't' ]) && ! empty ( $technolo [ $_GET [ 't' ]])) {
$i = $_GET [ 't' ];
$cntplan = count ( $queryPlanetes );
for ( $j = 0 ; $j < $cntplan ; $j ++ ) {
if ( ! empty ( $queryPlanetes [ $j ][ 'file_tech' ])) {
$fileRechPL = unserialize ( $queryPlanetes [ $j ][ 'file_tech' ]);
if ( $fileRechPL -> existe ( $i )) {
$template -> assign ( 'message' , 'Vous développez déjà cette recherche sur une autre planète.' );
$template -> assign ( 'script' , '<script type="text/javascript">setTimeout(\'document.location.href="?p=laboratoire";\', 3000);</script>' );
$template -> assign ( 'couleur' , 'red' );
$template -> display ( 'game/erreur.tpl' );
exit ;
}
}
}
if ( requestDeblok ( $technoloTECH [ $i ], $queryPlanete , $queryUser )) {
$n = $queryUser [ $technoloVAR [ $i ]] + 1 ;
eval ( $technoloCALC [ $i ][ 0 ]); $metal -= $a ;
eval ( $technoloCALC [ $i ][ 1 ]); $cristal -= $b ;
eval ( $technoloCALC [ $i ][ 2 ]); $hydrogene -= $c ;
if ( $metal < 0 || $cristal < 0 || $hydrogene < 0 ) {
$template -> assign ( 'message' , 'Vous n\'avez pas assez de ressources pour effectuer cette recherche.' );
$template -> assign ( 'script' , '<script type="text/javascript">setTimeout(\'document.location.href="?p=laboratoire";\', 3500);</script>' );
$template -> assign ( 'couleur' , 'red' );
$template -> display ( 'game/erreur.tpl' );
exit ;
}
eval ( $technoloCALC [ $i ][ 3 ]);
if ( ! $fileT -> existe ( $i ) && $fileT -> addObjet ( $i , 1 , ceil ( $sec ))) {
$export = serialize ( $fileT );
$bdd -> connexion ();
$bdd -> escape ( $export );
$bdd -> query ( " UPDATE $table_planete SET metal = ' $metal ', cristal = ' $cristal ', hydrogene = ' $hydrogene ', file_tech = ' $export ' WHERE id = ' $idPlan '; " );
$bdd -> deconnexion ();
}
elseif ( $file -> existe ( $i )) {
$template -> assign ( 'message' , 'Cette rechrche est déjà dans la file d\'attente !' );
$template -> assign ( 'script' , '<script type="text/javascript">setTimeout(\'document.location.href="?p=laboratoire";\', 3500);</script>' );
$template -> assign ( 'couleur' , 'red' );
$template -> display ( 'game/erreur.tpl' );
exit ;
}
else {
$template -> assign ( 'message' , 'Vous ne pouvez pas mettre plus de recherche en file d\'attente.' );
$template -> assign ( 'script' , '<script type="text/javascript">setTimeout(\'document.location.href="?p=laboratoire";\', 3500);</script>' );
$template -> assign ( 'couleur' , 'red' );
$template -> display ( 'game/erreur.tpl' );
exit ;
}
header ( 'Location: ?p=laboratoire' );
exit ;
}
}
//Annulation d'une nouvelle construction
if ( isset ( $_GET [ 'a' ]) && isset ( $technolo [ $_GET [ 'a' ]])) {
$i = $_GET [ 'a' ];
if ( $fileT -> existe ( $i )) {
$n = $queryUser [ $technoloVAR [ $i ]] + 1 ;
eval ( $technoloCALC [ $i ][ 0 ]); $metal += $a ;
eval ( $technoloCALC [ $i ][ 1 ]); $cristal += $b ;
eval ( $technoloCALC [ $i ][ 2 ]); $hydrogene += $c ;
$fileT -> delobjet ( $i );
$export = serialize ( $fileT );
$bdd -> connexion ();
$bdd -> escape ( $export );
$bdd -> query ( " UPDATE $table_planete SET metal = ' $metal ', cristal = ' $cristal ', hydrogene = ' $hydrogene ', file_tech = ' $export ' WHERE id = ' $idPlan '; " );
$bdd -> deconnexion ();
header ( 'Location: ?p=laboratoire' );
exit ;
}
}
//Règler la production à la châine
/* if ( isset ( $_GET [ 'r' ]) && ( $_GET [ 'r' ] == 1 || $_GET [ 'r' ] == 0 )) {
if ( $_GET [ 'r' ]) $fileT -> chaine = false ;
else $fileT -> chaine = true ;
$export = mysql_real_escape_string ( serialize ( $fileT ));
mysql_query ( " UPDATE planete SET file_tech = ' $export ' WHERE id = ' $id_user '; " );
header ( 'Location: ?p=laboratoire' );
exit ;
} */
for ( $i = 0 ; $i < $nbstop ; $i ++ ) {
$tr = 0 ; $a = 0 ; $b = 0 ; $c = 0 ; $sec = 0 ; $enFile = false ;
$nom_bdd = $technoloVAR [ $i ];
if ( $queryUser [ $nom_bdd ] > 0 ) $niveau = $queryUser [ $nom_bdd ]; else $niveau = 0 ;
$n = ( $queryUser [ $nom_bdd ] + 1 ); eval ( $technoloCALC [ $i ][ 0 ]); eval ( $technoloCALC [ $i ][ 1 ]); eval ( $technoloCALC [ $i ][ 2 ]); eval ( $technoloCALC [ $i ][ 3 ]);
if ( $fileT -> existe ( $i )) $enFile = true ;
if ( ! empty ( $technolo [ $i ]) && requestDeblok ( $technoloTECH [ $i ], $queryPlanete , $queryUser )) $TEMP_recherches [] =
array (
'image' => $technoli [ $i ],
'nom' => $technolo [ $i ],
'niveau' => $niveau ,
'description' => $technode [ $i ],
'descriptione' => addslashes ( $technode [ $i ]),
'nec_metal' => $a ,
'nec_cristal' => $b ,
'nec_hydrogene' => $c ,
'nec_metalS' => separerNombres ( $a ),
'nec_cristalS' => separerNombres ( $b ),
'nec_hydrogeneS' => separerNombres ( $c ),
'num' => $i ,
'enfile' => $enFile ,
'temps' => sec ( $sec ),
'maq_metal' => ceil ( $a - $metal ),
'maq_cristal' => ceil ( $b - $cristal ),
'maq_hydrogene' => ceil ( $c - $hydrogene )
);
}
$template -> assign ( 'recherches' , $TEMP_recherches );
$template -> assign ( 'chaine' , $fileT -> chaine );
$fileTech = array_merge ( $fileT -> file );
$nbfile = count ( $fileTech );
if ( $nbfile == 1 ) $template -> assign ( 'Pchaine' , true );
else $template -> assign ( 'Pchaine' , false );
if ( $nbfile == 0 ) $template -> assign ( 'Vchaine' , true );
else $template -> assign ( 'Vchaine' , false );
for ( $i = 0 ; $i < $nbfile ; $i ++ ) {
$fileTech [ $i ][ 3 ] = $technolo [ $fileTech [ $i ][ 0 ]];
if ( $i == 0 ) $fileTech [ $i ][ 2 ] -= time () - $fileT -> timestamp ;
}
$template -> assign ( 'file' , $fileTech );
?>