Correctifs sur la page de préparation d'envoie des flotte
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
52e4266218
commit
c56099e3b0
@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
define("INDEX", 1);
|
define("INDEX", 1);
|
||||||
|
define("DEBUG", false);
|
||||||
$chrono_start = microtime();
|
$chrono_start = microtime();
|
||||||
$onyx = @file_get_contents('./.onyx') or die("Configuration introuvable.");
|
require_once(trim(file_get_contents('./.onyx')));
|
||||||
define("_FCORE", trim($onyx));
|
require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
||||||
require(_FCORE."../game/Class/JSON.php");
|
require_once("function.php");
|
||||||
require_once(_FCORE."common.php");
|
require_once("Class/JSON.php");
|
||||||
|
require_once("Class/flotte.php");
|
||||||
|
require_once("Class/planete.php");
|
||||||
|
|
||||||
if (isset($sess) && isset($sess->values['connected']) && $sess->values['connected'] && !empty($sess->values['id']) && !empty($sess->level) && !empty($sess->values['idPlan'])) {
|
if (isset($SESS) && isset($SESS->values['connected']) && $SESS->values['connected'] && !empty($SESS->values['id']) && !empty($SESS->level) && !empty($SESS->values['idPlan'])) {
|
||||||
|
$idPrep = gpc("cds_temp", "post");
|
||||||
$json = new Services_JSON();
|
$json = new Services_JSON();
|
||||||
$nbtrajet = 2;
|
$nbtrajet = 2;
|
||||||
|
|
||||||
if (empty($config['flottes']) && $sess->level <= 1) {
|
if (empty($config['flottes']) && $SESS->level <= 1) {
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'destination' => '<input class="dest" type="text" id="amas" name="amas" maxlength="2" value="'.gpc('galaxie', 'post').'" />:<input class="dest" type="text" id="ss" name="ss" maxlength="2" value="'.gpc('ss', 'post').'" />:<input class="dest" type="text" id="plan" name="pos" maxlength="2" value="'.gpc('pos', 'post').'" />',
|
'destination' => '<input class="dest" type="text" id="amas" name="amas" maxlength="2" value="'.gpc('galaxie', 'post').'" />:<input class="dest" type="text" id="ss" name="ss" maxlength="2" value="'.gpc('ss', 'post').'" />:<input class="dest" type="text" id="plan" name="pos" maxlength="2" value="'.gpc('pos', 'post').'" />',
|
||||||
@ -28,8 +32,7 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
$destin = gpc('fav_dest', 'post');
|
$destin = gpc('fav_dest', 'post');
|
||||||
|
|
||||||
$chapeau = new bdd();
|
$chapeau = new bdd();
|
||||||
$chapeau->connexion();
|
$idPlan = $SESS->values['idPlan'];
|
||||||
$idPlan = $sess->values['idPlan'];
|
|
||||||
$queryPlanete = $chapeau->unique_query("SELECT * FROM $table_planete WHERE id = '$idPlan'");
|
$queryPlanete = $chapeau->unique_query("SELECT * FROM $table_planete WHERE id = '$idPlan'");
|
||||||
if (!empty($destin)) {
|
if (!empty($destin)) {
|
||||||
$chapeau->escape($destin);
|
$chapeau->escape($destin);
|
||||||
@ -45,18 +48,11 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
$start_ss = $queryPlanete['ss'];
|
$start_ss = $queryPlanete['ss'];
|
||||||
$start_position = $queryPlanete['position'];
|
$start_position = $queryPlanete['position'];
|
||||||
|
|
||||||
$met = gpc('met', 'post');
|
if (empty($SESS->values["prepFlottes"][$idPrep]['time']) ||
|
||||||
$cri = gpc('cri', 'post');
|
$SESS->values["prepFlottes"][$idPrep]['time'] + 1200 < time() ||
|
||||||
$hyd = gpc('hyd', 'post');
|
empty($SESS->values["prepFlottes"][$idPrep]['nbVaisseaux']) ||
|
||||||
if (!empty($sess->values['flcontenu']) && $met+$cri+$hyd >= 0 && $met >= 0 && $cri >= 0 && $hyd >= 0) {
|
empty($SESS->values["prepFlottes"][$idPrep]['vitesse']) &&
|
||||||
$places = $sess->values['flcontenu'] - ($met+$cri+$hyd);
|
isset($SESS->values['auth_level'])) {
|
||||||
} else {
|
|
||||||
$places = 'inconnu';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (empty($sess->values['fltime']) || $sess->values['fltime'] + 600 < time() || empty($sess->values['flnbvais']) || empty($sess->values['flvitesse']) && isset($sess->values['auth_level'])) {
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'destination' => $destinRapid,
|
'destination' => $destinRapid,
|
||||||
@ -64,7 +60,7 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
'deblok' => '<b>Une erreur est survenue lors de la création de la flotte. Veuillez recommencer</b>',
|
'deblok' => '<b>Une erreur est survenue lors de la création de la flotte. Veuillez recommencer</b>',
|
||||||
'conso' => '-',
|
'conso' => '-',
|
||||||
'tactique' => '',
|
'tactique' => '',
|
||||||
'places' => separerNombres($places)
|
'places' => '',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} elseif (empty($_POST['nom']) || preg_replace('@[^a-zA-Z0-9_ ]@i', '', $_POST['nom']) != $_POST['nom']) {
|
} elseif (empty($_POST['nom']) || preg_replace('@[^a-zA-Z0-9_ ]@i', '', $_POST['nom']) != $_POST['nom']) {
|
||||||
@ -75,10 +71,10 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
'deblok' => '<b>Nom de la flotte incorrect !</b>',
|
'deblok' => '<b>Nom de la flotte incorrect !</b>',
|
||||||
'conso' => '-',
|
'conso' => '-',
|
||||||
'tactique' => '',
|
'tactique' => '',
|
||||||
'places' => separerNombres($places)
|
'places' => '',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} elseif ($_POST['galaxie'] > MAX_AMAS || $_POST['ss'] > MAX_SYSTEME || $_POST['pos'] > MAX_PLANETE || $_POST['galaxie'] < 0 || $_POST['ss'] < 1 || $_POST['pos'] < 1 || ($_POST['galaxie'] < 1 && $sess->values['auth_level'] < 6)) {
|
} elseif ($_POST['galaxie'] > $VAR['nb_amas'] || $_POST['ss'] > $VAR['nb_systeme'] || $_POST['pos'] > $VAR['nb_planete'] || $_POST['galaxie'] < 0 || $_POST['ss'] < 1 || $_POST['pos'] < 1 || ($_POST['galaxie'] < 1 && $SESS->values['auth_level'] < 6)) {
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'destination' => $destinRapid,
|
'destination' => $destinRapid,
|
||||||
@ -86,23 +82,37 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
'deblok' => '<b>Corrigez la destination !</b>',
|
'deblok' => '<b>Corrigez la destination !</b>',
|
||||||
'conso' => '-',
|
'conso' => '-',
|
||||||
'tactique' => '',
|
'tactique' => '',
|
||||||
'places' => separerNombres($places)
|
'places' => '',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$_POST['vitesse'] /= 100;
|
$_POST['vitesse'] /= 100;
|
||||||
$temps = vais_tempsDeplacement($start_galaxie, $start_ss, $start_position, $_POST['galaxie'], $_POST['ss'], $_POST['pos'], $sess->values['flvitesse'], $_POST['vitesse'], $sess->values['flpreparation'], $sess->values['flchauffe']);
|
|
||||||
|
$planete = new planete($idPlan);
|
||||||
|
$flotte = new flotte();
|
||||||
|
$temps = $flotte->calc_deplacement($planete, $_POST['galaxie'], $_POST['ss'], $_POST['pos'], $_POST['vitesse'], $SESS->values["prepFlottes"][$idPrep]['vaisseaux'], 1000);
|
||||||
if ($temps <= 0) {
|
if ($temps <= 0) {
|
||||||
$temps = 454;
|
$temps = 454;
|
||||||
}
|
}
|
||||||
$conso = vais_conso($temps, $sess->values['flnbvais'])*$_POST['vitesse']/45;
|
$conso = $flotte->calc_deplacement($planete, $_POST['galaxie'], $_POST['ss'], $_POST['pos'], $_POST['vitesse'], $SESS->values["prepFlottes"][$idPrep]['vaisseaux'], 1000, false, true);
|
||||||
$places -= ceil($conso*$nbtrajet);
|
// $conso renvoi le temps ET la conso dans un array
|
||||||
|
$conso = intval($conso[1]);
|
||||||
|
|
||||||
|
$met = intval(gpc('met', 'post'));
|
||||||
|
$cri = intval(gpc('cri', 'post'));
|
||||||
|
$hyd = intval(gpc('hyd', 'post'));
|
||||||
|
$places = $flotte->calcStockage($SESS->values["prepFlottes"][$idPrep]['vaisseaux'], $planete);
|
||||||
|
$places -= ceil($conso * $nbtrajet);
|
||||||
|
if (($met+$cri+$hyd) > 0) {
|
||||||
|
$places -= ($met+$cri+$hyd);
|
||||||
|
}
|
||||||
$tactique = '';
|
$tactique = '';
|
||||||
if ($_POST['mission'] == '1') {
|
if ($_POST['mission'] == '1') {
|
||||||
$tactique = '<label for="selecttactique">Tactique d\'attaque :</label><select id="selecttactique" name="tactique">';
|
$tactique = '<label for="selecttactique">Tactique d\'attaque :</label><select id="selecttactique" name="tactique">';
|
||||||
//On récupère le niveau actuel de la technologie Commandement militaire
|
//On récupère le niveau actuel de la technologie Commandement militaire
|
||||||
$id_user = $sess->values['id'];
|
$id_user = $SESS->values['id'];
|
||||||
$table = $config['db_prefix'].'user';
|
global $table_user;
|
||||||
|
$table = $table_user;
|
||||||
$queryUser = $chapeau->unique_query("SELECT * FROM $table WHERE id = '$id_user'");
|
$queryUser = $chapeau->unique_query("SELECT * FROM $table WHERE id = '$id_user'");
|
||||||
$lvltechno = $queryUser['tactique'];
|
$lvltechno = $queryUser['tactique'];
|
||||||
$tactiquedef = $queryUser['combatAT_tactique'];
|
$tactiquedef = $queryUser['combatAT_tactique'];
|
||||||
@ -113,9 +123,9 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
'destination' => $destinRapid,
|
'destination' => $destinRapid,
|
||||||
'temps' => affTemp(floor($temps)),
|
'temps' => affTemp(floor($temps)),
|
||||||
'deblok' => '<b>Vous ne pouvez pas attaquer sans un minimum de connaissances militaires !</b>',
|
'deblok' => '<b>Vous ne pouvez pas attaquer sans un minimum de connaissances militaires !</b>',
|
||||||
'conso' => separerNombres(ceil($conso*$nbtrajet)),
|
'conso' => ceil($conso*$nbtrajet),
|
||||||
'tactique' => '',
|
'tactique' => '',
|
||||||
'places' => separerNombres($places)
|
'places' => $places
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
header("X-JSON: ".$json->encode($datas));
|
header("X-JSON: ".$json->encode($datas));
|
||||||
@ -131,17 +141,16 @@ if (isset($sess) && isset($sess->values['connected']) && $sess->values['connecte
|
|||||||
}
|
}
|
||||||
$tactique .= '</select><br />';
|
$tactique .= '</select><br />';
|
||||||
}
|
}
|
||||||
$cds = sha1('flotte'.$conso.'ß10'.time().'|HB;'.rand(10, 99).$temps);
|
$SESS->values['flcds'] = $idPrep;
|
||||||
$sess->values['flcds'] = $cds;
|
$SESS->put();
|
||||||
$sess->put();
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'root' => array(
|
'root' => array(
|
||||||
'destination' => $destinRapid,
|
'destination' => $destinRapid,
|
||||||
'temps' => affTemp(floor($temps)),
|
'temps' => affTemp(floor($temps)),
|
||||||
'deblok' => '<input type="hidden" name="cds" value="'.$cds.'" /><input type="submit" value="GO" class="submit" />',
|
'deblok' => '<input type="hidden" name="cds" value="'.$idPrep.'" /><input type="submit" value="GO" class="submit" />',
|
||||||
'conso' => separerNombres(ceil($conso*2)),
|
'conso' => ceil($conso*2),
|
||||||
'tactique' => $tactique,
|
'tactique' => $tactique,
|
||||||
'places' => separerNombres($places)
|
'places' => $places
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,26 @@ window.onload = function(){
|
|||||||
|
|
||||||
function tempsFlotte() {
|
function tempsFlotte() {
|
||||||
document.getElementById('deblok').innerHTML = '...';
|
document.getElementById('deblok').innerHTML = '...';
|
||||||
|
var url_string = (window.location.href).toLowerCase();
|
||||||
|
var url = new URL(url_string);
|
||||||
|
var cds = url.searchParams.get("c");
|
||||||
new Ajax.Request(
|
new Ajax.Request(
|
||||||
'ajax_flotte.php',
|
'ajax_flotte.php',
|
||||||
{
|
{
|
||||||
method: 'post',
|
method: 'post',
|
||||||
parameters: {fav_dest: document.getElementById('fav_dest').value, nom: document.getElementById('nom').value, mission: document.getElementById('mission').value, met: document.getElementById('metal').value, cri: document.getElementById('cristal').value, hyd: document.getElementById('hydrogene').value, galaxie: document.getElementById('amas').value, ss: document.getElementById('ss').value, pos: document.getElementById('plan').value, vitesse: document.getElementById('vitesse').value},
|
parameters: {
|
||||||
|
cds_temp: cds,
|
||||||
|
fav_dest: document.getElementById('fav_dest').value,
|
||||||
|
nom: document.getElementById('nom').value,
|
||||||
|
mission: document.getElementById('mission').value,
|
||||||
|
met: document.getElementById('metal').value,
|
||||||
|
cri: document.getElementById('cristal').value,
|
||||||
|
hyd: document.getElementById('hydrogene').value,
|
||||||
|
galaxie: document.getElementById('amas').value,
|
||||||
|
ss: document.getElementById('ss').value,
|
||||||
|
pos: document.getElementById('plan').value,
|
||||||
|
vitesse: document.getElementById('vitesse').value
|
||||||
|
},
|
||||||
onSuccess: function(transport, json) {
|
onSuccess: function(transport, json) {
|
||||||
document.getElementById('destination').innerHTML = json.root.destination;
|
document.getElementById('destination').innerHTML = json.root.destination;
|
||||||
document.getElementById('temps').innerHTML = json.root.temps;
|
document.getElementById('temps').innerHTML = json.root.temps;
|
||||||
@ -107,4 +122,4 @@ function tempsFlotte() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ class dSpatial implements Donnees
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function tailleCales($id)
|
public static function tailleCales($id, surface $planete)
|
||||||
{
|
{
|
||||||
if ($planete->race == "humain") {
|
if ($planete->race == "humain") {
|
||||||
switch ($id) {
|
switch ($id) {
|
||||||
@ -781,7 +781,7 @@ class dSpatial implements Donnees
|
|||||||
$vitesse = 15000;
|
$vitesse = 15000;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
$vitesse = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch ($id) {
|
switch ($id) {
|
||||||
@ -837,7 +837,7 @@ class dSpatial implements Donnees
|
|||||||
$vitesse = 20000000;
|
$vitesse = 20000000;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
$vitesse = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +846,7 @@ class dSpatial implements Donnees
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function vitesseP($id)
|
public static function vitesseP($id, surface $planete)
|
||||||
{
|
{
|
||||||
if ($planete->race == "humain") {
|
if ($planete->race == "humain") {
|
||||||
switch ($id) {
|
switch ($id) {
|
||||||
@ -957,7 +957,7 @@ class dSpatial implements Donnees
|
|||||||
return $vitesse;
|
return $vitesse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function vitesseS($id)
|
public static function vitesseS($id, surface $planete)
|
||||||
{
|
{
|
||||||
if ($planete->race == "humain") {
|
if ($planete->race == "humain") {
|
||||||
switch ($id) {
|
switch ($id) {
|
||||||
@ -1068,7 +1068,7 @@ class dSpatial implements Donnees
|
|||||||
return $vitesse;
|
return $vitesse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function vitesseG($id)
|
public static function vitesseG($id, surface $planete)
|
||||||
{
|
{
|
||||||
if ($planete->race == "humain") {
|
if ($planete->race == "humain") {
|
||||||
switch ($id) {
|
switch ($id) {
|
||||||
|
@ -88,12 +88,13 @@ class Flotte
|
|||||||
|
|
||||||
public function calculer()
|
public function calculer()
|
||||||
{
|
{
|
||||||
|
global $planete;
|
||||||
$this->nb_vais = 0;
|
$this->nb_vais = 0;
|
||||||
|
|
||||||
//Calcul de la capacité maximale d'embarquement de la flotte
|
//Calcul de la capacité maximale d'embarquement de la flotte
|
||||||
foreach ($this->vaisseaux as $key => $vais) {
|
foreach ($this->vaisseaux as $key => $vais) {
|
||||||
$this->nb_vais += $vais;
|
$this->nb_vais += $vais;
|
||||||
$this->contenuMax += dSpatial::tailleCales($key) * $vais;
|
$this->contenuMax += dSpatial::tailleCales($key, $planete) * $vais;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,20 +266,20 @@ class Flotte
|
|||||||
|
|
||||||
//Calcul du temps de déplacement entre planètes
|
//Calcul du temps de déplacement entre planètes
|
||||||
if ($start_planete->ss == $end_systeme && $start_planete->galaxie == $end_galaxie) {
|
if ($start_planete->ss == $end_systeme && $start_planete->galaxie == $end_galaxie) {
|
||||||
$temps[0][$key] = (1000/dSpatial::vitesseP($key)) * (1 + 0.1 * $diff_position);
|
$temps[0][$key] = (1000/dSpatial::vitesseP($key, $start_planete)) * (1 + 0.1 * $diff_position);
|
||||||
$temps[1][$key] = $temps[2][$key] = 0;
|
$temps[1][$key] = $temps[2][$key] = 0;
|
||||||
}
|
}
|
||||||
//Calcul du temps de déplacement entre système
|
//Calcul du temps de déplacement entre système
|
||||||
elseif ($start_planete->galaxie == $end_galaxie) {
|
elseif ($start_planete->galaxie == $end_galaxie) {
|
||||||
$temps[0][$key] = (1000/dSpatial::vitesseP($key)) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
|
$temps[0][$key] = (1000/dSpatial::vitesseP($key, $start_planete)) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
|
||||||
$temps[1][$key] = (2000/dSpatial::vitesseS($key)) * (2 + 1 * $diff_systeme);
|
$temps[1][$key] = (2000/dSpatial::vitesseS($key, $start_planete)) * (2 + 1 * $diff_systeme);
|
||||||
$temps[2][$key] = 0;
|
$temps[2][$key] = 0;
|
||||||
}
|
}
|
||||||
//Calcul du temps de déplacement entre galaxies
|
//Calcul du temps de déplacement entre galaxies
|
||||||
else {
|
else {
|
||||||
$temps[0][$key] = (1000/dSpatial::vitesseP($key)) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
|
$temps[0][$key] = (1000/dSpatial::vitesseP($key, $start_planete)) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
|
||||||
$temps[1][$key] = (2000/dSpatial::vitesseS($key)) * (2 + 1 * ($diff_centre_systeme_start + $diff_centre_systeme_end));
|
$temps[1][$key] = (2000/dSpatial::vitesseS($key, $start_planete)) * (2 + 1 * ($diff_centre_systeme_start + $diff_centre_systeme_end));
|
||||||
$temps[2][$key] = (5000/dSpatial::vitesseG($key)) * (2 + 1.5 * $diff_galaxie);
|
$temps[2][$key] = (5000/dSpatial::vitesseG($key, $start_planete)) * (2 + 1.5 * $diff_galaxie);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calcul du bonus pour le réacteur à combustion
|
//Calcul du bonus pour le réacteur à combustion
|
||||||
@ -332,7 +333,7 @@ class Flotte
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Si les chasseurs peuvent rentrer dans les cales des vaisseaux, on les enlèves
|
//Si les chasseurs peuvent rentrer dans les cales des vaisseaux, on les enlèves
|
||||||
if ($contenuDispo - ceil($conso[0]+$conso[1]+$conso[2]) - ($vaisseaux[4] * dSpatial::tailleCales(4) + $vaisseaux[5] * dSpatial::tailleCales(5)) >= ($vaisseaux[4] + $vaisseaux[5]) * 200) {
|
if ($contenuDispo - ceil($conso[0]+$conso[1]+$conso[2]) - ($vaisseaux[4] * dSpatial::tailleCales(4, $start_planete) + $vaisseaux[5] * dSpatial::tailleCales(5, $start_planete)) >= ($vaisseaux[4] + $vaisseaux[5]) * 200) {
|
||||||
$temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
|
$temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,6 +348,21 @@ class Flotte
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function calcStockage($vaisseaux, surface $planete)
|
||||||
|
{
|
||||||
|
global $LANG;
|
||||||
|
|
||||||
|
$contenuMax = 0;
|
||||||
|
foreach ($vaisseaux as $key => $vais) {
|
||||||
|
if (!isset($LANG[$planete->race]["vaisseaux"]["noms_sing"][$key])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$contenuMax += dSpatial::tailleCales($key, $planete) * $vais;
|
||||||
|
}
|
||||||
|
return $contenuMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function check_mission()
|
public function check_mission()
|
||||||
{
|
{
|
||||||
//On vérifie qu'un calcul ne soit pas déjà en cours
|
//On vérifie qu'un calcul ne soit pas déjà en cours
|
||||||
|
@ -5,7 +5,29 @@ if (!defined('INDEX')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$bdd->reconnexion();
|
$bdd->reconnexion();
|
||||||
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE (id_user = ".$planete->id_user." OR end_planete = ".$planete->id." OR id_alliance = ".$planete->id_alliance." OR end_planete = ".$planete->id_alliance.") AND (start_time + end_time) <= ".time()." AND last < ".(time()-10).";");
|
$sql = "";
|
||||||
|
if ($planete->id_user != null) {
|
||||||
|
$sql = "id_user = " . $planete->id_user . " ";
|
||||||
|
}
|
||||||
|
if ($planete->id != null) {
|
||||||
|
if ($sql != "") {
|
||||||
|
$sql .= " OR ";
|
||||||
|
}
|
||||||
|
$sql .= "end_planete = " . $planete->id . " ";
|
||||||
|
}
|
||||||
|
if ($planete->id_alliance != null) {
|
||||||
|
if ($sql != "") {
|
||||||
|
$sql .= " OR ";
|
||||||
|
}
|
||||||
|
$sql .= "id_alliance = " . $planete->id_alliance . " ";
|
||||||
|
}
|
||||||
|
if ($planete->id_alliance != null) {
|
||||||
|
if ($sql != "") {
|
||||||
|
$sql .= " OR ";
|
||||||
|
}
|
||||||
|
$sql .= "end_planete = " . $planete->id_alliance . " ";
|
||||||
|
}
|
||||||
|
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE (" . $sql . ") AND (start_time + end_time) <= ".time()." AND last < ".(time()-10).";");
|
||||||
$bdd->deconnexion();
|
$bdd->deconnexion();
|
||||||
|
|
||||||
if (!empty($flottes)) {
|
if (!empty($flottes)) {
|
||||||
|
@ -7,6 +7,10 @@ if (!defined('INDEX')) {
|
|||||||
//Génération d'un ID unique pour identifier la flotte durant sa création
|
//Génération d'un ID unique pour identifier la flotte durant sa création
|
||||||
$idPrep = random();
|
$idPrep = random();
|
||||||
|
|
||||||
|
//Supression des précédentes flottes, sinon il y a un risque de remplir le champs de BDD qui sauvegarde les flottes
|
||||||
|
$SESS->values["prepFlottes"] = null;
|
||||||
|
$SESS->values["prepFlottes"] = array();
|
||||||
|
|
||||||
//Création du tableau de session
|
//Création du tableau de session
|
||||||
$SESS->values["prepFlottes"][$idPrep] = array();
|
$SESS->values["prepFlottes"][$idPrep] = array();
|
||||||
|
|
||||||
@ -41,6 +45,7 @@ $SESS->values["prepFlottes"][$idPrep]['nbVaisseaux'] = $nombreVaisseau;
|
|||||||
$SESS->values['forceFlotte'] = false;
|
$SESS->values['forceFlotte'] = false;
|
||||||
$SESS->values["prepFlottes"][$idPrep]['time'] = time();
|
$SESS->values["prepFlottes"][$idPrep]['time'] = time();
|
||||||
$SESS->values["prepFlottes"][$idPrep]['statut'] = 1;
|
$SESS->values["prepFlottes"][$idPrep]['statut'] = 1;
|
||||||
|
$SESS->values["prepFlottes"][$idPrep]['vitesse'] = 100; // vitesse par défaut: 100%
|
||||||
$SESS->put();
|
$SESS->put();
|
||||||
|
|
||||||
unset($nombreVaisseau, $key, $vaisseau, $v);
|
unset($nombreVaisseau, $key, $vaisseau, $v);
|
||||||
|
@ -45,8 +45,8 @@ if ($onglet == "rapports") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$bdd->reconnexion();
|
$bdd->reconnexion();
|
||||||
$data = $bdd->query("SELECT * FROM $table_mail WHERE destinataire = ".$planete->id_user." AND expediteur = false AND vu != 's' ORDER BY id DESC;");
|
$data = $bdd->query("SELECT * FROM $table_mail WHERE destinataire = ".$planete->id_user." AND expediteur IS NULL AND vu != 's' ORDER BY id DESC;");
|
||||||
$bdd->query("UPDATE $table_mail SET vu = 0 WHERE destinataire = ".$planete->id_user." AND expediteur = false AND vu != 's';");
|
$bdd->query("UPDATE $table_mail SET vu = 0 WHERE destinataire = ".$planete->id_user." AND expediteur IS NULL AND vu != 's';");
|
||||||
$bdd->deconnexion();
|
$bdd->deconnexion();
|
||||||
|
|
||||||
$template->assign('messages', $data);
|
$template->assign('messages', $data);
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<h2>Envoyer</h2>
|
<h2>Envoyer</h2>
|
||||||
<noscript><span style="color: #FF0000; font-weight: bolder;">Le JavaScript est nécessaire pour envoyer une flotte.</span><br /></noscript>
|
<noscript><span style="color: #FF0000; font-weight: bolder;">Le JavaScript est nécessaire pour envoyer une flotte.</span><br /></noscript>
|
||||||
<input type="submit" value="GO" class="submit" /><input type="hidden" name="cds" value="{$idPrep}" /><br />
|
<input type="hidden" name="cds" value="{$idPrep}" /><br />
|
||||||
Temps de déplacement : <span id="temps">-</span><br />
|
Temps de déplacement : <span id="temps">-</span><br />
|
||||||
Consomation : <span id="conso">-</span><br />
|
Consomation : <span id="conso">-</span><br />
|
||||||
<span id="deblok"><b>Complètez les champs ci-dessus</b></span>
|
<span id="deblok"><b>Complètez les champs ci-dessus</b></span>
|
||||||
<br /><span id="vp"></span>
|
<br /><span id="vp"></span>
|
||||||
</form>
|
</form>
|
||||||
{include file='game/footer.tpl'}
|
{include file='game/footer.tpl'}
|
||||||
|
Loading…
Reference in New Issue
Block a user