HB/game/laboratoire.php

119 lines
4.6 KiB
PHP
Raw Normal View History

2008-11-17 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']) && isset($technolo[$_GET['t']])) {
$i = $_GET['t'];
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->addObjet($i, 1, ceil($sec))) {
$export = mysql_real_escape_string(serialize($fileT));
mysql_query("UPDATE `planete` SET `metal` = '$metal', `cristal` = '$cristal', `hydrogene` = '$hydrogene', `file_tech` = '$export' WHERE `id` = '$idPlan';");
}
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 = mysql_real_escape_string(serialize($fileT));
mysql_query("UPDATE `planete` SET `metal` = '$metal', `cristal` = '$cristal', `hydrogene` = '$hydrogene', `file_tech` = '$export' WHERE `id` = '$idPlan';");
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;
$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 (!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,
'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 = $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);
?>