forked from halo-battle/game
Version 1.9a
This commit is contained in:
parent
5f81f76b17
commit
d028822d0b
437 changed files with 27543 additions and 81793 deletions
89
game/jeu/batiments.php
Normal file
89
game/jeu/batiments.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$page = 'batiments';
|
||||
$titre = 'Batiments';
|
||||
|
||||
$TEMP_batiments = array();
|
||||
$nbstop = count($batiment);
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['c'])) {
|
||||
//Vérification que la planète ne soit pas pleine
|
||||
if ($planete->casesRest <= 0) erreur('Vous n\'avez plus de place sur votre planète.', "red", "?p=batiments", 3500);
|
||||
|
||||
//Récupération des erreurs de la mise en file d'attente pour traitement
|
||||
$construction = $planete->file_addObjet("batiments", intval(gpc('c')));
|
||||
|
||||
switch($construction){
|
||||
case 1: erreur('Vous n\'avez pas les bâtiments et/ou technologies nécessaires pour construire ce bâtiment.'); break;
|
||||
case 2: erreur('Ce bâtiment est déjà en file d\'attente !'); break;
|
||||
case 3: erreur('Vous n\'avez pas les ressources nécessaire pour construire ce bâtiment !'); break;
|
||||
default: header('Location: ?p=batiments'); exit;
|
||||
}
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($batiment[$_GET['a']])) {
|
||||
$i = intval(gpc('a'));
|
||||
//Vérification de la présence du batiment dans la file d'attente
|
||||
if($planete->file_exist($i, 'file_bat')) {
|
||||
$planete->file_delObjet("batiments", $i);
|
||||
header('Location: ?p=batiments');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
//Règler la production à la châine
|
||||
/* if (isset($_GET['r']) && ($_GET['r'] == 1 || $_GET['r'] == 0)) {
|
||||
if($_GET['r']) $file->chaine = false;
|
||||
else $file->chaine = true;
|
||||
$export = mysql_real_escape_string(serialize($file));
|
||||
mysql_query("UPDATE planete SET file_bat = '$export' WHERE id = '$idPlan';");
|
||||
header('Location: ?p=batiments');
|
||||
exit;
|
||||
}*/
|
||||
|
||||
for ($i=0 ; $i<$nbstop ; $i++) {
|
||||
$tr = 0; $a = 0; $b = 0; $c = 0; $sec = 0; $enFile = false;
|
||||
if ($planete->batiments[$i] > 0) $niveau = $planete->batiments[$i]; else $niveau = 0;
|
||||
$n = $planete->batiments[$i] + 1; eval($batimentCALC[$i][0]); eval($batimentCALC[$i][1]); eval($batimentCALC[$i][2]); eval($batimentCALC[$i][3]);
|
||||
if ($planete->file_exist($i, 'file_bat')) $enFile = true;
|
||||
if (!empty($batiment[$i]) && requestDeblok($batimentTECH[$i], $planete)) $TEMP_batiments[] =
|
||||
array(
|
||||
'image' => $batimeni[$i],
|
||||
'nom' => $batiment[$i],
|
||||
'niveau' => $niveau,
|
||||
'description' => $batimede[$i],
|
||||
'descriptione' => addslashes($batimede[$i]),
|
||||
'nec_metal' => $a,
|
||||
'nec_cristal' => $b,
|
||||
'nec_hydrogene' => $c,
|
||||
'nec_metalS' => separerNombres($a),
|
||||
'nec_cristalS' => separerNombres($b),
|
||||
'nec_hydrogeneS' => separerNombres($c),
|
||||
'temps' => sec($sec),
|
||||
'num' => $i,
|
||||
'enfile' => $enFile,
|
||||
'maq_metal' => ceil($a - $planete->metal),
|
||||
'maq_cristal' => ceil($b - $planete->cristal),
|
||||
'maq_hydrogene' => ceil($c - $planete->hydrogene)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_batiments);
|
||||
$template->assign('chaine', $planete->batiments);
|
||||
$nbfile = count($planete->file_bat) - 1;
|
||||
|
||||
if ($nbfile == 1) $template->assign('Pchaine', true);
|
||||
else $template->assign('Pchaine', false);
|
||||
if ($nbfile == 0) $template->assign('Vchaine', true);
|
||||
else $template->assign('Vchaine', false);
|
||||
|
||||
$file = array();
|
||||
for ($i=1 ; $i <= $nbfile ; $i++) {
|
||||
$file_unit = explode(',', $planete->file_bat[$i]);
|
||||
$n = $planete->batiments[$file_unit[0]] + 1;
|
||||
eval($batimentCALC[$file_unit[0]][3]);
|
||||
if ($i == 1) $file[] = array($file_unit[0], $file_unit[1], ceil($sec - (time() - $planete->file_bat[0])), $batiment[$file_unit[0]]);
|
||||
else $file[] = array($file_unit[0], $file_unit[1], ceil($sec), $batiment[$file_unit[0]]);
|
||||
}
|
||||
|
||||
$template->assign('file', $file);
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue