2007-11-13 11:00:00 +00:00
< ? php
session_start ();
$id = $_SESSION [ 'id' ];
$galaxy = $_SESSION [ 'galaxy' ];
$ss = $_SESSION [ 'ss' ];
$pos = $_SESSION [ 'pos' ];
$race = $_SESSION [ 'race' ];
require_once ( 'bdd.php' );
require_once ( 'noms.php' );
require ( '../connectBDD.php' );
if ( $_POST [ 'type' ] == 'e' && $labo >= 1 && ! ereg ( 'e,' , implode ( ',' , $fileVai ) . ',' )) {
$temps_s = '' ;
$vai = 'e' ;
}
else {
// Annulation de la production en cha<68> ne si elle existe
//if (ereg('e,', implode(',',$fileVai).',')) { header('Location: annul_bat.php?bat=e&go='.$_POST['type']); exit; }
if ( ! isset ( $_POST [ 'sa' ])) exit ;
else $sa = abs ( floor ( $_POST [ 'sa' ]));
2007-11-21 11:00:00 +00:00
if ( $_POST [ 'type' ] == 1 && $chantier_spatial >= 1 && $reacteur >= 4 ) {
2007-11-13 11:00:00 +00:00
$metal -= 1000 * $sa ;
$cristal -= 800 * $sa ;
$temps_s = ceil ( 1080 / pow ( 1.25 ,( $chantier_spatial - 1 )));
$vai = 1 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 2 && $chantier_spatial >= 5 && $reacteur_f >= 2 ) {
2007-11-13 11:00:00 +00:00
$metal -= 4000 * $sa ;
$cristal -= 3000 * $sa ;
$temps_s = ceil ( 6300 / pow ( 1.25 ,( $chantier_spatial - 5 )));
$vai = 2 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 3 && $chantier_spatial >= 5 && $reacteur_ff >= 1 ) {
2007-11-13 11:00:00 +00:00
$metal -= 9000 * $sa ;
$cristal -= 9000 * $sa ;
$hydrogene -= 1000 * $sa ;
$temps_s = ceil ( 8280 / pow ( 1.25 ,( $chantier_spatial - 5 )));
$vai = 3 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 4 && $chantier_spatial >= 3 && $reacteur >= 5 && $detection >= 2 ) {
2007-11-13 11:00:00 +00:00
$metal -= 1000 * $sa ;
$cristal -= 1200 * $sa ;
$hydrogene -= 100 * $sa ;
$temps_s = ceil ( 1440 / pow ( 1.25 ,( $chantier_spatial - 3 )));
$vai = 4 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 5 && $chantier_spatial >= 5 && $reacteur_f >= 4 && $blindage >= 5 ) {
2007-11-13 11:00:00 +00:00
$metal -= 15000 * $sa ;
$cristal -= 9000 * $sa ;
$hydrogene -= 1000 * $sa ;
$temps_s = ceil ( 7380 / pow ( 1.25 ,( $chantier_spatial - 5 )));
$vai = 5 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 6 && $chantier_spatial >= 1 && $reacteur >= 4 ) {
2007-11-13 11:00:00 +00:00
$metal -= 1700 * $sa ;
$cristal -= 1220 * $sa ;
$temps_s = ceil ( 1200 / pow ( 1.25 ,( $chantier_spatial - 1 )));
$vai = 6 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 7 && $chantier_spatial >= 3 && $reacteur_f >= 3 && $armement >= 1 ) {
2007-11-13 11:00:00 +00:00
$metal -= 5800 * $sa ;
$cristal -= 1400 * $sa ;
$temps_s = ceil ( 4680 / pow ( 1.25 ,( $chantier_spatial - 3 )));
$vai = 7 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 8 && $chantier_spatial >= 6 && $reacteur_ff >= 2 && $armement >= 3 && $blindage >= 4 ) {
2007-11-13 11:00:00 +00:00
$metal -= 20000 * $sa ;
$cristal -= 16000 * $sa ;
$hydrogene -= 1600 * $sa ;
$temps_s = ceil ( 16800 / pow ( 1.25 ,( $chantier_spatial - 6 )));
$vai = 8 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 9 && $chantier_spatial >= 6 && $reacteur_ff >= 3 && $armement >= 4 && $blindage >= 4 ) {
2007-11-13 11:00:00 +00:00
$metal -= 26000 * $sa ;
$cristal -= 16400 * $sa ;
$hydrogene -= 1600 * $sa ;
$temps_s = ceil ( 18060 / pow ( 1.25 ,( $chantier_spatial - 6 )));
$vai = 9 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 10 && $chantier_spatial >= 8 && $reacteur_ff >= 5 && $armement >= 6 && $blindage >= 6 ) {
2007-11-13 11:00:00 +00:00
$metal -= 60000 * $sa ;
$cristal -= 40000 * $sa ;
$hydrogene -= 3000 * $sa ;
$temps_s = ceil ( 32400 / pow ( 1.25 ,( $chantier_spatial - 8 )));
$vai = 10 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 11 && $chantier_spatial >= 12 && $reacteur_ff >= 10 && $armement >= 12 && $blindage >= 12 ) {
2007-11-13 11:00:00 +00:00
$metal -= 500000 * $sa ;
$cristal -= 400000 * $sa ;
$hydrogene -= 250000 * $sa ;
$temps_s = ceil ( 117000 / pow ( 1.25 ,( $chantier_spatial - 12 )));
$vai = 11 ;
}
2007-11-21 11:00:00 +00:00
elseif ( $_POST [ 'type' ] == 12 && $chantier_spatial >= 12 && $reacteur_ff >= 10 && $armement >= 12 && $blindage >= 12 ) {
2007-11-13 11:00:00 +00:00
$metal -= 500000 * $sa ;
$cristal -= 400000 * $sa ;
$hydrogene -= 250000 * $sa ;
$temps_s = ceil ( 117000 / pow ( 1.25 ,( $chantier_spatial - 12 )));
$vai = 12 ;
}
}
if ( isset ( $vai ) && $vai != '' && ( ! empty ( $nomvaisn [ $vai - 1 ]) || $vai == 'e' || ( isset ( $_GET [ 'act' ]) && $_GET [ 'act' ] == 'e' ))) {
if ( $metal >= 0 && $cristal >= 0 && $hydrogene >= 0 ) {
for ( $c = 0 ; $c < $sa ; $c ++ ){
$fileVai = explode ( ' ' , implode ( ' ' , $fileVai ) . ' ' . $vai );
}
$vai = implode ( ' ' , $fileVai );
if ( count ( $fileTemps_s ) == 0 || count ( $fileTemps_s ) == 1 ) {
$temps_ss = time ();
for ( $c = 0 ; $c < $sa ; $c ++ ){
$temps_ss .= ' ' . $temps_s ;
}
$temps_s = $temps_ss ;
}
else {
$temps_ss = implode ( ' ' , $fileTemps_s );
for ( $c = 0 ; $c < $sa ; $c ++ ){
$temps_ss .= ' ' . $temps_s ;
}
$temps_s = $temps_ss ;
}
2007-11-21 11:00:00 +00:00
mysql_query ( " UPDATE planete SET metal=' $metal ', cristal=' $cristal ', hydrogene=' $hydrogene ', temps_spatial=' $temps_s ', unit_s=' $vai ' WHERE id_user=' $id ' AND galaxie=' $galaxy ' AND ss=' $ss ' AND position=' $pos ' " ) or die ( " erreur sql " . mysql_error ());
2007-11-13 11:00:00 +00:00
}
else {
header ( 'Location: chantier_spatial.php?err=3' );
exit ;
}
}
mysql_close ();
$vai = $fileVai [ 0 ];
if ( isset ( $_GET [ 'go' ]) && $_GET [ 'go' ] == 1 ) header ( 'Location: chantier_spatial.php?err=2' );
else header ( 'Location: chantier_spatial.php' );
?>