2007-10-27 10:00:00 +00:00
< ? php
2007-11-03 11:00:00 +00:00
session_start ();
$id = $_SESSION [ 'id' ];
$galaxy = $_SESSION [ 'galaxy' ];
$ss = $_SESSION [ 'ss' ];
$pos = $_SESSION [ 'pos' ];
$race = $_SESSION [ 'race' ];
2008-11-19 11:00:00 +00:00
include_once ( 'common.php' );
2007-10-27 10:00:00 +00:00
require ( '../connectBDD.php' );
2007-11-03 11:00:00 +00:00
2007-11-13 11:00:00 +00:00
if ( ereg ( ',' . $_GET [ 'bat' ] . ',' , implode ( ',' , $fileBat ) . ',' )) { header ( 'Location: batiment.php?err=1' ); exit ; }
2007-11-03 11:00:00 +00:00
2007-11-21 11:00:00 +00:00
if ( $_GET [ 'bat' ] == 'e' && $labo >= 1 && ! ereg ( 'e,' , implode ( ',' , $fileBat ) . ',' )) {
$temps_bat = '' ;
$bat = 'e' ;
2007-11-09 11:00:00 +00:00
}
2007-11-21 11:00:00 +00:00
else {
// Annulation de la production en cha<68> ne si elle existe
if ( ereg ( 'e,' , implode ( ',' , $fileBat ) . ',' )) { header ( 'Location: annul_bat.php?bat=e&go=' . $_GET [ 'bat' ]); exit ; }
2007-11-09 11:00:00 +00:00
2007-11-21 11:00:00 +00:00
if ( $_GET [ 'bat' ] == 1 ) {
$metal -= ceil ( exp ( 0.4 * $mine_m ) * 190 );
$cristal -= ceil ( exp ( 0.4 * $mine_m ) * 90 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 1.7 , $mine_m ) * 120 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 1 ;
}
elseif ( $_GET [ 'bat' ] == 2 ) {
$metal -= ceil ( exp ( 0.43 * $mine_c ) * 205 );
$cristal -= ceil ( exp ( 0.43 * $mine_c ) * 110 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 1.72 , $mine_c ) * 160 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 2 ;
}
elseif ( $_GET [ 'bat' ] == 3 ) {
$metal -= ceil ( exp ( 0.445 * $mine_h ) * 235 );
$cristal -= ceil ( exp ( 0.445 * $mine_h ) * 150 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 1.75 , $mine_h ) * 180 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 3 ;
}
elseif ( $_GET [ 'bat' ] == 4 ) {
$metal -= ceil ( exp ( 0.442 * $centrale_s ) * 165 );
$cristal -= ceil ( exp ( 0.442 * $centrale_s ) * 99 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 1.68 , $centrale_s ) * 190 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 4 ;
}
2007-11-13 11:00:00 +00:00
elseif ( $_GET [ 'bat' ] == 5 && $centrale_s >= 12 && $energie_t >= 5 ) {
2007-11-21 11:00:00 +00:00
$metal -= ceil ( pow ( 1.8 , $centrale_f ) * 300 );
$cristal -= ceil ( pow ( 1.82 , $centrale_f ) * 230 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 1.8 , $centrale_f ) * 300 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 5 ;
}
2007-11-13 11:00:00 +00:00
elseif ( $_GET [ 'bat' ] == 6 && $detection >= 1 ) {
2007-11-21 11:00:00 +00:00
$metal -= ceil ( pow ( 2 , $radar ) * 750 );
$cristal -= ceil ( pow ( 2 , $radar ) * 500 );
$hydrogene -= ceil ( pow ( 2 , $radar ) * 50 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 2 , $radar ) * 720 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 6 ;
}
elseif ( $_GET [ 'bat' ] == 7 ) {
$metal -= ceil ( pow ( 2 , $labo ) * 200 );
$cristal -= ceil ( pow ( 2 , $labo ) * 150 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 2 , $labo ) * 720 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 7 ;
}
elseif ( $_GET [ 'bat' ] == 8 ) {
$metal -= ceil ( pow ( 2 , $chantier_terrestre ) * 520 );
$cristal -= ceil ( pow ( 2 , $chantier_terrestre ) * 380 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 2 , $chantier_terrestre ) * 420 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 8 ;
}
2007-11-13 11:00:00 +00:00
elseif ( $_GET [ 'bat' ] == 9 && $chantier_terrestre >= 2 ) {
2007-11-21 11:00:00 +00:00
$metal -= ceil ( pow ( 2 , $chantier_spatial ) * 600 );
$cristal -= ceil ( pow ( 2 , $chantier_spatial ) * 450 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 2 , $chantier_spatial ) * 600 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 9 ;
}
elseif ( $_GET [ 'bat' ] == 10 ) {
$metal -= ceil ( pow ( 2 , $caserne ) * 200 );
$cristal -= ceil ( pow ( 2 , $caserne ) * 100 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 2 , $caserne ) * 300 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 10 ;
}
elseif ( $_GET [ 'bat' ] == 11 ) {
$metal -= ceil ( pow ( 2 , $silo ) * 400 );
$cristal -= ceil ( pow ( 2 , $silo ) * 260 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 2 , $silo ) * 1200 ) / ( pow ( 1.23 , $centre_info ) + 0.0025 * $ingenieur ));
2007-11-21 11:00:00 +00:00
$bat = 11 ;
}
2007-11-13 11:00:00 +00:00
elseif ( $_GET [ 'bat' ] == 12 && $informatique >= 2 ) {
2007-11-21 11:00:00 +00:00
$metal -= ceil ( pow ( 1.7 , $centre_info ) * 600 );
$cristal -= ceil ( pow ( 1.7 , $centre_info ) * 420 );
$hydrogene -= ceil ( pow ( 1.7 , $centre_info ) * 100 );
2008-11-19 11:00:00 +00:00
$temps_bat = ceil (( pow ( 1.9 , $centre_info ) * 800 ) / (( 0.0025 * $ingenieur ) + 1 ));
2007-11-21 11:00:00 +00:00
$bat = 12 ;
}
2007-11-04 11:00:00 +00:00
}
2007-10-27 10:00:00 +00:00
2007-11-21 11:00:00 +00:00
if ( isset ( $bat ) && $bat != '' && ( ! empty ( $batiment [ $bat - 1 ]) || $bat == 'e' || ( isset ( $_GET [ 'act' ]) && $_GET [ 'act' ] == 'e' ))) {
if ( $metal >= 0 && $cristal >= 0 && $hydrogene >= 0 ) {
$bat = implode ( ' ' , $fileBat ) . ' ' . $bat . ' ' ;
if (( count ( $fileTemps_b ) == 0 || count ( $fileTemps_b ) == 1 || count ( $fileTemps_b ) == 2 ) && isset ( $_GET [ 'act' ]) && $_GET [ 'act' ] == 'e' && isset ( $_GET [ 'temps_bat' ])) $temps_bat = $_GET [ 'temps_bat' ] . ' ' . $temps_bat . ' ' ;
elseif ( count ( $fileTemps_b ) == 0 || count ( $fileTemps_b ) == 1 ) $temps_bat = time () . ' ' . $temps_bat . ' ' ;
else $temps_bat = implode ( ' ' , $fileTemps_b ) . ' ' . $temps_bat . '' ;
2007-11-03 11:00:00 +00:00
2007-11-21 11:00:00 +00:00
if ( isset ( $_GET [ 'act' ]) && $_GET [ 'act' ] == 'e' ) { $bat .= 'e' ; mysql_query ( " UPDATE planete SET metal=' $metal ', cristal=' $cristal ', temps_b=' $temps_bat ', bat=' $bat ' WHERE id_user=' $id ' AND galaxie=' $galaxy ' AND ss=' $ss ' AND position=' $pos ' " ); }
else mysql_query ( " UPDATE planete SET metal=' $metal ', cristal=' $cristal ', temps_b=' $temps_bat ', bat=' $bat ' WHERE id_user=' $id ' AND galaxie=' $galaxy ' AND ss=' $ss ' AND position=' $pos ' " );
}
}
mysql_close ();
$bat = $fileBat [ 0 ];
if ( isset ( $_GET [ 'go' ]) && $_GET [ 'go' ] == 1 ) header ( 'Location: batiment.php?err=2' );
else header ( 'Location: batiment.php' );
2007-11-03 11:00:00 +00:00
?>