game/pages/laboratoire.php

317 lines
12 KiB
PHP

<?php
session_start();
define('DESIGN', 'descriptions/diz/base.css');
define('HEAD', '<script language="javascript" src="time.js"></script>');
require('../header.php');
$id=$_SESSION['id'];
$galaxy=$_SESSION['galaxy'];
$ss=$_SESSION['ss'];
$pos=$_SESSION['pos'];
require_once('noms.php');
require_once('bdd.php');
print '<body>';
require_once('ressource.php');
function verification_des_ress($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) echo "<font color=teal><a href=\"construction.php?tec=".$numtec."\">Construire</a></font>";
else echo "<font color=red>Construire</font>";
}
function ressources($metal, $calcium, $nourriture, $ress_ness_metal, $ress_ness_calcium, $ress_ness_nourriture) {
if ($ress_ness_metal > 0) {
if ($metal <= $ress_ness_metal) {
$z=floor($metal)-$ress_ness_metal;
echo "<font color=red >Métal : <ACRONYM title=".$z.">".$ress_ness_metal."</ACRONYM> </font>";
}
else echo "<font color=teal >Métal : ".$ress_ness_metal." </font>"; }
if ($ress_ness_calcium > 0) {
if ($calcium <= $ress_ness_calcium) {
$z=floor($calcium)-$ress_ness_calcium;
echo "<font color=red >Cristal : <ACRONYM title=".$z.">".$ress_ness_calcium."</ACRONYM> </font>";
}
else echo "<font color=teal >Cristal : ".$ress_ness_calcium." </font>"; }
if ($ress_ness_nourriture > 0) {
if ($nourriture <= $ress_ness_nourriture) {
$z=floor($nourriture)-$ress_ness_nourriture;
echo "<font color=red >Hydrogène : <ACRONYM title=".$z.">".$ress_ness_nourriture."</ACRONYM> </font>";
}
else echo "<font color=teal >Hydrogène : ".$ress_ness_nourriture." </font>"; }
}
function sec ($time) {
$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 .= ' ';
}
}
echo $output;
}
?>
<table align=center>
<tr>
<?php
if ($labo > 0) {
if ($labo >= 1) {
echo"<tr><td>lmages</td><td width=350>Description</td><td width=120>Rechercher</td></tr>
<tr><td><img src=images/".$technolo[0].".jpg ></td><td>".$technolo[0]." niveau ".$informatique."<br><br>Coût: "; $n=($informatique-1);
$b=ceil(pow(2,$n)*500); $c=ceil(pow(2,$n)*150);
ressources($metal, $cristal, $hydrogene, 0, $b, $c);
echo"<br>Temps : "; sec(ceil((pow(2,$labo)*840) - ((pow(2,$labo)*840)*0.07*$labo))); echo"</td><td>";
if ($temps_tec > 0) {
if ($tec==1) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=1\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(1, $metal, $cristal, $hydrogene, 0, $b, $c);
}
echo"</td></tr>";
}
if ($labo >= 2 && $informatique >=2) {
echo "<tr><td><img src=images/".$technolo[1].".jpg ></td><td>".$technolo[1]." niveau ".$detection."<br><br>Coût: "; $n=($detection-1);
$a=ceil(pow(2,$n)*500); $b=ceil(pow(2,$n)*750); $c=ceil(pow(2,$n)*100);
ressources($metal, $cristal, $hydrogene, $a, $b, $c);
echo"<br>Temps : "; sec(ceil((pow(2,$labo)*1200) - ((pow(2,$labo)*1200)*0.07*$labo))); echo"<td>";
if ($temps_tec > 0) {
if ($tec==2) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=2\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(2, $metal, $cristal, $hydrogene, $a, $b, $c);
}
echo"</td></tr>";
}
if ($labo >= 5) {
echo "<tr><td><img src=images/".$technolo[2].".jpg ></td><td>".$technolo[2]." niveau ".$armement."<br><br>Coût: ";$n=($armement-1);
$a=ceil(pow(2,$n)*2500); $b=ceil(pow(2,$n)*500);
ressources($metal, $cristal, $hydrogene, $a, $b, 0);
echo"<br>Temps : "; sec(ceil((pow(2,$labo)*3000) - ((pow(2,$labo)*3000)*0.07*$labo))); echo"<td>";
if ($temps_tec > 0) {
if ($tec==3) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=3\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(3, $metal, $cristal, $hydrogene, $a, $b, 0);
}
echo"</td></tr>";
}
if ($labo >= 4) {
echo "<tr><td><img src=images/".$technolo[3].".jpg ></td><td>".$technolo[3]." niveau ".$blindage."<br><br>Coût: ";$n=($blindage-1);
$a=ceil(pow(2,$n)*4000); $b=ceil(pow(2,$n)*1500);
ressources($metal, $cristal, $hydrogene, $a, $b, 0);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*3420) - ((pow(2,$labo)*3420)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==12) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=12\">Annuler</a>";
}
}
else { if($bat == 7) {echo "Le laboratoire est en cours d'évolution"; } else {verification_des_ress(12, $metal, $cristal, $hydrogene, $a, $b,0); } }
echo"</td></tr>";
}
if ($labo >= 2) {
echo "<tr><td><img src=images/".$technolo[4].".jpg ></td><td>".$technolo[4]." niveau ".$energie_t."<br><br>Coût: ";
$n=($energie_t-1); $a=ceil(pow(2,$n)*2000); $b=ceil(pow(2,$n)*1500); $c=ceil(pow(2,$n)*300);
ressources($metal, $cristal, $hydrogene, $a, $b, $c);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*1800) - ((pow(2,$labo)*1800)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==5) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=5\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(5, $metal, $cristal, $hydrogene, $a, $b, $c);
}
echo"</td></tr>";
}
if ($labo >= 2) {
echo "<tr><td><img src=images/".$technolo[5].".jpg ></td><td>".$technolo[5]." niveau ".$reacteur."<br><br>Coût: ";
$n=($reacteur-1); $a=ceil(pow(2,$n)*1400); $b=ceil(pow(2,$n)*400);
ressources($metal, $cristal, $hydrogene, $a, $b, 0);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*1020) - ((pow(2,$labo)*1020)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==6) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=6\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(6, $metal, $cristal, $hydrogene, $a, $b, 0);
}
echo"</td></tr>";
}
if ($labo >= 4 && $energie_t >=2 && $reacteur >= 4) {
echo "<tr><td><img src=images/".$technolo[6].".jpg ></td><td>".$technolo[6]." niveau ".$reacteur_f."<br><br>Coût: ";
$n=($reacteur_f-1); $a=ceil(pow(2,$n)*3000); $b=ceil(pow(2,$n)*2100); $c=ceil(pow(2,$n)*750);
ressources($metal, $cristal, $hydrogene, $a, $b, $c);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*3300) - ((pow(2,$labo)*3300)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==7) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=7\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(7, $metal, $cristal, $hydrogene, $a, $b, $c);
}
echo"</td></tr>";
}
if ($labo >= 6 && $energie_t >=5 && $reacteur_f >= 4) {
echo "<tr><td><img src=images/".$technolo[7].".jpg ></td><td>".$technolo[7]." niveau ".$reacteur_ff."<br><br>Coût: ";
$n=($reacteur_ff-1); $a=ceil(pow(2,$n)*5000); $b=ceil(pow(2,$n)*4000); $c=ceil(pow(2,$n)*1500);
ressources($metal, $cristal, $hydrogene, $a, $b, $c);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*4800) - ((pow(2,$labo)*4800)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==8) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=8\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(8, $metal, $cristal, $hydrogene, $a, $b, $c);
}
echo"</td></tr>";
}
if ($labo >= 1) {
echo "<tr><td><img src=images/".$technolo[8].".jpg ></td><td>".$technolo[8]." niveau ".$medecine."<br><br>Coût: ";
$n=($medecine-1); $a=ceil(pow(2,$n)*800); $b=ceil(pow(2,$n)*1000);
ressources($metal, $cristal, $hydrogene, $a, $b,0);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*720) - ((pow(2,$labo)*720)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==9) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=9\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(9, $metal, $cristal, $hydrogene, $a, $b, 0);
}
echo"</td></tr>";
}
if ($labo >= 3) {
echo "<tr><td><img src=images/".$technolo[9].".jpg ></td><td>".$technolo[9]." niveau ".$tactique."<br><br>Coût: ";
$n=($tactique-1); $a=ceil(pow(2,$n)*2600); $b=ceil(pow(2,$n)*2600);
ressources($metal, $cristal, $hydrogene, $a, $b, 0);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*22800) - ((pow(2,$labo)*2280)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==10) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=10\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(10, $metal, $cristal, $hydrogene, $a, $b, 0);
}
echo"</td></tr>";
}
if ($labo >= 8 && $mine_m >= 18 && $mine_c >= 15 && $informatique >= 8) {
echo "<tr><td><img src=images/".$technolo[10].".jpg ></td><td>".$technolo[10]." niveau ".$developpement."<br><br>Coût: ";
$n=($developpement-1); $a=ceil(pow(2,$n)*10000); $b=ceil(pow(2,$n)*10000); $c=ceil(pow(2,$n)*5000);
ressources($metal, $cristal, $hydrogene, $a, $b, $c);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*8220) - ((pow(2,$labo)*8220)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==11) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=11\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(11, $metal, $cristal, $hydrogene, $a, $b, $c);
}
echo"</td></tr>";
}
if ($labo >= 8 && $medecine >= 5 && $informatique >= 8) {
echo "<tr><td><img src=images/".$technolo[11].".jpg ></td><td>".$technolo[11]." niveau ".$spartan."<br><br>Coût: ";
$n=($spartan-1); $a=ceil(pow(3,$n)*5200); $b=ceil(pow(3,$n)*4250); $c=ceil(pow(3,$n)*850);
ressources($metal, $cristal, $hydrogene, $a, $b, $c);
echo"<br>Temps : ";
sec(ceil((pow(2,$labo)*10000) - ((pow(3,$labo)*10000)*0.07*$labo)));
echo"<td>";
if ($temps_tec > 0) {
if ($tec==13) {
$tr=$temps_tec-time();
echo '<span id="axion"></span><br>';
echo '<script language="JavaScript">reste('.$tr.');</script>';
echo "<a href=\"anul_tec.php?tec=13\">Annuler</a>";
}
}
else {
if($bat == 7) echo "Le laboratoire est en cours d'évolution";
else verification_des_ress(13, $metal, $cristal, $hydrogene, $a, $b, $c);
}
echo"</td></tr>";
}
}
else echo "</tr></table><center><table><tr><td>Vous devez d'abord construire un centre de recherche !</td></tr></table></center>";
?>
</body>
</html>