forked from halo-battle/game
Version 1.14a
This commit is contained in:
parent
ba8f323879
commit
dc48225dc9
1094 changed files with 189052 additions and 13889 deletions
210
onyx2/include/Class/Donnees/alliances_batiments.php
Normal file
210
onyx2/include/Class/Donnees/alliances_batiments.php
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
<?php
|
||||
require_once("Class/Donnees/interface.php");
|
||||
|
||||
class dAlliancesBatiments implements Donnees
|
||||
{
|
||||
public static function metal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = ceil(pow(1.5, $niveau)*68);
|
||||
break;
|
||||
case 1:
|
||||
$metal = ceil(pow(1.6, $niveau)*53);
|
||||
break;
|
||||
case 2:
|
||||
$metal = ceil(pow(1.5, $niveau)*242);
|
||||
break;
|
||||
case 3:
|
||||
$metal = ceil(pow(1.5, $niveau)*92);
|
||||
break;
|
||||
case 4:
|
||||
$metal = ceil(pow(1.73, $niveau)*800);
|
||||
break;
|
||||
case 5:
|
||||
$metal = ceil(pow(2, $niveau)*750);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $metal;
|
||||
}
|
||||
|
||||
public static function cristal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = ceil(pow(1.5, $niveau)*17);
|
||||
break;
|
||||
case 1:
|
||||
$cristal = ceil(pow(1.6, $niveau)*27);
|
||||
break;
|
||||
case 2:
|
||||
$cristal = ceil(pow(1.5, $niveau)*72);
|
||||
break;
|
||||
case 3:
|
||||
$cristal = ceil(pow(1.5, $niveau)*37);
|
||||
break;
|
||||
case 4:
|
||||
$cristal = ceil(pow(1.73, $niveau)*420);
|
||||
break;
|
||||
case 5:
|
||||
$cristal = ceil(pow(2, $niveau)*500);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $cristal;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = ceil(pow(1.68, $niveau)*285);
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $hydrogene;
|
||||
}
|
||||
|
||||
public static function credits($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$credits = ceil(pow(1.68, $niveau)*25);
|
||||
break;
|
||||
case 1:
|
||||
$credits = ceil(pow(1.68, $niveau)*85);
|
||||
break;
|
||||
case 2:
|
||||
$credits = ceil(pow(1.68, $niveau)*185);
|
||||
break;
|
||||
case 3:
|
||||
$credits = ceil(pow(1.68, $niveau)*285);
|
||||
break;
|
||||
case 4:
|
||||
$credits = ceil(pow(1.68, $niveau)*385);
|
||||
break;
|
||||
case 5:
|
||||
$credits = ceil(pow(1.68, $niveau)*485);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $credits;
|
||||
}
|
||||
|
||||
public static function temps($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$sec = pow(1.5, $niveau)*6;
|
||||
break;
|
||||
case 1:
|
||||
$sec = pow(1.55, $niveau)*6;
|
||||
break;
|
||||
case 2:
|
||||
$sec = pow(1.624, $niveau)*6;
|
||||
break;
|
||||
case 3:
|
||||
$sec = pow(1.597, $niveau)*6;
|
||||
break;
|
||||
case 4:
|
||||
$sec = pow(1.7, $niveau)*6;
|
||||
break;
|
||||
case 5:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//Accélération du temps de construction
|
||||
$sec /= VITESSE;
|
||||
|
||||
return $sec;
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
//return "batimentcovieux4.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
//return "batimentcovieux4.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededAlliancesBatiments =
|
||||
array(
|
||||
0,
|
||||
array(
|
||||
array('batiments', 0, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 2)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededAlliancesBatiments[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededAlliancesBatiments[$id], $planete);
|
||||
}
|
||||
}
|
||||
?>
|
||||
517
onyx2/include/Class/Donnees/batiments.php
Normal file
517
onyx2/include/Class/Donnees/batiments.php
Normal file
|
|
@ -0,0 +1,517 @@
|
|||
<?php
|
||||
require_once("Class/Donnees/interface.php");
|
||||
|
||||
class dBatiments implements Donnees
|
||||
{
|
||||
public static function metal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = ceil(pow(1.5, $niveau)*68);
|
||||
break;
|
||||
case 1:
|
||||
$metal = ceil(pow(1.6, $niveau)*53);
|
||||
break;
|
||||
case 2:
|
||||
$metal = ceil(pow(1.5, $niveau)*242);
|
||||
break;
|
||||
case 3:
|
||||
$metal = ceil(pow(1.5, $niveau)*92);
|
||||
break;
|
||||
case 4:
|
||||
//$metal = ceil(pow(1.73, $niveau)*800);
|
||||
$metal = ceil(pow(3, $niveau)*5000);
|
||||
break;
|
||||
case 5:
|
||||
$metal = ceil(pow(2, $niveau)*750);
|
||||
break;
|
||||
case 6:
|
||||
$metal = ceil(pow(2, $niveau)*200);
|
||||
break;
|
||||
case 7:
|
||||
$metal = ceil(pow(2, $niveau)*520);
|
||||
break;
|
||||
case 8:
|
||||
$metal = ceil(pow(2, $niveau)*600);
|
||||
break;
|
||||
case 9:
|
||||
$metal = ceil(pow(2, $niveau)*200);
|
||||
break;
|
||||
case 10:
|
||||
$metal = ceil(pow(2, $niveau)*400);
|
||||
break;
|
||||
case 11:
|
||||
$metal = ceil(pow(1.7, $niveau)*600);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$metal = ceil(pow($niveau, 2.075)*1000+1500);
|
||||
break;
|
||||
case 13:
|
||||
$metal = ceil(pow($niveau,2.8)*1000+299000);
|
||||
break;
|
||||
case 14:
|
||||
$metal = ceil(pow($niveau, 2)*1200+140000);
|
||||
break;
|
||||
case 15:
|
||||
$metal = ceil(pow($niveau, 2)*1000+80000);
|
||||
break;
|
||||
case 16:
|
||||
$metal = ceil(pow($niveau, 2)*850+60000);
|
||||
break;
|
||||
case 17:
|
||||
$metal = ceil(pow($niveau, 2.5)*500 -300);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3)
|
||||
{
|
||||
if ($planete->technologies[0] &262144)
|
||||
{
|
||||
$metal *= 0.85;
|
||||
}
|
||||
elseif ($planete->technologies[0] &131072)
|
||||
{
|
||||
$metal *= 0.9;
|
||||
}
|
||||
elseif ($planete->technologies[0] &65536)
|
||||
{
|
||||
$metal *= 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
return $metal;
|
||||
}
|
||||
|
||||
public static function cristal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = ceil(pow(1.5, $niveau)*17);
|
||||
break;
|
||||
case 1:
|
||||
$cristal = ceil(pow(1.6, $niveau)*27);
|
||||
break;
|
||||
case 2:
|
||||
$cristal = ceil(pow(1.5, $niveau)*72);
|
||||
break;
|
||||
case 3:
|
||||
$cristal = ceil(pow(1.5, $niveau)*37);
|
||||
break;
|
||||
case 4:
|
||||
//$cristal = ceil(pow(1.73, $niveau)*420);
|
||||
$cristal = ceil(pow(3, $niveau)*3000);
|
||||
break;
|
||||
case 5:
|
||||
$cristal = ceil(pow(2, $niveau)*500);
|
||||
break;
|
||||
case 6:
|
||||
$cristal = ceil(pow(2, $niveau)*150);
|
||||
break;
|
||||
case 7:
|
||||
$cristal = ceil(pow(2, $niveau)*380);
|
||||
break;
|
||||
case 8:
|
||||
$cristal = ceil(pow(2, $niveau)*450);
|
||||
break;
|
||||
case 9:
|
||||
$cristal = ceil(pow(2, $niveau)*100);
|
||||
break;
|
||||
case 10:
|
||||
$cristal = ceil(pow(2, $niveau)*260);
|
||||
break;
|
||||
case 11:
|
||||
$cristal = ceil(pow(1.7, $niveau)*420);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$cristal = ceil(pow($niveau, 1.8)*1000+1000);
|
||||
break;
|
||||
case 13:
|
||||
$cristal = ceil(pow($niveau,2.5)*1000+149000);
|
||||
break;
|
||||
case 14:
|
||||
$cristal = ceil(pow($niveau, 2)*900+99000);
|
||||
break;
|
||||
case 15:
|
||||
$cristal = ceil(pow($niveau, 2)*750+65000);
|
||||
break;
|
||||
case 16:
|
||||
$cristal = ceil(pow($niveau, 2)*650+50000);
|
||||
break;
|
||||
case 17:
|
||||
$cristal = ceil(pow($niveau, 2.4)*400-250);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3)
|
||||
{
|
||||
if ($planete->technologies[0] &262144)
|
||||
{
|
||||
$cristal *= 0.85;
|
||||
}
|
||||
elseif ($planete->technologies[0] &131072)
|
||||
{
|
||||
$cristal *= 0.9;
|
||||
}
|
||||
elseif ($planete->technologies[0] &65536)
|
||||
{
|
||||
$cristal *= 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
return $cristal;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
//$hydrogene = ceil(pow(1.68, $niveau)*285);
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = ceil(pow(1.7, $niveau)*100);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 14:
|
||||
$hydrogene = ceil(pow($niveau, 2)*500+30000);
|
||||
break;
|
||||
case 15:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 16:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 17:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3)
|
||||
{
|
||||
if ($planete->technologies[0] &262144)
|
||||
{
|
||||
$hydrogene *= 0.85;
|
||||
}
|
||||
elseif ($planete->technologies[0] &131072)
|
||||
{
|
||||
$hydrogene *= 0.9;
|
||||
}
|
||||
elseif ($planete->technologies[0] &65536)
|
||||
{
|
||||
$hydrogene *= 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
return $hydrogene;
|
||||
}
|
||||
|
||||
public static function credits($id, $niveau, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $niveau, surface $planete, $demolition = false)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$sec = pow(1.5, $niveau)*6;
|
||||
break;
|
||||
case 1:
|
||||
$sec = pow(1.55, $niveau)*6;
|
||||
break;
|
||||
case 2:
|
||||
$sec = pow(1.624, $niveau)*6;
|
||||
break;
|
||||
case 3:
|
||||
$sec = pow(1.597, $niveau)*6;
|
||||
break;
|
||||
case 4:
|
||||
$sec = pow(1.7, $niveau)*6;
|
||||
break;
|
||||
case 5:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
case 6:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
case 7:
|
||||
$sec = ceil(pow(2, $niveau)*420);
|
||||
break;
|
||||
case 8:
|
||||
$sec = ceil(pow(2, $niveau)*600);
|
||||
break;
|
||||
case 9:
|
||||
$sec = ceil(pow(2, $niveau)*300);
|
||||
break;
|
||||
case 10:
|
||||
$sec = ceil(pow(2, $niveau)*1200);
|
||||
break;
|
||||
case 11:
|
||||
$sec = ceil((pow(1.9, $niveau)*800));
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$sec = ceil(pow($niveau, 2.5)*60+4)*60;
|
||||
break;
|
||||
case 13:
|
||||
$sec = ceil(pow($niveau, 1.6)*60+60)*60;
|
||||
break;
|
||||
case 14:
|
||||
$sec = ceil(pow($niveau, 2)*5+3)*60;
|
||||
break;
|
||||
case 15:
|
||||
$sec = pow($niveau, 2)*240;
|
||||
break;
|
||||
case 16:
|
||||
$sec = pow($niveau, 2)*180;
|
||||
break;
|
||||
case 17:
|
||||
$sec = pow($niveau, 1.65)*3600;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On applique le bonus de temps des ingénieurs et des centrales informatiques
|
||||
if ($id == 11 && $planete->casernes[7])
|
||||
$sec /= (1.0025 * $planete->casernes[7]);
|
||||
elseif ($id != 11 && ($planete->casernes[7] || $planete->batiments[11]))
|
||||
$sec /= (pow(1.23, $planete->batiments[11]) + 1.0025 * $planete->casernes[7]);
|
||||
|
||||
//Accélération du temps de construction
|
||||
$sec /= VITESSE;
|
||||
|
||||
if ($demolition)
|
||||
return $sec * Donnees::coeff_demolition;
|
||||
else
|
||||
return $sec;
|
||||
}
|
||||
|
||||
public static function type($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
return 1;
|
||||
case 6:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
return 2;
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
return 4;
|
||||
return 6;
|
||||
default:
|
||||
trigger_error("Bâtiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "batimentcovieux4.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "cristaloo3.png";
|
||||
break;
|
||||
case 2:
|
||||
return "powersupplycoviejq1.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "solaire.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "sanstitrevi7.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "oeilduprophetewj6.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "covielabocn5.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "chantierterrestrehg1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "sanstitretruecolor09zn6.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "caserncov0ry.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "stockagebasement1cs10bl.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "ordianteur_hologramme.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "mine_m.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "mine_c.png";
|
||||
break;
|
||||
case 2:
|
||||
return "synchroniseur.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "centrale solaire.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "centrale electrique.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "baseradardl3.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "recherches.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "chantierterrestrecopybj8.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "chantier spatial.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "ecole militaire.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "stockage.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "search0yp.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededBatiments =
|
||||
array (
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("batiments", 3, 12),
|
||||
array("batiments_max", 4, 4)
|
||||
),
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("technologies", 2,3, 9)
|
||||
),
|
||||
array(
|
||||
array("technologies", 2,4, 17)
|
||||
),
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("technologies", 1,12, 4096)
|
||||
),
|
||||
0,
|
||||
array(
|
||||
array("technologies", 3,8, 256)
|
||||
),
|
||||
array(
|
||||
array("technologies", 7,12, 4096)
|
||||
),
|
||||
array(
|
||||
array("technologies", 3,6, 64)
|
||||
),
|
||||
array(
|
||||
array("technologies", 3,7, 128)
|
||||
),
|
||||
0
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededBatiments[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededBatiments[$id], $planete);
|
||||
}
|
||||
}
|
||||
?>
|
||||
301
onyx2/include/Class/Donnees/caserne.php
Normal file
301
onyx2/include/Class/Donnees/caserne.php
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
<?php
|
||||
require_once("Class/Donnees/interface.php");
|
||||
|
||||
class dCaserne implements Donnees
|
||||
{
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = 80;
|
||||
break;
|
||||
case 1:
|
||||
$metal = 110;
|
||||
break;
|
||||
case 2:
|
||||
$metal = 150;
|
||||
break;
|
||||
case 3:
|
||||
$metal = 220;
|
||||
break;
|
||||
case 4:
|
||||
$metal = 180;
|
||||
break;
|
||||
case 5:
|
||||
$metal = 25000;
|
||||
break;
|
||||
case 6:
|
||||
$metal = 100;
|
||||
break;
|
||||
case 7:
|
||||
$metal = 90;
|
||||
break;
|
||||
case 8:
|
||||
$metal = 300;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$metal *= 0.9;
|
||||
|
||||
return $metal * $nombre;
|
||||
}
|
||||
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 45;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 90;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 105;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 150;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 100;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 10000;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 100;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 105;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 250;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 20;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$hydrogene *= 0.9;
|
||||
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$temps = 60;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 240;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 240;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 720;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 300;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 29700;
|
||||
$moins = 10;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 90;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 90;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 900;
|
||||
$moins = 5;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
|
||||
//On tient compte des bonus
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[9] - $moins))) * $nombre;
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
array('','','','','','','','','');
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "grunt1.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "jackal.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "94990342wb4.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "98004530fx3.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "88091275ja8.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "hunter1.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "81770345oo4.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "88218731ts1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "72188202fg9.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "marines.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "marinehf0.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "grenadier.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "TCAO2.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "sniper.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "spartan.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "ingenieurs.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "exosquelettehbpb2.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededCaserne =
|
||||
array(
|
||||
array(
|
||||
array('batiments', 9, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 10)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 5)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededCaserne[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededCaserne[$id], $planete);
|
||||
}
|
||||
}
|
||||
?>
|
||||
202
onyx2/include/Class/Donnees/interface.php
Normal file
202
onyx2/include/Class/Donnees/interface.php
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
interface Donnees
|
||||
{
|
||||
const image_covenant_default = "../covenant_na.jpg";
|
||||
const image_humain_default = "../humain_na.jpg";
|
||||
|
||||
const coeff_demolition = 0.6;
|
||||
|
||||
public static function metal($id, $niveau, surface $planete);
|
||||
public static function cristal($id, $niveau, surface $planete);
|
||||
public static function hydrogene($id, $niveau, surface $planete);
|
||||
public static function credits($id, $niveau, surface $planete);
|
||||
public static function temps($id, $niveau, surface $planete);
|
||||
|
||||
public static function image($id, surface $planete);
|
||||
|
||||
public static function needed($id, surface $planete, $print = false);
|
||||
}
|
||||
|
||||
class dDonnees{
|
||||
static function tailleFile(surface $planete)
|
||||
{
|
||||
//On calcul la taille maximale de la file d'attente
|
||||
if (!empty($planete->technologies[1]))
|
||||
{
|
||||
if (($planete->technologies[1] &131072) == 131072) return 5;
|
||||
elseif (($planete->technologies[1] &65536) == 65536) return 4;
|
||||
elseif (($planete->technologies[1] &32768) == 32768) return 3;
|
||||
else return 2;
|
||||
}
|
||||
else return 3; //Au cas où il n'y ait pas de technologie sur le lieu, on fixe la taille de la file d'attente
|
||||
}
|
||||
|
||||
|
||||
static function neededCheck($tableau, surface $planete)
|
||||
{
|
||||
if (!is_array($tableau)) return true;
|
||||
else
|
||||
{
|
||||
foreach ($tableau as $need)
|
||||
{
|
||||
switch($need[0])
|
||||
{
|
||||
case 'batiments':
|
||||
if (get_class($planete) == "Planete" && $planete->batiments[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'batiments_max':
|
||||
if (get_class($planete) == "Planete" && $planete->batiments[$need[1]] > $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'technologies':
|
||||
if (((int)$planete->technologies[$need[1]]& $need[3]) != $need[3])
|
||||
return false;
|
||||
break;
|
||||
case 'casernes':
|
||||
if ($planete->casernes[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'terrestres':
|
||||
if ($planete->terrestres[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'vaisseaux':
|
||||
if ($planete->vaisseaux[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static function print_neededCheck($tableau, surface $planete)
|
||||
{
|
||||
global $LANG;
|
||||
$race = $planete->race;
|
||||
if (!is_array($tableau)) return 'Débloqué';
|
||||
else
|
||||
{
|
||||
$return = '';
|
||||
foreach ($tableau as $need)
|
||||
{
|
||||
switch($need[0])
|
||||
{
|
||||
case 'batiments':
|
||||
if ($planete->batiments[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' niveau '.$need[2].' (batiment)</span><br />';
|
||||
else
|
||||
$return .= ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' niveau '.$need[2].' (batiment)<br />';
|
||||
break;
|
||||
case 'batiments_max':
|
||||
if ($planete->batiments[$need[1]] > $need[2])
|
||||
$return .= '<span class="lack">'.ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' < niveau '.($need[2]+1).' (batiment)</span><br />';
|
||||
else
|
||||
$return .= ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' < niveau '.($need[2]+1).' (batiment)<br />';
|
||||
break;
|
||||
case 'technologies':
|
||||
if (((int)$planete->technologies[$need[1]]& $need[3]) != $need[3])
|
||||
$return .= '<span class="lack">'.$LANG[$race]["technologies"]["noms_sing"][$need[1]][$need[2]].' (technologie)</span><br />';
|
||||
else
|
||||
$return .= $LANG[$race]["technologies"]["noms_sing"][$need[1]][$need[2]].' (technologie)<br />';
|
||||
break;
|
||||
case 'casernes':
|
||||
if ($planete->casernes[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["caserne"]["noms_pluriel"][$need[1]].' (unité de la caserne)</span><br />';
|
||||
else
|
||||
$return .= $need[2].' '.$LANG[$race]["caserne"]["noms_pluriel"][$need[1]].' (unité de la caserne)<br />';
|
||||
break;
|
||||
case 'terrestres':
|
||||
if ($planete->terrestres[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["terrestre"]["noms_pluriel"][$need[1]].' (unité du chantier terrestre)</span><br />';
|
||||
else
|
||||
$return .= $need[2].' '.$LANG[$race]["terrestre"]["noms_pluriel"][$need[1]].' (unité du chantier terrestre)<br />';
|
||||
break;
|
||||
case 'vaisseaux':
|
||||
if ($planete->vaisseaux[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["vaisseaux"]["noms_pluriel"][$need[1]].' (unité du chantier spatial)</span><br />';
|
||||
else
|
||||
$return .= $need[2].' '.$LANG[$race]["vaisseaux"]["noms_pluriel"][$need[1]].' (unité du chantier spatial)<br />';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
static function nameVAR($name)
|
||||
{
|
||||
if ($name == "alli_batiments")
|
||||
return "alli_batiments";
|
||||
elseif ($name == "batiments")
|
||||
return "batiments";
|
||||
elseif ($name == "technologies")
|
||||
return "technologies";
|
||||
elseif ($name == "casernes")
|
||||
return "caserne";
|
||||
elseif ($name == "terrestres")
|
||||
return "terrestre";
|
||||
elseif ($name == "vaisseaux")
|
||||
return "spatial";
|
||||
elseif ($name == "coeff_bat")
|
||||
return "coeff";
|
||||
}
|
||||
|
||||
|
||||
static function capaciteVilles(surface $planete)
|
||||
{
|
||||
return $planete->cases * pow($planete->batiments[17], -3) + 10;
|
||||
}
|
||||
|
||||
static function nameVilles($level)
|
||||
{
|
||||
switch ($level)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return "Poste d'observation taille ".($level+1);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return "Poste avancé taille ".($level-2);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return "Colonie taille ".($level-5);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return "Ville taille ".($level-8);
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return "Cité taille ".($level-12);
|
||||
break;
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
return "Grande cité taille ".($level-15);
|
||||
break;
|
||||
case 19:
|
||||
return "Mégapole";
|
||||
break;
|
||||
case 20:
|
||||
return "Mégalopole";
|
||||
break;
|
||||
default:
|
||||
trigger_error("Taille de ville incorrect !");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
631
onyx2/include/Class/Donnees/spatial.php
Normal file
631
onyx2/include/Class/Donnees/spatial.php
Normal file
|
|
@ -0,0 +1,631 @@
|
|||
<?php
|
||||
require_once("Class/Donnees/interface.php");
|
||||
|
||||
class dSpatial implements Donnees
|
||||
{
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = 1000;
|
||||
break;
|
||||
case 1:
|
||||
$metal = 4000;
|
||||
break;
|
||||
case 2:
|
||||
$metal = 4000;
|
||||
break;
|
||||
case 3:
|
||||
$metal = 9000;
|
||||
break;
|
||||
case 4:
|
||||
$metal = 9000;
|
||||
break;
|
||||
case 5:
|
||||
$metal = 1000;
|
||||
break;
|
||||
case 6:
|
||||
$metal = 15000;
|
||||
break;
|
||||
case 7:
|
||||
$metal = 1800;
|
||||
break;
|
||||
case 8:
|
||||
$metal = 2550;
|
||||
break;
|
||||
case 9:
|
||||
$metal = 12950;
|
||||
break;
|
||||
case 10:
|
||||
$metal = 26000;
|
||||
break;
|
||||
case 11:
|
||||
$metal = 60000;
|
||||
break;
|
||||
case 12:
|
||||
$metal = 500000;
|
||||
break;
|
||||
case 13:
|
||||
$metal = 500000;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$metal *= 0.9;
|
||||
|
||||
return $metal * $nombre;
|
||||
}
|
||||
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 800;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 3000;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 3000;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 9000;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 9000;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 1200;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 9000;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 1000;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 1350;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 16400;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 6900;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 40000;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 400000;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 400000;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 1000;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 1000;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 100;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 1000;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 65;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 100;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 1600;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = 3000;
|
||||
break;
|
||||
case 12:
|
||||
$hydrogene = 250000;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 250000;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$hydrogene *= 0.9;
|
||||
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$temps = 1080;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 6300;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 6300;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 8280;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 8280;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 1440;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 7380;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 1200;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 4680;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 9:
|
||||
$temps = 16800;
|
||||
$moins = 6;
|
||||
break;
|
||||
case 10:
|
||||
$temps = 16800;
|
||||
$moins = 6;
|
||||
break;
|
||||
case 11:
|
||||
$temps = 32400;
|
||||
$moins = 8;
|
||||
break;
|
||||
case 12:
|
||||
$temps = 117000;
|
||||
$moins = 12;
|
||||
break;
|
||||
case 13:
|
||||
$temps = 117000;
|
||||
$moins = 12;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
|
||||
//On tient compte des bonus
|
||||
if (SURFACE == "planete")
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[8] - $moins))) * $nombre;
|
||||
else
|
||||
return ($temps * $nombre);
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "cargo2pb6.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "sanstitre2copiegw9.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "colocopiers4.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "sonde_despionnage1.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "chasseurlourd7id.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "contactharvestbynameleszk3.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "vaisseauuu0.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "vaisseaudebataille9na.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "pv.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "stationorbitalezt7.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "citecovenant.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "csnucargoparabola2mc9.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "csnucargoladen2al8.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "colonisation.jpg";
|
||||
break;
|
||||
case 3:
|
||||
//return "";
|
||||
break;
|
||||
case 4:
|
||||
return "longsworduf9.jpg";
|
||||
break;
|
||||
case 5:
|
||||
//return "";
|
||||
break;
|
||||
case 6:
|
||||
//return "";
|
||||
break;
|
||||
case 7:
|
||||
return "frgatecopiegw1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
//return "";
|
||||
break;
|
||||
case 9:
|
||||
return "halcyo15.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "qsu169.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededSpatial =
|
||||
array(
|
||||
array(
|
||||
array('batiments', 8, 1),
|
||||
array('technologies', 0,3, 8)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 5),
|
||||
array('technologies', 0,3, 8),
|
||||
array('technologies', 1,6, 64)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 5),
|
||||
array('technologies', 8,0, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 5),
|
||||
array('technologies', 7,4, 16)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 5),
|
||||
array('technologies', 7,0, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 3),
|
||||
array('technologies', 7,1, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 5),
|
||||
array('technologies', 7,2, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 1),
|
||||
array('technologies', 7,3, 8)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 3),
|
||||
array('technologies', 7,5, 32)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 6),
|
||||
array('technologies', 7,6, 64)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 6),
|
||||
array('technologies', 7,1, 128)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 8),
|
||||
array('technologies', 7,8, 256)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 10),
|
||||
array('technologies', 7,9, 512)
|
||||
),
|
||||
array(
|
||||
array('batiments', 8, 10),
|
||||
array('technologies', 7,10, 1024)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededSpatial[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededSpatial[$id], $planete);
|
||||
}
|
||||
|
||||
|
||||
public static function tailleCales($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$vitesse = 10000;
|
||||
break;
|
||||
case 1:
|
||||
$vitesse = 50000;
|
||||
break;
|
||||
case 2:
|
||||
$vitesse = 25000;
|
||||
break;
|
||||
case 3:
|
||||
$vitesse = 25000;
|
||||
break;
|
||||
case 4:
|
||||
$vitesse = 100;
|
||||
break;
|
||||
case 5:
|
||||
$vitesse = 50;
|
||||
break;
|
||||
case 6:
|
||||
$vitesse = 200;
|
||||
break;
|
||||
case 7:
|
||||
$vitesse = 400;
|
||||
break;
|
||||
case 8:
|
||||
$vitesse = 800;
|
||||
break;
|
||||
case 9:
|
||||
$vitesse = 1000;
|
||||
break;
|
||||
case 10:
|
||||
$vitesse = 1500;
|
||||
break;
|
||||
case 11:
|
||||
$vitesse = 50000;
|
||||
break;
|
||||
case 12:
|
||||
$vitesse = 100000;
|
||||
break;
|
||||
case 13:
|
||||
$vitesse = 500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
return $vitesse;
|
||||
}
|
||||
|
||||
|
||||
public static function vitesseP($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$vitesse = 1080;
|
||||
break;
|
||||
case 1:
|
||||
$vitesse = 6300;
|
||||
break;
|
||||
case 2:
|
||||
$vitesse = 6300;
|
||||
break;
|
||||
case 3:
|
||||
$vitesse = 8280;
|
||||
break;
|
||||
case 4:
|
||||
$vitesse = 8280;
|
||||
break;
|
||||
case 5:
|
||||
$vitesse = 1440;
|
||||
break;
|
||||
case 6:
|
||||
$vitesse = 7380;
|
||||
break;
|
||||
case 7:
|
||||
$vitesse = 1200;
|
||||
break;
|
||||
case 8:
|
||||
$vitesse = 4680;
|
||||
break;
|
||||
case 9:
|
||||
$vitesse = 16800;
|
||||
break;
|
||||
case 10:
|
||||
$vitesse = 16800;
|
||||
break;
|
||||
case 11:
|
||||
$vitesse = 32400;
|
||||
break;
|
||||
case 12:
|
||||
$vitesse = 117000;
|
||||
break;
|
||||
case 13:
|
||||
$vitesse = 117000;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
return $vitesse;
|
||||
}
|
||||
|
||||
public static function vitesseS($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$vitesse = 1080;
|
||||
break;
|
||||
case 1:
|
||||
$vitesse = 6300;
|
||||
break;
|
||||
case 2:
|
||||
$vitesse = 6300;
|
||||
break;
|
||||
case 3:
|
||||
$vitesse = 8280;
|
||||
break;
|
||||
case 4:
|
||||
$vitesse = 8280;
|
||||
break;
|
||||
case 5:
|
||||
$vitesse = 1440;
|
||||
break;
|
||||
case 6:
|
||||
$vitesse = 7380;
|
||||
break;
|
||||
case 7:
|
||||
$vitesse = 1200;
|
||||
break;
|
||||
case 8:
|
||||
$vitesse = 4680;
|
||||
break;
|
||||
case 9:
|
||||
$vitesse = 16800;
|
||||
break;
|
||||
case 10:
|
||||
$vitesse = 16800;
|
||||
break;
|
||||
case 11:
|
||||
$vitesse = 32400;
|
||||
break;
|
||||
case 12:
|
||||
$vitesse = 117000;
|
||||
break;
|
||||
case 13:
|
||||
$vitesse = 117000;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
return $vitesse;
|
||||
}
|
||||
|
||||
public static function vitesseG($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$vitesse = 1080;
|
||||
break;
|
||||
case 1:
|
||||
$vitesse = 6300;
|
||||
break;
|
||||
case 2:
|
||||
$vitesse = 6300;
|
||||
break;
|
||||
case 3:
|
||||
$vitesse = 8280;
|
||||
break;
|
||||
case 4:
|
||||
$vitesse = 8280;
|
||||
break;
|
||||
case 5:
|
||||
$vitesse = 1440;
|
||||
break;
|
||||
case 6:
|
||||
$vitesse = 7380;
|
||||
break;
|
||||
case 7:
|
||||
$vitesse = 1200;
|
||||
break;
|
||||
case 8:
|
||||
$vitesse = 4680;
|
||||
break;
|
||||
case 9:
|
||||
$vitesse = 16800;
|
||||
break;
|
||||
case 10:
|
||||
$vitesse = 16800;
|
||||
break;
|
||||
case 11:
|
||||
$vitesse = 32400;
|
||||
break;
|
||||
case 12:
|
||||
$vitesse = 117000;
|
||||
break;
|
||||
case 13:
|
||||
$vitesse = 117000;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
return $vitesse;
|
||||
}
|
||||
}
|
||||
?>
|
||||
1146
onyx2/include/Class/Donnees/technologies.php
Normal file
1146
onyx2/include/Class/Donnees/technologies.php
Normal file
File diff suppressed because it is too large
Load diff
477
onyx2/include/Class/Donnees/terrestre.php
Normal file
477
onyx2/include/Class/Donnees/terrestre.php
Normal file
|
|
@ -0,0 +1,477 @@
|
|||
<?php
|
||||
require_once("Class/Donnees/interface.php");
|
||||
|
||||
class dTerrestre implements Donnees
|
||||
{
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 300;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 600;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 950;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 240;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 260;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 500;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 230;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 650;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 1750;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 3750;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 14:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 15:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$unite." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 300;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 600;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 950;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 240;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 260;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 500;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 230;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 650;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 1750;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 3750;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 14:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 15:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 80;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 100;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = 120;
|
||||
break;
|
||||
case 12:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 14:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 15:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$hydrogene *= 0.9;
|
||||
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$temps = 720;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 2040;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 7200;
|
||||
$moins = 4;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 3960;
|
||||
$moins = 6;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 600;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 1080;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 2160;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 4680;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 1080;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 9:
|
||||
$temps = 2040;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 10:
|
||||
$temps = 7200;
|
||||
$moins = 4;
|
||||
break;
|
||||
case 11:
|
||||
$temps = 3960;
|
||||
$moins = 7;
|
||||
break;
|
||||
case 12:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 13:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 14:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 15:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
|
||||
//On tient compte des bonus
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[7] - $moins))) * $nombre;
|
||||
}
|
||||
|
||||
public static function type($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return true;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return false;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
//Unités terrestres
|
||||
case 0:
|
||||
return "bansheeqp0.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "spirit1.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "phantomfu2.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "boardingcraft.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "ghostic1.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "shadow.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "spectre.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "wraith.jpg";
|
||||
break;
|
||||
|
||||
//Défenses
|
||||
case 8:
|
||||
return "shade.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "defcovie.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "tourellebarreau.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "tourelle.jpg";
|
||||
break;
|
||||
case 12:
|
||||
return "lanceur_torpilles.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
//Unités terrestres
|
||||
case 0:
|
||||
return "csnusparrowhawkkp4.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "pelican.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "csnushortswordad3.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "albatross.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "warthog-vrl.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "M12G1_LAAV_Warthog.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "M12A1_LAAV_Warthog.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "scorpionN.jpg";
|
||||
break;
|
||||
|
||||
//Défenses
|
||||
case 8:
|
||||
//return "";
|
||||
break;
|
||||
case 9:
|
||||
//return "";
|
||||
break;
|
||||
case 10:
|
||||
//return "";
|
||||
break;
|
||||
case 11:
|
||||
//return "";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededTerrestre = array(
|
||||
array(
|
||||
array('batiments', 7, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 6)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 5)
|
||||
),
|
||||
//Défenses
|
||||
array(
|
||||
array('batiments', 7, 1),
|
||||
array('technologies', 6, 0, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3),
|
||||
array('technologies', 6, 3, 8)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4),
|
||||
array('technologies', 6, 1, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4),
|
||||
array('technologies', 6, 4, 16)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 2, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 5, 32)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 6, 64)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 10),
|
||||
array('technologies', 7, 11, 2048)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededTerrestre[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededTerrestre[$id], $planete);
|
||||
}
|
||||
}
|
||||
?>
|
||||
257
onyx2/include/Class/File/alliances_batiments.php
Normal file
257
onyx2/include/Class/File/alliances_batiments.php
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
<?php
|
||||
require_once("Class/File/interface.php");
|
||||
|
||||
class FileAlliancesBatiments extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object, $type = null)
|
||||
{
|
||||
$c = 0;
|
||||
if (isset($type))
|
||||
{
|
||||
if (!isset($type) || $type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, true)));
|
||||
}
|
||||
}
|
||||
if (!isset($type) || !$type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dAlliancesBatiments::needed($object, $planete))
|
||||
throw new ExceptionHB(1, 2);
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de démolition du même bâtiment
|
||||
if ($this->nbObjectInFile($object, true) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
|
||||
//Calcul du prochain niveau du batiment
|
||||
$nextLvl = $planete->batiments[$object] + $this->nbObjectInFile($object, false) + 1;
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dAlliancesBatiments::metal($object, $nextLvl, $planete), dAlliancesBatiments::cristal($object, $nextLvl, $planete), dAlliancesBatiments::hydrogene($object, $nextLvl, $planete), dAlliancesBatiments::credits($object, $nextLvl, $planete)))
|
||||
{
|
||||
$this->files[$lieu][] = array($object, false);
|
||||
$planete->addModif("file_bat");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(1, 4);
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
|
||||
//On vérifie que le niveau actuel du batiment ne soit non nul
|
||||
if ($planete->batiments[$object] <= $this->nbObjectInFile($object, false))
|
||||
throw new ExceptionHB(1, 6);
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de construction du même bâtiment
|
||||
if ($this->nbObjectInFile($object, false) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, true);
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
|
||||
//On récupère le type de batiment
|
||||
$object = $this->files[$lieu][$id][0];
|
||||
|
||||
//On gère les démolition
|
||||
//@todo -cFileBatiments Est-ce vraiment utile de calculer le niveau du batiment en cas de démolition ?
|
||||
if ($this->files[$lieu][$id][1])
|
||||
$lvlAnnule = $planete->batiments[$object] - $this->nbObjectInFile($object, true) + 1;
|
||||
else
|
||||
$lvlAnnule = $planete->batiments[$object] + $this->nbObjectInFile($object, false);
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier batiment en lice
|
||||
if ($id == $this->findFirstKey($lieu))
|
||||
$this->times[$lieu] = time();
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
if (!$this->files[$lieu][$id][1])
|
||||
{
|
||||
//On redonne 60% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0)
|
||||
$planete->addRessources(dAlliancesBatiments::metal($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::cristal($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::hydrogene($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::credits($object, $lvlAnnule, $planete)*0.6);
|
||||
else
|
||||
$planete->addRessources(dAlliancesBatiments::metal($object, $lvlAnnule, $planete), dAlliancesBatiments::cristal($object, $lvlAnnule, $planete), dAlliancesBatiments::hydrogene($object, $lvlAnnule, $planete), dAlliancesBatiments::credits($object, $lvlAnnule, $planete));
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gère les démolitions
|
||||
if ($element[1])
|
||||
{
|
||||
//On récupère le niveau actuel du batiment
|
||||
$lvl = $planete->batiments[$element[0]];
|
||||
|
||||
//On calcul le temps de démolition nécessaire (60% du niveau actuel)
|
||||
$tempsNecessaire = dAlliancesBatiments::temps($element[0], $lvl, $planete, true);
|
||||
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
$metal = dAlliancesBatiments::metal($element[0], $lvl, $planete);
|
||||
$cristal = dAlliancesBatiments::cristal($element[0], $lvl, $planete);
|
||||
$hydrogene = dAlliancesBatiments::hydrogene($element[0], $lvl, $planete);
|
||||
|
||||
//On redonne 70% des ressources du batiment au joueur
|
||||
$planete->addRessources($metal*0.7, $cristal*0.7, $hydrogene*0.7);
|
||||
|
||||
//On retire un niveau au batiment
|
||||
$planete->batiments[$element[0]]--;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On retire les points
|
||||
$planete->addPoints($metal, $cristal, $hydrogene, 0, true);
|
||||
|
||||
unset($metal, $cristal, $hydrogene);
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du niveau du batiment
|
||||
$lvl = $planete->batiments[$element[0]] + 1;
|
||||
|
||||
$tempsNecessaire = dAlliancesBatiments::temps($element[0], $lvl, $planete);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->batiments[$element[0]]++;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dAlliancesBatiments::metal($element[0], $planete->batiments[$element[0]], $planete), dAlliancesBatiments::cristal($element[0], $planete->batiments[$element[0]], $planete), dAlliancesBatiments::hydrogene($element[0], $planete->batiments[$element[0]], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function printFile(SURFACE $planete, $lieu = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[1]) //Cas d'une démolition
|
||||
{
|
||||
$temps = dAlliancesBatiments::temps($element[0], $planete->batiments[$element[0]], $planete, true);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
else //Cas d'une construction
|
||||
{
|
||||
$temps = dAlliancesBatiments::temps($element[0], $planete->batiments[$element[0]]+1, $planete);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
268
onyx2/include/Class/File/batiments.php
Normal file
268
onyx2/include/Class/File/batiments.php
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
<?php
|
||||
require_once("Class/File/interface.php");
|
||||
|
||||
class FileBatiments extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object, $type = null)
|
||||
{
|
||||
$c = 0;
|
||||
if (!isset($object))
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count($file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($type) || $type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, true)));
|
||||
}
|
||||
}
|
||||
if (!isset($type) || !$type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dBatiments::needed($object, $planete))
|
||||
throw new ExceptionHB(1, 2);
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de démolition du même bâtiment
|
||||
if ($this->nbObjectInFile($object, true) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
|
||||
//On vérifie qu'il reste suffisamment de place sur la planète
|
||||
if ($planete->casesRest <= 0 || $planete->casesRest <= $this->nbObjectInFile(null))
|
||||
throw new ExceptionHB(1, 0);
|
||||
|
||||
//Calcul du prochain niveau du batiment
|
||||
$nextLvl = $planete->batiments[$object] + $this->nbObjectInFile($object, false) + 1;
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dBatiments::metal($object, $nextLvl, $planete), dBatiments::cristal($object, $nextLvl, $planete), dBatiments::hydrogene($object, $nextLvl, $planete), dBatiments::credits($object, $nextLvl, $planete)))
|
||||
{
|
||||
$this->files[$lieu][] = array($object, false);
|
||||
$planete->addModif("file_bat");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(1, 4);
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
|
||||
//On vérifie que le niveau actuel du batiment ne soit non nul
|
||||
if ($planete->batiments[$object] <= $this->nbObjectInFile($object, false))
|
||||
throw new ExceptionHB(1, 6);
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de construction du même bâtiment
|
||||
if ($this->nbObjectInFile($object, false) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, true);
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
|
||||
//On récupère le type de batiment
|
||||
$object = $this->files[$lieu][$id][0];
|
||||
|
||||
//On gère les démolition
|
||||
//@todo -cFileBatiments Est-ce vraiment utile de calculer le niveau du batiment en cas de démolition ?
|
||||
if ($this->files[$lieu][$id][1])
|
||||
$lvlAnnule = $planete->batiments[$object] - $this->nbObjectInFile($object, true) + 1;
|
||||
else
|
||||
$lvlAnnule = $planete->batiments[$object] + $this->nbObjectInFile($object, false);
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier batiment en lice
|
||||
if ($id == $this->findFirstKey($lieu))
|
||||
$this->times[$lieu] = time();
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
if (!$this->files[$lieu][$id][1])
|
||||
{
|
||||
//On redonne 60% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0)
|
||||
$planete->addRessources(dBatiments::metal($object, $lvlAnnule, $planete)*0.6, dBatiments::cristal($object, $lvlAnnule, $planete)*0.6, dBatiments::hydrogene($object, $lvlAnnule, $planete)*0.6, dBatiments::credits($object, $lvlAnnule, $planete)*0.6);
|
||||
else
|
||||
$planete->addRessources(dBatiments::metal($object, $lvlAnnule, $planete), dBatiments::cristal($object, $lvlAnnule, $planete), dBatiments::hydrogene($object, $lvlAnnule, $planete), dBatiments::credits($object, $lvlAnnule, $planete));
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gère les démolitions
|
||||
if ($element[1])
|
||||
{
|
||||
//On récupère le niveau actuel du batiment
|
||||
$lvl = $planete->batiments[$element[0]];
|
||||
|
||||
//On calcul le temps de démolition nécessaire (60% du niveau actuel)
|
||||
$tempsNecessaire = dBatiments::temps($element[0], $lvl, $planete, true);
|
||||
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
$metal = dBatiments::metal($element[0], $lvl, $planete);
|
||||
$cristal = dBatiments::cristal($element[0], $lvl, $planete);
|
||||
$hydrogene = dBatiments::hydrogene($element[0], $lvl, $planete);
|
||||
|
||||
//On redonne 70% des ressources du batiment au joueur
|
||||
$planete->addRessources($metal*0.7, $cristal*0.7, $hydrogene*0.7);
|
||||
|
||||
//On retire un niveau au batiment
|
||||
$planete->batiments[$element[0]]--;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On retire les points
|
||||
$planete->addPoints($metal, $cristal, $hydrogene, 0, true);
|
||||
|
||||
unset($metal, $cristal, $hydrogene);
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du niveau du batiment
|
||||
$lvl = $planete->batiments[$element[0]] + 1;
|
||||
|
||||
$tempsNecessaire = dBatiments::temps($element[0], $lvl, $planete);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->batiments[$element[0]]++;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dBatiments::metal($element[0], $planete->batiments[$element[0]], $planete), dBatiments::cristal($element[0], $planete->batiments[$element[0]], $planete), dBatiments::hydrogene($element[0], $planete->batiments[$element[0]], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function printFile(SURFACE $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[1]) //Cas d'une démolition
|
||||
{
|
||||
$temps = dBatiments::temps($element[0], $planete->batiments[$element[0]], $planete, true);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
else //Cas d'une construction
|
||||
{
|
||||
$temps = dBatiments::temps($element[0], $planete->batiments[$element[0]]+1, $planete);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
309
onyx2/include/Class/File/caserne.php
Normal file
309
onyx2/include/Class/File/caserne.php
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
<?php
|
||||
require_once("Class/File/interface.php");
|
||||
|
||||
class FileCaserne extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
{
|
||||
foreach($this->files[$lieu] as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
foreach($file as $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dCaserne::needed($object, $planete))
|
||||
throw new ExceptionHB(3, 2);
|
||||
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu))
|
||||
throw new ExceptionHB(3, 1);
|
||||
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dCaserne::metal($object, 1, $planete)) > 0)
|
||||
$metal = $planete->metal/$metal;
|
||||
else
|
||||
$metal = $nombre;
|
||||
if (($cristal = dCaserne::cristal($object, 1, $planete)) > 0)
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
else
|
||||
$cristal = $nombre;
|
||||
if (($hydrogene = dCaserne::hydrogene($object, 1, $planete)) > 0)
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
else
|
||||
$hydrogene = $nombre;
|
||||
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dCaserne::metal($object, $nombre, $planete), dCaserne::cristal($object, $nombre, $planete), dCaserne::hydrogene($object, $nombre, $planete), dCaserne::credits($object, $nombre, $planete)))
|
||||
{
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]]))
|
||||
{
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_cas");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu)))
|
||||
throw new ExceptionHB(3, 1);
|
||||
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->casernes[$object] < $nombre)
|
||||
throw new ExceptionHB(3, 6);
|
||||
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey))
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
else
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre)
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre)
|
||||
$this->times[$lieu] = time();
|
||||
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
if (!$this->files[$lieu][$id][2])
|
||||
$planete->addRessources(dCaserne::metal($objet, $nombre, $planete), dCaserne::cristal($objet, $nombre, $planete), dCaserne::hydrogene($objet, $nombre, $planete), dCaserne::credits($objet, $nombre, $planete));
|
||||
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax)
|
||||
unset($this->files[$lieu][$id]);
|
||||
else
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gére les licenciments !
|
||||
if ($element[2])
|
||||
{
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->casernes[$element[0]] <= 0)
|
||||
{
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_cas");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dCaserne::temps($element[0], 1, $planete) * 0.6;
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->casernes[$element[0]]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dCaserne::metal($element[0], $nbUnitee, $planete)*0.7, dCaserne::cristal($element[0], $nbUnitee, $planete)*0.7, dCaserne::hydrogene($element[0], $nbUnitee, $planete)*0.7, dCaserne::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
|
||||
//On retire les unités
|
||||
$planete->casernes[$element[0]] -= $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
else
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("casernes", $element[0]));
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
return false;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dCaserne::temps($element[0], 1, $planete);
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->casernes[$element[0]] += $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
else
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("casernes", $element[0]));
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
break;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function printFile(SURFACE $planete, $lieu = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[2])
|
||||
{
|
||||
$temps = dCaserne::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
else
|
||||
{
|
||||
$temps = dCaserne::temps($element[0], 1, $planete);
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
113
onyx2/include/Class/File/interface.php
Normal file
113
onyx2/include/Class/File/interface.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
interface File
|
||||
{
|
||||
public function objectInFile($object);
|
||||
public function nbObjectInFile($object);
|
||||
public function addObjet($object, $nombre, surface $planete);
|
||||
public function addDemolition($object, $nombre, surface $planete);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete);
|
||||
public function ready(surface $planete);
|
||||
|
||||
public function printFile(surface $planete, $lieu = NULL);
|
||||
}
|
||||
|
||||
class FileCommun
|
||||
{
|
||||
protected $files = array();
|
||||
protected $times = array();
|
||||
protected $simultane;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->times[] = time();
|
||||
$this->simultane = 1;
|
||||
}
|
||||
|
||||
function refreshTime($lieu)
|
||||
{
|
||||
if (empty($this->files[$lieu]) || count($this->files[$lieu]) < 1)
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
function reajusteVacances($timelost)
|
||||
{
|
||||
foreach($this->times as $key => $time)
|
||||
$this->times[$key] += $timelost;
|
||||
|
||||
return serialize($this);
|
||||
}
|
||||
|
||||
function hasObject()
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
if (count($file) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkMaxSize(surface $planete, $lieu = null)
|
||||
{
|
||||
$nombre = 0;
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
$nombre = count($this->files[$lieu]);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$nombre += count($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ($nombre < dDonnees::tailleFile($planete));
|
||||
}
|
||||
|
||||
function findShorter()
|
||||
{
|
||||
$short = 0;
|
||||
$value = 99;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
if ($key >= $this->simultane)
|
||||
break;
|
||||
|
||||
$count = count($file);
|
||||
if ($value > $count)
|
||||
{
|
||||
$value = $count;
|
||||
$short = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
|
||||
function findFirstKey($lieu)
|
||||
{
|
||||
foreach($this->files[$lieu] as $key => $file)
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
function DEBUG__print()
|
||||
{
|
||||
var_dump($this);
|
||||
var_dump($this->files);
|
||||
}
|
||||
|
||||
function DEBUG__setTime($lieu, $moins)
|
||||
{
|
||||
$this->times[$lieu] -= $moins;
|
||||
|
||||
return $this->times[$lieu];
|
||||
}
|
||||
}
|
||||
?>
|
||||
309
onyx2/include/Class/File/spatial.php
Normal file
309
onyx2/include/Class/File/spatial.php
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
<?php
|
||||
require_once("Class/File/interface.php");
|
||||
|
||||
class FileSpatial extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
{
|
||||
foreach($this->files[$lieu] as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
foreach($file as $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dSpatial::needed($object, $planete))
|
||||
throw new ExceptionHB(3, 2);
|
||||
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu))
|
||||
throw new ExceptionHB(3, 1);
|
||||
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dSpatial::metal($object, 1, $planete)) > 0)
|
||||
$metal = $planete->metal/$metal;
|
||||
else
|
||||
$metal = $nombre;
|
||||
if (($cristal = dSpatial::cristal($object, 1, $planete)) > 0)
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
else
|
||||
$cristal = $nombre;
|
||||
if (($hydrogene = dSpatial::hydrogene($object, 1, $planete)) > 0)
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
else
|
||||
$hydrogene = $nombre;
|
||||
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dSpatial::metal($object, $nombre, $planete), dSpatial::cristal($object, $nombre, $planete), dSpatial::hydrogene($object, $nombre, $planete), dSpatial::credits($object, $nombre, $planete)))
|
||||
{
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]]))
|
||||
{
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_vais");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu)))
|
||||
throw new ExceptionHB(3, 1);
|
||||
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->vaisseaux[$object] < $nombre)
|
||||
throw new ExceptionHB(3, 6);
|
||||
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey))
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
else
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre)
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre)
|
||||
$this->times[$lieu] = time();
|
||||
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
if (!$this->files[$lieu][$id][2])
|
||||
$planete->addRessources(dSpatial::metal($objet, $nombre, $planete), dSpatial::cristal($objet, $nombre, $planete), dSpatial::hydrogene($objet, $nombre, $planete), dSpatial::credits($objet, $nombre, $planete));
|
||||
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax)
|
||||
unset($this->files[$lieu][$id]);
|
||||
else
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gére les licenciments !
|
||||
if ($element[2])
|
||||
{
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->vaisseaux[$element[0]] <= 0)
|
||||
{
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_vais");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dSpatial::temps($element[0], 1, $planete) * 0.6;
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->vaisseaux[$element[0]]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dSpatial::metal($element[0], $nbUnitee, $planete)*0.7, dSpatial::cristal($element[0], $nbUnitee, $planete)*0.7, dSpatial::hydrogene($element[0], $nbUnitee, $planete)*0.7, dSpatial::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
|
||||
//On retire les unités
|
||||
$planete->vaisseaux[$element[0]] -= $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
else
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("vaisseaux", $element[0]));
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
return false;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dSpatial::temps($element[0], 1, $planete);
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->vaisseaux[$element[0]] += $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
else
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("vaisseaux", $element[0]));
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
break;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function printFile(SURFACE $planete, $lieu = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[2])
|
||||
{
|
||||
$temps = dSpatial::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
else
|
||||
{
|
||||
$temps = dSpatial::temps($element[0], 1, $planete);
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
163
onyx2/include/Class/File/technologies.php
Normal file
163
onyx2/include/Class/File/technologies.php
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
require_once("Class/File/interface.php");
|
||||
|
||||
//Un object au sens technologie est définit par un tableau : array($branche, $tech);
|
||||
|
||||
class FileTechnologies extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($branche, $tech = null)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($branche, $tech)));
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($branche, $tech, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(4, 1);
|
||||
|
||||
//On vérifie qu'il n'y ait pas une recherche de la même technologie
|
||||
if ($this->nbObjectInFile($branche, $tech) >= 1)
|
||||
throw new ExceptionHB(4, 7);
|
||||
|
||||
//On vérifie que la technologie ne soit pas déjà développée
|
||||
if (dTechnologies::idToBit($tech) & $planete->technologies[$branche])
|
||||
throw new ExceptionHB(4, 7);
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dTechnologies::needed(array($branche, $tech), $planete))
|
||||
throw new ExceptionHB(4, 2);
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dTechnologies::metal($branche, $tech, $planete), dTechnologies::cristal($branche, $tech, $planete), dTechnologies::hydrogene($branche, $tech, $planete), dTechnologies::credits($branche, $tech, $planete)))
|
||||
{
|
||||
$this->files[$lieu][] = array($branche, $tech);
|
||||
$planete->addModif("file_tech");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(4, 4);
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre = 1, surface $planete)
|
||||
{
|
||||
trigger_error("Pas de démolition possible pour les technologies");
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre = 1, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(4, 5);
|
||||
|
||||
//On récupère la branche et l'id de la technologie
|
||||
$branche = $this->files[$lieu][$id][0];
|
||||
$tech = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler la première recherche en lice
|
||||
if ($tech == $this->findFirstKey($lieu))
|
||||
$this->times[$lieu] = time();
|
||||
|
||||
$planete->addModif("file_tech");
|
||||
|
||||
//On redonne 70% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0)
|
||||
$planete->addRessources(dTechnologies::metal($branche, $tech, $planete)*0.7, dTechnologies::cristal($branche, $tech, $planete)*0.7, dTechnologies::hydrogene($branche, $tech, $planete)*0.7, dTechnologies::credits($branche, $tech, $planete)*0.7);
|
||||
else
|
||||
$planete->addRessources(dTechnologies::metal($branche, $tech, $planete), dTechnologies::cristal($branche, $tech, $planete), dTechnologies::hydrogene($branche, $tech, $planete), dTechnologies::credits($branche, $tech, $planete));
|
||||
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(surface $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de recherche
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
$tempsNecessaire = dTechnologies::temps($element[0], $element[1], $planete);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->technologies[$element[0]] = $planete->technologies[$element[0]] | dTechnologies::idToBit($element[1]);
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModifUser(array("technologies", $element[0]));
|
||||
$planete->addModif("file_tech");
|
||||
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dTechnologies::metal($element[0], $element[0], $planete), dTechnologies::cristal($element[0], $element[1], $planete), dTechnologies::hydrogene($element[0], $element[1], $planete), dTechnologies::credits($element[0], $element[1], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function printFile(surface $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$temps = dTechnologies::temps($element[0], $element[1], $planete);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
309
onyx2/include/Class/File/terrestre.php
Normal file
309
onyx2/include/Class/File/terrestre.php
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
<?php
|
||||
require_once("Class/File/interface.php");
|
||||
|
||||
class FileTerrestre extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
{
|
||||
foreach($this->files[$lieu] as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
foreach($file as $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dTerrestre::needed($object, $planete))
|
||||
throw new ExceptionHB(3, 2);
|
||||
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu))
|
||||
throw new ExceptionHB(3, 1);
|
||||
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dTerrestre::metal($object, 1, $planete)) > 0)
|
||||
$metal = $planete->metal/$metal;
|
||||
else
|
||||
$metal = $nombre;
|
||||
if (($cristal = dTerrestre::cristal($object, 1, $planete)) > 0)
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
else
|
||||
$cristal = $nombre;
|
||||
if (($hydrogene = dTerrestre::hydrogene($object, 1, $planete)) > 0)
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
else
|
||||
$hydrogene = $nombre;
|
||||
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dTerrestre::metal($object, $nombre, $planete), dTerrestre::cristal($object, $nombre, $planete), dTerrestre::hydrogene($object, $nombre, $planete), dTerrestre::credits($object, $nombre, $planete)))
|
||||
{
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]]))
|
||||
{
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_ter");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu)))
|
||||
throw new ExceptionHB(3, 1);
|
||||
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->terrestres[$object] < $nombre)
|
||||
throw new ExceptionHB(3, 6);
|
||||
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey))
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
else
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre)
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre)
|
||||
$this->times[$lieu] = time();
|
||||
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
if (!$this->files[$lieu][$id][2])
|
||||
$planete->addRessources(dTerrestre::metal($objet, $nombre, $planete), dTerrestre::cristal($objet, $nombre, $planete), dTerrestre::hydrogene($objet, $nombre, $planete), dTerrestre::credits($objet, $nombre, $planete));
|
||||
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax)
|
||||
unset($this->files[$lieu][$id]);
|
||||
else
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gére les licenciments !
|
||||
if ($element[2])
|
||||
{
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->terrestres[$element[0]] <= 0)
|
||||
{
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_ter");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dTerrestre::temps($element[0], 1, $planete) * 0.6;
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->terrestres[$element[0]]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dTerrestre::metal($element[0], $nbUnitee, $planete)*0.7, dTerrestre::cristal($element[0], $nbUnitee, $planete)*0.7, dTerrestre::hydrogene($element[0], $nbUnitee, $planete)*0.7, dTerrestre::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
|
||||
//On retire les unités
|
||||
$planete->terrestres[$element[0]] -= $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
else
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("terrestres", $element[0]));
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
return false;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dTerrestre::temps($element[0], 1, $planete);
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->terrestres[$element[0]] += $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
else
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("terrestres", $element[0]));
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
break;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function printFile(SURFACE $planete, $lieux = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[2])
|
||||
{
|
||||
$temps = dTerrestre::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems, dTerrestre::type($element[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$temps = dTerrestre::temps($element[0], 1, $planete);
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems, dTerrestre::type($element[0]));
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Alliance extends Surface{
|
||||
class Alliance extends SURFACE{
|
||||
var $id,
|
||||
$race,
|
||||
$fondateur,
|
||||
|
|
@ -17,7 +17,6 @@ class Alliance extends Surface{
|
|||
$tag,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$wing,
|
||||
$nom_asteroide,
|
||||
$image_asteroide,
|
||||
$debris_met,
|
||||
|
|
@ -37,7 +36,7 @@ class Alliance extends Surface{
|
|||
function Alliance($id = 0){
|
||||
if (!empty($id)) {
|
||||
global $var___db, $config, $table_alliances;
|
||||
global $alli_batimentVAR, $nomvaisnVAR;
|
||||
global $alli_batimentVAR, $spatialVAR;
|
||||
$bdd = new bdd();
|
||||
$bdd->connexion();
|
||||
$bdd->escape($id);
|
||||
|
|
@ -52,7 +51,7 @@ class Alliance extends Surface{
|
|||
$this->tag = $alli["tag"];
|
||||
$this->galaxie = $alli["galaxie"];
|
||||
$this->ss = $alli["ss"];
|
||||
$this->wing = $alli["wing"];
|
||||
$this->position = $alli["wing"];
|
||||
$this->nom_asteroide = $alli["nom_asteroide"];
|
||||
$this->image_asteroide = $alli["image_asteroide"];
|
||||
$this->debris_met = $alli["debris_met"];
|
||||
|
|
@ -67,7 +66,7 @@ class Alliance extends Surface{
|
|||
}
|
||||
$this->file_bat = unserialize($alli["file_bat"]);
|
||||
|
||||
foreach($nomvaisnVAR as $vais){
|
||||
foreach($spatialVAR as $vais){
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
}
|
||||
$this->file_vais = unserialize($alli["file_vais"]);
|
||||
385
onyx2/include/Class/asteroide.php
Normal file
385
onyx2/include/Class/asteroide.php
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
<?php
|
||||
include_once("Class/surface.php");
|
||||
/***************************************************************************
|
||||
* class.asteroide.php
|
||||
* ---------------------
|
||||
* begin : Jeudi 25 décembre 2008
|
||||
* update : Dimanche 4 janvier 2008
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Asteroide extends Surface
|
||||
{
|
||||
var $fondateur,
|
||||
$sante,
|
||||
$nom_alliance,
|
||||
$tag,
|
||||
$wing,
|
||||
$nom_asteroide,
|
||||
$image_asteroide,
|
||||
$position = 5,
|
||||
$cap = 123456789,
|
||||
$credits_alliance,
|
||||
$points_alliance,
|
||||
$url_chat,
|
||||
$url_forum,
|
||||
$details = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id = 0)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $table_alliances, $SESS;
|
||||
global $alli_batimentsVAR, $spatialVAR;
|
||||
$bdd = new BDD();
|
||||
|
||||
//On traite le cas où l'on envoie les coordonnées
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):?[Aa]?\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
die('Erreur #04 : Format de recherche d\'asteroide incorrect !');
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
$this->id = $plan["id"];
|
||||
parent::User($SESS->values['id']); //On utilise le numéro d'utilisateur enregistré en session
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->points_alliance = $plan["points_alliance"];
|
||||
$this->nom_asteroide = $plan["nom_asteroide"];
|
||||
$this->image = $this->image_asteroide = $plan["image_asteroide"];
|
||||
$this->debris_met = $plan["debris_met"];
|
||||
$this->debris_cri = $plan["debris_cri"];
|
||||
$this->metal = $plan["metal"];
|
||||
$this->cristal = $plan["cristal"];
|
||||
$this->hydrogene = $plan["hydrogene"];
|
||||
$this->credits_alliance = $plan["credits_alliance"];
|
||||
$this->fondateur = $plan["fondateur"];
|
||||
$this->nom_alliance = $plan["nom_alliance"];
|
||||
$this->wing = $plan["wing"];
|
||||
$this->tag = $plan["tag"];
|
||||
$this->url_forum = $plan["url_forum"];
|
||||
$this->url_chat = $plan["url_chat"];
|
||||
|
||||
foreach($alli_batimentsVAR as $bat)
|
||||
$this->batiments[] = $plan[$bat];
|
||||
if (!empty($plan["file_bat"]))
|
||||
$this->file_bat = unserialize($plan["file_bat"]);
|
||||
else
|
||||
$this->file_bat = new FileAlliancesBatiments();
|
||||
|
||||
foreach($spatialVAR as $vais)
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
if (!empty($plan["file_vais"]))
|
||||
$this->file_vais = unserialize($plan["file_vais"]);
|
||||
else
|
||||
$this->file_vais = new FileSpatial('vaisseaux');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadDetails()
|
||||
{
|
||||
global $table_alliances, $table_user;
|
||||
$bdd = new bdd();
|
||||
$this->details = array_merge($bdd->unique_query("SELECT presentation, message_inscription, texte_interne, port_chat, chan_chat, image, etat_inscription, defcon, defcon_txt FROM $table_alliances WHERE id = ".$this->id.";"), $bdd->unique_query("SELECT COUNT(id) AS nb_membres FROM $table_user WHERE id_alliance = ".$this->id.";"));
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
function actualiser($actuFile = true, $first = false)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile)
|
||||
{
|
||||
$this->file_bat->ready($this);
|
||||
$this->file_vais->ready($this);
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndRetireRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
if ($this->metal >= $metal && $this->cristal >= $cristal && $this->hydrogene >= $hydrogene && $this->credits_alliance >= $credits)
|
||||
{
|
||||
$this->metal -= $metal;
|
||||
$this->cristal -= $cristal;
|
||||
$this->hydrogene -= $hydrogene;
|
||||
$this->credits -= $credits;
|
||||
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function addRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
$perte = 0;
|
||||
|
||||
$this->metal += $metal;
|
||||
if ($this->metal > $this->cap)
|
||||
{
|
||||
$perte += $this->metal - $this->cap;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
|
||||
$this->cristal += $cristal;
|
||||
if ($this->cristal > $this->cap)
|
||||
{
|
||||
$perte += $this->cristal - $this->cap;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogene += $hydrogene;
|
||||
if ($this->hydrogene > $this->cap)
|
||||
{
|
||||
$perte += $this->hydrogene - $this->cap;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogecredits_alliancene += $credits;
|
||||
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
return $perte;
|
||||
}
|
||||
|
||||
function addCreditsAlliance($credits)
|
||||
{
|
||||
$this->credits_alliance += $credits;
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function addPoints($metal, $cristal, $hydrogene, $credits = 0, $demolition = false)
|
||||
{
|
||||
global $table_bourse_ressources;
|
||||
//On charge les 3 valeurs boursières
|
||||
$bdd = new BDD();
|
||||
$bourse = $bdd->query("SELECT dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
//TODO Equivalence non prouvée entre $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7); et $credits/bourse_calcPrixBase($bourse[0]["dispo"], 1) * 0.7; dans le but de ne donner que 70% des points
|
||||
$metal += $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7);
|
||||
$cristal += $credits/bourse_calcPrixBase($bourse[1]["dispo"], 0.7);
|
||||
$hydrogene += $credits/bourse_calcPrixBase($bourse[2]["dispo"], 0.7);
|
||||
}
|
||||
|
||||
$points = bourse_calcPrixBase($bourse[0]["dispo"], $metal);
|
||||
$points += bourse_calcPrixBase($bourse[1]["dispo"], $cristal);
|
||||
$points += bourse_calcPrixBase($bourse[2]["dispo"], $hydrogene);
|
||||
|
||||
if ($demolition)
|
||||
$this->points_alliance -= intval($points);
|
||||
else
|
||||
$this->points_alliance += intval($points);
|
||||
|
||||
$this->addModif("points_alliance");
|
||||
}
|
||||
|
||||
function creer($fondateur, $mere = false)
|
||||
{
|
||||
global $VAR, $table_alliances_creation;
|
||||
|
||||
$bdd = new BDD();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$fondateur->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
//On vérifie que l'alliance n'a pas déjà été créée
|
||||
if (empty($alliance))
|
||||
return 1;
|
||||
|
||||
//Définition des paramètres de l'utilisateur pour l'astéroide
|
||||
$this->fondateur = $alliance["fondateur"];
|
||||
$this->race = $fondateur->race;
|
||||
|
||||
//Génération du nombre de case et de l'image en fonction de la position dans le système
|
||||
$this->sante = 1;
|
||||
$this->nom_alliance = $alliance["nom_alliance"];
|
||||
$this->tag = $alliance["tag"];
|
||||
$this->nom_asteroide = $alliance["nom_alliance"];
|
||||
$this->image_asteroide = mt_rand(1,3);
|
||||
|
||||
$this->modif = array("fondateur", "race", "nom_alliance", "galaxie", "ss", "tag", "nom_asteroide", "image_asteroide");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (empty($this->ss) || empty($this->fondateur))
|
||||
return;
|
||||
if (DEBUG)
|
||||
var_dump($this);
|
||||
|
||||
global $table_alliances;
|
||||
if (empty($this->id))
|
||||
{
|
||||
$outNomChamps = array(); $outValeurs = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
if ($modif[0] == "batiments")
|
||||
$calc = dDonnees::nameVAR("alli_batiments");
|
||||
else
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$modif[1]];
|
||||
$outValeurs[] = $this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
{
|
||||
$outNomChamps[] = "metal";
|
||||
$outNomChamps[] = "cristal";
|
||||
$outNomChamps[] = "hydrogene";
|
||||
|
||||
$outValeurs[] = $this->metal;
|
||||
$outValeurs[] = $this->cristal;
|
||||
$outValeurs[] = $this->hydrogene;
|
||||
}
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$outNomChamps[] = $modif;
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$outValeurs[] = $this->{$modif};
|
||||
else
|
||||
$outValeurs[] = "'".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$outNomChamps[] = $modif;
|
||||
$outValeurs[] = "'$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
{
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$j];
|
||||
$outValeurs[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//On supprime le lien de construction de l'alliance
|
||||
$bdd->query("DELETE FROM $table_alliances_creation WHERE fondateur = ".$this->fondateur.";");
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : fondateur = ".$this->fondateur, 2);
|
||||
//On ajout l'astéroide
|
||||
$bdd->query("INSERT INTO $table_alliances (".implode(', ', $outNomChamps).") VALUES (".implode(', ', $outValeurs).");");
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : outNomChamps = ".serialize($outNomChamps)." ; outValeurs = ".serialize($outValeurs), 2);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
if ($modif[0] == "batiments")
|
||||
$calc = dDonnees::nameVAR("alli_batiments");
|
||||
else
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (empty(${$calc.'VAR'}))
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
{
|
||||
$out[] = "metal = ".$this->metal;
|
||||
$out[] = "cristal = ".$this->cristal;
|
||||
$out[] = "hydrogene = ".$this->hydrogene;
|
||||
}
|
||||
elseif (!is_array($this->{$modif}) && !is_object($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out[] = $modif." = ".$this->{$modif};
|
||||
else
|
||||
$out[] = $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_alliances SET ".implode(', ', $out)." WHERE id = ".$this->id.";";
|
||||
if (DEBUG)
|
||||
echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out), 2);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
42
onyx2/include/Class/attaques.php
Normal file
42
onyx2/include/Class/attaques.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Attaques
|
||||
{
|
||||
var $groupes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function addGroupe($groupe)
|
||||
{
|
||||
$this->groupes[] = $groupe;
|
||||
}
|
||||
|
||||
function checkAllGroupes()
|
||||
{
|
||||
foreach ($groupes as $key => $groupe)
|
||||
$this->checkGroupe($key);
|
||||
}
|
||||
|
||||
function checkGroupe($id)
|
||||
{
|
||||
if (is_a($this->groupes[$id], "Groupe"))
|
||||
{
|
||||
if ($this->groupes[$id]->)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
$groupes[$id]->
|
||||
}
|
||||
}
|
||||
?>
|
||||
262
onyx2/include/Class/class.donnee.php
Normal file
262
onyx2/include/Class/class.donnee.php
Normal file
|
|
@ -0,0 +1,262 @@
|
|||
<?php
|
||||
/***************************************************************************
|
||||
* class.var.php
|
||||
* ---------------
|
||||
* begin : Jeudi 29 janvier 2009
|
||||
* update : Vendredi 27 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Donnee
|
||||
{
|
||||
static function donneeTechnologie($branche, $idTechnologie, $retour, Planete $planete)
|
||||
{
|
||||
//TODO : Faire un switch pour ne renvoyer le tableau que de la branche plutôt que ce tableau avec l'intégralité des branches.
|
||||
$technologies_donnees = array(
|
||||
//Industrie
|
||||
array(
|
||||
array(1, 0, 1000, 54000),
|
||||
array(2, 1, 2000, 90000),
|
||||
array(4, 3, 4000, 126000),
|
||||
array(8, 1, 4000, 126000),
|
||||
array(16, 1, 2000, 72000),
|
||||
array(32, 17, 4000, 108000),
|
||||
array(64, 49, 8000, 144000),
|
||||
array(128, 1, 2000, 72000),
|
||||
array(256, 129, 4000, 108000),
|
||||
array(512, 385, 8000, 144000),
|
||||
array(1024, 1, 2000, 72000),
|
||||
array(2048, 1025, 4000, 108000),
|
||||
array(4096, 3073, 8000, 144000),
|
||||
array(8192, 9, 3000, 126000),
|
||||
array(16384, 8201, 6000, 162000),
|
||||
array(32768, 24585, 12000, 198000),
|
||||
array(65536, 1169, 3000, 126000),
|
||||
array(131072, 66705, 6000, 162000),
|
||||
array(262144, 197777, 12000, 198000)
|
||||
),
|
||||
//Ingénieurie
|
||||
array(
|
||||
array(1, 0, 1000, 54000),
|
||||
array(2, 1, 2000, 90000),
|
||||
array(4, 3, 4000, 126000),
|
||||
array(8, 1, 2000, 90000),
|
||||
array(16, 9, 4000, 126000),
|
||||
array(32, 25, 8000, 162000),
|
||||
array(64, 9, 3000, 126000),
|
||||
array(128, 73, 6000, 162000),
|
||||
array(256, 201, 12000, 198000),
|
||||
array(512, 73, 4000, 162000),
|
||||
array(1024, 585, 8000, 198000),
|
||||
array(2048, 1609, 16000, 234000),
|
||||
array(4096, 0, 1000, 54000),
|
||||
array(8192, 4096, 2000, 90000),
|
||||
array(16384, 12288, 4000, 126000),
|
||||
array(32768, 4096, 2000, 54000),
|
||||
array(65536, 36864, 4000, 90000),
|
||||
array(131072, 102400, 8000, 126000),
|
||||
array(262144, 12288, 2000, 72000),
|
||||
array(524288, 274432, 4000, 108000),
|
||||
array(1048576, 798720, 8000, 144000),
|
||||
array(2097152, 274432, 2000, 54000),
|
||||
array(4194304, 2371584, 4000, 90000),
|
||||
array(8388608, 6565888, 8000, 126000),
|
||||
array(16777216, 28672, 2000, 54000),
|
||||
array(33554432, 16805888, 4000, 90000),
|
||||
array(67108864, 50360320, 8000, 126000),
|
||||
array(134217728, 28672, 3000, 90000),
|
||||
array(268435456, 134246400, 6000, 126000),
|
||||
array(536870912, 402681856, 12000, 162000)
|
||||
),
|
||||
//Ingénieurie 2
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 4000, 126000),
|
||||
array(16, 1, 4000, 126000),
|
||||
array(32, 25, 4000, 126000),
|
||||
array(64, 57, 8000, 162000),
|
||||
array(128, 121, 16000, 198000)
|
||||
),
|
||||
//Politique
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 2000, 72000),
|
||||
array(16, 9, 4000, 108000),
|
||||
array(32, 25, 8000, 144000),
|
||||
array(64, 9, 4000, 126000),
|
||||
array(128, 8, 6000, 162000),
|
||||
array(256, 9, 6000, 162000),
|
||||
array(512, 0, 1000, 90000),
|
||||
array(1024, 512, 2000, 90000),
|
||||
array(2048, 1536, 4000, 90000),
|
||||
array(4096, 512, 2000, 72000),
|
||||
array(8192, 4608, 4000, 108000),
|
||||
array(16384, 12800, 8000, 144000)
|
||||
),
|
||||
|
||||
//Armement
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 1000, 54000),
|
||||
array(16, 9, 2000, 90000),
|
||||
array(32, 25, 4000, 126000),
|
||||
array(64, 9, 2000, 72000),
|
||||
array(128, 73, 4000, 108000),
|
||||
array(256, 201, 8000, 144000),
|
||||
array(512, 73, 2000, 90000),
|
||||
array(1024, 585, 4000, 126000),
|
||||
array(2048, 1609, 8000, 162000),
|
||||
array(4096, 1, 3000, 108000),
|
||||
array(8192, 4097, 6000, 144000),
|
||||
array(16384, 12289, 12000, 180000),
|
||||
array(32768, 4097, 3000, 126000),
|
||||
array(65536, 36865, 6000, 162000),
|
||||
array(131072, 102401, 12000, 198000)
|
||||
),
|
||||
//Défense
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 2000, 72000),
|
||||
array(16, 9, 4000, 108000),
|
||||
array(32, 25, 8000, 144000),
|
||||
array(64, 9, 3000, 108000),
|
||||
array(128, 73, 6000, 144000),
|
||||
array(256, 201, 12000, 180000),
|
||||
array(512, 0, 1000, 36000),
|
||||
array(1024, 512, 2000, 72000),
|
||||
array(2048, 1536, 4000, 108000),
|
||||
array(4096, 512, 2000, 72000),
|
||||
array(8192, 4608, 4000, 108000),
|
||||
array(16384, 12800, 8000, 144000),
|
||||
array(32768, 4608, 3000, 108000),
|
||||
array(65536, 37376, 6000, 144000),
|
||||
array(131072, 102912, 12000, 180000),
|
||||
array(262144, 512, 1000, 54000),
|
||||
array(524288, 262656, 2000, 90000),
|
||||
array(1048576, 786944, 4000, 126000),
|
||||
array(2097152, 262656, 2000, 90000),
|
||||
array(4194304, 2359808, 4000, 126000),
|
||||
array(8388608, 6554112, 8000, 162000),
|
||||
array(16777216, 2359808, 3000, 126000),
|
||||
array(33554432, 19137024, 6000, 162000),
|
||||
array(67108864, 52691456, 12000, 198000)
|
||||
),
|
||||
//Défense 2
|
||||
array(
|
||||
array(1, 0, 2000, 72000),
|
||||
array(2, 1, 4000, 144000),
|
||||
array(4, 3, 6000, 216000),
|
||||
array(8, 0, 2000, 72000),
|
||||
array(16, 8, 4000, 144000),
|
||||
array(32, 24, 6000, 216000),
|
||||
array(64, 27, 8000, 288000)
|
||||
),
|
||||
//Projets expérimentaux
|
||||
array(
|
||||
array(1, 0, 2000, 36000),
|
||||
array(2, 1, 4000, 72000),
|
||||
array(4, 2, 4000, 108000),
|
||||
array(8, 4, 6000, 144000),
|
||||
array(16, 8, 6000, 144000),
|
||||
array(32, 8, 8000, 180000),
|
||||
array(64, 32, 10000, 216000),
|
||||
array(128, 64, 10000, 234000),
|
||||
array(256, 128, 12000, 288000),
|
||||
array(512, 256, 14000, 324000),
|
||||
array(1024, 64, 14000, 342000),
|
||||
array(2048, 256, 16000, 360000),
|
||||
array(4096, 576, 18000, 396000),
|
||||
array(8192, 4096, 20000, 432000),
|
||||
array(16384, 8192, 22000, 504000)
|
||||
),
|
||||
//Technologie expansion
|
||||
array(
|
||||
array(1, 0, 4000, 54000),
|
||||
array(2, 1, 6000, 72000),
|
||||
array(4, 3, 8000, 90000),
|
||||
array(8, 7, 10000, 108000),
|
||||
array(16, 15, 12000, 126000),
|
||||
array(32, 31, 14000, 144000),
|
||||
array(64, 63, 16000, 162000),
|
||||
array(128, 127, 18000, 180000),
|
||||
array(256, 255, 20000, 198000),
|
||||
array(512, 511, 22000, 216000),
|
||||
array(1024, 1023, 24000, 234000),
|
||||
array(2048, 2047, 26000, 252000),
|
||||
array(4096, 4095, 28000, 270000),
|
||||
array(8192, 8191, 30000, 288000),
|
||||
array(16384, 16383, 32000, 306000),
|
||||
array(32768, 32767, 34000, 324000),
|
||||
array(65536, 65535, 36000, 342000),
|
||||
array(131072, 131071, 38000, 360000)
|
||||
)
|
||||
);
|
||||
|
||||
if ($retour == "metal") return 0;
|
||||
elseif ($retour == "cristal") return 0;
|
||||
elseif ($retour == "hydrogene") return 0;
|
||||
elseif ($retour == "credits") return $technologies_donnees[$branche][$idTechnologie][2];
|
||||
elseif ($retour == "temps") return $technologies_donnees[$branche][$idTechnologie][3]/VITESSE;
|
||||
elseif ($retour == "needed") return $technologies_donnees[$branche][$idTechnologie][1];
|
||||
elseif ($retour == "id") return $technologies_donnees[$branche][$idTechnologie][0];
|
||||
elseif ($retour == "array") return array(0, 0, 0, $technologies_donnees[$branche][$idTechnologie][2], $technologies_donnees[$branche][$idTechnologie][3]/VITESSE);
|
||||
}
|
||||
|
||||
static function metalTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "metal", $planete);
|
||||
}
|
||||
|
||||
static function cristalTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "cristal", $planete);
|
||||
}
|
||||
|
||||
static function hydrogeneTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "hydrogene", $planete);
|
||||
}
|
||||
|
||||
static function creditsTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "credits", $planete);
|
||||
}
|
||||
|
||||
static function tempsTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "temps", $planete);
|
||||
}
|
||||
|
||||
static function idTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "id", $planete);
|
||||
}
|
||||
|
||||
static function neededTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
$neededTechnologies = Donnee::donneeTechnologie($branche, $idTechnologie, "needed", $planete);
|
||||
if (empty($neededTechnologies)) return true;
|
||||
if (is_array($neededTechnologies))
|
||||
{
|
||||
//TODO prévoir le besoin de plus d'une technologie pour la validation, dans une autre branche, batiment (?) ...
|
||||
die('TODO '.__LINE__.' in '.__FILE__);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((int)$planete->technologies[$branche]& $neededTechnologies) == $neededTechnologies)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1210
onyx2/include/Class/class.file.php
Normal file
1210
onyx2/include/Class/class.file.php
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -33,13 +33,13 @@ class FlotteGroupee
|
|||
if (!empty($id))
|
||||
{
|
||||
global $table_flottes_preparation;
|
||||
global $nomvaisnVAR, $ressoVAR;
|
||||
|
||||
global $spatialVAR, $ressoVAR;
|
||||
|
||||
$id = intval($id);
|
||||
$bdd = new BDD();
|
||||
$flotte = $bdd->unique_query("SELECT * FROM $table_flottes_preparation WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
|
||||
if (!empty($flotte))
|
||||
{
|
||||
$this->id_flotte = $flotte["id"];
|
||||
|
|
@ -48,7 +48,7 @@ class FlotteGroupee
|
|||
$this->end_type = $flotte["end_type"];
|
||||
$this->time_end = $flotte["time_end"];
|
||||
$this->mission = $flotte["mission"];
|
||||
|
||||
|
||||
if (empty($this->flottes)
|
||||
$this->flottes = array();
|
||||
else
|
||||
|
|
@ -92,7 +92,7 @@ class FlotteGroupee
|
|||
|
||||
function lancer()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
function addModifFlotte($modif)
|
||||
|
|
@ -110,7 +110,7 @@ class FlotteGroupee
|
|||
function __destruct()
|
||||
{
|
||||
global $table_flottes;
|
||||
|
||||
|
||||
if ($this->modifFlotte === "DELETE")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
|
|
@ -124,10 +124,10 @@ class FlotteGroupee
|
|||
if ($this->modifFlotte == "INSERT")
|
||||
{
|
||||
$out1 = ''; $out2 = '';
|
||||
global $nomvaisnVAR;
|
||||
global $spatialVAR;
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
{
|
||||
$out1 .= ', '.$nomvaisnVAR[$key];
|
||||
$out1 .= ', '.$spatialVAR[$key];
|
||||
$out2 .= ', '.$vais;
|
||||
}
|
||||
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
153
onyx2/include/Class/exceptionHB.php
Normal file
153
onyx2/include/Class/exceptionHB.php
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
/***************************************************************************
|
||||
* class.exceptionHB.php
|
||||
* -----------------------
|
||||
* begin : Lundi 9 février 2009
|
||||
* update : Vendredi 27 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
class ExceptionHB extends Exception {
|
||||
|
||||
public function __construct($branche, $code = 0, $debug = true, $gerer = false) {
|
||||
if ($gerer)
|
||||
parent::__construct($branche, $code);
|
||||
else
|
||||
{
|
||||
if (is_numeric($branche))
|
||||
{
|
||||
switch($branche)
|
||||
{
|
||||
case 1:
|
||||
switch($code)
|
||||
{
|
||||
case 0:
|
||||
$message = "La planète est pleine, vous ne pouvez plus construire de batiment dessus !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de batiments.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour construire ce bâtiment.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Le bâtiment dont vous demandez la construction est actuellement en démolition. Annulez la démolition pour lui ajouter l'aggrandir.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour construire ce bâtiment !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la construction de ce bâtiment, il n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démolir ce batiment, il n'est pas encore construit !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Le bâtiment dont vous demandez la démolition est actuellement en travaux. Annulez les travaux en cours pour pouvoir le démolir.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch($code)
|
||||
{
|
||||
case 0:
|
||||
$message = "Cette technologie est déjà en file d'attente, soyez patient !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de technologies.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Vous possédez déjà cette technologie !";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les crédits ou ressources nécessaires pour rechercher cette technologie !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvée dans la file !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch($code)
|
||||
{
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus d'unités.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour entraîner ces unités.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "L'unité dont vous demandez l'entraînement est actuellement en démentellement. Annulez le démentellement pour l'entraîner de nouveau.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour entraîner cette unité !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler l'entraînement de cette unité, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démenteler autant d'unités !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "L'unité dont vous demandez le démentellement est actuellement en entraînement. Annulez l'entraînement en cours pour pouvoir la démenteller.";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$message = "Dépassement de capacité.<br />Vous ne pouvez pas demander la construction d'autant d'unités en même temps.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch($code)
|
||||
{
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de recherches.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour rechercher cette technologie !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Il n'est pas possible d'annuler une technologie connue";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Vous recherchez déjà cette technologie !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
$message = $branche;
|
||||
|
||||
if ($debug || empty($message))
|
||||
$message = "Erreur #".intval($branche)."/".$code." :<br />".$message;
|
||||
|
||||
global $template, $page;
|
||||
if (!empty($page))
|
||||
$template->assign('page', $page);
|
||||
$template->assign('message', $message);
|
||||
$template->assign('couleur', 'red');
|
||||
$template->display('game/erreur.tpl');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
839
onyx2/include/Class/flotte.php
Normal file
839
onyx2/include/Class/flotte.php
Normal file
|
|
@ -0,0 +1,839 @@
|
|||
<?php
|
||||
include_once("Class/rapport.php");
|
||||
/***************************************************************************
|
||||
* class.flotte.php
|
||||
* ------------------
|
||||
* begin : Samedi 20 septembre 2008
|
||||
* update : Samedi 20 septembre 2008
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Flotte
|
||||
{
|
||||
var $id_flotte = 0,
|
||||
$nom,
|
||||
$start_planete,
|
||||
$start_time,
|
||||
$start_type,
|
||||
$end_planete,
|
||||
$end_time,
|
||||
$end_type,
|
||||
$ret_planete,
|
||||
$ret_type,
|
||||
$ret_time,
|
||||
$nb_vais,
|
||||
$vaisseaux = array(),
|
||||
$tactique = 0,
|
||||
$mission,
|
||||
$vitesse,
|
||||
$statut = 0,
|
||||
$last,
|
||||
$contenu = array(0,0,0),
|
||||
$contenuMax = 0,
|
||||
$modifFlotte = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la flotte à importer
|
||||
* @param bool $verrou Booléen disant si la classe doit obtenir préalablement un verrou pour la flotte.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id = 0, $verrou = true)
|
||||
{
|
||||
if (!empty($id))
|
||||
{
|
||||
global $table_flottes;
|
||||
global $ressoVAR, $spatialVAR;
|
||||
|
||||
$id = intval($id);
|
||||
$bdd = new BDD();
|
||||
$flotte = $bdd->unique_query("SELECT * FROM $table_flottes WHERE id = $id;");
|
||||
if ($verrou)
|
||||
$bdd->query("UPDATE $table_flottes SET last = ".time()." WHERE id = $id;"); //Obtention d'un vérrou de 10 seconde sur la flotte
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($flotte))
|
||||
{
|
||||
$this->id_flotte = $flotte["id"];
|
||||
$this->nom = $flotte["nom"];
|
||||
$this->start_planete = $flotte["start_planete"];
|
||||
$this->start_type = $flotte["start_type"];
|
||||
$this->start_time = $flotte["start_time"];
|
||||
$this->end_planete = $flotte["end_planete"];
|
||||
$this->end_type = $flotte["end_type"];
|
||||
$this->end_time = $flotte["end_time"];
|
||||
$this->ret_planete = $flotte["ret_planete"];
|
||||
$this->ret_type = $flotte["ret_type"];
|
||||
$this->ret_time = $flotte["ret_time"];
|
||||
$this->tactique = $flotte["tactique"];
|
||||
$this->mission = $flotte["mission"];
|
||||
$this->vitesse = $flotte["vitesse"];
|
||||
$this->statut = $flotte["statut"];
|
||||
$this->last = $flotte["last"];
|
||||
$this->nb_vais = $flotte["nb_vais"];
|
||||
|
||||
foreach($spatialVAR as $vais)
|
||||
$this->vaisseaux[] = $flotte[$vais];
|
||||
|
||||
$this->contenu = array($flotte["contenu_metal"], $flotte["contenu_cristal"], $flotte["contenu_hydrogene"]);
|
||||
|
||||
$this->calculer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function calculer()
|
||||
{
|
||||
$this->nb_vais = 0;
|
||||
|
||||
//Calcul de la capacité maximale d'embarquement de la flotte
|
||||
foreach($this->vaisseaux as $key => $vais)
|
||||
{
|
||||
$this->nb_vais += $vais;
|
||||
$this->contenuMax += dSpatial::tailleCales($key) * $vais;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function load_planete()
|
||||
{
|
||||
if (!empty($this->start_planete) && is_numeric($this->start_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fournis
|
||||
if ($this->start_type == 0)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->start_planete)
|
||||
$this->start_planete = $planete;
|
||||
else
|
||||
$this->start_planete = new Planete($this->start_planete);
|
||||
}
|
||||
elseif ($this->start_type == 2)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->start_planete)
|
||||
$this->start_planete = $planete;
|
||||
else
|
||||
$this->start_planete = new Asteroide($this->start_planete);
|
||||
}
|
||||
}
|
||||
if (!empty($this->end_planete) && is_numeric($this->end_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fournis
|
||||
if ($this->end_type == 0 || $this->ret_type == 1)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->end_planete)
|
||||
$this->end_planete = $planete;
|
||||
else
|
||||
$this->end_planete = new Planete($this->end_planete);
|
||||
}
|
||||
elseif ($this->end_type == 2)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->end_planete)
|
||||
$this->end_planete = $planete;
|
||||
else
|
||||
$this->end_planete = new Asteroide($this->end_planete);
|
||||
}
|
||||
}
|
||||
if (!empty($this->ret_planete) && is_numeric($this->ret_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fournis
|
||||
if ($this->ret_type == 0)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->ret_planete)
|
||||
$this->ret_planete = $planete;
|
||||
else
|
||||
$this->ret_planete = new Planete($this->ret_planete);
|
||||
}
|
||||
elseif ($this->ret_type == 2)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->ret_planete)
|
||||
$this->ret_planete = $planete;
|
||||
else
|
||||
$this->ret_planete = new Asteroide($this->ret_planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function creer(surface $start_planete, $tableau, $resultat)
|
||||
{
|
||||
$sauv = $start_planete->vaisseaux; //Sauvegarde les vaisseaux de la planète avant le lancement
|
||||
foreach ($tableau['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
$this->vaisseaux[$key] = $vaisseau;
|
||||
$sauv[$key] -= $vaisseau;
|
||||
|
||||
if ($sauv[$key] < 0)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//Définition des paramètres de la flotte en fonction des données enregistrées en session
|
||||
$this->nom = $tableau["nom"];
|
||||
$this->vitesse = $tableau["vitesse"];
|
||||
$this->mission = $tableau["mission"];
|
||||
$this->start_planete = $start_planete;
|
||||
if (SURFACE == "planete")
|
||||
$this->start_type = 0;
|
||||
elseif (SURFACE == "asteroide")
|
||||
$this->start_type = 2;
|
||||
$this->start_time = time();
|
||||
|
||||
//On traite le cas des planètes qui n'existent pas (dans le cas de la mission colonisation)
|
||||
if ($tableau["mission"] == 2)
|
||||
{
|
||||
//On traite le cas des colonisation d'astéroïdes
|
||||
if ($tableau["end_position"] == "A")
|
||||
$this->end_type = 3;
|
||||
else
|
||||
$this->end_type = 1;
|
||||
|
||||
$this->end_planete = $tableau["end_galaxie"].':'.$tableau["end_systeme"].':'.$tableau["end_position"];
|
||||
}
|
||||
//On traite le cas des envoie vers les alliances
|
||||
elseif ($tableau["end_position"] == "A")
|
||||
{
|
||||
$this->end_type = 2;
|
||||
$this->end_planete = $resultat['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->end_type = 0;
|
||||
$this->end_planete = $resultat['id'];
|
||||
}
|
||||
|
||||
if (empty($this->end_planete))
|
||||
erreur("Planète d'arriver incorrecte !");
|
||||
|
||||
//On vérifie qu'il y a assez de place dans les cales des vaisseaux avant l'envoie ainsi que de ressources sur la planète
|
||||
$this->calculer();
|
||||
|
||||
$calc = Flotte::calc_deplacement($start_planete, $tableau["end_galaxie"], $tableau["end_systeme"], $tableau["end_position"], $tableau["vitesse"]/100, $tableau["vaisseaux"], $this->contenuMax - $tableau["embarquer"][0] - $tableau["embarquer"][1] - $tableau["embarquer"][2], false, true);
|
||||
|
||||
$this->end_time = $calc[0];
|
||||
//On double la consomation si on fait un aller-retour
|
||||
if ($tableau["mission"] == 1 || $tableau["mission"] == 2 || $tableau["mission"] == 4 || $tableau["mission"] == 5)
|
||||
$calc[1] *= 2;
|
||||
|
||||
if ($this->contenuMax < $tableau["embarquer"][0] + $tableau["embarquer"][1] + $tableau["embarquer"][2] + $calc[1])
|
||||
erreur('Vous ne pouvez pas embarquer autant de ressources, les cales débordent. '.$this->contenuMax, "red", '?p=flotte', 3500);
|
||||
elseif ($start_planete->metal < $tableau["embarquer"][0] || $start_planete->cristal < $tableau["embarquer"][1] || $start_planete->hydrogene < $tableau["embarquer"][2] + $calc[1])
|
||||
erreur('Vous n\'avez pas assez de ressources sur cette planète pour envoyer cette flotte.', "red", '?p=flotte', 3500);
|
||||
|
||||
$this->contenu = $tableau["embarquer"];
|
||||
$this->modifFlotte = "INSERT";
|
||||
|
||||
//On actualise la planète
|
||||
$start_planete->metal -= $tableau["embarquer"][0];
|
||||
$start_planete->cristal -= $tableau["embarquer"][1];
|
||||
$start_planete->hydrogene -= floor($tableau["embarquer"][2] + $calc[1]);
|
||||
$start_planete->vaisseaux = $sauv;
|
||||
$start_planete->addModif("vaisseaux");
|
||||
$start_planete->addModif("force");
|
||||
}
|
||||
|
||||
static function calc_deplacement($start_planete, $end_galaxie, $end_systeme, $end_position, $vitesse, $vaisseaux, $contenuDispo, $returnArray = false, $returnConso = false)
|
||||
{
|
||||
global $VAR;
|
||||
|
||||
//Calcul de la longueur du déplacement
|
||||
$diff_galaxie = abs($start_planete->galaxie - $end_galaxie);
|
||||
$diff_systeme = abs($start_planete->ss - $end_systeme);
|
||||
$diff_position = abs($start_planete->position - $end_position);
|
||||
|
||||
$diff_centre_position_start = abs(ceil($VAR['nb_amas']/2) - $start_planete->position);
|
||||
$diff_centre_systeme_start = abs(ceil($VAR['nb_systeme']/2) - $start_planete->ss);
|
||||
|
||||
$diff_centre_position_end = abs(ceil($VAR['nb_amas']/2) - $end_position);
|
||||
$diff_centre_systeme_end = abs(ceil($VAR['nb_systeme']/2) - $end_systeme);
|
||||
|
||||
//Calcul du temps de déplacement pour chaque vaisseau
|
||||
$temps = array(); $conso = array(0, 0, 0);
|
||||
foreach($vaisseaux as $key => $vais)
|
||||
{
|
||||
//S'il n'y a pas de vaisseaux de ce type, on ne calcul pas leur vitesse
|
||||
if ($vais == 0)
|
||||
continue;
|
||||
|
||||
//Calcul du temps de déplacement entre planètes
|
||||
if ($start_planete->ss == $end_systeme && $start_planete->galaxie == $end_galaxie)
|
||||
{
|
||||
$temps[0][$key] = (1000/dSpatial::vitesseP($key)) * (1 + 0.1 * $diff_position);
|
||||
$temps[1][$key] = $temps[2][$key] = 0;
|
||||
}
|
||||
//Calcul du temps de déplacement entre système
|
||||
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[1][$key] = (2000/dSpatial::vitesseS($key)) * (2 + 1 * $diff_systeme);
|
||||
$temps[2][$key] = 0;
|
||||
}
|
||||
//Calcul du temps de déplacement entre galaxies
|
||||
else
|
||||
{
|
||||
$temps[0][$key] = (1000/dSpatial::vitesseP($key)) * (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[2][$key] = (5000/dSpatial::vitesseG($key)) * (2 + 1.5 * $diff_galaxie);
|
||||
}
|
||||
|
||||
//Calcul du bonus pour le réacteur à combustion
|
||||
$techR = $start_planete->technologies[1];
|
||||
if ($techR & 56)
|
||||
$bonus = 0.7;
|
||||
elseif ($techR & 24)
|
||||
$bonus = 0.8;
|
||||
elseif ($techR & 8)
|
||||
$bonus = 0.9;
|
||||
else
|
||||
$bonus = 1;
|
||||
$temps[0][$key] *= $bonus * 1/$vitesse;
|
||||
$conso[0] += $vais * $temps[0][$key] * $bonus / exp($vitesse/5);
|
||||
|
||||
//Calcul du bonus pour le réacteur à fusion
|
||||
$techR = $start_planete->technologies[1];
|
||||
if ($techR &448)
|
||||
$bonus = 0.7;
|
||||
elseif ($techR &192)
|
||||
$bonus = 0.8;
|
||||
elseif ($techR &64)
|
||||
$bonus = 0.9;
|
||||
else
|
||||
$bonus = 1;
|
||||
$temps[1][$key] *= $bonus * 1/$vitesse;
|
||||
$conso[1] += $vais * $temps[1][$key] * $bonus / exp($vitesse/7.5);
|
||||
|
||||
//Calcul du bonus pour le réacteur à fusion de type II
|
||||
$techR = $start_planete->technologies[1];
|
||||
if ($techR &3584)
|
||||
$bonus = 0.7;
|
||||
elseif ($techR &1536)
|
||||
$bonus = 0.8;
|
||||
elseif ($techR &512)
|
||||
$bonus = 0.9;
|
||||
else
|
||||
$bonus = 1;
|
||||
$temps[2][$key] *= $bonus * 1/$vitesse;
|
||||
$conso[2] += $vais * $temps[2][$key] * $bonus / exp($vitesse/10);
|
||||
}
|
||||
|
||||
if (!isset($vaisseaux[4]))
|
||||
$vaisseaux[4] = 0;
|
||||
if (!isset($vaisseaux[5]))
|
||||
$vaisseaux[5] = 0;
|
||||
|
||||
//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)
|
||||
$temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
|
||||
|
||||
//On calcul le temps de déplacement maximal
|
||||
if ($returnArray)
|
||||
return $temps;
|
||||
elseif ($returnConso)
|
||||
return array(max($temps[0]) + max($temps[1]) + max($temps[2]), ceil($conso[0]+$conso[1]+$conso[2]));
|
||||
else
|
||||
return (max($temps[0]) + max($temps[1]) + max($temps[2]));
|
||||
}
|
||||
|
||||
|
||||
function check_mission()
|
||||
{
|
||||
//On vérifie qu'un calcul ne soit pas déjà en cours
|
||||
if ($this->last >= time() - 10)
|
||||
return false;
|
||||
elseif ($this->start_time + $this->end_time > time())
|
||||
return false;
|
||||
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
switch($this->mission)
|
||||
{
|
||||
case 6:
|
||||
case 7:
|
||||
$this->stationner();
|
||||
break;
|
||||
case 1:
|
||||
$this->transporter();
|
||||
break;
|
||||
case 2:
|
||||
$this->coloniser();
|
||||
break;
|
||||
case 3:
|
||||
$this->attaquer();
|
||||
break;
|
||||
case 4:
|
||||
$this->recycler();
|
||||
break;
|
||||
case 5:
|
||||
$this->espionner();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->statut == 1 && ($this->ret_time > time() || $this->start_time + $this->end_time * 2 <= time()))
|
||||
$this->retourner();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function stationner()
|
||||
{
|
||||
//On décharge les ressources éventuellement contenue
|
||||
$this->decharger();
|
||||
|
||||
//On fait atterir les vaisseaux
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
$this->end_planete->vaisseaux[$key] += $vais;
|
||||
|
||||
if (!in_array("vaisseaux", $this->end_planete->modif))
|
||||
$this->end_planete->modif[] = "vaisseaux";
|
||||
$this->modifFlotte = "DELETE";
|
||||
}
|
||||
|
||||
|
||||
function transporter()
|
||||
{
|
||||
$max = $this->decharger();
|
||||
|
||||
//Envoie du MP de confirmation au joueur
|
||||
$send = new Rapport(2, $this->start_planete, $this->end_planete, $this->start_time + $this->end_time);
|
||||
$send->addInfo($this->end_planete, 0);
|
||||
$send->addInfo($max, 1);
|
||||
$send->sendTransport();
|
||||
|
||||
$this->statut = 1;
|
||||
$this->addModifFlotte("statut");
|
||||
}
|
||||
|
||||
|
||||
function coloniser()
|
||||
{
|
||||
//On vérifie que les coordonnées de la planètes sont bien enregistrée
|
||||
if (empty($this->end_planete) || is_object($this->end_planete) || !preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([A0-9]{1,2})\]?$#', $this->end_planete))
|
||||
{
|
||||
$this->load_planete();
|
||||
file_log("Erreur de colonisation de la planète : ".$this->end_planete." pour le joueur : ".$this->start_planete->id_user, 2);
|
||||
send_mp($this->start_planete->id_user, "Erreur de colonisation [F#01]", "Une erreur s'est produite lors de la tentative de colonisation de votre flotte, elle a fait demi-tour.", $this->start_time + $this->end_time);
|
||||
$this->rappeler();
|
||||
}
|
||||
|
||||
//On vérifie que la planète ne soit pas déjà colonisée
|
||||
global $table_planete, $table_alliances, $table_alliances_creation, $table_user;
|
||||
preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([A0-9]{1,2})\]?$#', $this->end_planete, $position);
|
||||
if (is_numeric($position[3]))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$p = $bdd->query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$p = $bdd->query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$alliance = $bdd->unique_query("SELECT signatures FROM $table_alliances_creation WHERE fondateur = ".$this->start_planete->id_user.";");
|
||||
$signaturesExport = implode(' OR id = ', explode(';', substr($alliance["signatures"], 1), -1));
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
$this->load_planete();
|
||||
|
||||
if ($p && (!isset($signaturesExport) || count($signaturesExport) < nb_signatures))
|
||||
{
|
||||
$rapport = new Rapport(2, $this->start_planete, 0, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo(array($position[1], $position[2], $position[3]), 0);
|
||||
$rapport->addInfo(false, 1);
|
||||
$rapport->send();
|
||||
|
||||
$this->statut = 1;
|
||||
$this->addModifFlotte("statut");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_numeric($position[3]))
|
||||
{
|
||||
//On crée la planète
|
||||
$this->end_planete = new Planete(false);
|
||||
$this->end_planete->galaxie = $position[1];
|
||||
$this->end_planete->ss = $position[2];
|
||||
$this->end_planete->position = $position[3];
|
||||
$this->end_planete->creer($this->start_planete->id_user);
|
||||
|
||||
//On définit la limite de ressources pour permettre le déchargement de celles contenues dans les vaisseaux
|
||||
$this->end_planete->cap = 100000;
|
||||
}
|
||||
else
|
||||
{
|
||||
//On crée l'astéroide
|
||||
$this->end_planete = new Asteroide(false);
|
||||
$this->end_planete->galaxie = $position[1];
|
||||
$this->end_planete->ss = $position[2];
|
||||
$this->end_planete->creer($this->start_planete);
|
||||
}
|
||||
|
||||
//Rembousement du carburant non utilisé (la colonisation prévois au départ un allé/retour)
|
||||
$conso = $this->calc_deplacement($this->start_planete, $position[1], $position[2], $position[3], $this->vitesse, $this->vaisseaux, 0, false, true);
|
||||
$this->end_planete->hydrogene += $conso[1];
|
||||
|
||||
//On enlève un vaisseau de colonisation de la liste
|
||||
$this->vaisseaux[2]--;
|
||||
|
||||
//On fait atterir les vaisseaux et décharger les ressources
|
||||
$this->decharger();
|
||||
$this->atterir();
|
||||
|
||||
//On envoie un rapport
|
||||
$rapport = new Rapport(2, $this->start_planete, 0, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo(array($position[1], $position[2], $position[3]), 0);
|
||||
$rapport->addInfo(true, 1);
|
||||
$rapport->send();
|
||||
|
||||
if (!is_numeric($position[3]))
|
||||
{
|
||||
unset($this->end_planete);
|
||||
$bdd = new BDD();
|
||||
$p = $bdd->unique_query("SELECT id FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND fondateur = ".$this->start_planete->id_user.";");
|
||||
print "UPDATE $table_user SET alliance = '".$p['id']."' WHERE id = $signaturesExport OR id = ".$this->start_planete->id_user.";";
|
||||
$bdd->query("UPDATE $table_user SET id_alliance = '".$p['id']."' WHERE id = $signaturesExport OR id = ".$this->start_planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function recycler()
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->end_planete))
|
||||
$this->load_planete();
|
||||
|
||||
$coeff = ($this->contenuMax - $this->contenu[0] - $this->contenu[1] - $this->contenu[2])/($this->end_planete->debris_met + $this->end_planete->debris_cri);
|
||||
if ($coeff > 1)
|
||||
$coeff = 1;
|
||||
|
||||
$a = floor($this->end_planete->debris_met * $coeff);
|
||||
$b = floor($this->end_planete->debris_cri * $coeff);
|
||||
|
||||
$this->contenu[0] += $a;
|
||||
$this->contenu[1] += $b;
|
||||
if (!in_array('contenu', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'contenu';
|
||||
|
||||
$this->end_planete->debris_met -= $a;
|
||||
$this->end_planete->debris_cri -= $b;
|
||||
if (!in_array('debris_met', $this->end_planete->modif))
|
||||
$this->end_planete->modif[] = 'debris_met';
|
||||
if (!in_array('debris_cri', $this->end_planete->modif))
|
||||
$this->end_planete->modif[] = 'debris_cri';
|
||||
|
||||
//Send link
|
||||
$rapport = new Rapport(4, $this->start_planete, 0, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo($this->end_planete, 0);
|
||||
$rapport->addInfo(array($a, $b), 1);
|
||||
$rapport->send();
|
||||
|
||||
$this->statut = 1;
|
||||
if (!in_array('statut', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'statut';
|
||||
}
|
||||
|
||||
|
||||
function espionner()
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->end_planete))
|
||||
$this->load_planete();
|
||||
|
||||
//Extraction des niveaux technologique des deux adversaires
|
||||
if (($this->start_planete->technologies[1]& 67108864) == 67108864)
|
||||
$espionnage_A = 3;
|
||||
elseif (($this->start_planete->technologies[1]& 33554432) == 33554432)
|
||||
$espionnage_A = 3;
|
||||
elseif (($this->start_planete->technologies[1]& 16777216) == 16777216)
|
||||
$espionnage_A = 3;
|
||||
else
|
||||
$espionnage_A = 0;
|
||||
if (($this->start_planete->technologies[1]& 536870912) == 536870912)
|
||||
$contreespionnage_B = 3;
|
||||
elseif (($this->start_planete->technologies[1]& 268435456) == 268435456)
|
||||
$contreespionnage_B = 2;
|
||||
elseif (($this->start_planete->technologies[1]& 134217728) == 134217728)
|
||||
$contreespionnage_B = 1;
|
||||
else
|
||||
$contreespionnage_B = 0;
|
||||
|
||||
//Création du rapport
|
||||
$rapport = new Rapport(5, $this->start_planete, $this->end_planete, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo($this->end_planete, 0);
|
||||
$rapport->addInfo($contreespionnage_B/$espionnage_A/10, 1);
|
||||
$rapport->addInfo($espionnage_A+2-$contreespionnage_B+1, 2);
|
||||
$rapport->addInfo($contreespionnage_B, 3);
|
||||
$rapport->send();
|
||||
|
||||
$this->statut = 1;
|
||||
$this->addModifFlotte("statut");
|
||||
}
|
||||
|
||||
|
||||
function decharger($plan = "end_planete")
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->$plan))
|
||||
$this->load_planete();
|
||||
$max = array(0, 0, 0);
|
||||
|
||||
//Si on dépasse les capacités, on laisse les ressources en trop dans le cargo
|
||||
if ($this->$plan->metal + $this->contenu[0] > $this->$plan->cap)
|
||||
{
|
||||
$max[0] = $this->$plan->cap - $this->$plan->metal;
|
||||
if ($max[0] < 0) $max[0] = 0;
|
||||
}
|
||||
else
|
||||
$max[0] = $this->contenu[0];
|
||||
$this->$plan->metal += $max[0];
|
||||
$this->contenu[0] -= $max[0];
|
||||
|
||||
if ($this->$plan->cristal + $this->contenu[1] > $this->$plan->cap)
|
||||
{
|
||||
$max[1] = $this->$plan->cap - $this->$plan->cristal;
|
||||
if ($max[1] < 0) $max[1] = 0;
|
||||
}
|
||||
else
|
||||
$max[1] = $this->contenu[1];
|
||||
$this->$plan->cristal += $max[1];
|
||||
$this->contenu[1] -= $max[1];
|
||||
|
||||
if ($this->$plan->hydrogene + $this->contenu[2] > $this->$plan->cap)
|
||||
{
|
||||
$max[2] = $this->$plan->cap - $this->$plan->hydrogene;
|
||||
if ($max[2] < 0) $max[2] = 0;
|
||||
}
|
||||
else
|
||||
$max[2] = $this->contenu[2];
|
||||
$this->$plan->hydrogene += $max[2];
|
||||
$this->contenu[2] -= $max[2];
|
||||
|
||||
$this->$plan->addModif("force");
|
||||
|
||||
$this->addModifFlotte("contenu");
|
||||
return $max;
|
||||
}
|
||||
|
||||
|
||||
function atterir($plan = "end_planete")
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->$plan))
|
||||
$this->load_planete();
|
||||
|
||||
if (isset($this->$plan->vaisseaux[0]))
|
||||
{
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
$this->$plan->vaisseaux[$key] += $vais;
|
||||
}
|
||||
else
|
||||
$this->$plan->vaisseaux = $this->vaisseaux;
|
||||
|
||||
$this->$plan->addModif("vaisseaux");
|
||||
|
||||
$this->modifFlotte = "DELETE";
|
||||
}
|
||||
|
||||
|
||||
function rappeler()
|
||||
{
|
||||
if ($this->start_time + $this->end_time >= time())
|
||||
return false;
|
||||
else
|
||||
{
|
||||
$this->end_time = time() - $this->start_time + 10;
|
||||
$this->mission = 5;
|
||||
if (!in_array('mission', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'mission';
|
||||
if (!in_array('end_time', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'end_time';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function retourner()
|
||||
{
|
||||
//Si la planète de départ n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->start_planete))
|
||||
$this->load_planete();
|
||||
|
||||
//Si on a demandé une planète particulière au retour
|
||||
if (!empty($this->ret_time) && !empty($this->ret_planete) && !is_numeric($this->ret_planete))
|
||||
{
|
||||
$this->decharger("ret_planete");
|
||||
$this->atterir("ret_planete");
|
||||
}
|
||||
//Si le retour se fait sur la planète source
|
||||
else
|
||||
{
|
||||
$this->decharger("start_planete");
|
||||
$this->atterir("start_planete");
|
||||
}
|
||||
|
||||
$this->modifFlotte = "DELETE";
|
||||
}
|
||||
|
||||
|
||||
function addModifFlotte($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifFlotte))
|
||||
$this->modifFlotte[] = $modif;
|
||||
}
|
||||
|
||||
|
||||
function printTime_end()
|
||||
{
|
||||
return $this->start_time + $this->end_time;
|
||||
}
|
||||
|
||||
function printTime_ret()
|
||||
{
|
||||
if (!empty($this->ret_time))
|
||||
return $this->ret_time;
|
||||
elseif ($this->mission == 1 || $this->mission == 4 || $this->mission == 5 || (($this->mission == 3 || $this->mission == 2) && $this->statut != 0))
|
||||
return $this->start_time + $this->end_time*2;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static function txtMission($mission)
|
||||
{
|
||||
switch($mission)
|
||||
{
|
||||
case 1:
|
||||
return "Transporter";
|
||||
break;
|
||||
case 2:
|
||||
return "Coloniser";
|
||||
break;
|
||||
case 3:
|
||||
return "Attaquer";
|
||||
break;
|
||||
case 4:
|
||||
return "Recycler";
|
||||
break;
|
||||
case 5:
|
||||
return "Espionner";
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
return "Stationner";
|
||||
break;
|
||||
default:
|
||||
return "Inconnu";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
global $table_flottes;
|
||||
|
||||
if ($this->modifFlotte === "DELETE")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : suppr ID = ".$this->id_flotte, 2);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($this->id_flotte) && $this->modifFlotte == "INSERT")
|
||||
{
|
||||
$out1 = ''; $out2 = '';
|
||||
global $spatialVAR;
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
{
|
||||
if ($vais > 0)
|
||||
{
|
||||
$out1 .= ', '.$spatialVAR[$key];
|
||||
$out2 .= ', '.$vais;
|
||||
}
|
||||
}
|
||||
if (SURFACE == "asteroide")
|
||||
$sql = "INSERT INTO $table_flottes (id_user, id_alliance, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES (0, ".$this->start_planete->id.", '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
else
|
||||
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
if (DEBUG) echo $sql;
|
||||
$bdd = new BDD();
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : insertion flotte", 2);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif(isset($this->modifFlotte[0]))
|
||||
{
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modifFlotte as $modif)
|
||||
{
|
||||
if (!is_array($this->{$modif}))
|
||||
{
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out[] .= $modif." = ".$this->{$modif};
|
||||
else
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif == "contenu")
|
||||
$calc = "resso";
|
||||
elseif ($modif == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach(${$calc.'VAR'} as $key => $var)
|
||||
{
|
||||
$bdd->escape($this->{$modif}[$key]);
|
||||
$out[] = ${$calc.'VAR'}[$key]." = ".$this->{$modif}[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";";
|
||||
if (DEBUG)
|
||||
var_dump($sql);
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out)." avec l'ID : ".$this->id_flotte, 2);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
36
onyx2/include/Class/groupe.php
Normal file
36
onyx2/include/Class/groupe.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Groupe
|
||||
{
|
||||
var $contenu = array(); //Tableau contenant les vaisseaux de l'utilisateur
|
||||
var $caracteristiques = array();
|
||||
var $example = array(
|
||||
array("somme boucliers", "somme pv", "nbVaisseauxInitiaux")
|
||||
);
|
||||
var $user; //Classe donnant des informations sur l'utilisateur de la flotte ou l'ID de l'utilisateur
|
||||
var $camp = 0; //Camp du groupe
|
||||
var $timestamp = 0; //TImestamp de la dernière attaque
|
||||
var $actions = array(); //Tableau des actions faite ou à faire
|
||||
var $action_encours = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function regenereBoucliers()
|
||||
{
|
||||
foreach ($this->caracteristiques as $caracteristique)
|
||||
{
|
||||
if ($this->actions[$action_encours][0] == 2)
|
||||
$
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -460,7 +460,7 @@ class PHPMailer
|
|||
* @return bool
|
||||
*/
|
||||
function SmtpSend($header, $body) {
|
||||
include_once($this->PluginDir . "class.smtp.php");
|
||||
include_once($this->PluginDir . "smtp.php");
|
||||
$error = "";
|
||||
$bad_rcpt = array();
|
||||
|
||||
878
onyx2/include/Class/planete.php
Normal file
878
onyx2/include/Class/planete.php
Normal file
|
|
@ -0,0 +1,878 @@
|
|||
<?php
|
||||
//Gestion des dépendances, on importe les classes nécessaires à la classe en cours
|
||||
include_once("Class/surface.php");
|
||||
include_once("donnees.php");
|
||||
|
||||
/***************************************************************************
|
||||
* class.planete.php
|
||||
* -------------------
|
||||
* begin : Jeudi 21 août 2008
|
||||
* update : Vendredi 27 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Planete extends Surface
|
||||
{
|
||||
private $timestamp_lastSilo,
|
||||
$timestamp_lastMineM,
|
||||
$timestamp_lastMineC,
|
||||
$timestamp_lastMineH;
|
||||
|
||||
public $position,
|
||||
$nom_planete,
|
||||
$cases,
|
||||
$casesRest,
|
||||
$cap,
|
||||
$population,
|
||||
$population_max,
|
||||
$moral,
|
||||
$energie,
|
||||
$energieConso,
|
||||
$energieCentrale,
|
||||
$file_tech,
|
||||
$file_cas,
|
||||
$file_ter,
|
||||
$coeff_bat = array(),
|
||||
$casernes = array(),
|
||||
$terrestres = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param mixed $id id de la planète à importer/coordonnées
|
||||
* @param bool $first Bloquer l'affichage des messages d'erreurs
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id, $first = false)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_planete;
|
||||
$bdd = new BDD();
|
||||
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de la planète
|
||||
if ($id === false)
|
||||
$bdd->deconnexion();
|
||||
elseif (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
trigger_error('Erreur #04 : Format de recherche de planete incorrect !', E_USER_ERROR);
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $plan["id"];
|
||||
parent::User($plan["id_user"]);
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->position = $plan["position"];
|
||||
if (!empty($plan["isolement"])) $this->isolement = unserialize($plan["isolement"]);
|
||||
else $this->isolement = array();
|
||||
$this->nom_planete = $plan["nom_planete"];
|
||||
$this->image = $plan["image"];
|
||||
$this->cases = $plan["cases"];
|
||||
$this->energieCentrale = $plan["energieCentrale"];
|
||||
$this->debris_met = $plan["debris_met"];
|
||||
$this->debris_cri = $plan["debris_cri"];
|
||||
$this->metal = $plan["metal"];
|
||||
$this->cristal = $plan["cristal"];
|
||||
$this->hydrogene = $plan["hydrogene"];
|
||||
$this->population = $plan["population"];
|
||||
$this->moral = $plan["moral"];
|
||||
$this->timestamp = $plan["timestamp"];
|
||||
|
||||
//Chargement des variables de conversion
|
||||
global $batimentsVAR, $caserneVAR, $terrestreVAR, $spatialVAR;
|
||||
|
||||
$this->casesRest = $this->cases; //Calcul du nombre de cases en même temps
|
||||
foreach($batimentsVAR as $bat)
|
||||
{
|
||||
$this->batiments[] = $plan[$bat];
|
||||
$this->casesRest -= $plan[$bat];
|
||||
}
|
||||
if (!empty($plan["file_bat"]))
|
||||
$this->file_bat = unserialize($plan["file_bat"]);
|
||||
else
|
||||
$this->file_bat = new FileBatiments();
|
||||
|
||||
$this->coeff_bat = array($plan["coeff_mine_m"], $plan["coeff_mine_c"], $plan["coeff_mine_h"], $plan["coeff_centrale_s"], $plan["coeff_centrale_f"]);
|
||||
//On vérifie que les coefficient ne soient pas supérieurs à 1 ou inférieurs à 0
|
||||
for($i = 0; $i < 5; $i++)
|
||||
{
|
||||
if ($this->coeff_bat[$i] > 1)
|
||||
$this->coeff_bat[$i] = 1;
|
||||
elseif ($this->coeff_bat[$i] < 0)
|
||||
$this->coeff_bat[$i] = 0;
|
||||
}
|
||||
|
||||
if (!empty($plan["file_tech"]))
|
||||
$this->file_tech = unserialize($plan["file_tech"]);
|
||||
else
|
||||
$this->file_tech = new FileTechnologies();
|
||||
|
||||
foreach($caserneVAR as $cas)
|
||||
$this->casernes[] = $plan[$cas];
|
||||
if (!empty($plan["file_cas"]))
|
||||
$this->file_cas = unserialize($plan["file_cas"]);
|
||||
else
|
||||
$this->file_cas = new FileCaserne();
|
||||
|
||||
foreach($terrestreVAR as $ter)
|
||||
$this->terrestres[] = $plan[$ter];
|
||||
if (!empty($plan["file_ter"]))
|
||||
$this->file_ter = unserialize($plan["file_ter"]);
|
||||
else
|
||||
$this->file_ter = new FileTerrestre();
|
||||
|
||||
foreach($spatialVAR as $vais)
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
if (!empty($plan["file_vais"]))
|
||||
$this->file_vais = unserialize($plan["file_vais"]);
|
||||
else
|
||||
$this->file_vais = new FileSpatial();
|
||||
|
||||
//Calcul de la population logée
|
||||
$this->population_max = (pow($this->batiments[12],1.5)+pow($this->batiments[13],2.1))*1000+3000;
|
||||
//Détermination des capacités maximales
|
||||
$this->cap = pow(2, $this->batiments[10]) * 100000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function actualiser($actuFile = true, $first = false)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile)
|
||||
{
|
||||
$this->file_bat->ready($this);
|
||||
$this->file_tech->ready($this);
|
||||
$this->file_cas->ready($this);
|
||||
$this->file_ter->ready($this);
|
||||
$this->file_vais->ready($this);
|
||||
}
|
||||
|
||||
if (!empty($this->timestamp_lastSilo))
|
||||
{
|
||||
$this->cap = pow(2, $this->batiments[10]-1) * 100000;
|
||||
$capnouv = pow(2, $this->batiments[10]) * 100000;
|
||||
$this->addModif("force");
|
||||
}
|
||||
|
||||
//Calcul du temps écoulé depuis la dernière mise à jour de la planète
|
||||
$temps_ecoule = time() - $this->timestamp;
|
||||
$ressources = $this->production($temps_ecoule);
|
||||
|
||||
if ($this->metal + $ressources[0] < $this->cap)
|
||||
$this->metal += $ressources[0];
|
||||
else
|
||||
{
|
||||
//Si les capacités de stockage ont changé depuis la dernière actualisation
|
||||
if (isset($capnouv))
|
||||
{
|
||||
$ressources = $this->production($this->timestamp_lastSilo - $this->timestamp);
|
||||
if ($this->metal + $ressources[0] < $this->cap)
|
||||
$this->metal += $ressources[0];
|
||||
else
|
||||
$this->metal = $this->cap;
|
||||
|
||||
$ressources = $this->production(time() - $this->timestamp_lastSilo);
|
||||
if ($this->metal + $ressources[0] < $capnouv)
|
||||
$this->metal += $ressources[0];
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[0] = true;
|
||||
$this->metal = $capnouv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[0] = true;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
}
|
||||
if ($this->cristal + $ressources[1] < $this->cap)
|
||||
$this->cristal += $ressources[1];
|
||||
else
|
||||
{
|
||||
//Si les capacités de stockage ont changé depuis la dernière actualisation
|
||||
if (isset($capnouv))
|
||||
{
|
||||
$ressources = $this->production($this->timestamp_lastSilo - $this->timestamp);
|
||||
if ($this->cristal + $ressources[0] < $this->cap)
|
||||
$this->cristal += $ressources[0];
|
||||
else
|
||||
$this->cristal = $this->cap;
|
||||
|
||||
$ressources = $this->production(time() - $this->timestamp_lastSilo);
|
||||
if ($this->cristal + $ressources[0] < $capnouv)
|
||||
$this->cristal += $ressources[0];
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[1] = true;
|
||||
$this->cristal = $capnouv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[1] = true;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
}
|
||||
if ($this->hydrogene + $ressources[2] < $this->cap)
|
||||
$this->hydrogene += $ressources[2];
|
||||
else
|
||||
{
|
||||
//Si les capacités de stockage ont changé depuis la dernière actualisation
|
||||
if (isset($capnouv))
|
||||
{
|
||||
$ressources = $this->production($this->timestamp_lastSilo - $this->timestamp);
|
||||
if ($this->hydrogene + $ressources[0] < $this->cap)
|
||||
$this->hydrogene += $ressources[0];
|
||||
else
|
||||
$this->hydrogene = $this->cap;
|
||||
|
||||
$ressources = $this->production(time() - $this->timestamp_lastSilo);
|
||||
if ($this->hydrogene + $ressources[0] < $capnouv)
|
||||
$this->hydrogene += $ressources[0];
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[2] = true;
|
||||
$this->hydrogene = $capnouv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[2] = true;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
}
|
||||
|
||||
//Vérification de la date pour faire les actions journalières
|
||||
if (date('zya') != date('zya', $this->timestamp)) //Mise à jour trois fois par jour : 0h, 1h, 13h
|
||||
//if (date('zy') != date('zy', $this->timestamp)) //Mise à jour une fois par jour : 0h
|
||||
{
|
||||
//On évalue le moral
|
||||
$this->evalMoral($first);
|
||||
|
||||
//Si la population est à 0, on ajoute des habitants
|
||||
if ($this->population <= 0)
|
||||
$this->population = 1000;
|
||||
|
||||
$popPlus = $this->population * 0.0153^max(1, floor((time()-$this->timestamp)/86400));
|
||||
|
||||
if ($this->politique == 2)
|
||||
$popPlus *= 1.1; //Communisme : 10 % de population qui arrive en plus.
|
||||
elseif ($this->politique == 3)
|
||||
$popPlus *= 1.05; //Démocratie : 5 % de population qui arrive en plus.
|
||||
|
||||
if ($this->technologies[2] & 4)
|
||||
$popPlus *= 1.15;
|
||||
elseif ($this->technologies[2] & 2)
|
||||
$popPlus *= 1.10;
|
||||
elseif ($this->technologies[2] & 1)
|
||||
$popPlus *= 1.05;
|
||||
|
||||
$this->population += $popPlus;
|
||||
$this->addCredits(($this->population/100*exp(0.01)*25) + ($this->population*0.01*$this->batiments[15])); //Première partie : production normale; seconde : batiment commercial
|
||||
$this->addModif("population");
|
||||
}
|
||||
|
||||
$this->timestamp = time();
|
||||
}
|
||||
|
||||
function setMoral($difference)
|
||||
{
|
||||
$this->moral += $difference;
|
||||
|
||||
//Ajustement du moral
|
||||
if ($this->moral > 1)
|
||||
$this->moral = 1;
|
||||
elseif ($this->moral < 0)
|
||||
$this->moral = 0;
|
||||
|
||||
$this->addModif("moral");
|
||||
}
|
||||
|
||||
function evalMoral($first = false)
|
||||
{
|
||||
$evolution = array();
|
||||
//Cas de sous-production
|
||||
if (($this->coeff_bat[0] + $this->coeff_bat[1] + $this->coeff_bat[2])/3 < 0.9)
|
||||
{
|
||||
if ($this->politique == 2)
|
||||
$this->moral -= 0.10; //Communisme : démoralise 2x plus
|
||||
else
|
||||
$this->moral -= 0.05;
|
||||
|
||||
$this->addModif("moral");
|
||||
}
|
||||
|
||||
//Surpopulation
|
||||
|
||||
//Surlogement
|
||||
|
||||
//Effets des batiments loisirs et commerces
|
||||
$this->moral += 0.0025*$this->batiments[15] + 0.1*$this->batiments[16];
|
||||
|
||||
//Ajustement du moral en fonction de la politique
|
||||
if ($this->politique == 1 && $this->moral > 0.7)
|
||||
$this->moral = 0.7;
|
||||
|
||||
//On vérifie qu'on ne dépasse pas le maximum
|
||||
if ($this->moral > 1)
|
||||
$this->moral = 1;
|
||||
if ($this->moral < 0)
|
||||
$this->moral = 0;
|
||||
|
||||
//Isolement si besoin
|
||||
if ($this->moral < 0.1)
|
||||
{
|
||||
//On vérifie qu'il ne s'agit pas de la planète mère
|
||||
global $table_planete;
|
||||
$bdd = new Bdd();
|
||||
$bdd->reconnexion();
|
||||
$res = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($res['id'] != $this->id)
|
||||
{
|
||||
if ($this->moral <= 0.04)
|
||||
{
|
||||
if ($this->moral <= 0.01)
|
||||
$rand = rand(0,4);
|
||||
else
|
||||
$rand = rand(0,20);
|
||||
//Perte de la planète
|
||||
if ($rand == 1)
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("DELETE FROM $table_planete WHERE id = ".$this->id.";");
|
||||
$bdd->deconnexion();
|
||||
send_mp($this->id_user, 'Perte de contrôle de '.$this->nom_planete, "Suite à une démoralisation persistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a renversé votre gouvernement en tuant tous vos gouverneurs. Vous perdez donc définitivement le contrôle de cette planète.");
|
||||
if (!$first)
|
||||
{
|
||||
$sess->values['idPlan'] = $res['id'];
|
||||
erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révolté contre vous. Vous ne contrôlez plus cette planète.');
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($this->moral <= 0.1)
|
||||
{
|
||||
if ($this->moral <= 0.06)
|
||||
$rand = rand(0,2);
|
||||
else
|
||||
$rand = rand(0,10);
|
||||
//Perte de contrôle temporaire
|
||||
if ($rand == 1)
|
||||
{
|
||||
$debut = time() - rand(0, 3600)*4;
|
||||
$fin = $debut + 86400;
|
||||
$this->isolement = array($debut, $fin);
|
||||
$this->addModif("isolement");
|
||||
|
||||
send_mp($this->id_user, 'Perte de contrôle temporaire de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a pris le contrôle de votre planète. Vous perdez le contrôle de cette planète le temps que vos gouverneurs reprennent le pouvoir.");
|
||||
if (!$first)
|
||||
{
|
||||
$sess->values['idPlan'] = $res['id'];
|
||||
erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révoltée contre vous. Vous perdez temporairement le contrôle de cette planète.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndRetireRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
if ($this->metal >= $metal && $this->cristal >= $cristal && $this->hydrogene >= $hydrogene && $this->credits >= $credits)
|
||||
{
|
||||
$this->metal -= $metal;
|
||||
$this->cristal -= $cristal;
|
||||
$this->hydrogene -= $hydrogene;
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
$this->credits -= $credits;
|
||||
$this->addModifUser("credits");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function addRessources($metal, $cristal, $hydrogene, $credits = 0)
|
||||
{
|
||||
$perte = 0;
|
||||
|
||||
$this->metal += $metal;
|
||||
if ($this->metal > $this->cap)
|
||||
{
|
||||
$perte += $this->metal - $this->cap;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
|
||||
$this->cristal += $cristal;
|
||||
if ($this->cristal > $this->cap)
|
||||
{
|
||||
$perte += $this->cristal - $this->cap;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogene += $hydrogene;
|
||||
if ($this->hydrogene > $this->cap)
|
||||
{
|
||||
$perte += $this->hydrogene - $this->cap;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
$this->credits += $credits;
|
||||
$this->addModifUser("credits");
|
||||
}
|
||||
|
||||
return $perte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si la planète est isolée ou non
|
||||
*
|
||||
* @return boolean
|
||||
* @access public
|
||||
*/
|
||||
function isolement()
|
||||
{
|
||||
$return = false;
|
||||
|
||||
global $queryPlanetes;
|
||||
|
||||
//Détermination du numéro de la planète par rapport aux autres, dans l'ordre de colonisation
|
||||
$numP = 0;
|
||||
foreach ($queryPlanetes as $key => $p)
|
||||
{
|
||||
if ($p['id'] == $this->id)
|
||||
$numP = $key + 1;
|
||||
}
|
||||
|
||||
if ($numP >= 11)
|
||||
{
|
||||
if (!isset($this->isolement[0]) || (time() > $this->isolement[0] && (!isset($this->isolement[1]) || (time() > $this->isolement[1] && date('dmY') != date('dmY', $this->isolement[0])))))
|
||||
{
|
||||
switch($numP)
|
||||
{
|
||||
case 11:
|
||||
$tps = 2;
|
||||
break;
|
||||
case 12:
|
||||
$tps = 4;
|
||||
break;
|
||||
case 13:
|
||||
$tps = 6;
|
||||
break;
|
||||
case 14:
|
||||
$tps = 8;
|
||||
break;
|
||||
case 15:
|
||||
$tps = 12;
|
||||
break;
|
||||
case 16:
|
||||
$tps = 16;
|
||||
break;
|
||||
case 17:
|
||||
$tps = 20;
|
||||
break;
|
||||
default:
|
||||
$tps = 24;
|
||||
}
|
||||
$debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
|
||||
$fin = $debut + $tps * 3600;
|
||||
|
||||
$this->isolement[0] = $debut;
|
||||
if (time() > $this->isolement[0])
|
||||
$this->isolement[1] = $fin;
|
||||
$this->addModif("isolement");
|
||||
}
|
||||
if (isset($this->isolement[1]) && time() < $this->isolement[1])
|
||||
$return = true;
|
||||
}
|
||||
elseif (!isset($this->isolement[0]))
|
||||
{
|
||||
$this->isolement = array(0,0);
|
||||
$this->addModif("isolement");
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcul les ressources produites en fonction de $temps_ecoule
|
||||
* @param int $temps_ecoule Temps écoulé depuis la dernière actualisation
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
function production($temps_ecoule, $retarray = false)
|
||||
{
|
||||
//Accélération de la production
|
||||
$temps_ecoule *= VITESSE;
|
||||
|
||||
//Si l'on est en auto contrôle des mines, on fixe le rendement de la centrale solaire à 1
|
||||
if ($this->options& 8)
|
||||
{
|
||||
$this->coeff_bat[3] = 1;
|
||||
$this->coeff_bat[4] = 1;
|
||||
}
|
||||
|
||||
//Calcul de la consomation d'énergie
|
||||
if ($this->batiments[0] > 0)
|
||||
$energie_m = ceil(exp(0.28*$this->batiments[0])*10);
|
||||
else
|
||||
$energie_m = 0;
|
||||
if ($this->batiments[1] > 0)
|
||||
$energie_c = ceil(exp(0.28*$this->batiments[1])*10);
|
||||
else
|
||||
$energie_c = 0;
|
||||
if ($this->batiments[2] > 0)
|
||||
$energie_h = ceil(exp(0.2849*$this->batiments[2])*13);
|
||||
else
|
||||
$energie_h = 0;
|
||||
if ($this->batiments[3] > 0)
|
||||
$energie_s = ceil(exp(0.28*$this->batiments[3])*22);
|
||||
else
|
||||
$energie_s = 0;
|
||||
|
||||
$energie_f = 100 + $this->energieCentrale;
|
||||
|
||||
//Calcul de la consomation d'énergie
|
||||
$this->energieConso = $energie_m * $this->coeff_bat[0] + $energie_c * $this->coeff_bat[1] + $energie_h * $this->coeff_bat[2];
|
||||
$nrjmx = $energie_m + $energie_c + $energie_h;
|
||||
|
||||
//Calcul de la production d'énergie
|
||||
$this->energie = $energie_s * $this->coeff_bat[3] + $energie_f * $this->coeff_bat[4];
|
||||
|
||||
if ($this->energieConso == 0)
|
||||
$coeff = 0;
|
||||
else
|
||||
$coeff = $this->energie / $this->energieConso;
|
||||
|
||||
if ($coeff < 0)
|
||||
$coeff = 0;
|
||||
elseif ($coeff > 1 && !($this->options& 8))
|
||||
$coeff = 1;
|
||||
|
||||
$Ncoeff = array();
|
||||
for($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$Ncoeff[$i] = $coeff * $this->coeff_bat[$i];
|
||||
if ($Ncoeff[$i] > 1)
|
||||
$Ncoeff[$i] = 1;
|
||||
if ($Ncoeff[$i] < $this->coeff_bat[$i] || ($Ncoeff[$i] > $this->coeff_bat[$i] && $this->options& 16) && $this->batiments[$i] != 0)
|
||||
{
|
||||
$this->coeff_bat[$i] = $Ncoeff[$i];
|
||||
$this->addModif("coeff_bat");
|
||||
}
|
||||
}
|
||||
|
||||
//Calcul de la consomation d'hydrogène
|
||||
//if ($this->batiments[4] > 0)
|
||||
// $conso_h = ((ceil(pow(1.34,($this->batiments[4]-1))*9)/3600)*$temps_ecoule) * $this->coeff_bat[4];
|
||||
//else
|
||||
$conso_h = 0;
|
||||
|
||||
//Calcul des production de ressources
|
||||
if ($this->batiments[0] <= 0 || $this->batiments[3] <= 0)
|
||||
$prod_met = 0.011 * $temps_ecoule;
|
||||
else
|
||||
$prod_met = ((ceil(pow(1.1, $this->batiments[0]) * 52 * $this->batiments[0]) / 3600) * $temps_ecoule) * $this->coeff_bat[0];
|
||||
|
||||
if ($this->batiments[1] <= 0 || $this->batiments[3] <= 0)
|
||||
$prod_cri = 0.0055 * $temps_ecoule;
|
||||
else
|
||||
$prod_cri = ((ceil(pow(1.1, $this->batiments[1]) * 34 * $this->batiments[1]) / 3600) * $temps_ecoule) * $this->coeff_bat[1];
|
||||
|
||||
if ($this->batiments[2] <= 0)
|
||||
$prod_hy = 0;
|
||||
else
|
||||
$prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 21 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2];
|
||||
|
||||
$this->coeff_bat[3] = 1;
|
||||
//Augmentation de la production en fonction des technologies
|
||||
if ($this->technologies[0] &4)
|
||||
{
|
||||
$prod_met *= 1.15;
|
||||
$prod_cri *= 1.15;
|
||||
$prod_hy *= 1.15;
|
||||
}
|
||||
elseif ($this->technologies[0] &2)
|
||||
{
|
||||
$prod_met *= 1.10;
|
||||
$prod_cri *= 1.10;
|
||||
$prod_hy *= 1.10;
|
||||
}
|
||||
elseif ($this->technologies[0] &1)
|
||||
{
|
||||
$prod_met *= 1.05;
|
||||
$prod_cri *= 1.05;
|
||||
$prod_hy *= 1.05;
|
||||
}
|
||||
//Rendement métal
|
||||
if ($this->technologies[0] &64)
|
||||
$prod_met *= 1.3;
|
||||
elseif ($this->technologies[0] &32)
|
||||
$prod_met *= 1.2;
|
||||
elseif ($this->technologies[0] &16)
|
||||
$prod_met *= 1.1;
|
||||
//Rendemant cristal
|
||||
if ($this->technologies[0] &512)
|
||||
$prod_cri *= 1.3;
|
||||
elseif ($this->technologies[0] &256)
|
||||
$prod_cri *= 1.2;
|
||||
elseif ($this->technologies[0] &128)
|
||||
$prod_cri *= 1.1;
|
||||
//Rendement hydrogène
|
||||
if ($this->technologies[0] &4096)
|
||||
$prod_hy *= 1.3;
|
||||
elseif ($this->technologies[0] &2048)
|
||||
$prod_hy *= 1.2;
|
||||
elseif ($this->technologies[0] &1024)
|
||||
$prod_hy *= 1.1;
|
||||
|
||||
//Augmentation de la production en fonction du moral
|
||||
if ($this->moral > 0.9)
|
||||
{
|
||||
$prod_met *= 1.05;
|
||||
$prod_cri *= 1.05;
|
||||
$prod_hy *= 1.05;
|
||||
}
|
||||
elseif ($this->moral > 0.75)
|
||||
{
|
||||
$prod_met *= 1.02;
|
||||
$prod_cri *= 1.02;
|
||||
$prod_hy *= 1.02;
|
||||
}
|
||||
elseif ($this->moral < 0.45)
|
||||
{
|
||||
$prod_met *= 0.97;
|
||||
$prod_cri *= 0.97;
|
||||
$prod_hy *= 0.97;
|
||||
}
|
||||
elseif ($this->moral < 0.25)
|
||||
{
|
||||
$prod_met *= 0.94;
|
||||
$prod_cri *= 0.94;
|
||||
$prod_hy *= 0.94;
|
||||
}
|
||||
|
||||
//Augmentation de la production en fonction de la politique
|
||||
if ($this->politique == 2)
|
||||
{
|
||||
$prod_met *= 1.10;
|
||||
$prod_cri *= 1.10;
|
||||
$prod_hy *= 1.10;
|
||||
}
|
||||
|
||||
//On enlève la consomation d'hydrogène
|
||||
$prod_hy -= $conso_h;
|
||||
|
||||
if ($retarray)
|
||||
return array(array(ceil($this->coeff_bat[0]*100), ceil($this->coeff_bat[1]*100), ceil($this->coeff_bat[2]*100), ceil($this->coeff_bat[3]*100), ceil($this->coeff_bat[4]*100)), array($prod_met, $prod_cri, $prod_hy + $conso_h, $energie_s*$this->coeff_bat[3], $energie_f*$this->coeff_bat[4]), array($energie_m*$this->coeff_bat[0], $energie_c*$this->coeff_bat[1], $energie_h*$this->coeff_bat[2], $conso_h, ($energie_s*$this->coeff_bat[3] + $energie_f*$this->coeff_bat[4])-($energie_m*$this->coeff_bat[0] + $energie_c*$this->coeff_bat[1] + $energie_h*$this->coeff_bat[2])));
|
||||
else
|
||||
return array($prod_met, $prod_cri, $prod_hy);
|
||||
}
|
||||
|
||||
function creer($id_user, $mere = false)
|
||||
{
|
||||
global $VAR;
|
||||
//Définition des paramètres de l'utilisateur pour la planète
|
||||
$this->id_user = $id_user;
|
||||
|
||||
//Génération du nombre de case et de l'image en fonction de la position dans le système
|
||||
if ($mere)
|
||||
{
|
||||
$this->cases = 225;
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
elseif ($this->position > $VAR['nb_planete']*0.75)
|
||||
{
|
||||
$this->cases = mt_rand(200,255);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
elseif ($this->position > $VAR['nb_planete']/2)
|
||||
{
|
||||
$this->cases = mt_rand(250,300);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
elseif ($this->position > $VAR['nb_planete']/4)
|
||||
{
|
||||
$this->cases = mt_rand(175,260);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cases = mt_rand(150,220);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
|
||||
//Définition des principaux paramètres de la planète
|
||||
if ($mere)
|
||||
$this->nom_planete = 'Planète mère';
|
||||
else
|
||||
$this->nom_planete = 'Planète colonisée';
|
||||
|
||||
$this->metal = 1000;
|
||||
$this->cristal = 700;
|
||||
$this->hydrogene = 0;
|
||||
|
||||
$this->modif = array("id_user", "nom_planete", "galaxie", "ss", "position", "image", "cases");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (empty($this->ss) || empty($this->id_user))
|
||||
return;
|
||||
if (DEBUG)
|
||||
var_dump($this);
|
||||
|
||||
global $table_planete;
|
||||
if (empty($this->id))
|
||||
{
|
||||
$outNomChamps = array(); $outValeurs = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$modif[1]];
|
||||
$outValeurs[] = $this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
continue;
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$outNomChamps[] = $modif;
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$outValeurs[] = $this->{$modif};
|
||||
else
|
||||
$outValeurs[] = "'".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$outNomChamps[] = $modif;
|
||||
$outValeurs[] = "'$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
{
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$j];
|
||||
$outValeurs[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$bdd->query("INSERT INTO $table_planete (".implode(', ', $outNomChamps).", hash_planete) VALUES (".implode(', ', $outValeurs).", SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)))");
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : outNomChamps = ".serialize($outNomChamps)." ; outValeurs = ".serialize($outValeurs), 2);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (empty(${$calc.'VAR'}))
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
$out[] = "timestamp = timestamp";
|
||||
elseif (!is_array($this->{$modif}) && !is_object($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out[] = $modif." = ".$this->{$modif};
|
||||
else
|
||||
$out[] = $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_planete SET timestamp = ".time().", metal = ".$this->metal.", cristal = ".$this->cristal.", hydrogene = ".$this->hydrogene.", ".implode(', ', $out)." WHERE id = ".$this->id.";";
|
||||
if (DEBUG)
|
||||
echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out)." avec l'ID : ".$this->id, 2);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
403
onyx2/include/Class/rapport.php
Normal file
403
onyx2/include/Class/rapport.php
Normal file
|
|
@ -0,0 +1,403 @@
|
|||
<?php
|
||||
/**
|
||||
* Class Rapport
|
||||
*
|
||||
* Génération et envoie de rapport de mission de flotte
|
||||
*
|
||||
*/
|
||||
class Rapport
|
||||
{
|
||||
var $type = 0;
|
||||
var $var = array();
|
||||
var $utilA = 0;
|
||||
var $utilB = 0;
|
||||
var $timestamp = 0;
|
||||
|
||||
var $titreA = "";
|
||||
var $titreB = "";
|
||||
var $rapportA = "";
|
||||
var $rapportB = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @access protected
|
||||
*/
|
||||
function Rapport($type, $utilA, $utilB, $time)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->utilA = $utilA;
|
||||
$this->utilB = $utilB;
|
||||
$this->timestamp = $time;
|
||||
}
|
||||
|
||||
function addInfo($info, $id)
|
||||
{
|
||||
$this->var[$id] = $info;
|
||||
}
|
||||
|
||||
function sendRapport()
|
||||
{
|
||||
if (!empty($this->utilA) && !empty($this->rapportA))
|
||||
send_mp($this->utilA->id_user, $this->titreA, $this->rapportA, $this->timestamp);
|
||||
if (!empty($this->utilB) && !empty($this->rapportB))
|
||||
send_mp($this->utilB->id_user, $this->titreB, $this->rapportB, $this->timestamp);
|
||||
}
|
||||
|
||||
function send()
|
||||
{
|
||||
if ($this->type == '3')
|
||||
$this->sendCombat();
|
||||
elseif ($this->type == '1')
|
||||
$this->sendTransport();
|
||||
elseif ($this->type == '2')
|
||||
$this->sendColonisation();
|
||||
elseif ($this->type == '4')
|
||||
$this->sendRecyclage();
|
||||
elseif ($this->type == '5')
|
||||
$this->sendEspionnage();
|
||||
elseif ($this->type == '6')
|
||||
$this->sendAlliance();
|
||||
elseif ($this->type == '7')
|
||||
$this->sendAlliance2();
|
||||
}
|
||||
|
||||
function sendEspionnage()
|
||||
{
|
||||
global $LANG;
|
||||
|
||||
//Différentiation entre les planètes et les astéroides
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$this->titreA = "Rapport d'espionnage de ".$this->var[0]->nom_asteroide." [".$this->var[0]->galaxie.":".$this->var[0]->ss.":A".$this->var[0]->position."]";
|
||||
$this->rapportA = "<strong>Espionnage de ".$this->var[0]->pseudo." sur ".$this->var[0]->nom_asteroide."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":A".$this->var[0]->position."]</strong><br /><br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->titreA = "Rapport d'espionnage de ".$this->var[0]->nom_planete." [".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."]";
|
||||
$this->rapportA = "<strong>Espionnage de ".$this->var[0]->pseudo." sur ".$this->var[0]->nom_planete."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."]</strong><br /><br />";
|
||||
}
|
||||
|
||||
if ($this->var[2] < 1)
|
||||
$this->rapportA .= "<em>Nos sondes n'ont pas pu récolter d'informations sur cette planète.</em>";
|
||||
else {
|
||||
//Ressources
|
||||
if ($this->var[2] > 1)
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th colspan=\"2\">Ressources sur la planète :</th></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["metal"]." :</td><td>".$this->var[0]->metal."</td></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["cristal"]." :</td><td>".$this->var[0]->cristal."</td></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["hydrogene"]." :</td><td>".$this->var[0]->hydrogene."</td></tr></table><br />";
|
||||
|
||||
//Bâtiments
|
||||
if ($this->var[2] > 2)
|
||||
{
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Niveau</th><th>Bâtiment</th></tr>";
|
||||
foreach ($this->var[0]->batiments as $key => $batiment)
|
||||
{
|
||||
$this->rapportA .= "<tr><td>".rand($batiment * (1 - $this->var[1]), $batiment * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["batiments"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
|
||||
//Flottes en orbite
|
||||
if ($this->var[2] > 3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Flottes au sol
|
||||
if ($this->var[2] > 5)
|
||||
{
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Nombre</th><th>Vaisseaux</th></tr>";
|
||||
foreach ($this->var[0]->vaisseaux as $key => $vaisseau)
|
||||
{
|
||||
$this->rapportA .= "<tr><td>".rand($vaisseau * (1 - $this->var[1]), $vaisseau * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["vaisseaux"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
|
||||
//Défenses
|
||||
if ($this->var[2] > 4)
|
||||
{
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Nombre</th><th>Défenses</th></tr>";
|
||||
foreach ($this->var[0]->terrestres as $key => $unite)
|
||||
{
|
||||
if (!dTerrestre::type($key)) $this->rapportA .= "<tr><td>".rand($unite * (1 - $this->var[1]), $unite * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["terrestre"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->var[3] >= 1)
|
||||
{
|
||||
$this->titreB = "Rapport de contre-espionnage";
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
$this->rapportB = "Nous venons d'apprendre que notre planète : ".$this->var[0]->nom_asteroide."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":A] a été la cible d'un espionnage de la part de ".$this->utilA->pseudo;
|
||||
else
|
||||
$this->rapportB = "Nous venons d'apprendre que notre planète : ".$this->var[0]->nom_planete."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."] a été la cible d'un espionnage de la part de ".$this->utilA->pseudo;
|
||||
}
|
||||
$this->rapportA = $this->rapportA;
|
||||
}
|
||||
|
||||
function sendTransport()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$this->rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
$this->rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$this->rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
$this->rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($this->rapportA);
|
||||
$db->escape($this->rapportB);
|
||||
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$this->rapportA', '$temps');");
|
||||
if ($this->utilA->id_user != $this->utilB->id_user) $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user.", '$titre', '$this->rapportB', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendColonisation()
|
||||
{
|
||||
$titre = 'Colonisation de ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].']';
|
||||
if (is_numeric($this->var[0][2]))
|
||||
{
|
||||
if ($this->var[1])
|
||||
$rapport = 'Votre vaisseau a atteint la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
else
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->var[1])
|
||||
$rapport = 'Votre vaisseau a atteint l\'astéroide ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
else
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendRecyclage()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendCombat(){
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
$this->rapportA = new Smarty();
|
||||
$this->rapportB = new Smarty();
|
||||
|
||||
$this->rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->rapportB->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportB->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportB->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportB->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->var[4]['pseudo'] = trouvNom($this->var[4]['id_user']);
|
||||
$this->var[5]['pseudo'] = trouvNom($this->var[5]['id_user']);
|
||||
|
||||
$this->rapportA->assign('tour', $this->var[3]);
|
||||
$this->rapportA->assign('EN', $this->var[4]);
|
||||
$this->rapportA->assign('flotte', $this->var[5]);
|
||||
$this->rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportA->assign('defenses1', $this->var[2]);
|
||||
$this->rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportA->assign('defenses2', $this->var[9]);
|
||||
|
||||
$this->rapportA->assign('termine', $this->var[6][0]);
|
||||
$this->rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportA->assign('pillage', $this->var[11]);
|
||||
|
||||
$this->rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportA->assign('defBC', $defense_bc);
|
||||
$this->rapportA->assign('defPV', $defense_pv);
|
||||
$this->rapportA->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('ressources', $ressourc);
|
||||
$this->rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportA->assign('nomdefEN', $nomterra);
|
||||
|
||||
$this->rapportA = $this->rapportA->fetch('game/ATrapport_combat.tpl');
|
||||
|
||||
|
||||
$this->rapportB->assign('tour', $this->var[3]);
|
||||
$this->rapportB->assign('EN', $this->var[4]);
|
||||
$this->rapportB->assign('flotte', $this->var[5]);
|
||||
$this->rapportB->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportB->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportB->assign('defenses1', $this->var[2]);
|
||||
$this->rapportB->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportB->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportB->assign('defenses2', $this->var[9]);
|
||||
|
||||
$this->rapportB->assign('termine', $this->var[6][0]);
|
||||
$this->rapportB->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportB->assign('matchnul', $this->var[6][2]);
|
||||
$this->rapportB->assign('pillage', $this->var[11]);
|
||||
|
||||
$this->rapportB->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportB->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportB->assign('defBC', $defense_bc);
|
||||
$this->rapportB->assign('defPV', $defense_pv);
|
||||
$this->rapportB->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportB->assign('ressources', $ressourc);
|
||||
$this->rapportB->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportB->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportB->assign('nomdefEN', $nomterra);
|
||||
|
||||
$this->rapportB = $this->rapportB->fetch('game/ENrapport_combat.tpl');
|
||||
|
||||
|
||||
$this->titreA = 'Combat contre '.$this->var[4]['pseudo'];
|
||||
$this->titreB = 'Combat contre '.$this->var[5]['pseudo'];
|
||||
$temps = $this->timestamp;
|
||||
$db = new bdd();
|
||||
$db->connexion();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->titreB);
|
||||
$db->escape($this->rapportA);
|
||||
$db->escape($this->rapportB);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user."', '$this->titreB', '$this->rapportB', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function show(){
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
$this->rapportA = new Smarty();
|
||||
|
||||
$this->rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->rapportA->assign('tour', $this->var[3]);
|
||||
$this->rapportA->assign('EN', $this->var[4]);
|
||||
$this->rapportA->assign('flotte', $this->var[5]);
|
||||
$this->rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportA->assign('defenses1', $this->var[2]);
|
||||
$this->rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportA->assign('defenses2', $this->var[9]);
|
||||
|
||||
$this->rapportA->assign('termine', $this->var[6][0]);
|
||||
$this->rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportA->assign('pillage', $this->var[11]);
|
||||
$this->rapportA->assign('debris', $this->var[12]);
|
||||
$this->rapportA->assign('infoPLUS', $this->var[14]);
|
||||
//$this->rapportA->assign('infoPLUS2', $this->var[15]);
|
||||
|
||||
$this->rapportA->assign('page', 'simulation');
|
||||
$this->rapportA->assign('enligne', $this->var[13][0]);
|
||||
$this->rapportA->assign('infos', $this->var[13][1]);
|
||||
$this->rapportA->assign('nbinfos', $this->var[13][2]);
|
||||
$this->rapportA->assign('count', $this->var[13][3]);
|
||||
$this->rapportA->assign('version', $this->var[13][4]);
|
||||
$this->rapportA->assign('tpsdejeu', $this->var[13][5]);
|
||||
|
||||
$this->rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportA->assign('defBC', $defense_bc);
|
||||
$this->rapportA->assign('defPV', $defense_pv);
|
||||
$this->rapportA->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('ressources', $ressourc);
|
||||
$this->rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
$this->rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportA->assign('nomdefEN', $nomterra);
|
||||
$this->rapportA->assign('race', $race);
|
||||
|
||||
return $this->rapportA->fetch('game/SIMrapport_combat.tpl');
|
||||
return $this->rapportA;
|
||||
}
|
||||
|
||||
function sendAlliance()
|
||||
{
|
||||
$this->titreA = 'Déclaration officielle de votre alliance !';
|
||||
$this->rapportA = 'Félicitations, votre alliance a recueilli suffisament de signature, sa déclaration est maintenant officielle !<br /><br />Vous pouvez dès maintenant administrer votre alliance en vous rendant sur la page Alliance.';
|
||||
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendAlliance2()
|
||||
{
|
||||
$this->titreA = 'Fondation de votre alliance !';
|
||||
$this->rapportA = 'Pour terminer la création de votre alliance, trouvez 4 joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature : <a href="?p=alliances&q=signer&i='.$this->var[0].'">http://'.$_SERVER['HTTP_HOST'].'/?p=alliances&q=signer&i='.$this->var[0].'</a>';
|
||||
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
onyx2/include/Class/surface.php
Normal file
43
onyx2/include/Class/surface.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
include_once("Class/user.php");
|
||||
/***************************************************************************
|
||||
* class.SURFACE.php
|
||||
* -------------------
|
||||
* begin : Jeudi 21 août 2008
|
||||
* update : Dimanche 8 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class SURFACE extends User
|
||||
{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$image,
|
||||
$debris_met,
|
||||
$debris_cri,
|
||||
$metal,
|
||||
$cristal,
|
||||
$hydrogene,
|
||||
$alert_ressources = array(false, false, false),
|
||||
$timestamp,
|
||||
$file_bat,
|
||||
$file_vais,
|
||||
$isolement = false,
|
||||
$batiments = array(),
|
||||
$vaisseaux = array(),
|
||||
$modif = array();
|
||||
|
||||
function isolement()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function addModif($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modif))
|
||||
$this->modif[] = $modif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
47
onyx2/include/Class/tinyplanete.php
Normal file
47
onyx2/include/Class/tinyplanete.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
class TinyPlanete{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$position,
|
||||
$nom_planete;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_planete;
|
||||
$bdd = new bdd();
|
||||
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de la planète
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
trigger_error('Erreur #04 : Format de recherche de planete incorrect !', E_USER_ERROR);
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $plan["id"];
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->position = $plan["position"];
|
||||
$this->nom_planete = $plan["nom_planete"];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
//Gestion des dépendances
|
||||
include_once("game/Class/class.tinyasteroide.php");
|
||||
include_once("Class/tinyasteroide.php");
|
||||
|
||||
/***************************************************************************
|
||||
* class.user.php
|
||||
|
|
@ -15,6 +15,7 @@ class User{
|
|||
var $id_user,
|
||||
$pseudo,
|
||||
$auth_level,
|
||||
$options,
|
||||
$race,
|
||||
$alliance,
|
||||
$id_alliance,
|
||||
|
|
@ -55,6 +56,7 @@ class User{
|
|||
$this->pseudo = $user["pseudo"];
|
||||
$this->auth_level = $user["auth_level"];
|
||||
$this->race = $user["race"];
|
||||
$this->options = intval($user["options"]);
|
||||
$this->mv = $user["mv"];
|
||||
$this->id_alliance = $user["id_alliance"];
|
||||
$this->id_grade_alliance = $user["id_grade_alliance"];
|
||||
|
|
@ -74,7 +76,7 @@ class User{
|
|||
$this->combatDE_tactique = $user["combatDE_tactique"];
|
||||
|
||||
foreach($technologiesVAR as $tech){
|
||||
$this->technologies[] = $user[$tech];
|
||||
$this->technologies[] = intval($user[$tech]);
|
||||
}
|
||||
|
||||
//Si l'ID d'alliance est défini, on charge l'alliance
|
||||
|
|
@ -86,33 +88,61 @@ class User{
|
|||
}
|
||||
|
||||
function loadPermissions($fondateur = 0)
|
||||
{
|
||||
if ($fondateur == $this->id_user)
|
||||
$this->permissions_alliance = 1023;
|
||||
else
|
||||
{
|
||||
if ($fondateur == $this->id_user)
|
||||
$this->permissions_alliance = 1023;
|
||||
else
|
||||
{
|
||||
global $table_alliances_grade;
|
||||
$bdd = new BDD();
|
||||
$grade = $bdd->unique_query("SELECT * FROM $table_alliances_grade WHERE id = ".$this->id_grade_alliance.";");
|
||||
$bdd->deconnexion();
|
||||
global $table_alliances_grade;
|
||||
$bdd = new BDD();
|
||||
$grade = $bdd->unique_query("SELECT * FROM $table_alliances_grade WHERE id = ".$this->id_grade_alliance.";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$this->permissions_alliance = intval($grade['auth']);
|
||||
}
|
||||
$this->permissions_alliance = intval($grade['auth']);
|
||||
}
|
||||
}
|
||||
|
||||
function addPoints($metal, $cristal, $hydrogene, $credits = 0, $demolition = false)
|
||||
{
|
||||
global $table_bourse_ressources;
|
||||
//On charge les 3 valeurs boursières
|
||||
$bdd = new BDD();
|
||||
$bourse = $bdd->query("SELECT dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
//TODO Equivalence non prouvée entre $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7); et $credits/bourse_calcPrixBase($bourse[0]["dispo"], 1) * 0.7; dans le but de ne donner que 70% des points
|
||||
$metal += $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7);
|
||||
$cristal += $credits/bourse_calcPrixBase($bourse[1]["dispo"], 0.7);
|
||||
$hydrogene += $credits/bourse_calcPrixBase($bourse[2]["dispo"], 0.7);
|
||||
}
|
||||
|
||||
$points = bourse_calcPrixBase($bourse[0]["dispo"], $metal);
|
||||
$points += bourse_calcPrixBase($bourse[1]["dispo"], $cristal);
|
||||
$points += bourse_calcPrixBase($bourse[2]["dispo"], $hydrogene);
|
||||
|
||||
if ($demolition)
|
||||
$this->points -= intval($points);
|
||||
else
|
||||
$this->points += intval($points);
|
||||
|
||||
$this->addModifUser("points");
|
||||
}
|
||||
|
||||
function addCredits($credits)
|
||||
{
|
||||
$this->credits += $credits;
|
||||
$this->addModifUser("credits");
|
||||
{
|
||||
$this->credits += $credits;
|
||||
$this->addModifUser("credits");
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function addModifUser($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifUser))
|
||||
$this->modifUser[] = $modif;
|
||||
}
|
||||
{
|
||||
if (!in_array($modif, $this->modifUser))
|
||||
$this->modifUser[] = $modif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
|
|
@ -121,56 +151,59 @@ class User{
|
|||
* @access public
|
||||
*/
|
||||
function __destruct(){
|
||||
global $var___db, $config, $table_user;
|
||||
global $table_user;
|
||||
$out = array();
|
||||
$bdd = new bdd();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modifUser as $key => $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
if ($modif == "force")
|
||||
$out[] = " ";
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) $out[] .= $modif." = ".$this->{$modif};
|
||||
else $out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ereg('file', $modif))
|
||||
{
|
||||
$prep = implode(';', $this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] .= $modif." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif == "batiments")
|
||||
$calc = "batiment";
|
||||
elseif ($modif == "technologies")
|
||||
$calc = "technologies";
|
||||
elseif ($modif == "casernes")
|
||||
$calc = "casernen";
|
||||
elseif ($modif == "terrestres")
|
||||
$calc = "nomterrn";
|
||||
elseif ($modif == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (empty(${$calc.'VAR'}))
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
|
||||
$nombr = count(${$calc.'VAR'});
|
||||
for($j = 0; $j < $nombr; $j++){
|
||||
$bdd->escape($this->{$modif}[$j]);
|
||||
$out[] .= ${$calc.'VAR'}[$j]." = ".$this->{$modif}[$j];
|
||||
}
|
||||
}
|
||||
}
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
$out[] = " ";
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) $out[] .= $modif." = ".$this->{$modif};
|
||||
else $out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_user SET ".implode(', ', $out)." WHERE id = ".$this->id_user.";";
|
||||
if (DEBUG) echo '<br /><br />'.$sql;
|
||||
if (DEBUG)
|
||||
echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out)." avec l'ID ".$this->id_user, 2);
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
if (!empty($_POST["req"]))
|
||||
$req = gpc("req", "post");
|
||||
$req = stripslashes(gpc("req", "post"));
|
||||
elseif (!empty($_GET["req"]))
|
||||
$req = gpc("req");
|
||||
else
|
||||
|
|
|
|||
|
|
@ -12,7 +12,17 @@ if (!empty($_POST["HB_pseudo"]) && !empty($_POST["race"]))
|
|||
{
|
||||
$_POST['HB_mdp'] = cxor(gpc("HB_mdp", "post"), sha1(gpc("HB_pseudo", "post").'£'.gpc("race", "post")));
|
||||
$cds = sha1(gpc("HB_pseudo", "post").'$'.gpc("race", "post").'£'.gpc("HB_mdp", "post").'#'.gpc("HB_mail", "post").'ß'.time().'Ó'.$_SERVER['HTTP_USER_AGENT'].'♀☻'.$_SERVER['REMOTE_ADDR'].gpc("HB_placement", "post"));
|
||||
erreur('MDP: <em>'.gpc("HB_conf", "post").'</em><br />URL : <a href="?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds.'">Lien</a><br /><br />L\'inscription doit avoir lieu par vous même en raison des procédures de sécurités !', "white");
|
||||
if (empty($_POST['mailler']))
|
||||
erreur('MDP: <em>'.gpc("HB_conf", "post").'</em><br />URL : <a href="?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds.'">Lien</a><br /><br />L\'inscription doit avoir lieu par vous même en raison des procédures de sécurités !', "white");
|
||||
else
|
||||
{
|
||||
if (send_mail(gpc("HB_mail", "post"), "Halo-Battle :: Inscription sur le serveur ".$VAR['serveur_name'], "Bonjour ".gpc("HB_pseudo", "post")." et bienvenue dans l'univers d'Halo-Battle !\n\nNous sommes ravi de vous annoncer qu'un opérateur vient de vous créer un compte sur le serveur ".$VAR['serveur_name'].".\n\nVoici le mot de passe qui vous servira à vous connecter à ce serveur : ".gpc("HB_conf", "post")."\n\nA bientôt,\nLe staff de Halo-Battle"))
|
||||
{
|
||||
|
||||
}
|
||||
header('Location: admin.php?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
erreur('Mot de passe incorrect !');
|
||||
|
|
|
|||
|
|
@ -10,17 +10,22 @@ if (empty($page) || !is_numeric($page))
|
|||
|
||||
$act = gpc('act');
|
||||
if ($act == 'multiok')
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$user = intval(gpc('util'));
|
||||
$bdd->query("UPDATE $table_user SET multi = '1' WHERE id = ".$user.";");
|
||||
$bdd->deconnexion();
|
||||
unset($user);
|
||||
}
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$user = intval(gpc('util'));
|
||||
$bdd->query("UPDATE $table_user SET multi = '1' WHERE id = ".$user.";");
|
||||
$bdd->deconnexion();
|
||||
unset($user);
|
||||
}
|
||||
|
||||
$trace = 'absent pour plus de rapidité';
|
||||
|
||||
$bdd = new BDD();
|
||||
if (isset($_GET['ip']))
|
||||
{
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE ip = '".gpc('ip')."' ORDER BY ip ASC;");
|
||||
$trace = gethostbyaddr($req[0]['ip']);
|
||||
}
|
||||
elseif (isset($_GET['util']) && isset($_GET['comp']))
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = ".intval(gpc('util'))." OR id_util = ".intval(gpc('comp'))." ORDER BY ip ASC;");
|
||||
elseif (isset($_GET['util']))
|
||||
|
|
@ -36,19 +41,19 @@ $bdd->deconnexion();
|
|||
$anc = array('ip' => 0, 'id_util' => 0);
|
||||
$tableau = array();
|
||||
foreach($req as $resultat)
|
||||
{
|
||||
if ($resultat['mv'] == 3)
|
||||
$color = 'DFBF00';
|
||||
elseif ($resultat['multi'] == 1 && $anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util'])
|
||||
$color = 'EE66EE';
|
||||
elseif ($anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util'])
|
||||
$color = 'FF0000';
|
||||
else
|
||||
$color = false;
|
||||
{
|
||||
if ($resultat['mv'] == 3)
|
||||
$color = 'DFBF00';
|
||||
elseif ($resultat['multi'] == 1 && $anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util'])
|
||||
$color = 'EE66EE';
|
||||
elseif ($anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util'])
|
||||
$color = 'FF0000';
|
||||
else
|
||||
$color = false;
|
||||
|
||||
$tableau[] = array($resultat['ip'], 'absent pour plus de rapidité'/*gethostbyaddr($resultat['ip'])*/, $resultat['id_util'], $resultat['pseudo'], $resultat['time'], $resultat['mv'], $color);
|
||||
$anc = $resultat;
|
||||
}
|
||||
$tableau[] = array($resultat['ip'], $trace, $resultat['id_util'], $resultat['pseudo'], $resultat['time'], $resultat['mv'], $color);
|
||||
$anc = $resultat;
|
||||
}
|
||||
$template->assign('ips', $tableau);
|
||||
$template->assign('numpage', $page);
|
||||
$template->assign('nbpage', floor($nbpage['nb']/75));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
if (empty($sess->values["connected"]) && !defined("xCSRF"))
|
||||
define("xCSRF", true);
|
||||
|
|
@ -18,39 +19,41 @@ $SESS = new Session();
|
|||
//Extraction des données en cache pour le header, sinon création du cache
|
||||
$header = Cache::read("headerNB");
|
||||
if (empty($header))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
{
|
||||
$bdd = new BDD();
|
||||
|
||||
$nbcovie = $bdd->unique_query("SELECT COUNT(id) AS covenants FROM $table_user WHERE race = 'covenant';");
|
||||
$nbhumain = $bdd->unique_query("SELECT COUNT(id) AS humains FROM $table_user WHERE race = 'humain';");
|
||||
$enligne = $bdd->unique_query("SELECT COUNT(session) AS enligne FROM sessions WHERE active = true AND var != '0';");
|
||||
$infos = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id DESC;");
|
||||
$msgdem = $bdd->unique_query("SELECT titre FROM $table_messages_demarrage ORDER BY id DESC LIMIT 1;");
|
||||
$nbcovie = $bdd->unique_query("SELECT COUNT(id) AS covenants FROM $table_user WHERE race = 'covenant';");
|
||||
$nbhumain = $bdd->unique_query("SELECT COUNT(id) AS humains FROM $table_user WHERE race = 'humain';");
|
||||
$enligne = $bdd->unique_query("SELECT COUNT(session) AS enligne FROM sessions WHERE active = true AND var != '0';");
|
||||
$infos = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id DESC;");
|
||||
$msgdem = $bdd->unique_query("SELECT titre FROM $table_messages_demarrage ORDER BY id DESC LIMIT 1;");
|
||||
|
||||
$bdd->deconnexion();
|
||||
$bdd->deconnexion();
|
||||
|
||||
Cache::set("headerNB", array("count" => array($nbcovie["covenants"], $nbhumain["humains"], "cette", $enligne["enligne"]), "infos" => $infos, "messagedemarrage" => $msgdem["titre"]));
|
||||
unset($nbcovie, $nbhumain, $enligne, $infos, $msgdem, $bdd);
|
||||
Cache::set("headerNB", array("count" => array($nbcovie["covenants"], $nbhumain["humains"], "cette", $enligne["enligne"]), "infos" => $infos, "messagedemarrage" => $msgdem["titre"]));
|
||||
unset($nbcovie, $nbhumain, $enligne, $infos, $msgdem, $bdd);
|
||||
|
||||
$header = Cache::read("headerNB");
|
||||
}
|
||||
$header = Cache::read("headerNB");
|
||||
}
|
||||
$template->assign("header", $header);
|
||||
$template->assign("version", $VAR["version"]);
|
||||
$template->assign("serveur_name", $VAR["serveur_name"]);
|
||||
$template->assign("first_page", $VAR["first_page"]);
|
||||
$template->assign("LANG", $LANG);
|
||||
|
||||
define("VITESSE", $VAR["vitesse"]);
|
||||
define("debut_d_univers", true); //Constante pour savoir si l'on offre ou pas un vaisseau de colonisation et s'il est possible de se désangager d'une signature
|
||||
define("nb_signatures", 4);
|
||||
|
||||
//Si l'on est pas connecté, on garde le header pour comparer lors de la connexion
|
||||
if (!empty($sess->values["connected"]))
|
||||
unset($header);
|
||||
|
||||
//Evite les attaques CSRF
|
||||
//TODO remplacer les ereg par des preg !
|
||||
if (!empty($_SERVER["HTTP_REFERER"]) && !ereg(time()."http://".$_SERVER['HTTP_HOST'], time().$_SERVER["HTTP_REFERER"]) && !defined("xCSRF"))
|
||||
{
|
||||
elog("Possibilité d'attaque CSRF\n".var_export($_REQUEST, TRUE), 2);
|
||||
unset($_POST, $_GET);
|
||||
$_GET = $_POST = array();
|
||||
}
|
||||
if (!empty($_SERVER["HTTP_REFERER"]) && !(preg_match('#^http://'.$_SERVER['HTTP_HOST'].'#', $_SERVER["HTTP_REFERER"]) && defined("xCSRF")))
|
||||
{
|
||||
elog("Possibilité d'attaque CSRF\n".var_export($_REQUEST, TRUE), 2);
|
||||
unset($_POST, $_GET);
|
||||
$_GET = $_POST = array();
|
||||
}
|
||||
?>
|
||||
33
onyx2/include/donnees.php
Normal file
33
onyx2/include/donnees.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
if (!defined('INDEX') || INDEX != 2)
|
||||
{
|
||||
//On inclut les classes de données
|
||||
require_once("Class/Donnees/interface.php");
|
||||
require_once("Class/Donnees/alliances_batiments.php");
|
||||
require_once("Class/Donnees/batiments.php");
|
||||
require_once("Class/Donnees/caserne.php");
|
||||
require_once("Class/Donnees/technologies.php");
|
||||
require_once("Class/Donnees/terrestre.php");
|
||||
require_once("Class/Donnees/spatial.php");
|
||||
|
||||
//On inclut les classes de file d'attente
|
||||
require_once("Class/File/interface.php");
|
||||
require_once("Class/File/alliances_batiments.php");
|
||||
require_once("Class/File/batiments.php");
|
||||
require_once("Class/File/caserne.php");
|
||||
require_once("Class/File/technologies.php");
|
||||
require_once("Class/File/terrestre.php");
|
||||
require_once("Class/File/spatial.php");
|
||||
}
|
||||
|
||||
//On déffinit les constantes de correspondance Champs/Array
|
||||
$alli_batimentsVAR = array("centre", "port", "forge", "urgence", "propagande", "economie");
|
||||
$technologiesVAR = array("techno_indu", "techno_inge", "techno_inge2", "techno_poli", "techno_arme", "techno_defe", "techno_defe2", "techno_proj", "techno_expansion");
|
||||
$batimentsVAR = array("mine_m", "mine_c", "mine_h", "centrale_s", "centrale_f", "radar", "labo", "chantier_terrestre", "chantier_spatial", "caserne", "silo", "centre_info", "habitation", "arcologies", "bunker", "stations", "commercial", "loisir", "administration");
|
||||
$caserneVAR = array("soldat1", "soldat2", "soldat3", "soldat4", "sniper", "spartan", "medecin", "ingenieur", "soldat_lourd");
|
||||
$spatialVAR = array("vaisseau_1", "vaisseau_2", "vaisseau_3", "vaisseau_4", "vaisseau_5", "vaisseau_6", "vaisseau_7", "vaisseau_8", "vaisseau_9", "vaisseau_10", "vaisseau_11", "vaisseau_12", "vaisseau_13", "vaisseau_14");
|
||||
$terrestreVAR = array("vais_0", "vais_1", "vais_2", "vais_3", "vcl_1", "vcl_2", "vcl_3", "vcl_4", "def_1", "def_2", "def_3", "def_4", "def_5", "def_6", "def_7", "def_8");
|
||||
$coeffVAR = array("coeff_mine_m", "coeff_mine_c", "coeff_mine_h", "coeff_centrale_s", "coeff_centrale_f");
|
||||
?>
|
||||
|
|
@ -5,8 +5,10 @@ $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).";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($flottes) {
|
||||
foreach($flottes as $flotte) {
|
||||
if (!empty($flottes))
|
||||
{
|
||||
foreach($flottes as $flotte)
|
||||
{
|
||||
$flotte = new Flotte($flotte['id']);
|
||||
$flotte->check_mission();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,10 +173,11 @@ function erreur($message, $color = "red", $lien = "", $temps = 2500)
|
|||
exit;
|
||||
}
|
||||
|
||||
function send_mp($joueur, $titre, $message, $type = 0, $emetteur = 0)
|
||||
function send_mp($joueur, $titre, $message, $temps = 0, $emetteur = 0, $type = 0)
|
||||
{
|
||||
global $table_mail, $bdd, $VAR;
|
||||
$temps = time();
|
||||
global $table_mail, $VAR;
|
||||
if (empty($temps))
|
||||
$temps = time();
|
||||
$mail = false;
|
||||
if (!is_numeric($joueur))
|
||||
{
|
||||
|
|
@ -205,7 +206,7 @@ function send_mp($joueur, $titre, $message, $type = 0, $emetteur = 0)
|
|||
}
|
||||
if (!empty($joueur))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($joueur);
|
||||
$bdd->escape($titre);
|
||||
$bdd->escape($message);
|
||||
|
|
@ -213,7 +214,12 @@ function send_mp($joueur, $titre, $message, $type = 0, $emetteur = 0)
|
|||
$bdd->deconnexion();
|
||||
|
||||
if ($mail)
|
||||
send_mail($mail, "Halo-Battle :: Nouveau message privé", 'Bonjour,\n\nVous recevez ce courriel suite à l\'arrivée d\'un nouveau message privé reçu sur votre compte de jeu du serveur '.$VAR['serveur_name'].'. Le sujet de ce message est : "'.$titre.'". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://'.$_SERVER['HTTP_HOST'].'/'.$VAR['first_page'].'?p=messagerie\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l\'onglet "notifications"\n\nA bientôt dans Halo-Battle,\nLe Staff');
|
||||
{
|
||||
if ($emetteur == 0)
|
||||
send_mail($mail, "Halo-Battle :: Nouveau rapport", "Bonjour,\n\nVous recevez ce courriel suite à l'arrivée d'un nouveau rapport reçu sur votre compte de jeu du serveur ".$VAR['serveur_name'].". Le rapport concerne : \"".$titre."\". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://".$_SERVER['HTTP_HOST']."/".$VAR["first_page"].$VAR["menu"]["messages"]."&n=recus\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l'onglet \"notifications\"\n\nA bientôt dans Halo-Battle,\nLe Staff");
|
||||
else
|
||||
send_mail($mail, "Halo-Battle :: Nouveau message privé", "Bonjour,\n\nVous recevez ce courriel suite à l'arrivée d'un nouveau message privé reçu sur votre compte de jeu du serveur ".$VAR['serveur_name'].". Le sujet de ce message est : \"".$titre."\". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://".$_SERVER['HTTP_HOST']."/".$VAR["first_page"].$VAR["menu"]["messages"]."&n=recus\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l'onglet \"notifications\"\n\nA bientôt dans Halo-Battle,\nLe Staff");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,337 +0,0 @@
|
|||
<?php
|
||||
include_once("game/Class/class.surface.php");
|
||||
/***************************************************************************
|
||||
* class.asteroide.php
|
||||
* ---------------------
|
||||
* begin : Jeudi 25 décembre 2008
|
||||
* update : Dimanche 4 janvier 2008
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Asteroide extends Surface
|
||||
{
|
||||
var $fondateur,
|
||||
$sante,
|
||||
$nom_alliance,
|
||||
$tag,
|
||||
$wing,
|
||||
$nom_asteroide,
|
||||
$image_asteroide,
|
||||
$position = 5,
|
||||
$cap = 123456789,
|
||||
$credits_alliance,
|
||||
$url_chat,
|
||||
$url_forum,
|
||||
$details = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function Asteroide($id = 0)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $table_alliances, $SESS;
|
||||
global $alli_batimentVAR, $nomvaisnVAR;
|
||||
$bdd = new bdd();
|
||||
|
||||
//On traite le cas où l'on envoie les coordonnées
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):?[Aa]?\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
die('Erreur #04 : Format de recherche d\'asteroide incorrect !');
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
$this->id = $plan["id"];
|
||||
parent::User($SESS->values['id']); //On utilise le numéro d'utilisateur enregistré en session
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->nom_asteroide = $plan["nom_asteroide"];
|
||||
$this->image = $this->image_asteroide = $plan["image_asteroide"];
|
||||
$this->debris_met = $plan["debris_met"];
|
||||
$this->debris_cri = $plan["debris_cri"];
|
||||
$this->metal = $plan["metal"];
|
||||
$this->cristal = $plan["cristal"];
|
||||
$this->hydrogene = $plan["hydrogene"];
|
||||
$this->credits_alliance = $plan["credits_alliance"];
|
||||
$this->fondateur = $plan["fondateur"];
|
||||
$this->nom_alliance = $plan["nom_alliance"];
|
||||
$this->wing = $plan["wing"];
|
||||
$this->tag = $plan["tag"];
|
||||
$this->url_forum = $plan["url_forum"];
|
||||
$this->url_chat = $plan["url_chat"];
|
||||
|
||||
foreach($alli_batimentVAR as $bat)
|
||||
$this->batiments[] = $plan[$bat];
|
||||
if (!empty($plan["file_bat"]))
|
||||
$this->file_bat = unserialize($plan["file_bat"]);
|
||||
else
|
||||
$this->file_bat = new File('alli_batiments');
|
||||
|
||||
foreach($nomvaisnVAR as $vais)
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
if (!empty($plan["file_vais"]))
|
||||
$this->file_vais = unserialize($plan["file_vais"]);
|
||||
else
|
||||
$this->file_vais = new File('vaisseaux');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadDetails()
|
||||
{
|
||||
global $table_alliances;
|
||||
$bdd = new bdd();
|
||||
$this->details = $bdd->unique_query("SELECT presentation, message_inscription, texte_interne, port_chat, chan_chat, image, etat_inscription, defcon, defcon_txt FROM $table_alliances WHERE id = ".$this->id.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
function actualiser($actuFile = true, $first = false)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile)
|
||||
{
|
||||
$this->file_bat->batiment_ready($this);
|
||||
$this->file_vais->vaisseaux_ready($this);
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndRetireRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
if ($this->metal >= $metal && $this->cristal >= $cristal && $this->hydrogene >= $hydrogene && $this->credits_alliance >= $credits)
|
||||
{
|
||||
$this->metal -= $metal;
|
||||
$this->cristal -= $cristal;
|
||||
$this->hydrogene -= $hydrogene;
|
||||
$this->credits -= $credits;
|
||||
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function addRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
$perte = 0;
|
||||
|
||||
$this->metal += $metal;
|
||||
if ($this->metal > $this->cap)
|
||||
{
|
||||
$perte += $this->metal - $this->cap;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
|
||||
$this->cristal += $cristal;
|
||||
if ($this->cristal > $this->cap)
|
||||
{
|
||||
$perte += $this->cristal - $this->cap;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogene += $hydrogene;
|
||||
if ($this->hydrogene > $this->cap)
|
||||
{
|
||||
$perte += $this->hydrogene - $this->cap;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogecredits_alliancene += $credits;
|
||||
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
return $perte;
|
||||
}
|
||||
|
||||
function addCreditsAlliance($credits)
|
||||
{
|
||||
$this->credits_alliance += $credits;
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function creer($fondateur, $mere = false)
|
||||
{
|
||||
global $VAR, $table_alliances_creation;
|
||||
|
||||
$bdd = new BDD();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$fondateur->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
//On vérifie que l'alliance n'a pas déjà été créée
|
||||
if (empty($alliance))
|
||||
return 1;
|
||||
|
||||
//Définition des paramètres de l'utilisateur pour l'astéroide
|
||||
$this->fondateur = $alliance["fondateur"];
|
||||
$this->race = $fondateur->race;
|
||||
|
||||
//Génération du nombre de case et de l'image en fonction de la position dans le système
|
||||
$this->sante = 1;
|
||||
$this->nom_alliance = $alliance["nom_alliance"];
|
||||
$this->tag = $alliance["tag"];
|
||||
$this->nom_asteroide = $alliance["nom_alliance"];
|
||||
$this->image_asteroide = mt_rand(1,3);
|
||||
|
||||
$this->modif = array("fondateur", "race", "nom_alliance", "galaxie", "ss", "tag", "nom_asteroide", "image_asteroide");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (empty($this->ss) || empty($this->fondateur))
|
||||
return;
|
||||
|
||||
global $table_alliances;
|
||||
if (empty($this->id))
|
||||
{
|
||||
$out1 = array(); $out2 = array();
|
||||
$bdd = new bdd();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
if ($modif == "force")
|
||||
continue;
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$out1[] = $modif;
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out2[] = $this->{$modif};
|
||||
else
|
||||
$out2[] = "'".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out1[] = $modif;
|
||||
$out2[] = "'$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif == "batiments")
|
||||
$calc = "batiment";
|
||||
elseif ($modif == "technologies")
|
||||
$calc = "technolo";
|
||||
elseif ($modif == "casernes")
|
||||
$calc = "casernen";
|
||||
elseif ($modif == "terrestres")
|
||||
$calc = "nomterrn";
|
||||
elseif ($modif == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
elseif ($modif == "coeff_bat")
|
||||
$calc = "coeff";
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
{
|
||||
$out1[] = ${$calc.'VAR'}[$j];
|
||||
$out2[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$bdd->query("INSERT INTO $table_alliances (".implode(', ', $out1).") VALUES (".implode(', ', $out2).")");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$nb = count($this->modif);
|
||||
$out = array();
|
||||
$bdd = new bdd();
|
||||
for($i = 0; $i < $nb; $i++)
|
||||
{
|
||||
if ($this->modif[$i] == "force")
|
||||
$out[] = "metal = ".$this->metal.", cristal = ".$this->cristal.", hydrogene = ".$this->hydrogene;
|
||||
elseif ($this->modif[$i] == 'technologies')
|
||||
$this->modifUser[] = $this->modif[$i];
|
||||
elseif (is_object($this->{$this->modif[$i]}))
|
||||
{
|
||||
$export = serialize($this->{$this->modif[$i]});
|
||||
$bdd->escape($export);
|
||||
$out[] = $this->modif[$i]." = '".$export."'";
|
||||
}
|
||||
elseif (!is_array($this->{$this->modif[$i]}))
|
||||
{
|
||||
$bdd->escape($this->{$this->modif[$i]});
|
||||
if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]}))
|
||||
$out[] = $this->modif[$i]." = ".$this->{$this->modif[$i]};
|
||||
else
|
||||
$out[] = $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$this->modif[$i]}) && $this->modif[$i] != "coeff_bat" && $this->modif[$i] != "vaisseaux" && $this->modif[$i] != "terrestres" && $this->modif[$i] != "casernes" && $this->modif[$i] != "technologies" && $this->modif[$i] != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$this->modif[$i]});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $this->modif[$i]." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->modif[$i] == "batiments")
|
||||
$calc = "alli_batiment";
|
||||
elseif ($this->modif[$i] == "technologies")
|
||||
$calc = "technolo";
|
||||
elseif ($this->modif[$i] == "casernes")
|
||||
$calc = "casernen";
|
||||
elseif ($this->modif[$i] == "terrestres")
|
||||
$calc = "nomterrn";
|
||||
elseif ($this->modif[$i] == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
elseif ($this->modif[$i] == "coeff_bat")
|
||||
$calc = "coeff";
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
$nombr = count(${$calc.'VAR'});
|
||||
for($j = 0; $j < $nombr; $j++)
|
||||
{
|
||||
$bdd->escape($this->{$this->modif[$i]}[$j]);
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_alliances SET ".implode(', ', $out)." WHERE id = ".$this->id.";";
|
||||
if (DEBUG) echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,128 +0,0 @@
|
|||
<?php
|
||||
/***************************************************************************
|
||||
* class.exceptionHB.php
|
||||
* -----------------------
|
||||
* begin : Lundi 9 février 2009
|
||||
* update : Vendredi 27 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
class ExceptionHB extends Exception {
|
||||
|
||||
public function __construct($branche, $code = 0, $debug = true, $gerer = false) {
|
||||
if ($gerer)
|
||||
parent::__construct($branche, $code);
|
||||
else
|
||||
{
|
||||
if (is_numeric($branche))
|
||||
{
|
||||
switch($branche)
|
||||
{
|
||||
case 1:
|
||||
switch($code)
|
||||
{
|
||||
case 0:
|
||||
$message = "La planète est pleine, vous ne pouvez plus construire de batiment dessus !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de batiments.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour construire ce bâtiment.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Le bâtiment dont vous demandez la construction est actuellement en démolition. Annulez la démolition pour lui ajouter l'aggrandir.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour construire ce bâtiment !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la construction de ce bâtiment, il n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démolir ce batiment, il n'est pas encore construit !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Le bâtiment dont vous demandez la démolition est actuellement en travaux. Annulez les travaux en cours pour pouvoir le démolir.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch($code)
|
||||
{
|
||||
case 0:
|
||||
$message = "Cette technologie est déjà en file d'attente, soyez patient !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de technologies.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Vous possédez déjà cette technologie !";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les crédits ou ressources nécessaires pour rechercher cette technologie !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvée dans la file !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch($code)
|
||||
{
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus d'unités.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour entraîner ces unités.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "L'unité dont vous demandez l'entraînement est actuellement en démentellement. Annulez le démentellement pour l'entraîner de nouveau.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour entraîner cette unité !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler l'entraînement de cette unité, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démenteler autant d'unités !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "L'unité dont vous demandez le démentellement est actuellement en entraînement. Annulez l'entraînement en cours pour pouvoir la démenteller.";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$message = "Dépassement de capacité.<br />Vous ne pouvez pas demander la construction d'autant d'unités en même temps.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
$message = $branche;
|
||||
|
||||
if ($debug || empty($message))
|
||||
$message = "Erreur #".intval($branche)."/".$code." :<br />".$message;
|
||||
|
||||
global $template, $page;
|
||||
if (!empty($page))
|
||||
$template->assign('page', $page);
|
||||
$template->assign('message', $message);
|
||||
$template->assign('couleur', 'red');
|
||||
$template->display('game/erreur.tpl');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,832 +0,0 @@
|
|||
<?php
|
||||
include_once("game/Class/class.rapport.php");
|
||||
/***************************************************************************
|
||||
* class.flotte.php
|
||||
* ------------------
|
||||
* begin : Samedi 20 septembre 2008
|
||||
* update : Samedi 20 septembre 2008
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Flotte
|
||||
{
|
||||
var $id_flotte = 0,
|
||||
$nom,
|
||||
$start_planete,
|
||||
$start_time,
|
||||
$start_type,
|
||||
$end_planete,
|
||||
$end_time,
|
||||
$end_type,
|
||||
$ret_planete,
|
||||
$ret_type,
|
||||
$ret_time,
|
||||
$nb_vais,
|
||||
$vaisseaux = array(),
|
||||
$tactique = 0,
|
||||
$mission,
|
||||
$vitesse,
|
||||
$statut = 0,
|
||||
$last,
|
||||
$contenu = array(0,0,0),
|
||||
$contenuMax = 0,
|
||||
$modifFlotte = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la flotte à importer
|
||||
* @param bool $verrou Booléen disant si la classe doit obtenir préalablement un verrou pour la flotte.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id = 0, $verrou = true)
|
||||
{
|
||||
if (!empty($id))
|
||||
{
|
||||
global $table_flottes;
|
||||
global $nomvaisnVAR, $ressoVAR;
|
||||
|
||||
$id = intval($id);
|
||||
$bdd = new BDD();
|
||||
$flotte = $bdd->unique_query("SELECT * FROM $table_flottes WHERE id = $id;");
|
||||
if ($verrou)
|
||||
$bdd->query("UPDATE $table_flottes SET last = ".time()." WHERE id = $id;"); //Obtention d'un vérrou de 10 seconde sur la flotte
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($flotte))
|
||||
{
|
||||
$this->id_flotte = $flotte["id"];
|
||||
$this->nom = $flotte["nom"];
|
||||
$this->start_planete = $flotte["start_planete"];
|
||||
$this->start_type = $flotte["start_type"];
|
||||
$this->start_time = $flotte["start_time"];
|
||||
$this->end_planete = $flotte["end_planete"];
|
||||
$this->end_type = $flotte["end_type"];
|
||||
$this->end_time = $flotte["end_time"];
|
||||
$this->ret_planete = $flotte["ret_planete"];
|
||||
$this->ret_type = $flotte["ret_type"];
|
||||
$this->ret_time = $flotte["ret_time"];
|
||||
$this->tactique = $flotte["tactique"];
|
||||
$this->mission = $flotte["mission"];
|
||||
$this->vitesse = $flotte["vitesse"];
|
||||
$this->statut = $flotte["statut"];
|
||||
$this->last = $flotte["last"];
|
||||
$this->nb_vais = $flotte["nb_vais"];
|
||||
|
||||
foreach($nomvaisnVAR as $vais)
|
||||
$this->vaisseaux[] = $flotte[$vais];
|
||||
|
||||
$this->contenu = array($flotte["contenu_metal"], $flotte["contenu_cristal"], $flotte["contenu_hydrogene"]);
|
||||
|
||||
$this->calculer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function calculer()
|
||||
{
|
||||
global $nomvais_rs;
|
||||
|
||||
$this->nb_vais = 0;
|
||||
|
||||
//Calcul de la capacité maximale d'embarquement de la flotte
|
||||
foreach($this->vaisseaux as $key => $vais)
|
||||
{
|
||||
$this->nb_vais += $vais;
|
||||
$this->contenuMax += $nomvais_rs[$key] * $vais;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function load_planete()
|
||||
{
|
||||
if (!empty($this->start_planete) && is_numeric($this->start_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fournis
|
||||
if ($this->start_type == 0)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->start_planete)
|
||||
$this->start_planete = $planete;
|
||||
else
|
||||
$this->start_planete = new Planete($this->start_planete);
|
||||
}
|
||||
elseif ($this->start_type == 2)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->start_planete)
|
||||
$this->start_planete = $planete;
|
||||
else
|
||||
$this->start_planete = new Asteroide($this->start_planete);
|
||||
}
|
||||
}
|
||||
if (!empty($this->end_planete) && is_numeric($this->end_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fournis
|
||||
if ($this->end_type == 0 || $this->ret_type == 1)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->end_planete)
|
||||
$this->end_planete = $planete;
|
||||
else
|
||||
$this->end_planete = new Planete($this->end_planete);
|
||||
}
|
||||
elseif ($this->end_type == 2)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->end_planete)
|
||||
$this->end_planete = $planete;
|
||||
else
|
||||
$this->end_planete = new Asteroide($this->end_planete);
|
||||
}
|
||||
}
|
||||
if (!empty($this->ret_planete) && is_numeric($this->ret_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fournis
|
||||
if ($this->ret_type == 0)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->ret_planete)
|
||||
$this->ret_planete = $planete;
|
||||
else
|
||||
$this->ret_planete = new Planete($this->ret_planete);
|
||||
}
|
||||
elseif ($this->ret_type == 2)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->ret_planete)
|
||||
$this->ret_planete = $planete;
|
||||
else
|
||||
$this->ret_planete = new Asteroide($this->ret_planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function creer(Surface $start_planete, $tableau, $resultat)
|
||||
{
|
||||
$sauv = $start_planete->vaisseaux; //Sauvegarde les vaisseaux de la planète avant le lancement
|
||||
foreach ($tableau['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
$this->vaisseaux[$key] = $vaisseau;
|
||||
$sauv[$key] -= $vaisseau;
|
||||
|
||||
if ($sauv[$key] < 0)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//Définition des paramètres de la flotte en fonction des données enregistrées en session
|
||||
$this->nom = $tableau["nom"];
|
||||
$this->vitesse = $tableau["vitesse"];
|
||||
$this->mission = $tableau["mission"];
|
||||
$this->start_planete = $start_planete;
|
||||
if (SURFACE == "planete")
|
||||
$this->start_type = 0;
|
||||
elseif (SURFACE == "asteroide")
|
||||
$this->start_type = 2;
|
||||
$this->start_time = time();
|
||||
|
||||
//On traite le cas des planètes qui n'existent pas (dans le cas de la mission colonisation)
|
||||
if ($tableau["mission"] == 2)
|
||||
{
|
||||
//On traite le cas des colonisation d'astéroïdes
|
||||
if ($tableau["end_position"] == "A")
|
||||
$this->end_type = 3;
|
||||
else
|
||||
$this->end_type = 1;
|
||||
|
||||
$this->end_planete = $tableau["end_galaxie"].':'.$tableau["end_systeme"].':'.$tableau["end_position"];
|
||||
}
|
||||
//On traite le cas des envoie vers les alliances
|
||||
elseif ($tableau["end_position"] == "A")
|
||||
{
|
||||
$this->end_type = 2;
|
||||
$this->end_planete = $resultat['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->end_type = 0;
|
||||
$this->end_planete = $resultat['id'];
|
||||
}
|
||||
|
||||
if (empty($this->end_planete))
|
||||
erreur("Planète d'arriver incorrecte !");
|
||||
|
||||
//On vérifie qu'il y a assez de place dans les cales des vaisseaux avant l'envoie ainsi que de ressources sur la planète
|
||||
$this->calculer();
|
||||
|
||||
$calc = Flotte::calc_deplacement($start_planete, $tableau["end_galaxie"], $tableau["end_systeme"], $tableau["end_position"], $tableau["vitesse"]/100, $tableau["vaisseaux"], $this->contenuMax - $tableau["embarquer"][0] - $tableau["embarquer"][1] - $tableau["embarquer"][2], false, true);
|
||||
|
||||
$this->end_time = $calc[0];
|
||||
//On double la consomation si on fait un aller-retour
|
||||
if ($tableau["mission"] == 1 || $tableau["mission"] == 2 || $tableau["mission"] == 4 || $tableau["mission"] == 5)
|
||||
$calc[1] *= 2;
|
||||
|
||||
if ($this->contenuMax < $tableau["embarquer"][0] + $tableau["embarquer"][1] + $tableau["embarquer"][2] + $calc[1])
|
||||
erreur('Vous ne pouvez pas embarquer autant de ressources, les cales débordent. '.$this->contenuMax, "red", '?p=flotte', 3500);
|
||||
elseif ($start_planete->metal < $tableau["embarquer"][0] || $start_planete->cristal < $tableau["embarquer"][1] || $start_planete->hydrogene < $tableau["embarquer"][2] + $calc[1])
|
||||
erreur('Vous n\'avez pas assez de ressources sur cette planète pour envoyer cette flotte.', "red", '?p=flotte', 3500);
|
||||
|
||||
$this->contenu = $tableau["embarquer"];
|
||||
$this->modifFlotte = "INSERT";
|
||||
|
||||
//On actualise la planète
|
||||
$start_planete->metal -= $tableau["embarquer"][0];
|
||||
$start_planete->cristal -= $tableau["embarquer"][1];
|
||||
$start_planete->hydrogene -= floor($tableau["embarquer"][2] + $calc[1]);
|
||||
$start_planete->vaisseaux = $sauv;
|
||||
$start_planete->addModif("vaisseaux");
|
||||
$start_planete->addModif("force");
|
||||
}
|
||||
|
||||
static function calc_deplacement($start_planete, $end_galaxie, $end_systeme, $end_position, $vitesse, $vaisseaux, $contenuDispo, $returnArray = false, $returnConso = false)
|
||||
{
|
||||
global $VAR, $nomvais_vitesseP, $nomvais_vitesseS, $nomvais_vitesseG, $nomvais_rs;
|
||||
|
||||
//Calcul de la longueur du déplacement
|
||||
$diff_galaxie = abs($start_planete->galaxie - $end_galaxie);
|
||||
$diff_systeme = abs($start_planete->ss - $end_systeme);
|
||||
$diff_position = abs($start_planete->position - $end_position);
|
||||
|
||||
$diff_centre_position_start = abs(ceil($VAR['nb_amas']/2) - $start_planete->position);
|
||||
$diff_centre_systeme_start = abs(ceil($VAR['nb_systeme']/2) - $start_planete->ss);
|
||||
|
||||
$diff_centre_position_end = abs(ceil($VAR['nb_amas']/2) - $end_position);
|
||||
$diff_centre_systeme_end = abs(ceil($VAR['nb_systeme']/2) - $end_systeme);
|
||||
|
||||
//Calcul du temps de déplacement pour chaque vaisseau
|
||||
$temps = array(); $conso = array(0, 0, 0);
|
||||
foreach($vaisseaux as $key => $vais)
|
||||
{
|
||||
//S'il n'y a pas de vaisseaux de ce type, on ne calcul pas leur vitesse
|
||||
if ($vais == 0)
|
||||
continue;
|
||||
|
||||
//Calcul du temps de déplacement entre planètes
|
||||
if ($start_planete->ss == $end_systeme && $start_planete->galaxie == $end_galaxie)
|
||||
{
|
||||
$temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * $diff_position);
|
||||
$temps[1][$key] = $temps[2][$key] = 0;
|
||||
}
|
||||
//Calcul du temps de déplacement entre système
|
||||
elseif ($start_planete->galaxie == $end_galaxie)
|
||||
{
|
||||
$temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
|
||||
$temps[1][$key] = (20/$nomvais_vitesseS[$key]) * (2 + 1 * $diff_systeme);
|
||||
$temps[2][$key] = 0;
|
||||
}
|
||||
//Calcul du temps de déplacement entre galaxies
|
||||
else
|
||||
{
|
||||
$temps[0][$key] = (10/$nomvais_vitesseP[$key]) * (1 + 0.1 * ($diff_centre_position_start + $diff_centre_position_end));
|
||||
$temps[1][$key] = (20/$nomvais_vitesseS[$key]) * (2 + 1 * ($diff_centre_systeme_start + $diff_centre_systeme_end));
|
||||
$temps[2][$key] = (50/$nomvais_vitesseG[$key]) * (2 + 1.5 * $diff_galaxie);
|
||||
}
|
||||
|
||||
//Calcul du bonus pour le réacteur à combustion
|
||||
$techR = $start_planete->technologies[1];
|
||||
if ($techR & 56)
|
||||
$bonus = 0.7;
|
||||
elseif ($techR & 24)
|
||||
$bonus = 0.8;
|
||||
elseif ($techR & 8)
|
||||
$bonus = 0.9;
|
||||
else
|
||||
$bonus = 1;
|
||||
$temps[0][$key] *= $bonus * 1/$vitesse;
|
||||
$conso[0] += $vais * $temps[0][$key] * $bonus / exp($vitesse/5);
|
||||
|
||||
//Calcul du bonus pour le réacteur à fusion
|
||||
$techR = $start_planete->technologies[1];
|
||||
if ($techR &448)
|
||||
$bonus = 0.7;
|
||||
elseif ($techR &192)
|
||||
$bonus = 0.8;
|
||||
elseif ($techR &64)
|
||||
$bonus = 0.9;
|
||||
else
|
||||
$bonus = 1;
|
||||
$temps[1][$key] *= $bonus * 1/$vitesse;
|
||||
$conso[1] += $vais * $temps[1][$key] * $bonus / exp($vitesse/7.5);
|
||||
|
||||
//Calcul du bonus pour le réacteur à fusion de type II
|
||||
$techR = $start_planete->technologies[1];
|
||||
if ($techR &3584)
|
||||
$bonus = 0.7;
|
||||
elseif ($techR &1536)
|
||||
$bonus = 0.8;
|
||||
elseif ($techR &512)
|
||||
$bonus = 0.9;
|
||||
else
|
||||
$bonus = 1;
|
||||
$temps[2][$key] *= $bonus * 1/$vitesse;
|
||||
$conso[2] += $vais * $temps[2][$key] * $bonus / exp($vitesse/10);
|
||||
}
|
||||
|
||||
if (!isset($vaisseaux[4]))
|
||||
$vaisseaux[4] = 0;
|
||||
if (!isset($vaisseaux[5]))
|
||||
$vaisseaux[5] = 0;
|
||||
|
||||
//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] * $nomvais_rs[4] + $vaisseaux[5] * $nomvais_rs[5]) >= ($vaisseaux[4] + $vaisseaux[5]) * 200)
|
||||
$temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
|
||||
|
||||
//On calcul le temps de déplacement maximal
|
||||
if ($returnArray)
|
||||
return $temps;
|
||||
elseif ($returnConso)
|
||||
return array(max($temps[0]) + max($temps[1]) + max($temps[2]), ceil($conso[0]+$conso[1]+$conso[2]));
|
||||
else
|
||||
return (max($temps[0]) + max($temps[1]) + max($temps[2]));
|
||||
}
|
||||
|
||||
|
||||
function check_mission()
|
||||
{
|
||||
//On vérifie qu'un calcul ne soit pas déjà en cours
|
||||
if ($this->last >= time() - 10)
|
||||
return false;
|
||||
elseif ($this->start_time + $this->end_time > time())
|
||||
return false;
|
||||
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
switch($this->mission)
|
||||
{
|
||||
case 6:
|
||||
case 7:
|
||||
$this->stationner();
|
||||
break;
|
||||
case 1:
|
||||
$this->transporter();
|
||||
break;
|
||||
case 2:
|
||||
$this->coloniser();
|
||||
break;
|
||||
case 3:
|
||||
$this->attaquer();
|
||||
break;
|
||||
case 4:
|
||||
$this->recycler();
|
||||
break;
|
||||
case 5:
|
||||
$this->espionner();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->statut == 1 && ($this->ret_time > time() || $this->start_time + $this->end_time * 2 <= time()))
|
||||
$this->retourner();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function stationner()
|
||||
{
|
||||
//On décharge les ressources éventuellement contenue
|
||||
$this->decharger();
|
||||
|
||||
//On fait atterir les vaisseaux
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
$this->end_planete->vaisseaux[$key] += $vais;
|
||||
|
||||
if (!in_array("vaisseaux", $this->end_planete->modif))
|
||||
$this->end_planete->modif[] = "vaisseaux";
|
||||
$this->modifFlotte = "DELETE";
|
||||
}
|
||||
|
||||
|
||||
function transporter()
|
||||
{
|
||||
$max = $this->decharger();
|
||||
|
||||
//Envoie du MP de confirmation au joueur
|
||||
$send = new Rapport(2, $this->start_planete, $this->end_planete, $this->start_time + $this->end_time);
|
||||
$send->addInfo($this->end_planete, 0);
|
||||
$send->addInfo($max, 1);
|
||||
$send->sendTransport();
|
||||
|
||||
$this->statut = 1;
|
||||
$this->addModifFlotte("statut");
|
||||
}
|
||||
|
||||
|
||||
function coloniser()
|
||||
{
|
||||
//On vérifie que les coordonnées de la planètes sont bien enregistrée
|
||||
if (empty($this->end_planete) || is_object($this->end_planete) || !preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([A0-9]{1,2})\]?$#', $this->end_planete))
|
||||
{
|
||||
$this->load_planete();
|
||||
file_log("Erreur de colonisation de la planète : ".$this->end_planete." pour le joueur : ".$this->start_planete->id_user, 2);
|
||||
send_mp($this->start_planete->id_user, "Erreur de colonisation [F#01]", "Une erreur s'est produite lors de la tentative de colonisation de votre flotte, elle a fait demi-tour.");
|
||||
$this->rappeler();
|
||||
}
|
||||
|
||||
//On vérifie que la planète ne soit pas déjà colonisée
|
||||
global $table_planete, $table_alliances, $table_alliances_creation, $table_user;
|
||||
preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([A0-9]{1,2})\]?$#', $this->end_planete, $position);
|
||||
if (is_numeric($position[3]))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$p = $bdd->query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$p = $bdd->query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
$this->load_planete();
|
||||
|
||||
if ($p)
|
||||
{
|
||||
$rapport = new Rapport(2, $this->start_planete, 0, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo(array($position[1], $position[2], $position[3]), 0);
|
||||
$rapport->addInfo(false, 1);
|
||||
$rapport->send();
|
||||
|
||||
$this->statut = 1;
|
||||
$this->addModifFlotte("statut");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_numeric($position[3]))
|
||||
{
|
||||
//On crée la planète
|
||||
$this->end_planete = new Planete(false);
|
||||
$this->end_planete->galaxie = $position[1];
|
||||
$this->end_planete->ss = $position[2];
|
||||
$this->end_planete->position = $position[3];
|
||||
$this->end_planete->creer($this->start_planete->id_user);
|
||||
|
||||
//On définit la limite de ressources pour permettre le déchargement de celles contenues dans les vaisseaux
|
||||
$this->end_planete->cap = 100000;
|
||||
}
|
||||
else
|
||||
{
|
||||
//On crée l'astéroide
|
||||
$this->end_planete = new Asteroide(false);
|
||||
$this->end_planete->galaxie = $position[1];
|
||||
$this->end_planete->ss = $position[2];
|
||||
$this->end_planete->creer($this->start_planete);
|
||||
}
|
||||
|
||||
//Rembousement du carburant non utilisé (la colonisation prévois au départ un allé/retour)
|
||||
$conso = $this->calc_deplacement($this->start_planete, $position[1], $position[2], $position[3], $this->vitesse, $this->vaisseaux, 0, false, true);
|
||||
$this->end_planete->hydrogene += $conso[1];
|
||||
|
||||
//On enlève un vaisseau de colonisation de la liste
|
||||
$this->vaisseaux[2]--;
|
||||
|
||||
//On fait atterir les vaisseaux et décharger les ressources
|
||||
$this->decharger();
|
||||
$this->atterir();
|
||||
|
||||
//On envoie un rapport
|
||||
$rapport = new Rapport(2, $this->start_planete, 0, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo(array($position[1], $position[2], $position[3]), 0);
|
||||
$rapport->addInfo(true, 1);
|
||||
$rapport->send();
|
||||
|
||||
if (!is_numeric($position[3]))
|
||||
{
|
||||
unset($this->end_planete);
|
||||
$bdd = new BDD();
|
||||
$alliance = $bdd->unique_query("SELECT signatures FROM $table_alliances_creation WHERE fondateur = ".$this->start_planete->id_user.";");
|
||||
$p = $bdd->unique_query("SELECT id FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND fondateur = ".$this->start_planete->id_user.";");
|
||||
$signaturesExport = implode(' OR id = ', explode(';', substr($alliance["signatures"], 1), -1));
|
||||
print "UPDATE $table_user SET alliance = '".$p['id']."' WHERE id = $signaturesExport OR id = ".$this->start_planete->id_user.";";
|
||||
$bdd->query("UPDATE $table_user SET id_alliance = '".$p['id']."' WHERE id = $signaturesExport OR id = ".$this->start_planete->id_user.";");
|
||||
//$bdd->query("DELETE FROM $table_alliances_creation WHERE fondateur = ".$this->start_planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function recycler()
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->end_planete))
|
||||
$this->load_planete();
|
||||
|
||||
$coeff = ($this->contenuMax - $this->contenu[0] - $this->contenu[1] - $this->contenu[2])/($this->end_planete->debris_met + $this->end_planete->debris_cri);
|
||||
if ($coeff > 1)
|
||||
$coeff = 1;
|
||||
|
||||
$a = floor($this->end_planete->debris_met * $coeff);
|
||||
$b = floor($this->end_planete->debris_cri * $coeff);
|
||||
|
||||
$this->contenu[0] += $a;
|
||||
$this->contenu[1] += $b;
|
||||
if (!in_array('contenu', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'contenu';
|
||||
|
||||
$this->end_planete->debris_met -= $a;
|
||||
$this->end_planete->debris_cri -= $b;
|
||||
if (!in_array('debris_met', $this->end_planete->modif))
|
||||
$this->end_planete->modif[] = 'debris_met';
|
||||
if (!in_array('debris_cri', $this->end_planete->modif))
|
||||
$this->end_planete->modif[] = 'debris_cri';
|
||||
|
||||
//Send link
|
||||
$rapport = new Rapport(4, $this->start_planete, 0, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo($this->end_planete, 0);
|
||||
$rapport->addInfo(array($a, $b), 1);
|
||||
$rapport->send();
|
||||
|
||||
$this->statut = 1;
|
||||
if (!in_array('statut', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'statut';
|
||||
}
|
||||
|
||||
|
||||
function espionner()
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->end_planete))
|
||||
$this->load_planete();
|
||||
|
||||
//Extraction des niveaux technologique des deux adversaires
|
||||
if (($this->start_planete->technologies[1]& 67108864) == 67108864)
|
||||
$espionnage_A = 3;
|
||||
elseif (($this->start_planete->technologies[1]& 33554432) == 33554432)
|
||||
$espionnage_A = 3;
|
||||
elseif (($this->start_planete->technologies[1]& 16777216) == 16777216)
|
||||
$espionnage_A = 3;
|
||||
else
|
||||
$espionnage_A = 0;
|
||||
if (($this->start_planete->technologies[1]& 536870912) == 536870912)
|
||||
$contreespionnage_B = 3;
|
||||
elseif (($this->start_planete->technologies[1]& 268435456) == 268435456)
|
||||
$contreespionnage_B = 2;
|
||||
elseif (($this->start_planete->technologies[1]& 134217728) == 134217728)
|
||||
$contreespionnage_B = 1;
|
||||
else
|
||||
$contreespionnage_B = 0;
|
||||
|
||||
//Création du rapport
|
||||
$rapport = new Rapport(5, $this->start_planete, $this->end_planete, $this->start_time + $this->end_time);
|
||||
$rapport->addInfo($this->end_planete, 0);
|
||||
$rapport->addInfo($contreespionnage_B/$espionnage_A/10, 1);
|
||||
$rapport->addInfo($espionnage_A+2-$contreespionnage_B+1, 2);
|
||||
$rapport->addInfo($contreespionnage_B, 3);
|
||||
$rapport->send();
|
||||
|
||||
$this->statut = 1;
|
||||
$this->addModifFlotte("statut");
|
||||
}
|
||||
|
||||
|
||||
function decharger($plan = "end_planete")
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->$plan))
|
||||
$this->load_planete();
|
||||
$max = array(0, 0, 0);
|
||||
|
||||
//Si on dépasse les capacités, on laisse les ressources en trop dans le cargo
|
||||
if ($this->$plan->metal + $this->contenu[0] > $this->$plan->cap)
|
||||
{
|
||||
$max[0] = $this->$plan->cap - $this->$plan->metal;
|
||||
if ($max[0] < 0) $max[0] = 0;
|
||||
}
|
||||
else
|
||||
$max[0] = $this->contenu[0];
|
||||
$this->$plan->metal += $max[0];
|
||||
$this->contenu[0] -= $max[0];
|
||||
|
||||
if ($this->$plan->cristal + $this->contenu[1] > $this->$plan->cap)
|
||||
{
|
||||
$max[1] = $this->$plan->cap - $this->$plan->cristal;
|
||||
if ($max[1] < 0) $max[1] = 0;
|
||||
}
|
||||
else
|
||||
$max[1] = $this->contenu[1];
|
||||
$this->$plan->cristal += $max[1];
|
||||
$this->contenu[1] -= $max[1];
|
||||
|
||||
if ($this->$plan->hydrogene + $this->contenu[2] > $this->$plan->cap)
|
||||
{
|
||||
$max[2] = $this->$plan->cap - $this->$plan->hydrogene;
|
||||
if ($max[2] < 0) $max[2] = 0;
|
||||
}
|
||||
else
|
||||
$max[2] = $this->contenu[2];
|
||||
$this->$plan->hydrogene += $max[2];
|
||||
$this->contenu[2] -= $max[2];
|
||||
|
||||
$this->$plan->addModif("force");
|
||||
|
||||
$this->addModifFlotte("contenu");
|
||||
return $max;
|
||||
}
|
||||
|
||||
|
||||
function atterir($plan = "end_planete")
|
||||
{
|
||||
//Si la planète d'arrivé n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->$plan))
|
||||
$this->load_planete();
|
||||
|
||||
if (isset($this->$plan->vaisseaux[0]))
|
||||
{
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
$this->$plan->vaisseaux[$key] += $vais;
|
||||
}
|
||||
else
|
||||
$this->$plan->vaisseaux = $this->vaisseaux;
|
||||
|
||||
$this->$plan->addModif("vaisseaux");
|
||||
|
||||
$this->modifFlotte = "DELETE";
|
||||
}
|
||||
|
||||
|
||||
function rappeler()
|
||||
{
|
||||
if ($this->start_time + $this->end_time >= time())
|
||||
return false;
|
||||
else
|
||||
{
|
||||
$this->end_time = time() - $this->start_time + 10;
|
||||
$this->mission = 5;
|
||||
if (!in_array('mission', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'mission';
|
||||
if (!in_array('end_time', $this->modifFlotte))
|
||||
$this->modifFlotte[] = 'end_time';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function retourner()
|
||||
{
|
||||
//Si la planète de départ n'est pas chargée, on charge les planètes
|
||||
if (is_numeric($this->start_planete))
|
||||
$this->load_planete();
|
||||
|
||||
//Si on a demandé une planète particulière au retour
|
||||
if (!empty($this->ret_time) && !empty($this->ret_planete) && !is_numeric($this->ret_planete))
|
||||
{
|
||||
$this->decharger("ret_planete");
|
||||
$this->atterir("ret_planete");
|
||||
}
|
||||
//Si le retour se fait sur la planète source
|
||||
else
|
||||
{
|
||||
$this->decharger("start_planete");
|
||||
$this->atterir("start_planete");
|
||||
}
|
||||
|
||||
$this->modifFlotte = "DELETE";
|
||||
}
|
||||
|
||||
|
||||
function addModifFlotte($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifFlotte))
|
||||
$this->modifFlotte[] = $modif;
|
||||
}
|
||||
|
||||
|
||||
function printTime_end()
|
||||
{
|
||||
return $this->start_time + $this->end_time;
|
||||
}
|
||||
|
||||
function printTime_ret()
|
||||
{
|
||||
if (!empty($this->ret_time))
|
||||
return $this->ret_time;
|
||||
elseif ($this->mission == 1 || $this->mission == 4 || $this->mission == 5 || (($this->mission == 3 || $this->mission == 2) && $this->statut != 0))
|
||||
return $this->start_time + $this->end_time*2;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static function txtMission($mission)
|
||||
{
|
||||
switch($mission)
|
||||
{
|
||||
case 1:
|
||||
return "Transporter";
|
||||
break;
|
||||
case 2:
|
||||
return "Coloniser";
|
||||
break;
|
||||
case 3:
|
||||
return "Attaquer";
|
||||
break;
|
||||
case 4:
|
||||
return "Recycler";
|
||||
break;
|
||||
case 5:
|
||||
return "Espionner";
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
return "Stationner";
|
||||
break;
|
||||
default:
|
||||
return "Inconnu";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
global $table_flottes;
|
||||
|
||||
if ($this->modifFlotte === "DELETE")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($this->id_flotte) && $this->modifFlotte == "INSERT")
|
||||
{
|
||||
$out1 = ''; $out2 = '';
|
||||
global $nomvaisnVAR;
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
{
|
||||
$out1 .= ', '.$nomvaisnVAR[$key];
|
||||
$out2 .= ', '.$vais;
|
||||
}
|
||||
if (SURFACE == "asteroide")
|
||||
$sql = "INSERT INTO $table_flottes (id_user, id_alliance, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES (0, ".$this->start_planete->id.", '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
else
|
||||
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
if (DEBUG) echo $sql;
|
||||
$bdd = new BDD();
|
||||
$bdd->query($sql);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif(isset($this->modifFlotte[0]))
|
||||
{
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modifFlotte as $modif)
|
||||
{
|
||||
if (!is_array($this->{$modif}))
|
||||
{
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out[] .= $modif." = ".$this->{$modif};
|
||||
else
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif == "contenu")
|
||||
$calc = "resso";
|
||||
elseif ($modif == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach(${$calc.'VAR'} as $key => $var)
|
||||
{
|
||||
$bdd->escape($this->{$modif}[$key]);
|
||||
$out[] = ${$calc.'VAR'}[$key]." = ".$this->{$modif}[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";";
|
||||
if (DEBUG) var_dump($sql);
|
||||
$bdd->query($sql);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,876 +0,0 @@
|
|||
<?php
|
||||
//Gestion des dépendances, on importe les classes nécessaires à la classe en cours
|
||||
include_once("game/Class/class.surface.php");
|
||||
include_once("game/Class/class.file.php");
|
||||
|
||||
/***************************************************************************
|
||||
* class.planete.php
|
||||
* -------------------
|
||||
* begin : Jeudi 21 août 2008
|
||||
* update : Vendredi 27 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Planete extends Surface
|
||||
{
|
||||
private $timestamp_lastSilo,
|
||||
$timestamp_lastMineM,
|
||||
$timestamp_lastMineC,
|
||||
$timestamp_lastMineH;
|
||||
|
||||
public $position,
|
||||
$nom_planete,
|
||||
$cases,
|
||||
$casesRest,
|
||||
$cap,
|
||||
$population,
|
||||
$population_max,
|
||||
$moral,
|
||||
$energie,
|
||||
$energieConso,
|
||||
$file_tech,
|
||||
$file_cas,
|
||||
$file_ter,
|
||||
$coeff_bat = array(),
|
||||
$casernes = array(),
|
||||
$terrestres = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param mixed $id id de la planète à importer/coordonnées
|
||||
* @param bool $first Bloquer l'affichage des messages d'erreurs
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id, $first = false)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_planete;
|
||||
$bdd = new bdd();
|
||||
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de la planète
|
||||
if ($id === false)
|
||||
$bdd->deconnexion();
|
||||
elseif (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
trigger_error('Erreur #04 : Format de recherche de planete incorrect !', E_USER_ERROR);
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $plan["id"];
|
||||
parent::User($plan["id_user"]);
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->position = $plan["position"];
|
||||
if (!empty($plan["isolement"])) $this->isolement = unserialize($plan["isolement"]);
|
||||
else $this->isolement = array();
|
||||
$this->nom_planete = $plan["nom_planete"];
|
||||
$this->image = $plan["image"];
|
||||
$this->cases = $plan["cases"];
|
||||
$this->debris_met = $plan["debris_met"];
|
||||
$this->debris_cri = $plan["debris_cri"];
|
||||
$this->metal = $plan["metal"];
|
||||
$this->cristal = $plan["cristal"];
|
||||
$this->hydrogene = $plan["hydrogene"];
|
||||
$this->population = $plan["population"];
|
||||
$this->moral = $plan["moral"];
|
||||
$this->timestamp = $plan["timestamp"];
|
||||
|
||||
//Chargement des variables de conversion
|
||||
global $batimentVAR, $casernenVAR, $nomterrnVAR, $nomvaisnVAR;
|
||||
|
||||
$this->casesRest = $this->cases; //Calcul du nombre de cases en même temps
|
||||
foreach($batimentVAR as $bat)
|
||||
{
|
||||
$this->batiments[] = $plan[$bat];
|
||||
$this->casesRest -= $plan[$bat];
|
||||
}
|
||||
if (!empty($plan["file_bat"]))
|
||||
$this->file_bat = unserialize($plan["file_bat"]);
|
||||
else
|
||||
$this->file_bat = new File('batiments');
|
||||
|
||||
$this->coeff_bat = array($plan["coeff_mine_m"], $plan["coeff_mine_c"], $plan["coeff_mine_h"], $plan["coeff_centrale_s"], $plan["coeff_centrale_f"]);
|
||||
//On vérifie que les coefficient ne soient pas supérieurs à 1 ou inférieurs à 0
|
||||
for($i = 0; $i < 5; $i++)
|
||||
{
|
||||
if ($this->coeff_bat[$i] > 1)
|
||||
$this->coeff_bat[$i] = 1;
|
||||
elseif ($this->coeff_bat[$i] < 0)
|
||||
$this->coeff_bat[$i] = 0;
|
||||
}
|
||||
|
||||
if (!empty($plan["file_tech"]))
|
||||
$this->file_tech = unserialize($plan["file_tech"]);
|
||||
else
|
||||
$this->file_tech = new File('technologies');
|
||||
|
||||
foreach($casernenVAR as $cas)
|
||||
$this->casernes[] = $plan[$cas];
|
||||
if (!empty($plan["file_cas"]))
|
||||
$this->file_cas = unserialize($plan["file_cas"]);
|
||||
else
|
||||
$this->file_cas = new File('casernes');
|
||||
|
||||
foreach($nomterrnVAR as $ter)
|
||||
$this->terrestres[] = $plan[$ter];
|
||||
if (!empty($plan["file_ter"]))
|
||||
$this->file_ter = unserialize($plan["file_ter"]);
|
||||
else
|
||||
$this->file_ter = new File('terrestres');
|
||||
|
||||
foreach($nomvaisnVAR as $vais)
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
if (!empty($plan["file_vais"]))
|
||||
$this->file_vais = unserialize($plan["file_vais"]);
|
||||
else
|
||||
$this->file_vais = new File('vaisseaux');
|
||||
|
||||
//Calcul de la population logée
|
||||
$this->population_max = (pow($this->batiments[12],1.5)+pow($this->batiments[13],2.1))*1000+3000;
|
||||
//Détermination des capacités maximales
|
||||
$this->cap = pow(2, $this->batiments[10]) * 100000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function actualiser($actuFile = true, $first = false)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile)
|
||||
{
|
||||
$this->file_bat->batiment_ready($this);
|
||||
$this->file_tech->technologie_ready($this);
|
||||
$this->file_cas->caserne_ready($this);
|
||||
$this->file_ter->terrestre_ready($this);
|
||||
$this->file_vais->vaisseaux_ready($this);
|
||||
}
|
||||
|
||||
if (!empty($this->timestamp_lastSilo))
|
||||
{
|
||||
$this->cap = pow(2, $this->batiments[10]-1) * 100000;
|
||||
$capnouv = pow(2, $this->batiments[10]) * 100000;
|
||||
}
|
||||
|
||||
//Calcul du temps écoulé depuis la dernière mise à jour de la planète
|
||||
$temps_ecoule = time() - $this->timestamp;
|
||||
$ressources = $this->production($temps_ecoule);
|
||||
|
||||
if ($this->metal + $ressources[0] < $this->cap)
|
||||
$this->metal += $ressources[0];
|
||||
else
|
||||
{
|
||||
//Si les capacités de stockage ont changé depuis la dernière actualisation
|
||||
if (isset($capnouv))
|
||||
{
|
||||
$ressources = $this->production($this->timestamp_lastSilo - $this->timestamp);
|
||||
if ($this->metal + $ressources[0] < $this->cap)
|
||||
$this->metal += $ressources[0];
|
||||
else
|
||||
$this->metal = $this->cap;
|
||||
|
||||
$ressources = $this->production(time() - $this->timestamp_lastSilo);
|
||||
if ($this->metal + $ressources[0] < $capnouv)
|
||||
$this->metal += $ressources[0];
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[0] = true;
|
||||
$this->metal = $capnouv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[0] = true;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
}
|
||||
if ($this->cristal + $ressources[1] < $this->cap)
|
||||
$this->cristal += $ressources[1];
|
||||
else
|
||||
{
|
||||
//Si les capacités de stockage ont changé depuis la dernière actualisation
|
||||
if (isset($capnouv))
|
||||
{
|
||||
$ressources = $this->production($this->timestamp_lastSilo - $this->timestamp);
|
||||
if ($this->cristal + $ressources[0] < $this->cap)
|
||||
$this->cristal += $ressources[0];
|
||||
else
|
||||
$this->cristal = $this->cap;
|
||||
|
||||
$ressources = $this->production(time() - $this->timestamp_lastSilo);
|
||||
if ($this->cristal + $ressources[0] < $capnouv)
|
||||
$this->cristal += $ressources[0];
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[1] = true;
|
||||
$this->cristal = $capnouv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[1] = true;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
}
|
||||
if ($this->hydrogene + $ressources[2] < $this->cap)
|
||||
$this->hydrogene += $ressources[2];
|
||||
else
|
||||
{
|
||||
//Si les capacités de stockage ont changé depuis la dernière actualisation
|
||||
if (isset($capnouv))
|
||||
{
|
||||
$ressources = $this->production($this->timestamp_lastSilo - $this->timestamp);
|
||||
if ($this->hydrogene + $ressources[0] < $this->cap)
|
||||
$this->hydrogene += $ressources[0];
|
||||
else
|
||||
$this->hydrogene = $this->cap;
|
||||
|
||||
$ressources = $this->production(time() - $this->timestamp_lastSilo);
|
||||
if ($this->hydrogene + $ressources[0] < $capnouv)
|
||||
$this->hydrogene += $ressources[0];
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[2] = true;
|
||||
$this->hydrogene = $capnouv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->alert_ressources[2] = true;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
}
|
||||
|
||||
//Vérification de la date pour faire les actions journalières
|
||||
if (date('zya') != date('zya', $this->timestamp)) //Mise à jour trois fois par jour : 0h, 1h, 13h
|
||||
//if (date('zy') != date('zy', $this->timestamp)) //Mise à jour une fois par jour : 0h
|
||||
{
|
||||
//On évalue le moral
|
||||
$this->evalMoral($first);
|
||||
|
||||
//Si la population est à 0, on ajoute des habitants
|
||||
if ($this->population <= 0)
|
||||
$this->population = 1000;
|
||||
|
||||
$popPlus = $this->population * 0.0153^max(1, floor((time()-$this->timestamp)/86400));
|
||||
|
||||
if ($this->politique == 2)
|
||||
$popPlus *= 1.1; //Communisme : 10 % de population qui arrive en plus.
|
||||
elseif ($this->politique == 3)
|
||||
$popPlus *= 1.05; //Démocratie : 5 % de population qui arrive en plus.
|
||||
|
||||
if ($this->technologies[2] & 4)
|
||||
$popPlus *= 1.15;
|
||||
elseif ($this->technologies[2] & 2)
|
||||
$popPlus *= 1.10;
|
||||
elseif ($this->technologies[2] & 1)
|
||||
$popPlus *= 1.05;
|
||||
|
||||
$this->population += $popPlus;
|
||||
$this->addCredits(($this->population/100*exp(0.01)*25) + ($this->population*0.01*$this->batiments[15])); //Première partie : production normale; seconde : batiment commercial
|
||||
$this->addModif("population");
|
||||
}
|
||||
|
||||
$this->timestamp = time();
|
||||
}
|
||||
|
||||
function setMoral($difference)
|
||||
{
|
||||
$this->moral += $difference;
|
||||
|
||||
//Ajustement du moral
|
||||
if ($this->moral > 1)
|
||||
$this->moral = 1;
|
||||
elseif ($this->moral < 0)
|
||||
$this->moral = 0;
|
||||
|
||||
$this->addModif("moral");
|
||||
}
|
||||
|
||||
function evalMoral($first = false)
|
||||
{
|
||||
$evolution = array();
|
||||
//Cas de sous-production
|
||||
if (($this->coeff_bat[0] + $this->coeff_bat[1] + $this->coeff_bat[2])/3 < 0.9)
|
||||
{
|
||||
if ($this->politique == 2)
|
||||
$this->moral -= 0.10; //Communisme : démoralise 2x plus
|
||||
else
|
||||
$this->moral -= 0.05;
|
||||
|
||||
$this->addModif("moral");
|
||||
}
|
||||
|
||||
//Surpopulation
|
||||
|
||||
//Surlogement
|
||||
|
||||
//Effets des batiments loisirs et commerces
|
||||
$this->moral += 0.0025*$this->batiments[15] + 0.1*$this->batiments[16];
|
||||
|
||||
//Ajustement du moral en fonction de la politique
|
||||
if ($this->politique == 1 && $this->moral > 0.7)
|
||||
$this->moral = 0.7;
|
||||
|
||||
//On vérifie qu'on ne dépasse pas le maximum
|
||||
if ($this->moral > 1)
|
||||
$this->moral = 1;
|
||||
if ($this->moral < 0)
|
||||
$this->moral = 0;
|
||||
|
||||
//Isolement si besoin
|
||||
if ($this->moral < 0.1)
|
||||
{
|
||||
//On vérifie qu'il ne s'agit pas de la planète mère
|
||||
global $table_planete;
|
||||
$bdd = new Bdd();
|
||||
$bdd->reconnexion();
|
||||
$res = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$this->id_user." ORDER BY id LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($res['id'] != $this->id)
|
||||
{
|
||||
if ($this->moral <= 0.04)
|
||||
{
|
||||
if ($this->moral <= 0.01)
|
||||
$rand = rand(0,4);
|
||||
else
|
||||
$rand = rand(0,20);
|
||||
//Perte de la planète
|
||||
if ($rand == 1)
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("DELETE FROM $table_planete WHERE id = ".$this->id.";");
|
||||
$bdd->deconnexion();
|
||||
send_mp($this->id_user, 'Perte de contrôle de '.$this->nom_planete, "Suite à une démoralisation persistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a renversé votre gouvernement en tuant tous vos gouverneurs. Vous perdez donc définitivement le contrôle de cette planète.");
|
||||
if (!$first)
|
||||
{
|
||||
$sess->values['idPlan'] = $res['id'];
|
||||
erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révolté contre vous. Vous ne contrôlez plus cette planète.');
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($this->moral <= 0.1)
|
||||
{
|
||||
if ($this->moral <= 0.06)
|
||||
$rand = rand(0,2);
|
||||
else
|
||||
$rand = rand(0,10);
|
||||
//Perte de contrôle temporaire
|
||||
if ($rand == 1)
|
||||
{
|
||||
$debut = time() - rand(0, 3600)*4;
|
||||
$fin = $debut + 86400;
|
||||
$this->isolement = array($debut, $fin);
|
||||
$this->addModif("isolement");
|
||||
|
||||
send_mp($this->id_user, 'Perte de contrôle temporaire de '.$this->nom_planete, "Suite à une démoralisation percistante de la population sur la planète ".$this->nom_planete." [".$this->galaxie.":".$this->ss.":".$this->position."], la population a pris le contrôle de votre planète. Vous perdez le contrôle de cette planète le temps que vos gouverneurs reprennent le pouvoir.");
|
||||
if (!$first)
|
||||
{
|
||||
$sess->values['idPlan'] = $res['id'];
|
||||
erreur('La population de cette planète est tellement démoralisée qu\'elle s\'est révoltée contre vous. Vous perdez temporairement le contrôle de cette planète.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndRetireRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
if ($this->metal >= $metal && $this->cristal >= $cristal && $this->hydrogene >= $hydrogene && $this->credits >= $credits)
|
||||
{
|
||||
$this->metal -= $metal;
|
||||
$this->cristal -= $cristal;
|
||||
$this->hydrogene -= $hydrogene;
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
$this->credits -= $credits;
|
||||
$this->addModifUser("credits");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function addRessources($metal, $cristal, $hydrogene, $credits = 0)
|
||||
{
|
||||
$perte = 0;
|
||||
|
||||
$this->metal += $metal;
|
||||
if ($this->metal > $this->cap)
|
||||
{
|
||||
$perte += $this->metal - $this->cap;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
|
||||
$this->cristal += $cristal;
|
||||
if ($this->cristal > $this->cap)
|
||||
{
|
||||
$perte += $this->cristal - $this->cap;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogene += $hydrogene;
|
||||
if ($this->hydrogene > $this->cap)
|
||||
{
|
||||
$perte += $this->hydrogene - $this->cap;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
$this->credits += $credits;
|
||||
$this->addModifUser("credits");
|
||||
}
|
||||
|
||||
return $perte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie si la planète est isolée ou non
|
||||
*
|
||||
* @return boolean
|
||||
* @access public
|
||||
*/
|
||||
function isolement()
|
||||
{
|
||||
$return = false;
|
||||
|
||||
global $queryPlanetes;
|
||||
|
||||
//Détermination du numéro de la planète par rapport aux autres, dans l'ordre de colonisation
|
||||
$numP = 0;
|
||||
foreach ($queryPlanetes as $key => $p)
|
||||
{
|
||||
if ($p['id'] == $this->id)
|
||||
$numP = $key + 1;
|
||||
}
|
||||
|
||||
if ($numP >= 11)
|
||||
{
|
||||
if (!isset($this->isolement[0]) || (time() > $this->isolement[0] && (!isset($this->isolement[1]) || (time() > $this->isolement[1] && date('dmY') != date('dmY', $this->isolement[0])))))
|
||||
{
|
||||
switch($numP)
|
||||
{
|
||||
case 11:
|
||||
$tps = 2;
|
||||
break;
|
||||
case 12:
|
||||
$tps = 4;
|
||||
break;
|
||||
case 13:
|
||||
$tps = 6;
|
||||
break;
|
||||
case 14:
|
||||
$tps = 8;
|
||||
break;
|
||||
case 15:
|
||||
$tps = 12;
|
||||
break;
|
||||
case 16:
|
||||
$tps = 16;
|
||||
break;
|
||||
case 17:
|
||||
$tps = 20;
|
||||
break;
|
||||
default:
|
||||
$tps = 24;
|
||||
}
|
||||
$debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
|
||||
$fin = $debut + $tps * 3600;
|
||||
|
||||
$this->isolement[0] = $debut;
|
||||
if (time() > $this->isolement[0])
|
||||
$this->isolement[1] = $fin;
|
||||
$this->addModif("isolement");
|
||||
}
|
||||
if (isset($this->isolement[1]) && time() < $this->isolement[1])
|
||||
$return = true;
|
||||
}
|
||||
elseif (!isset($this->isolement[0]))
|
||||
{
|
||||
$this->isolement = array(0,0);
|
||||
$this->addModif("isolement");
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcul les ressources produites en fonction de $temps_ecoule
|
||||
* @param int $temps_ecoule Temps écoulé depuis la dernière actualisation
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
function production($temps_ecoule, $retarray = false)
|
||||
{
|
||||
//Accélération de la production
|
||||
$temps_ecoule *= VITESSE;
|
||||
|
||||
//Calcul de la consomation d'énergie
|
||||
if ($this->batiments[0] > 0)
|
||||
$energie_m = ceil(exp(0.28*$this->batiments[0])*10);
|
||||
else
|
||||
$energie_m = 0;
|
||||
if ($this->batiments[1] > 0)
|
||||
$energie_c = ceil(exp(0.28*$this->batiments[1])*10);
|
||||
else
|
||||
$energie_c = 0;
|
||||
if ($this->batiments[2] > 0)
|
||||
$energie_h = ceil(exp(0.2849*$this->batiments[2])*13);
|
||||
else
|
||||
$energie_h = 0;
|
||||
if ($this->batiments[3] > 0)
|
||||
$energie_s = ceil(exp(0.28*$this->batiments[3])*22);
|
||||
else
|
||||
$energie_s = 0;
|
||||
if ($this->batiments[4] > 0)
|
||||
$energie_f = ceil(exp(0.297*$this->batiments[4])*25);
|
||||
else
|
||||
$energie_f = 0;
|
||||
|
||||
//Calcul de la consomation d'énergie
|
||||
$this->energieConso = $energie_m * $this->coeff_bat[0] + $energie_c * $this->coeff_bat[1] + $energie_h * $this->coeff_bat[2];
|
||||
$nrjmx = $energie_m + $energie_c + $energie_h;
|
||||
|
||||
//Calcul de la production d'énergie
|
||||
$this->energie = $energie_s * $this->coeff_bat[3] + $energie_f * $this->coeff_bat[4];
|
||||
|
||||
if ($this->energieConso == 0)
|
||||
$coeff = 0;
|
||||
else
|
||||
$coeff = $this->energie / $this->energieConso;
|
||||
|
||||
if ($coeff < 0)
|
||||
$coeff = 0;
|
||||
elseif ($coeff > 1)
|
||||
$coeff = 1;
|
||||
|
||||
$Ncoeff = array();
|
||||
for($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$Ncoeff[$i] = $coeff * $this->coeff_bat[$i];
|
||||
if ($Ncoeff[$i] > 1)
|
||||
$Ncoeff[$i] = 1;
|
||||
if ($Ncoeff[$i] < $this->coeff_bat[$i] && $this->batiments[$i] != 0)
|
||||
{
|
||||
$this->coeff_bat[$i] = $Ncoeff[$i];
|
||||
$this->addModif("coeff_bat");
|
||||
}
|
||||
}
|
||||
|
||||
//Calcul de la consomation d'hydrogène
|
||||
if ($this->batiments[4] > 0)
|
||||
$conso_h = ((ceil(pow(1.34,($this->batiments[4]-1))*9)/3600)*$temps_ecoule) * $this->coeff_bat[4];
|
||||
else
|
||||
$conso_h = 0;
|
||||
|
||||
//Calcul des production de ressources
|
||||
if ($this->batiments[0] <= 0 || $this->batiments[3] <= 0)
|
||||
$prod_met = 0.011 * $temps_ecoule;
|
||||
else
|
||||
$prod_met = ((ceil(pow(1.1, $this->batiments[0]) * 52 * $this->batiments[0]) / 3600) * $temps_ecoule) * $this->coeff_bat[0];
|
||||
|
||||
if ($this->batiments[1] <= 0 || $this->batiments[3] <= 0)
|
||||
$prod_cri = 0.0055 * $temps_ecoule;
|
||||
else
|
||||
$prod_cri = ((ceil(pow(1.1, $this->batiments[1]) * 34 * $this->batiments[1]) / 3600) * $temps_ecoule) * $this->coeff_bat[1];
|
||||
|
||||
if ($this->batiments[2] <= 0)
|
||||
$prod_hy = 0;
|
||||
else
|
||||
$prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 21 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2];
|
||||
|
||||
//Augmentation de la production en fonction des technologies
|
||||
if ($this->technologies[0] &4)
|
||||
{
|
||||
$prod_met *= 1.15;
|
||||
$prod_cri *= 1.15;
|
||||
$prod_hy *= 1.15;
|
||||
}
|
||||
elseif ($this->technologies[0] &2)
|
||||
{
|
||||
$prod_met *= 1.10;
|
||||
$prod_cri *= 1.10;
|
||||
$prod_hy *= 1.10;
|
||||
}
|
||||
elseif ($this->technologies[0] &1)
|
||||
{
|
||||
$prod_met *= 1.05;
|
||||
$prod_cri *= 1.05;
|
||||
$prod_hy *= 1.05;
|
||||
}
|
||||
//Rendement métal
|
||||
if ($this->technologies[0] &64)
|
||||
$prod_met *= 1.3;
|
||||
elseif ($this->technologies[0] &32)
|
||||
$prod_met *= 1.2;
|
||||
elseif ($this->technologies[0] &16)
|
||||
$prod_met *= 1.1;
|
||||
//Rendemant cristal
|
||||
if ($this->technologies[0] &512)
|
||||
$prod_cri *= 1.3;
|
||||
elseif ($this->technologies[0] &256)
|
||||
$prod_cri *= 1.2;
|
||||
elseif ($this->technologies[0] &128)
|
||||
$prod_cri *= 1.1;
|
||||
//Rendement hydrogène
|
||||
if ($this->technologies[0] &4096)
|
||||
$prod_hy *= 1.3;
|
||||
elseif ($this->technologies[0] &2048)
|
||||
$prod_hy *= 1.2;
|
||||
elseif ($this->technologies[0] &1024)
|
||||
$prod_hy *= 1.1;
|
||||
|
||||
//Augmentation de la production en fonction du moral
|
||||
if ($this->moral > 0.9)
|
||||
{
|
||||
$prod_met *= 1.05;
|
||||
$prod_cri *= 1.05;
|
||||
$prod_hy *= 1.05;
|
||||
}
|
||||
elseif ($this->moral > 0.75)
|
||||
{
|
||||
$prod_met *= 1.02;
|
||||
$prod_cri *= 1.02;
|
||||
$prod_hy *= 1.02;
|
||||
}
|
||||
elseif ($this->moral < 0.45)
|
||||
{
|
||||
$prod_met *= 0.97;
|
||||
$prod_cri *= 0.97;
|
||||
$prod_hy *= 0.97;
|
||||
}
|
||||
elseif ($this->moral < 0.25)
|
||||
{
|
||||
$prod_met *= 0.94;
|
||||
$prod_cri *= 0.94;
|
||||
$prod_hy *= 0.94;
|
||||
}
|
||||
|
||||
//Augmentation de la production en fonction de la politique
|
||||
if ($this->politique == 2)
|
||||
{
|
||||
$prod_met *= 1.10;
|
||||
$prod_cri *= 1.10;
|
||||
$prod_hy *= 1.10;
|
||||
}
|
||||
|
||||
//On enlève la consomation d'hydrogène
|
||||
$prod_hy -= $conso_h;
|
||||
|
||||
if ($retarray)
|
||||
return array(array(ceil($this->coeff_bat[0]*100), ceil($this->coeff_bat[1]*100), ceil($this->coeff_bat[2]*100), ceil($this->coeff_bat[3]*100), ceil($this->coeff_bat[4]*100)), array($prod_met, $prod_cri, $prod_hy + $conso_h, $energie_s*$this->coeff_bat[3], $energie_f*$this->coeff_bat[4]), array($energie_m*$this->coeff_bat[0], $energie_c*$this->coeff_bat[1], $energie_h*$this->coeff_bat[2], $conso_h, ($energie_s*$this->coeff_bat[3] + $energie_f*$this->coeff_bat[4])-($energie_m*$this->coeff_bat[0] + $energie_c*$this->coeff_bat[1] + $energie_h*$this->coeff_bat[2])));
|
||||
else
|
||||
return array($prod_met, $prod_cri, $prod_hy);
|
||||
}
|
||||
|
||||
function creer($id_user, $mere = false)
|
||||
{
|
||||
global $VAR;
|
||||
//Définition des paramètres de l'utilisateur pour la planète
|
||||
$this->id_user = $id_user;
|
||||
|
||||
//Génération du nombre de case et de l'image en fonction de la position dans le système
|
||||
if ($mere)
|
||||
{
|
||||
$this->cases = 225;
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
elseif ($this->position > $VAR['nb_planete']*0.75)
|
||||
{
|
||||
$this->cases = mt_rand(200,255);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
elseif ($this->position > $VAR['nb_planete']/2)
|
||||
{
|
||||
$this->cases = mt_rand(250,300);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
elseif ($this->position > $VAR['nb_planete']/4)
|
||||
{
|
||||
$this->cases = mt_rand(175,260);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->cases = mt_rand(150,220);
|
||||
$this->image = mt_rand(1,19);
|
||||
}
|
||||
|
||||
//Définition des principaux paramètres de la planète
|
||||
if ($mere)
|
||||
$this->nom_planete = 'Planète mère';
|
||||
else
|
||||
$this->nom_planete = 'Planète colonisée';
|
||||
|
||||
$this->metal = 1000;
|
||||
$this->cristal = 700;
|
||||
$this->hydrogene = 0;
|
||||
|
||||
$this->modif = array("id_user", "nom_planete", "galaxie", "ss", "position", "image", "cases");
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (empty($this->ss) || empty($this->id_user))
|
||||
return;
|
||||
if ($this->id_user == 1)
|
||||
var_dump($this);
|
||||
|
||||
global $var___db, $config, $table_planete;
|
||||
if (empty($this->id))
|
||||
{
|
||||
$out1 = array(); $out2 = array();
|
||||
$bdd = new bdd();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
if ($modif == "force")
|
||||
continue;
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$out1[] = $modif;
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out2[] = $this->{$modif};
|
||||
else
|
||||
$out2[] = "'".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out1[] = $modif;
|
||||
$out2[] = "'$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif == "batiments")
|
||||
$calc = "batiment";
|
||||
elseif ($modif == "technologies")
|
||||
$calc = "technolo";
|
||||
elseif ($modif == "casernes")
|
||||
$calc = "casernen";
|
||||
elseif ($modif == "terrestres")
|
||||
$calc = "nomterrn";
|
||||
elseif ($modif == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
elseif ($modif == "coeff_bat")
|
||||
$calc = "coeff";
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
{
|
||||
$out1[] = ${$calc.'VAR'}[$j];
|
||||
$out2[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$bdd->query("INSERT INTO $table_planete (".implode(', ', $out1).", hash_planete) VALUES (".implode(', ', $out2).", SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)))");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$nb = count($this->modif);
|
||||
$out = array();
|
||||
$bdd = new bdd();
|
||||
for($i = 0; $i < $nb; $i++)
|
||||
{
|
||||
if ($this->modif[$i] == "force")
|
||||
$out[] = "timestamp = timestamp";
|
||||
elseif ($this->modif[$i] == 'technologies')
|
||||
$this->modifUser[] = $this->modif[$i];
|
||||
elseif (is_object($this->{$this->modif[$i]}))
|
||||
{
|
||||
$export = serialize($this->{$this->modif[$i]});
|
||||
$bdd->escape($export);
|
||||
$out[] = $this->modif[$i]." = '".$export."'";
|
||||
}
|
||||
elseif (!is_array($this->{$this->modif[$i]}))
|
||||
{
|
||||
$bdd->escape($this->{$this->modif[$i]});
|
||||
if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]}))
|
||||
$out[] = $this->modif[$i]." = ".$this->{$this->modif[$i]};
|
||||
else
|
||||
$out[] = $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$this->modif[$i]}) && $this->modif[$i] != "coeff_bat" && $this->modif[$i] != "vaisseaux" && $this->modif[$i] != "terrestres" && $this->modif[$i] != "casernes" && $this->modif[$i] != "technologies" && $this->modif[$i] != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$this->modif[$i]});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $this->modif[$i]." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->modif[$i] == "batiments")
|
||||
$calc = "batiment";
|
||||
elseif ($this->modif[$i] == "technologies")
|
||||
$calc = "technolo";
|
||||
elseif ($this->modif[$i] == "casernes")
|
||||
$calc = "casernen";
|
||||
elseif ($this->modif[$i] == "terrestres")
|
||||
$calc = "nomterrn";
|
||||
elseif ($this->modif[$i] == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
elseif ($this->modif[$i] == "coeff_bat")
|
||||
$calc = "coeff";
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
|
||||
$nombr = count(${$calc.'VAR'});
|
||||
for($j = 0; $j < $nombr; $j++)
|
||||
{
|
||||
$bdd->escape($this->{$this->modif[$i]}[$j]);
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_planete SET timestamp = ".time().", metal = ".$this->metal.", cristal = ".$this->cristal.", hydrogene = ".$this->hydrogene.", ".implode(', ', $out)." WHERE id = ".$this->id.";";
|
||||
if (DEBUG) echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,399 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Class Rapport
|
||||
*
|
||||
* Génération et envoie de rapport de mission de flotte
|
||||
*
|
||||
*/
|
||||
class Rapport{
|
||||
var $table = 'mail';
|
||||
var $type = 0;
|
||||
var $var = array();
|
||||
var $utilA = 0;
|
||||
var $utilB = 0;
|
||||
var $timestamp = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @access protected
|
||||
*/
|
||||
function Rapport($type, $utilA, $utilB, $time)
|
||||
{
|
||||
global $table_mail;
|
||||
$this->table = $table_mail;
|
||||
|
||||
$this->type = $type;
|
||||
$this->utilA = $utilA;
|
||||
$this->utilB = $utilB;
|
||||
$this->timestamp = $time;
|
||||
}
|
||||
|
||||
function addInfo($info, $id)
|
||||
{
|
||||
$this->var[$id] = $info;
|
||||
}
|
||||
|
||||
function send()
|
||||
{
|
||||
if ($this->type == '3')
|
||||
$this->sendCombat();
|
||||
elseif ($this->type == '1')
|
||||
$this->sendTransport();
|
||||
elseif ($this->type == '2')
|
||||
$this->sendColonisation();
|
||||
elseif ($this->type == '4')
|
||||
$this->sendRecyclage();
|
||||
elseif ($this->type == '5')
|
||||
$this->sendEspionnage();
|
||||
elseif ($this->type == '6')
|
||||
$this->sendAlliance();
|
||||
elseif ($this->type == '7')
|
||||
$this->sendAlliance2();
|
||||
}
|
||||
|
||||
function sendEspionnage()
|
||||
{
|
||||
global $LANG;
|
||||
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titreA = 'Rapport d\'espionnage de '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$rapportA = '<b>Espionnage de '.$this->var[0]->pseudo.' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titreA = 'Rapport d\'espionnage de '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$rapportA = '<b>Espionnage de '.$this->var[0]->pseudo.' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
}
|
||||
|
||||
if ($this->var[2] < 1) $rapportA .= '<i>Nos sondes n\'ont pas pu récolter d\'informations sur cette planète.</i>';
|
||||
else {
|
||||
//Ressources
|
||||
if ($this->var[2] > 1)
|
||||
$rapportA .= '<table style="margin: auto;"><tr><th colspan="2">Ressources sur la planète :</th></tr><tr><td>'.$LANG[$this->var[0]->race]["ressources"]["noms"]["metal"].' :</td><td>'.$this->var[0]->metal.'</td></tr><tr><td>'.$LANG[$this->var[0]->race]["ressources"]["noms"]["cristal"].' :</td><td>'.$this->var[0]->cristal.'</td></tr><tr><td>'.$LANG[$this->var[0]->race]["ressources"]["noms"]["hydrogene"].' :</td><td>'.$this->var[0]->hydrogene.'</td></tr></table><br />';
|
||||
|
||||
//Bâtiments
|
||||
if ($this->var[2] > 2)
|
||||
{
|
||||
$rapportA .= '<table style="margin: auto;"><tr><th>Niveau</th><th>Bâtiment</th></tr>';
|
||||
foreach ($this->var[0]->batiments as $key => $batiment)
|
||||
{
|
||||
$rapportA .= '<tr><td>'.rand($batiment * (1 - $this->var[1]), $batiment * (1 + $this->var[1])).'</td><td>'.$LANG[$this->var[0]->race]["batiments"]["noms_sing"][$key].'</td></tr>';
|
||||
}
|
||||
$rapportA .= '</table><br />';
|
||||
}
|
||||
|
||||
//Flottes en orbite
|
||||
if ($this->var[2] > 3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Flottes au sol
|
||||
if ($this->var[2] > 5)
|
||||
{
|
||||
$rapportA .= '<table style="margin: auto;"><tr><th>Nombre</th><th>Vaisseaux</th></tr>';
|
||||
foreach ($this->var[0]->vaisseaux as $key => $vaisseau)
|
||||
{
|
||||
$rapportA .= '<tr><td>'.rand($vaisseau * (1 - $this->var[1]), $vaisseau * (1 + $this->var[1])).'</td><td>'.$LANG[$this->var[0]->race]["vaisseaux"]["noms_sing"][$key].'</td></tr>';
|
||||
}
|
||||
$rapportA .= '</table><br />';
|
||||
}
|
||||
|
||||
//Défenses
|
||||
if ($this->var[2] > 4)
|
||||
{
|
||||
$rapportA .= '<table style="margin: auto;"><tr><th>Nombre</th><th>Défenses</th></tr>';
|
||||
foreach ($this->var[0]->terrestres as $key => $unite)
|
||||
{
|
||||
if (!Donnee::typeTerrestre($key)) $rapportA .= '<tr><td>'.rand($unite * (1 - $this->var[1]), $unite * (1 + $this->var[1])).'</td><td>'.$LANG[$this->var[0]->race]["terrestre"]["noms_sing"][$key].'</td></tr>';
|
||||
}
|
||||
$rapportA .= '</table><br />';
|
||||
}
|
||||
}
|
||||
|
||||
$titreB = 'Rapport de contre-espionnage';
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
$rapportB = 'Nous venons d\'apprendre que notre planète : '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A] a été la cible d\'un espionnage de la part de '.$this->utilA->pseudo;
|
||||
else
|
||||
$rapportB = 'Nous venons d\'apprendre que notre planète : '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.'] a été la cible d\'un espionnage de la part de '.$this->utilA->pseudo;
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titreA);
|
||||
$db->escape($titreB);
|
||||
$db->escape($rapportA);
|
||||
$db->escape($rapportB);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titreA', '$rapportA', '$temps')");
|
||||
//On envoie un rapport au joueur espionné uniquement s'il a un contre-espionnage
|
||||
if ($this->var[3] >= 1)
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user.", '$titreB', '$rapportB', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendTransport()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
$rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
$rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapportA);
|
||||
$db->escape($rapportB);
|
||||
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapportA', '$temps');");
|
||||
if ($this->utilA->id_user != $this->utilB->id_user) $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user.", '$titre', '$rapportB', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendColonisation()
|
||||
{
|
||||
$titre = 'Colonisation de ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].']';
|
||||
if (is_numeric($this->var[0][2]))
|
||||
{
|
||||
if ($this->var[1])
|
||||
$rapport = 'Votre vaisseau a atteint la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
else
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->var[1])
|
||||
$rapport = 'Votre vaisseau a atteint l\'astéroide ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
else
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendRecyclage()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendCombat(){
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
$rapportA = new Smarty();
|
||||
$rapportB = new Smarty();
|
||||
|
||||
$rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$rapportB->template_dir = _FCORE.'templates/templates/';
|
||||
$rapportB->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$rapportB->config_dir = _FCORE.'templates/configs/';
|
||||
$rapportB->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->var[4]['pseudo'] = trouvNom($this->var[4]['id_user']);
|
||||
$this->var[5]['pseudo'] = trouvNom($this->var[5]['id_user']);
|
||||
|
||||
$rapportA->assign('tour', $this->var[3]);
|
||||
$rapportA->assign('EN', $this->var[4]);
|
||||
$rapportA->assign('flotte', $this->var[5]);
|
||||
$rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$rapportA->assign('defenses1', $this->var[2]);
|
||||
$rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$rapportA->assign('defenses2', $this->var[9]);
|
||||
|
||||
$rapportA->assign('termine', $this->var[6][0]);
|
||||
$rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$rapportA->assign('pillage', $this->var[11]);
|
||||
|
||||
$rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$rapportA->assign('defBC', $defense_bc);
|
||||
$rapportA->assign('defPV', $defense_pv);
|
||||
$rapportA->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$rapportA->assign('ressources', $ressourc);
|
||||
$rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$rapportA->assign('nomdefEN', $nomterra);
|
||||
|
||||
$rapportA = $rapportA->fetch('game/ATrapport_combat.tpl');
|
||||
|
||||
|
||||
$rapportB->assign('tour', $this->var[3]);
|
||||
$rapportB->assign('EN', $this->var[4]);
|
||||
$rapportB->assign('flotte', $this->var[5]);
|
||||
$rapportB->assign('vaisseaux1', $this->var[0]);
|
||||
$rapportB->assign('vaisseaux2', $this->var[1]);
|
||||
$rapportB->assign('defenses1', $this->var[2]);
|
||||
$rapportB->assign('vaisseaux3', $this->var[7]);
|
||||
$rapportB->assign('vaisseaux4', $this->var[8]);
|
||||
$rapportB->assign('defenses2', $this->var[9]);
|
||||
|
||||
$rapportB->assign('termine', $this->var[6][0]);
|
||||
$rapportB->assign('attaquantG', $this->var[6][1]);
|
||||
$rapportB->assign('matchnul', $this->var[6][2]);
|
||||
$rapportB->assign('pillage', $this->var[11]);
|
||||
|
||||
$rapportB->assign('vaisBC', $nomvais_bc);
|
||||
$rapportB->assign('vaisPV', $nomvais_pv);
|
||||
$rapportB->assign('defBC', $defense_bc);
|
||||
$rapportB->assign('defPV', $defense_pv);
|
||||
$rapportB->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$rapportB->assign('ressources', $ressourc);
|
||||
$rapportB->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$rapportB->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$rapportB->assign('nomdefEN', $nomterra);
|
||||
|
||||
$rapportB = $rapportB->fetch('game/ENrapport_combat.tpl');
|
||||
|
||||
|
||||
$titreA = 'Combat contre '.$this->var[4]['pseudo'];
|
||||
$titreB = 'Combat contre '.$this->var[5]['pseudo'];
|
||||
$temps = $this->timestamp;
|
||||
$db = new bdd();
|
||||
$db->connexion();
|
||||
$db->escape($titreA);
|
||||
$db->escape($titreB);
|
||||
$db->escape($rapportA);
|
||||
$db->escape($rapportB);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titreA', '$rapportA', '$temps')");
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user."', '$titreB', '$rapportB', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function show(){
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
$rapportA = new Smarty();
|
||||
|
||||
$rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$rapportA->assign('tour', $this->var[3]);
|
||||
$rapportA->assign('EN', $this->var[4]);
|
||||
$rapportA->assign('flotte', $this->var[5]);
|
||||
$rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$rapportA->assign('defenses1', $this->var[2]);
|
||||
$rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$rapportA->assign('defenses2', $this->var[9]);
|
||||
|
||||
$rapportA->assign('termine', $this->var[6][0]);
|
||||
$rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$rapportA->assign('pillage', $this->var[11]);
|
||||
$rapportA->assign('debris', $this->var[12]);
|
||||
$rapportA->assign('infoPLUS', $this->var[14]);
|
||||
//$rapportA->assign('infoPLUS2', $this->var[15]);
|
||||
|
||||
$rapportA->assign('page', 'simulation');
|
||||
$rapportA->assign('enligne', $this->var[13][0]);
|
||||
$rapportA->assign('infos', $this->var[13][1]);
|
||||
$rapportA->assign('nbinfos', $this->var[13][2]);
|
||||
$rapportA->assign('count', $this->var[13][3]);
|
||||
$rapportA->assign('version', $this->var[13][4]);
|
||||
$rapportA->assign('tpsdejeu', $this->var[13][5]);
|
||||
|
||||
$rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$rapportA->assign('defBC', $defense_bc);
|
||||
$rapportA->assign('defPV', $defense_pv);
|
||||
$rapportA->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$rapportA->assign('ressources', $ressourc);
|
||||
$rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
$rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$rapportA->assign('nomdefEN', $nomterra);
|
||||
$rapportA->assign('race', $race);
|
||||
|
||||
return $rapportA->fetch('game/SIMrapport_combat.tpl');
|
||||
return $rapportA;
|
||||
}
|
||||
|
||||
function sendAlliance()
|
||||
{
|
||||
$titreA = 'Déclaration officielle de votre alliance !';
|
||||
$rapportA = 'Félicitations, votre alliance a recueilli suffisament de signature, sa déclaration est maintenant officielle !<br /><br />Vous pouvez dès maintenant administrer votre alliance en vous rendant sur la page Alliance.';
|
||||
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($titreA);
|
||||
$db->escape($rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titreA', '$rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendAlliance2()
|
||||
{
|
||||
$titreA = 'Fondation de votre alliance !';
|
||||
$rapportA = 'Pour terminer la création de votre alliance, trouvez 4 joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature : <a href="?p=alliances&q=signer&i='.$this->var[0].'">http://'.$_SERVER['HTTP_HOST'].'/?p=alliances&q=signer&i='.$this->var[0].'</a>';
|
||||
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($titreA);
|
||||
$db->escape($rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titreA', '$rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
include_once("game/Class/class.user.php");
|
||||
/***************************************************************************
|
||||
* class.surface.php
|
||||
* -------------------
|
||||
* begin : Jeudi 21 août 2008
|
||||
* update : Dimanche 8 février 2009
|
||||
* email : nemunaire@gmail.com
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Surface extends User
|
||||
{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$image,
|
||||
$debris_met,
|
||||
$debris_cri,
|
||||
$metal,
|
||||
$cristal,
|
||||
$hydrogene,
|
||||
$alert_ressources = array(false, false, false),
|
||||
$timestamp,
|
||||
$file_bat,
|
||||
$file_vais,
|
||||
$isolement = false,
|
||||
$batiments = array(),
|
||||
$vaisseaux = array(),
|
||||
$modif = array();
|
||||
|
||||
function isolement()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function addModif($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modif))
|
||||
$this->modif[] = $modif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
class TinyPlanete{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$position,
|
||||
$nom_planete;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_planete;
|
||||
$bdd = new bdd();
|
||||
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de la planète
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
trigger_error('Erreur #04 : Format de recherche de planete incorrect !', E_USER_ERROR);
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $plan["id"];
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->position = $plan["position"];
|
||||
$this->nom_planete = $plan["nom_planete"];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
if (!empty($_GET['v']))
|
||||
include('game/jeu/alliances/voir.php');
|
||||
include('game/alliances/voir.php');
|
||||
elseif (!empty($_GET['signer']))
|
||||
include('game/jeu/alliances/signer.php');
|
||||
include('game/alliances/signer.php');
|
||||
elseif (!empty($planete->id_alliance))
|
||||
{
|
||||
$SESS->values['idPlan'] = 0;
|
||||
|
|
@ -14,7 +14,7 @@ elseif (!empty($planete->id_alliance))
|
|||
redirection("?p=accueil");
|
||||
}
|
||||
elseif (!empty($_GET['postuler']))
|
||||
include('game/jeu/alliances/postuler.php');
|
||||
include('game/alliances/postuler.php');
|
||||
else
|
||||
include('game/jeu/alliances/sans.php');
|
||||
include('game/alliances/sans.php');
|
||||
?>
|
||||
|
|
@ -163,8 +163,8 @@ elseif ($gestion == "wings")
|
|||
$bdd->escape($nom);
|
||||
$bdd->escape($tag);
|
||||
$user = $bdd->unique_query("SELECT id, pseudo FROM $table_user WHERE pseudo = '$fondateur' AND id_alliance = 0;");
|
||||
$alliances = $bdd->query("SELECT id FROM $table_alliances WHERE nom_alliance = 'nom' OR tag = '$tag';");
|
||||
$wings = $bdd->query("SELECT COUNT(id) AS nb FROM $table_alliances WHERE galaxie = ".$planate->galaxie." AND ss = ".$planate->ss.";");
|
||||
$alliances = $bdd->query("SELECT id FROM $table_alliances WHERE nom_alliance = '$nom' OR tag = '$tag';");
|
||||
$wings = $bdd->unique_query("SELECT COUNT(id) AS nb FROM $table_alliances WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss.";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($alliances))
|
||||
|
|
@ -181,7 +181,7 @@ elseif ($gestion == "wings")
|
|||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($race);
|
||||
$bdd->query("INSERT INTO $table_alliances (race, sante, nom_alliance, tag, galaxie, ss, wing) VALUES ('$race', 1, '$nom', '$tag', ".$planate->galaxie.", ".$planate->ss.", ".$wings['nb'].")");
|
||||
$bdd->query("INSERT INTO $table_alliances (race, sante, nom_alliance, tag, galaxie, ss, wing) VALUES ('$race', 1, '$nom', '$tag', ".$planete->galaxie.", ".$planete->ss.", ".$wings['nb'].")");
|
||||
$affected = $bdd->affected();
|
||||
$bdd->deconnexion();
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ elseif ($gestion == "wings")
|
|||
|
||||
//On charge la liste des wings
|
||||
$bdd->reconnexion();
|
||||
$wings = $bdd->query("SELECT id, race, nom_alliance, tag FROM $table_alliances WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss." AND wing != 0;");
|
||||
$wings = $bdd->query("SELECT A.id, A.race, A.nom_alliance, A.tag, COUNT(U.id) AS nbMembres, V.id AS id_fondateur, V.pseudo AS pseudo_fondateur FROM $table_alliances A LEFT JOIN $table_user U ON U.id_alliance = A.id LEFT JOIN $table_user V ON V.id = A.fondateur WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss." AND wing != 0 GROUP BY A.id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("wings", $wings);
|
||||
unset($wings);
|
||||
|
|
@ -11,7 +11,7 @@ if (!empty($message))
|
|||
$bdd->escape($message);
|
||||
$postul = $bdd->unique_query("SELECT id FROM $table_alliances_attente WHERE id_alliance = $id AND id_membre = ".$planete->id_user." LIMIT 1;");
|
||||
if (empty($postul))
|
||||
$bdd->query("INSERT INTO $table_alliances_attente (id_alliance, id_membre, timestamp, message) VALUES ($id, ".$planete->id_user.", ".time().", '$message');");
|
||||
$bdd->query("INSERT INTO $table_alliances_attente (id_alliance, id_user, timestamp, message) VALUES ($id, ".$planete->id_user.", ".time().", '$message');");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (empty($postul))
|
||||
|
|
@ -25,8 +25,8 @@ else
|
|||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$postul = $bdd->unique_query("SELECT id FROM $table_alliances_attente WHERE id_alliance = $id AND id_membre = ".$planete->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
|
||||
|
||||
|
||||
if (!empty($postul))
|
||||
erreur("Vous avez déjà une candidature en cours pour cette alliance !", "red", $VAR["menu"]["alliance"]."&v=".$id, 3000);
|
||||
elseif (!empty($alliance))
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$act = gpc('q');
|
||||
|
||||
|
|
@ -36,8 +36,8 @@ if ($act == "fonder")
|
|||
erreur("Le nom ou le tag que vous avez choisi est déjà utilisé par une alliance.", "red");
|
||||
else
|
||||
{
|
||||
send_mp($planete->id_user, "Fondation de votre alliance !", 'Pour terminer la création de votre alliance, trouvez au moins 4 joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature :<br /><a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>');
|
||||
erreur('Votre alliance a bien été créée.<br />Il ne vous reste plus qu\'à trouver au moins 4 signatures pour finir la création de votre alliance.<br /><br />Le lien permettant à vos quatres personnes de signer est <a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>', "green");
|
||||
send_mp($planete->id_user, "Fondation de votre alliance !", 'Pour terminer la création de votre alliance, trouvez au moins '.nb_signatures.' joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature :<br /><a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>');
|
||||
erreur('Votre alliance a bien été créée.<br />Il ne vous reste plus qu\'à trouver au moins '.nb_signatures.' signatures pour finir la création de votre alliance.<br /><br />Le lien permettant à vos quatres personnes de signer est <a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>', "green");
|
||||
}
|
||||
}
|
||||
unset($nom, $tag);
|
||||
98
onyx2/include/game/alliances/signer.php
Normal file
98
onyx2/include/game/alliances/signer.php
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$hash = gpc('signer');
|
||||
|
||||
$page = 'alliance/nm_signer';
|
||||
if (!empty($planete->id_alliance))
|
||||
erreur("Vous êtes déjà dans une alliance, vous ne pouvez pas ratifier d'alliance !", "red");
|
||||
elseif (!empty($_POST["sign"]))
|
||||
{
|
||||
if (trim(strtolower(gpc("sign", "post"))) == "oui")
|
||||
{
|
||||
$hash = intval($hash);
|
||||
$bdd->reconnexion();
|
||||
$ratifier = $bdd->unique_query("SELECT id, fondateur, signatures FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
if (!empty($ratifier))
|
||||
{
|
||||
$ratifier["signatures"] = explode(';', substr($ratifier["signatures"], 1), -1);
|
||||
unset($ratifier["signatures"][array_search($planete->id_user, $ratifier["signatures"])]);
|
||||
if (count($ratifier["signatures"]) == 0)
|
||||
$ratifier["signatures"] = "";
|
||||
else
|
||||
$ratifier["signatures"] = ';'.implode(';', $ratifier["signatures"]).';';
|
||||
$bdd->escape($ratifier["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$ratifier["signatures"]."' WHERE id = ".$ratifier["id"].";");
|
||||
}
|
||||
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE id = $hash;");
|
||||
if (!empty($alliance["signatures"]))
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
else
|
||||
$alliance["signatures"] = array();
|
||||
|
||||
$alliance["signatures"][] = $planete->id_user;
|
||||
$newnb = count($alliance["signatures"]);
|
||||
$alliance["signatures"] = ';'.implode(';', $alliance["signatures"]).';';
|
||||
$bdd->escape($alliance["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$alliance["signatures"]."' WHERE id = $hash;");
|
||||
if (debut_d_univers) //Si on est en début d'univers, on recherche une planète du joueur fondateur
|
||||
$planete_fondateur = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$alliance["fondateur"]." ORDER BY id ASC LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($newnb >= nb_signatures)
|
||||
{
|
||||
if (debut_d_univers && $newnb == nb_signatures && empty($planete_fondateur->vaisseaux[2]))
|
||||
{
|
||||
//On donne un vaisseau de colonisation au fondateur
|
||||
$planete_fondateur = new Planete($planete_fondateur["id"]);
|
||||
$planete_fondateur->vaisseaux[2]++;
|
||||
unset($planete_fondateur);
|
||||
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Pour vous féliciter, le conseil intergalactique a décidé de vous offrir un vaisseau de colonisation pour aller coloniser un astéroide afin d'implanter votre alliance.");
|
||||
}
|
||||
else
|
||||
//TODO refaire un message plus RP
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Envoyez-en un dès maintenant !");
|
||||
}
|
||||
else
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.");
|
||||
|
||||
erreur("Votre signature a bien été prise en compte !", "green");
|
||||
}
|
||||
else
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($hash);
|
||||
$fonder = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." LIMIT 1;");
|
||||
if (!empty($fonder))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Vous ne pouvez pas ratifier d'alliance car vous en fonder actuellement une !", "red");
|
||||
}
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE lien = '$hash';");
|
||||
$ratifier = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($alliance) && sha1($alliance['tag'].'Hb$'.$alliance['nom_alliance'].'☺Ø'.$alliance['fondateur'].'‘«'.$planete->race) == $hash)
|
||||
{
|
||||
if (!empty($alliance["signatures"]))
|
||||
{
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
if (in_array($planete->id_user, $alliance["signatures"]))
|
||||
erreur("Vous avez déjà ratifier cette alliance !");
|
||||
$alliance["nbsignatures"] = count($alliance["signatures"]);
|
||||
}
|
||||
else
|
||||
$alliance["nbsignatures"] = 0;
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("ratifier", $ratifier);
|
||||
}
|
||||
elseif (!empty($alliance))
|
||||
erreur("Impossible de ratifier cette alliance.<br />Vous n'êtes peut-être pas de la même race que le fondateur.", 'red', $VAR["menu"]["alliance"], 4000);
|
||||
else
|
||||
erreur("Vous ne pouvez plus signer pour cette alliance !", 'red', $_SERVER["HTTP_REFERER"], 4000);
|
||||
}
|
||||
?>
|
||||
91
onyx2/include/game/arbre.php
Normal file
91
onyx2/include/game/arbre.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'arbre';
|
||||
$titre = 'Arbre des technologies';
|
||||
|
||||
if (empty($_GET['q']))
|
||||
$_GET['q'] = '';
|
||||
$template->assign('defaut', gpc('q'));
|
||||
|
||||
//Récupération et vérification de la race voulue ou définition d'une race par défaut
|
||||
if (empty($_GET['r']) || (gpc('r') != 'humain' && gpc('r') != 'covenant'))
|
||||
$_GET['r'] = $planete->race;
|
||||
|
||||
$race = gpc('r');
|
||||
$template->assign('raceAff', $race);
|
||||
|
||||
if (SURFACE == "asteroide")
|
||||
{
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $id => $batiment)
|
||||
{
|
||||
if (!empty($LANG[$race]["alli_batiments"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => dAlliancesBatiments::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
}
|
||||
else
|
||||
{
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $id => $batiment)
|
||||
{
|
||||
if (!empty($LANG[$race]["batiments"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => dBatiments::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
}
|
||||
|
||||
/*
|
||||
$TEMP_technologies = array();
|
||||
$nb = count($technolo);
|
||||
for ($id=0 ; $id<$nb ; $id++) {
|
||||
if (!empty($technolo[$id])) $TEMP_technologies[] = array(
|
||||
'id' => $id,
|
||||
'nom' => $technolo[$id],
|
||||
'niveau' => $planete->technologies[$id],
|
||||
'etat' => readDeblok($technoloTECH[$id], $planete)
|
||||
);
|
||||
}
|
||||
$template->assign('technologies',$TEMP_technologies);
|
||||
*/
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->casernes as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["caserne"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dCaserne::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('caserne', $TEMP_liste);
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->terrestres as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["terrestre"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dTerrestre::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->vaisseaux as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["vaisseaux"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dSpatial::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('vaisseaux', $TEMP_liste);
|
||||
|
||||
unset($TEMP_liste, $id, $unite);
|
||||
?>
|
||||
97
onyx2/include/game/batiments.php
Normal file
97
onyx2/include/game/batiments.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
|
||||
$titre = 'Bâtiments';
|
||||
|
||||
//Si l'on est sur un astéroide, on vérifie que le joueur ait les permissions nécessaire
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &1))
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des bâtiments de l'astéroide.");
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['c']))
|
||||
{
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if(gpc('c') == 6 && $planete->file_tech->hasObject())
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
|
||||
$planete->file_bat->addObjet(intval(gpc('c')), 1, $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
//Lancement d'une déconstruction
|
||||
if (isset($_GET['d']))
|
||||
{
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if($_GET['d'] == 6 && $planete->file_tech->hasObject())
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
|
||||
$planete->file_bat->addDemolition(intval(gpc('d')), 1, $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$planete->file_bat->delObjet(intval(gpc('b')), 1, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$page = 'batiments';
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $i => $niveau)
|
||||
{
|
||||
//On vérifie le type par rapport à l'onglet
|
||||
if (isset($_GET["n"]) && !(intval($_GET["n"])& dBatiments::type($i)))
|
||||
continue;
|
||||
|
||||
//Si l'on est pas sur la planète mère, on désactive le laboratoire
|
||||
if ($i == 6 && $queryPlanetes[0]['id'] != $planete->id)
|
||||
continue;
|
||||
|
||||
if (!empty($LANG[$planete->race]['batiments']['noms_sing'][$i]) && dBatiments::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dBatiments::image($i, $planete),
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => dBatiments::metal($i, $niveau+1, $planete),
|
||||
'nec_cristal' => dBatiments::cristal($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => dBatiments::hydrogene($i, $niveau+1, $planete),
|
||||
'temps' => sec(dBatiments::temps($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'batiments_alli';
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $i => $niveau)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['alli_batiments']['noms_sing'][$i]) && dAlliancesBatiments::needed($i, $planete) && $niveau < 6)
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dAlliancesBatiments::image($i, $planete),
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => dAlliancesBatiments::metal($i, $niveau+1, $planete),
|
||||
'nec_cristal' => dAlliancesBatiments::cristal($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => dAlliancesBatiments::hydrogene($i, $niveau+1, $planete),
|
||||
'nec_credits' => dAlliancesBatiments::credits($i, $niveau+1, $planete),
|
||||
'temps' => sec(dAlliancesBatiments::temps($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
$template->assign('onglet', gpc("n"));
|
||||
$template->assign('files', $planete->file_bat->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $niveau, $i);
|
||||
?>
|
||||
102
onyx2/include/game/carte.php
Normal file
102
onyx2/include/game/carte.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$page = 'carte';
|
||||
$titre = 'Carte spatiale';
|
||||
|
||||
//Récupération d'un numéro d'amas à regarder
|
||||
if (isset($_GET['amas']))
|
||||
$g = intval(gpc('amas'));
|
||||
elseif (isset($_GET['galaxie']))
|
||||
$g = intval(gpc('galaxie'));
|
||||
else
|
||||
$g = $planete->galaxie;
|
||||
|
||||
//Validation du numéro de l'amas
|
||||
if ($planete->auth_level >= 5 && $g <= 0)
|
||||
$g = 0;
|
||||
elseif ($g < 1)
|
||||
$g = 1;
|
||||
if ($g > $VAR['nb_amas'])
|
||||
$g = 1;
|
||||
|
||||
//Récupération d'un numéro de système à regarder
|
||||
if (isset($_GET['systeme']))
|
||||
$s = intval(gpc('systeme'));
|
||||
elseif (isset($_GET['ss']))
|
||||
$s = intval(gpc('ss'));
|
||||
else
|
||||
$s = $planete->ss;
|
||||
|
||||
//Validation du numéro de système
|
||||
if ($s < 1)
|
||||
$s = 1;
|
||||
if ($s > $VAR['nb_systeme'])
|
||||
$s = $VAR['nb_systeme'];
|
||||
|
||||
//Calcul des prochains amas et systèmes
|
||||
if ($s == 1 && $g > 1)
|
||||
{
|
||||
$Gmu = $g - 1;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
}
|
||||
elseif ($s == 1)
|
||||
{
|
||||
$Gmu = 15;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$Gmu = $g;
|
||||
$Smu = $s - 1;
|
||||
}
|
||||
if ($s == $VAR['nb_systeme'])
|
||||
{
|
||||
$Gpu = $g + 1;
|
||||
$Spu = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Gpu = $g;
|
||||
$Spu = $s + 1;
|
||||
}
|
||||
|
||||
//Erreur au cas où la zone soit trop lointaine par rapport au niveau de la technologie
|
||||
//if (($planete->technologies[1] < 1 && ($g != $planete->galaxie || $s != $planete->ss)) || ($planete->technologies[1] < 2 && $g != $planete->galaxie))
|
||||
// erreur('Pour afficher cette zone de la carte spatiale, vous devez plus développer votre technologie ');
|
||||
|
||||
//Génération de la carte à afficher
|
||||
$TEMP_carte = array();
|
||||
for ($i = 1; $i <= $VAR['nb_planete']; $i++)
|
||||
{
|
||||
//Cas d'un système à astéroïde
|
||||
if ($s%5 == 2 && $i == ceil($VAR['nb_planete']/2))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$d = $bdd->unique_query("SELECT race, nom_asteroide, debris_met, debris_cri, nom_alliance, image, tag, fondateur FROM $table_alliances WHERE galaxie = $g AND ss = $s;");
|
||||
$bdd->deconnexion();
|
||||
if($d)
|
||||
$TEMP_carte[] = array('A', $d['nom_asteroide'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['nom_alliance'], $d['tag'], $d['image'], 0);
|
||||
else
|
||||
$TEMP_carte[] = array('A');
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->query("SELECT id FROM $table_planete WHERE galaxie = $g AND ss = $s AND position = $i;");
|
||||
if($resultat)
|
||||
{
|
||||
$d = $bdd->unique_query("SELECT P.nom_planete, P.image, P.debris_met, P.debris_cri, U.pseudo, U.race, U.politique, U.id_alliance, A.tag FROM $table_planete P INNER JOIN $table_user U ON U.id = P.id_user LEFT OUTER JOIN $table_alliances A ON A.id = U.id_alliance WHERE P.galaxie = $g AND P.ss = $s AND P.position = $i;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$TEMP_carte[] = array($i, $d['nom_planete'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['pseudo'], $d['tag'], $d['image'], $d['politique']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
$TEMP_carte[] = array($i);
|
||||
}
|
||||
}
|
||||
$template->assign('carte', $TEMP_carte);
|
||||
$template->assign('position', array($g, $s, $Gpu, $Spu, $Gmu, $Smu));
|
||||
|
||||
unset($TEMP_carte, $g, $s, $Gpu, $Spu, $Gmu, $Smu, $resultat, $d, $i);
|
||||
?>
|
||||
56
onyx2/include/game/caserne.php
Normal file
56
onyx2/include/game/caserne.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
|
||||
$page = 'caserne';
|
||||
$titre = $LANG[$planete->race]['batiments']['noms_sing'][9];
|
||||
|
||||
//Vérification que le joueur ait bien une caserne avant d'afficher la page
|
||||
if ($planete->batiments[9] <= 0)
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['batiments']['noms_sing'][9], "red", '?p=batiments', 3500);
|
||||
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[9] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
|
||||
//Lancement d'un nouvel entrainement
|
||||
if (isset($_GET['c']) && ($id = intval(gpc('c'))) >= 0 && $nbc = floor(gpc('cas'.$id, 'post')))
|
||||
{
|
||||
$planete->file_cas->addObjet($id, $nbc, $planete, $lieu);
|
||||
|
||||
redirection($VAR['menu']['caserne']."&k=".$lieu);
|
||||
}
|
||||
//Annulation d'un entrainement
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_cas->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['caserne']."&k=".$lieu);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->casernes as $i => $nombre)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['caserne']['noms_sing'][$i]) && dCaserne::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dCaserne::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dCaserne::metal($i, 1, $planete),
|
||||
'nec_cristal' => dCaserne::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dCaserne::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dCaserne::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_cas->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
$template->assign('lieu', $lieu);
|
||||
$template->assign('files', $planete->file_cas->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau);
|
||||
?>
|
||||
74
onyx2/include/game/chantierspatial.php
Normal file
74
onyx2/include/game/chantierspatial.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
|
||||
$page = 'chantierspatial';
|
||||
if (SURFACE == "planete")
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][8]);
|
||||
else
|
||||
$titre = ucfirst($LANG[$planete->race]['alli_batiments']['noms_sing'][3]);
|
||||
|
||||
//Si l'on est sur un astéroide, on vérifie que le joueur ait les permissions nécessaire
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &2))
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des vaisseaux de l'astéroide.");
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if (SURFACE == "planete" && $planete->batiments[8] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][8], "red", '?p=batiments', 3500);
|
||||
elseif(SURFACE == "asteroide" && $planete->batiments[3] <= 0)
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['alli_batiments']['noms_sing'][3], "red", '?p=batiments', 3500);
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[8] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
}
|
||||
elseif (SURFACE == "asteroide")
|
||||
{
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[3] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
}
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('vais'.$id, 'post')))
|
||||
{
|
||||
$planete->file_vais->addObjet($id, $nbv, $planete, $lieu);
|
||||
|
||||
redirection($VAR['menu']['chantierspatial']."&k=".$lieu);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_vais->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['chantierspatial']."&k=".$lieu);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->vaisseaux as $i => $nombre)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['vaisseaux']['noms_sing'][$i]) && dSpatial::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dSpatial::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dSpatial::metal($i, 1, $planete),
|
||||
'nec_cristal' => dSpatial::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dSpatial::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dSpatial::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_vais->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('vaisseaux', $TEMP_liste);
|
||||
$template->assign('lieu', $lieu);
|
||||
$template->assign('files', $planete->file_vais->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau);
|
||||
?>
|
||||
63
onyx2/include/game/chantierterrestre.php
Normal file
63
onyx2/include/game/chantierterrestre.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
|
||||
$page = $p;
|
||||
$onglet = gpc('n');
|
||||
if (!empty($onglet))
|
||||
$template->assign('onglet', $onglet);
|
||||
else
|
||||
$template->assign('onglet', "unites");
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][7]);
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if ($planete->batiments[7] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][7], "red", '?p=batiments', 3500);
|
||||
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[7] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('terr'.$id, 'post')))
|
||||
{
|
||||
$planete->file_ter->addObjet($id, $nbv, $planete, $lieu);
|
||||
|
||||
redirection($VAR['menu'][$p].'&k='.$lieu.'&n='.$onglet);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_ter->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu'][$p].'&k='.$lieu.'&n='.$onglet);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->terrestres as $i => $nombre)
|
||||
{
|
||||
$type = dTerrestre::type($i);
|
||||
|
||||
if (!empty($LANG[$planete->race]['terrestre']['noms_sing'][$i]) && (($onglet == "defenses" && !$type) || ($onglet != "defenses" && $type)) && dTerrestre::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dTerrestre::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dTerrestre::metal($i, 1, $planete),
|
||||
'nec_cristal' => dTerrestre::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dTerrestre::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dTerrestre::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_ter->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
$template->assign('lieu', $lieu);
|
||||
$template->assign('files', $planete->file_ter->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau, $onglet, $type);
|
||||
?>
|
||||
153
onyx2/include/game/description.php
Normal file
153
onyx2/include/game/description.php
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'description';
|
||||
$titre = 'Détails';
|
||||
|
||||
function tableauProd($ibat,$nivo)
|
||||
{
|
||||
$return = array();
|
||||
$c = $nivo-2 < 1 ? 1 : $nivo-2;
|
||||
$a = $c + 6;
|
||||
|
||||
if ($ibat == 0)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 52 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 52 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 1)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 34 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 34 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 2)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 21 * ($c + 0.7));
|
||||
$production_diff = ceil(pow(1.1, $c) * 21 * ($c + 0.7)) - ceil(pow(1.1, $nivo) * 21 * ($nivo + 0.7));
|
||||
|
||||
$energie = ceil(exp(0.2849*$c)*13);
|
||||
$energie_diff = ceil(exp(0.2849*$c)*13) - ceil(exp(0.2849*$nivo)*13);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 3)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(exp(0.28*$c)*22);
|
||||
$production_diff = ceil(exp(0.28*$c)*22) - ceil(exp(0.28*$nivo)*22);
|
||||
|
||||
$return[] = array($c, $production, 0, $production_diff, 0);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 4) {
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(exp(0.297*$c)*25);
|
||||
$production_diff = ceil(exp(0.297*$c)*25) - ceil(exp(0.297*$nivo)*25);
|
||||
|
||||
$energie = ceil(pow(1.34,($c-1)) * 9);
|
||||
$energie_diff = ceil(pow(1.34,($c-1)) * 9) - ceil(pow(1.34,($nivo-1)) * 9);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
if (empty($_GET['r']) || ($_GET['r'] != 'humain' && $_GET['r'] != 'covenant'))
|
||||
$_GET['r'] = $planete->race;
|
||||
$race = gpc('r');
|
||||
$template->assign('raceAff', $race);
|
||||
|
||||
if (isset($_GET['t']) && is_numeric($_GET['t']) && !empty($LANG[$race]["technologies"]["noms_sing"][$_GET['b']][$_GET['t']]))
|
||||
{
|
||||
$template->assign('type', 'technologies');
|
||||
$b = intval(gpc('b'));
|
||||
$t = intval(gpc('t'));
|
||||
$template->assign('branche', $b);
|
||||
$template->assign('id', $t);
|
||||
|
||||
$template->assign('ressourcesNext', array(Donnee::creditsTechnologie($b, $t, $planete), Donnee::tempsTechnologie($b, $t, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededTechnologie($b, $t, $planete, $race));
|
||||
}
|
||||
elseif (isset($_GET['b']) && is_numeric($_GET['b']) && !empty($LANG[$race]["batiments"]["noms_sing"][$_GET['b']]))
|
||||
{
|
||||
$template->assign('type', 'batiments');
|
||||
$t = intval(gpc('b'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dBatiments::image($t, $planete));
|
||||
$template->assign('tableau_prod', tableauProd($t, $planete->batiments[$t]));
|
||||
|
||||
$n = $planete->batiments[$t] + 1;
|
||||
$template->assign('ressourcesNext', array(dBatiments::metal($t, $n, $planete), dBatiments::cristal($t, $n, $planete), dBatiments::hydrogene($t, $n, $planete), dBatiments::temps($t, $n, $planete)));
|
||||
|
||||
$template->assign('etat', dBatiments::needed($t, $planete, true));
|
||||
}
|
||||
elseif (isset($_GET['v']) && is_numeric($_GET['v']) && !empty($LANG[$race]["vaisseaux"]["noms_sing"][$_GET['v']]))
|
||||
{
|
||||
$template->assign('type', 'vaisseaux');
|
||||
$t = intval(gpc('v'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dSpatial::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dSpatial::metal($t, 1, $planete), dSpatial::cristal($t, 1, $planete), dSpatial::hydrogene($t, 1, $planete), dSpatial::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dSpatial::needed($t, $planete, $race));
|
||||
$template->assign('caract', array($nomvais_at[$t], $nomvais_bc[$t], $nomvais_pv[$t], $nomvais_rs[$t]));
|
||||
}
|
||||
elseif (isset($_GET['d']) && is_numeric($_GET['d']) && !empty($LANG[$race]["terrestre"]["noms_sing"][$_GET['d']]))
|
||||
{
|
||||
$template->assign('type', 'terrestre');
|
||||
$t = gpc('d');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dTerrestre::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dTerrestre::metal($t, 1, $planete), dTerrestre::cristal($t, 1, $planete), dTerrestre::hydrogene($t, 1, $planete), dTerrestre::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dTerrestre::needed($t, $planete, true));
|
||||
if ($t-8 >= 0)
|
||||
{
|
||||
$t -= 8;
|
||||
$template->assign('caract', array($defense_at[$t], $defense_bc[$t], $defense_pv[$t]));
|
||||
}
|
||||
}
|
||||
elseif (isset($_GET['c']) && is_numeric($_GET['c']) && !empty($LANG[$race]["caserne"]["noms_sing"][$_GET['c']]))
|
||||
{
|
||||
$template->assign('type', 'caserne');
|
||||
$t = gpc('c');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dCaserne::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dCaserne::metal($t, 1, $planete), dCaserne::cristal($t, 1, $planete), dCaserne::hydrogene($t, 1, $planete), dCaserne::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dCaserne::needed($t, $planete, true));
|
||||
$template->assign('caract', array('!!', '!!', '!!'));
|
||||
}
|
||||
else
|
||||
redirection('?p=accueil');
|
||||
|
||||
unset($t, $race);
|
||||
?>
|
||||
|
|
@ -2,21 +2,21 @@
|
|||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$titre = 'Flottes';
|
||||
$page = 'flotte'; //Définition d'un nom de page inexistant, mais permet de passer le nom de l'onglet dans une erreur
|
||||
include_once("game/Class/class.flotte.php");
|
||||
include_once("Class/flotte.php");
|
||||
|
||||
//Création de flotte : envoi final
|
||||
if (!empty($_POST['cds']) && !empty($SESS->values["prepFlottes"][$_POST['cds']]))
|
||||
require('game/jeu/flottes/envoyer.php');
|
||||
require('game/flottes/envoyer.php');
|
||||
//Restauration d'une flotte sauvegardée
|
||||
elseif (isset($_GET['c']) && !empty($SESS->values["prepFlottes"][$_GET['c']]))
|
||||
require('game/jeu/flottes/restaure.php');
|
||||
require('game/flottes/restaure.php');
|
||||
//Création de flotte : page 2
|
||||
elseif (!empty($_POST['envoie']) || !empty($_POST['groupe']))
|
||||
require('game/jeu/flottes/preparer.php');
|
||||
require('game/flottes/preparer.php');
|
||||
//Affichage du détail d'une flotte
|
||||
elseif (!empty($_GET['n']))
|
||||
require('game/jeu/flottes/details.php');
|
||||
require('game/flottes/details.php');
|
||||
//Affichage de la page générale
|
||||
else
|
||||
require('game/jeu/flottes/principal.php');
|
||||
require('game/flottes/principal.php');
|
||||
?>
|
||||
162
onyx2/include/game/flottes/envoyer.php
Normal file
162
onyx2/include/game/flottes/envoyer.php
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
//Récupération des informations envoyées
|
||||
$idPrep = gpc("cds", "post");
|
||||
|
||||
$SESS->values["prepFlottes"][$idPrep]['nom'] = gpc('nomflotte', 'post');
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_galaxie'] = $end_galaxie = intval(gpc('amas', 'post'));
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_systeme'] = $end_ss = intval(gpc('ss', 'post'));
|
||||
$end_pos = gpc('pos', 'post');
|
||||
if ($end_pos != "A")
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = floor($end_pos);
|
||||
else
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = $end_pos;
|
||||
$SESS->values["prepFlottes"][$idPrep]['embarquer'] = array($EBmetal = floor(str_replace(' ', '', gpc('metal', 'post'))), $EBcristal = floor(str_replace(' ', '', gpc('cristal', 'post'))), $EBhydrogene = floor(str_replace(' ', '', gpc('hydrogene', 'post'))));
|
||||
$SESS->values["prepFlottes"][$idPrep]['mission'] = $mission = intval(gpc('mission', 'post'));
|
||||
$SESS->values["prepFlottes"][$idPrep]['vitesse'] = $vitesse = intval(gpc('vitesse', 'post'));
|
||||
|
||||
//On met à jour la session
|
||||
$SESS->put();
|
||||
|
||||
//Vérification du nombre de vaisseaux sur la planète
|
||||
foreach ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
//On vérifie qu'il y a suffisamment de vaisseaux sur la planète
|
||||
if ($planete->vaisseaux[$key] < $vaisseau)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//Vérification des conditions de mission
|
||||
if ($mission <= 0 || $mission > 7 || ($SESS->values["prepFlottes"][$idPrep]['type'] == 3 && $mission != 3 && $mission != 2))
|
||||
erreur("La mission sélectionnée est incorrecte !", "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//Vérification que le nombre de slots ne soit pas dépassé
|
||||
if (slots($planete->id_user) <= 0)
|
||||
erreur('Vous ne pouvez pas envoyer plus de flottes simultanément.', "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//Vérifications en cas de mission colonisation
|
||||
if ($mission == 2)
|
||||
{
|
||||
//On vérifie la mission, si elle est de coloniser, il faut qu'il y ait des vaisseaux de colonisation
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][2] <= 0)
|
||||
erreur('Vous ne pouvez pas coloniser sans vaisseau de colonisation !', "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//On vérifie qu'une colonisation d'asteroide soit bien faite par un fondateur d'alliance en cours de création
|
||||
if ($end_pos == "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
if (!$resultat)
|
||||
erreur('Fonder d\'abord une alliance avant de coloniser un astéroide !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
}
|
||||
|
||||
//On vérifie que les attaques soient bien activées
|
||||
if ($mission == 3 && !$VAR["attaques"])
|
||||
erreur('Les attaques sont désactivées pour le moment. Pour plus d\'informations, <a href="'.$VAR["menu"]["forums"].'">consultez le forum</a>.', "red", $VAR["menu"]["flotte"], 5000);
|
||||
|
||||
//On vérifie la mission, si elle est de recycler, il faut qu'il y ait des reclycleurs
|
||||
if ($mission == 4 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][3] <= 0)
|
||||
erreur('Vous ne pouvez pas recycler sans recycleur !', "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//On vérifie la mission, si elle est d'espionner, il faut qu'il y ait des sondes
|
||||
if ($mission == 5 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][6] <= 0 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][13] <= 0)
|
||||
erreur('Vous ne pouvez pas espionner sans sonde d\'espionnage !', "red", '?p=flotte');
|
||||
|
||||
//Vérification que la destination ne soit pas en dehors de la galaxie
|
||||
if ($end_galaxie > $VAR['nb_amas'] || $end_ss > $VAR['nb_systeme'] || $end_galaxie < 0 || $end_ss < 1 || (($end_pos > $VAR['nb_planete'] || $end_pos < 1) && $end_pos != "A") || ($end_galaxie < 1 && $SESS->level < 6))
|
||||
erreur('La destination de la flotte n\'est pas correcte.', "red", '?p=flotte');
|
||||
|
||||
//On vérifie que l'on possède assez de ressources
|
||||
if ((!empty($EBmetal) && !$EBmetal > $planete->metal) || (!empty($EBcristal) && !$EBcristal > $planete->cristal) || (!empty($EBhydrogene) && !$EBhydrogene > $planete->hydrogene))
|
||||
erreur('Vous ne pouvez pas envoyer plus de ressources que vous n\'en posséder.', "red", '?p=flotte');
|
||||
|
||||
//On vérifie que l'on n'envoie pas des ressources négatives
|
||||
if ((!empty($EBmetal) && $EBmetal < 0) || (!empty($EBcristal) && $EBcristal < 0) || (!empty($EBhydrogene) && $EBhydrogene < 0))
|
||||
erreur('Vous avez spécifié des valeurs de ressources à embarquer incorrectes !', "red", '?p=flotte', 4000);
|
||||
|
||||
//On vérifie la vitesse de la flotte
|
||||
if (!is_numeric($vitesse) || $vitesse < 0 || $vitesse > 100)
|
||||
erreur('La vitesse de votre flotte est incorrecte !', "red", '?p=flotte');
|
||||
|
||||
|
||||
//Recherche de la planète ou de l'astéroïde
|
||||
if ($end_pos == "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id AS id_user, debris_met, debris_cri FROM $table_alliances WHERE galaxie = $end_galaxie AND ss = $end_ss;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id_user, debris_met, debris_cri FROM $table_planete WHERE galaxie = $end_galaxie AND ss = $end_ss AND position = $end_pos;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une interaction entre deux multi-comptes
|
||||
if (count($multi) > 1 && ($mission == 1 || $mission == 6 || $mission == 7))
|
||||
{
|
||||
foreach($multi as $test)
|
||||
{
|
||||
if ($test['id_util'] == $resultat['id_user'])
|
||||
erreur('Vous ne pouvez pas avoir d\'interaction avec ce joueur pour raison de multi-compte (voir page d\'accueil).');
|
||||
}
|
||||
}
|
||||
|
||||
if ($mission == 1 && !$resultat)
|
||||
erreur('Impossible de transporter des ressources vers la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
elseif ($mission == 2 && $resultat)
|
||||
{
|
||||
if ($end_pos != "A")
|
||||
erreur('La planète que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
else
|
||||
erreur('L\'astéroide que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
}
|
||||
//Si la mission est d'attaquer, on vérifie que le joueur cible ne soit pas ne mode vacances ou qu'il soit tout jeune
|
||||
elseif ($mission == 3 && $end_pos != "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultatu = $bdd->unique_query("SELECT mv, time_inscription FROM $table_user WHERE id = ".$resultat['id_user'].";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($resultatu['mv'] > 0)
|
||||
erreur('Le joueur que vous tentez d\'attaquer est actuellement en mode vacances, vous ne pouvez donc pas l\'attaquer avant son retour de vacances.', "red", '?p=flotte', 3000); //TODO Mettre le numéro du mode vacances et non > 0 !!!
|
||||
elseif ($resultatu['time_inscription'] + 604800 > time())
|
||||
erreur('Le joueur que vous tentez d\'attaquer s\'est inscrit récemment, laissez-lui le temps de se préparer au combat !', "red", '?p=flotte', 3000);
|
||||
elseif (!$resultat)
|
||||
erreur('La planète que vous tentez d\'attaquer est inhabitée.', "red", '?p=flotte');
|
||||
elseif ($resultat['id_user'] == $planete->id_user)
|
||||
erreur('La planète que vous tentez d\'attaquer vous appartient.', "red", '?p=flotte');
|
||||
}
|
||||
elseif ($mission == 4 && ($resultat['debris_met'] <= 0 || $resultat['debris_cri'] <= 0) && empty($SESS->values['forceFlotte']))
|
||||
{
|
||||
$SESS->values['forceFlotte'] = true;
|
||||
$SESS->put();
|
||||
erreur('Il n\'y a rien à recycler sur la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'].<br />Vous pouvez forcer le lancement de la flotte en rechargeant cette page.', "orange");
|
||||
}
|
||||
//TODO Autoriser l'espionnage sur les planètes inhabités
|
||||
elseif ($mission == 5)
|
||||
{
|
||||
if (!$resultat)
|
||||
erreur('Impossible d\'espionner la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
elseif ($end_pos != "A" && $resultat['id_user'] == $planete->id_user)
|
||||
erreur('La planète que vous désirez espionner vous appartient !', "red", '?p=flotte', 3000);
|
||||
}
|
||||
|
||||
elseif ($mission == 6 && $resultat['id_user'] != $planete->id_user && $resultat['id_user'] != $planete->id_alliance)
|
||||
erreur('La planète sur laquelle vous désirez stationner ne vous appartient pas.', "red", '?p=flotte', 3000);
|
||||
elseif ($mission == 7 && !$resultat)
|
||||
erreur('La planète sur laquelle vous désirez donner vos vaisseaux n\'existe pas.', "red", '?p=flotte', 3000);
|
||||
|
||||
|
||||
//Création de la flotte
|
||||
$flotte = new flotte();
|
||||
$flotte->creer($planete, $SESS->values["prepFlottes"][$idPrep], $resultat);
|
||||
$SESS->values["prepFlottes"][$idPrep]["statut"] = 2;
|
||||
$SESS->put();
|
||||
|
||||
erreur('Votre flotte a été envoyée avec succès.', "green", '?p=flotte', 4000);
|
||||
?>
|
||||
47
onyx2/include/game/flottes/preparer.php
Normal file
47
onyx2/include/game/flottes/preparer.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
//Génération d'un ID unique pour identifier la flotte durant sa création
|
||||
$idPrep = random();
|
||||
|
||||
//Création du tableau de session
|
||||
$SESS->values["prepFlottes"][$idPrep] = array();
|
||||
|
||||
//On récupère les vaisseaux à envoyer
|
||||
$nombreVaisseau = 0;
|
||||
foreach ($planete->vaisseaux as $key => $vaisseau)
|
||||
{
|
||||
$v = gpc('v'.$key, 'post');
|
||||
if (!is_numeric($v) || $v < 0)
|
||||
$v = 0;
|
||||
|
||||
$SESS->values["prepFlottes"][$idPrep]['vaisseaux'][$key] = $v;
|
||||
$nombreVaisseau += $v;
|
||||
}
|
||||
//On vérifie que l'utilisateur a bien envoyé plus d'un vaisseau
|
||||
if ($nombreVaisseau <= 0)
|
||||
{
|
||||
unset($SESS->values["prepFlottes"][$idPrep]);
|
||||
erreur('Vous devez envoyer au moins un vaisseau.', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//On définit le type de la flotte (utilisateur ou alliance)
|
||||
if (!empty($_POST['envoie']))
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 1;
|
||||
elseif (!empty($_POST['groupe']))
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 2;
|
||||
else
|
||||
die ('Erreur !');
|
||||
|
||||
//On enregistre les paramètres en session
|
||||
$SESS->values["prepFlottes"][$idPrep]['nbVaisseaux'] = $nombreVaisseau;
|
||||
$SESS->values['forceFlotte'] = false;
|
||||
$SESS->values["prepFlottes"][$idPrep]['time'] = time();
|
||||
$SESS->values["prepFlottes"][$idPrep]['statut'] = 1;
|
||||
$SESS->put();
|
||||
|
||||
unset($nombreVaisseau, $key, $vaisseau, $v);
|
||||
|
||||
header('Location: ?p=flotte&c='.$idPrep);
|
||||
exit;
|
||||
?>
|
||||
56
onyx2/include/game/flottes/restaure.php
Normal file
56
onyx2/include/game/flottes/restaure.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
$idPrep = gpc('c');
|
||||
$template->assign('idPrep', $idPrep);
|
||||
$template->assign('restaure', $SESS->values["prepFlottes"][$idPrep]);
|
||||
|
||||
foreach ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
//On vérifie qu'il y a suffisamment de vaisseaux sur la planète
|
||||
if ($planete->vaisseaux[$key] < $vaisseau)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//Génération de la liste de mission possible avec les vaisseaux de la flotte
|
||||
$missions = array();
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['type'] == 1)
|
||||
$missions = array(6 => "Stationner", 7 => "Donner des vaisseaux", 1 => "Transporter");
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][2])
|
||||
$missions[2] = "Coloniser";
|
||||
if ($planete->technologies[7]& 16 && $VAR["attaques"])
|
||||
$missions[3] = "Attaquer";
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['type'] == 1 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][3])
|
||||
$missions[4] = "Recycler";
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['type'] == 1 && ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][6] || $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][13]))
|
||||
$missions[5] = "Espionner";
|
||||
|
||||
//S'il n'y a aucun choix de mission possible, on abandonne
|
||||
if (count($missions) == 0)
|
||||
erreur('Aucune mission disponible !', "red", '?p=flotte');
|
||||
$template->assign('missions', $missions);
|
||||
|
||||
$template->assign('scripth', '<script src="js/prototype.js" type="text/javascript"></script>');
|
||||
$template->assign('script', '<script type="text/javascript">document.getElementById(\'nom\').focus();</script><script src="js/flotte.js" type="text/javascript"></script>');
|
||||
$page = 'flotte2';
|
||||
|
||||
//Récupération des destinations favorites et des colonies
|
||||
$favoris = array();
|
||||
include_once("Class/tinyplanete.php");
|
||||
foreach ($planete->destinationsFavoris as $fav)
|
||||
{
|
||||
$fav_Planete = new TinyPlanete($fav);
|
||||
if (!empty($fav_Planete->nom_planete)) $favoris[$fav_Planete->id] = $fav_Planete->nom_planete;
|
||||
else $favoris[$fav_Planete->id] = '['.$fav_Planete->galaxie.':'.$fav_Planete->ss.':'.$fav_Planete->position.']';
|
||||
}
|
||||
$favorisC = array();
|
||||
foreach ($queryPlanetes as $fav)
|
||||
{
|
||||
if (!empty($fav['nom_planete'])) $favorisC[$fav['id']] = $fav['nom_planete'];
|
||||
else $favorisC[$fav['id']] = '['.$fav['galaxie'].':'.$fav['ss'].':'.$fav['position'].']';
|
||||
}
|
||||
$template->assign('favoris', $favoris);
|
||||
$template->assign('favorisColonies', $favorisC);
|
||||
|
||||
unset($idPrep, $missions, $fav, $vaisseau, $key, $favorisC, $favoris);
|
||||
?>
|
||||
|
|
@ -3,7 +3,7 @@ if(!defined('INDEX')) { header('Location: ../'); exit; }
|
|||
|
||||
//Si l'on est sur un astéroïde, on charge la page de gestion d'alliance !
|
||||
if (SURFACE == "asteroide")
|
||||
include("game/jeu/alliances/gestion.php");
|
||||
include("game/alliances/gestion.php");
|
||||
else
|
||||
{
|
||||
$page = 'gestion';
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
//Constante pour savoir si l'on offre ou pas un vaisseau de colonisation et s'il est possible de se désangager d'une signature
|
||||
define("debut_d_univers", true);
|
||||
|
||||
$hash = gpc('signer');
|
||||
|
||||
$page = 'alliance/nm_signer';
|
||||
if (!empty($planete->id_alliance))
|
||||
erreur("Vous êtes déjà dans une alliance, vous ne pouvez pas ratifier d'alliance !", "red");
|
||||
elseif (!empty($_POST["sign"]))
|
||||
{
|
||||
if (trim(strtolower(gpc("sign", "post"))) == "oui")
|
||||
{
|
||||
$hash = intval($hash);
|
||||
$bdd->reconnexion();
|
||||
$ratifier = $bdd->unique_query("SELECT id, fondateur, signatures FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
if (!empty($ratifier))
|
||||
{
|
||||
$ratifier["signatures"] = explode(';', substr($ratifier["signatures"], 1), -1);
|
||||
unset($ratifier["signatures"][array_search($planete->id_user, $ratifier["signatures"])]);
|
||||
if (count($ratifier["signatures"]) == 0)
|
||||
$ratifier["signatures"] = "";
|
||||
else
|
||||
$ratifier["signatures"] = ';'.implode(';', $ratifier["signatures"]).';';
|
||||
$bdd->escape($ratifier["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$ratifier["signatures"]."' WHERE id = ".$ratifier["id"].";");
|
||||
}
|
||||
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE id = $hash;");
|
||||
if (!empty($alliance["signatures"]))
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
else
|
||||
$alliance["signatures"] = array();
|
||||
|
||||
$alliance["signatures"][] = $planete->id_user;
|
||||
$newnb = count($alliance["signatures"]);
|
||||
$alliance["signatures"] = ';'.implode(';', $alliance["signatures"]).';';
|
||||
$bdd->escape($alliance["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$alliance["signatures"]."' WHERE id = $hash;");
|
||||
if (debut_d_univers) //Si on est en début d'univers, on recherche une planète du joueur fondateur
|
||||
$planete_fondateur = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$alliance["fondateur"]." ORDER BY id ASC LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($newnb >= 4)
|
||||
{
|
||||
if (debut_d_univers && $newnb == 4)
|
||||
{
|
||||
//On donne un vaisseau de colonisation au fondateur
|
||||
$planete_fondateur = new Planete($planete_fondateur["id"]);
|
||||
$planete_fondateur->vaisseaux[2]++;
|
||||
unset($planete_fondateur);
|
||||
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Pour vous féliciter, le conseil intergalactique a décidé de vous offrir un vaisseau de colonisation pour aller coloniser un astéroide afin d'implanter votre alliance.");
|
||||
}
|
||||
else
|
||||
//TODO refaire un message plus RP
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Envoyez-en un dès maintenant !");
|
||||
}
|
||||
else
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.");
|
||||
|
||||
erreur("Votre signature a bien été prise en compte !", "green");
|
||||
}
|
||||
else
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($hash);
|
||||
$fonder = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." LIMIT 1;");
|
||||
if (!empty($fonder))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Vous ne pouvez pas ratifier d'alliance car vous en fonder actuellement une !", "red");
|
||||
}
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE lien = '$hash';");
|
||||
$ratifier = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($alliance) && sha1($alliance['tag'].'Hb$'.$alliance['nom_alliance'].'☺Ø'.$alliance['fondateur'].'‘«'.$planete->race) == $hash)
|
||||
{
|
||||
if (!empty($alliance["signatures"]))
|
||||
{
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
if (in_array($planete->id_user, $alliance["signatures"]))
|
||||
erreur("Vous avez déjà ratifier cette alliance !");
|
||||
$alliance["nbsignatures"] = count($alliance["signatures"]);
|
||||
}
|
||||
else
|
||||
$alliance["nbsignatures"] = 0;
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("ratifier", $ratifier);
|
||||
}
|
||||
elseif (!empty($alliance))
|
||||
erreur("Impossible de ratifier cette alliance.<br />Vous n'êtes peut-être pas de la même race que le fondateur.", 'red', $VAR["menu"]["alliance"], 4000);
|
||||
else
|
||||
erreur("Vous ne pouvez plus signer pour cette alliance !", 'red', $_SERVER["HTTP_REFERER"], 4000);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'arbre';
|
||||
$titre = 'Arbre des technologies';
|
||||
|
||||
if (empty($_GET['q']))
|
||||
$_GET['q'] = '';
|
||||
$template->assign('defaut', gpc('q'));
|
||||
|
||||
//Récupération et vérification de la race voulue ou définition d'une race par défaut
|
||||
if (empty($_GET['r']) || (gpc('r') != 'humain' && gpc('r') != 'covenant'))
|
||||
$_GET['r'] = $planete->race;
|
||||
|
||||
$race = gpc('r');
|
||||
$template->assign('raceAff', $race);
|
||||
|
||||
if (SURFACE == "asteroide")
|
||||
{
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $id => $batiment)
|
||||
{
|
||||
if (!empty($LANG[$race]["alli_batiments"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => Donnee::print_neededAlli_Batiments($id, $planete, $race)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
}
|
||||
else
|
||||
{
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $id => $batiment)
|
||||
{
|
||||
if (!empty($LANG[$race]["batiments"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => Donnee::print_neededBatiments($id, $planete, $race)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
}
|
||||
|
||||
/*
|
||||
$TEMP_technologies = array();
|
||||
$nb = count($technolo);
|
||||
for ($id=0 ; $id<$nb ; $id++) {
|
||||
if (!empty($technolo[$id])) $TEMP_technologies[] = array(
|
||||
'id' => $id,
|
||||
'nom' => $technolo[$id],
|
||||
'niveau' => $planete->technologies[$id],
|
||||
'etat' => readDeblok($technoloTECH[$id], $planete)
|
||||
);
|
||||
}
|
||||
$template->assign('technologies',$TEMP_technologies);
|
||||
*/
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->casernes as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["caserne"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => Donnee::print_neededCaserne($id, $planete, $race)
|
||||
);
|
||||
}
|
||||
$template->assign('caserne', $TEMP_liste);
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->terrestres as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["terrestre"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => Donnee::print_neededTerrestre($id, $planete, $race)
|
||||
);
|
||||
}
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->vaisseaux as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["vaisseaux"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => Donnee::print_neededVaisseaux($id, $planete, $race)
|
||||
);
|
||||
}
|
||||
$template->assign('vaisseaux', $TEMP_liste);
|
||||
|
||||
unset($TEMP_liste, $id, $unite);
|
||||
?>
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$titre = 'Batiments';
|
||||
|
||||
//Si l'on est sur un astéroide, on vérifie que le joueur ait les permissions nécessaire
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &1))
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des bâtiments de l'astéroide.");
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['c']))
|
||||
{
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if(gpc('c') == 6 && $planete->file_tech->hasObject())
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
|
||||
$planete->file_bat->batiment_addObjet(intval(gpc('c')), $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
//Lancement d'une déconstruction
|
||||
if (isset($_GET['d']))
|
||||
{
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if($_GET['d'] == 6 && $planete->file_tech->hasObject())
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
|
||||
$planete->file_bat->batiment_addDemolition(intval(gpc('d')), $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']))
|
||||
{
|
||||
$planete->file_bat->batiment_delObjet(intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$page = 'batiments';
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $i => $niveau)
|
||||
{
|
||||
//Si l'on est pas sur la planète mère, on désactive le laboratoire
|
||||
if ($i == 6 && $queryPlanetes[0]['id'] != $planete->id)
|
||||
continue;
|
||||
|
||||
if (!empty($LANG[$planete->race]['batiments']['noms_sing'][$i]) && Donnee::neededBatiments($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => $batimeni[$i],
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => Donnee::metalBatiments($i, $niveau+1, $planete),
|
||||
'nec_cristal' => Donnee::cristalBatiments($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => Donnee::hydrogeneBatiments($i, $niveau+1, $planete),
|
||||
'temps' => sec(Donnee::tempsBatiments($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->batiment_objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'batiments_alli';
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $i => $niveau)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['alli_batiments']['noms_sing'][$i]) && Donnee::neededAlli_Batiments($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => $alli_batimeni[$i],
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => Donnee::metalAlli_Batiments($i, $niveau+1, $planete),
|
||||
'nec_cristal' => Donnee::cristalAlli_Batiments($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => Donnee::hydrogeneAlli_Batiments($i, $niveau+1, $planete),
|
||||
'nec_credits' => Donnee::creditsAlli_Batiments($i, $niveau+1, $planete),
|
||||
'temps' => sec(Donnee::tempsAlli_Batiments($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->batiment_objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
$template->assign('file', $planete->file_bat->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $niveau, $i);
|
||||
?>
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$page = 'carte';
|
||||
$titre = 'Carte spatiale';
|
||||
|
||||
//Récupération d'un numéro d'amas à regarder
|
||||
if (isset($_GET['galaxie']))
|
||||
$g = intval(gpc('galaxie'));
|
||||
else
|
||||
$g = $planete->galaxie;
|
||||
|
||||
//Validation du numéro de l'amas
|
||||
if ($planete->auth_level >= 5 && $g <= 0)
|
||||
$g = 0;
|
||||
elseif ($g < 1)
|
||||
$g = 1;
|
||||
if ($g > $VAR['nb_amas'])
|
||||
$g = 1;
|
||||
|
||||
//Récupération d'un numéro de système à regarder
|
||||
if (isset($_GET['ss']))
|
||||
$s = intval(gpc('ss'));
|
||||
else
|
||||
$s = $planete->ss;
|
||||
|
||||
//Validation du numéro de système
|
||||
if ($s < 1)
|
||||
$s = 1;
|
||||
if ($s > $VAR['nb_systeme'])
|
||||
$s = $VAR['nb_systeme'];
|
||||
|
||||
//Calcul des prochains amas et systèmes
|
||||
if ($s == 1 && $g > 1)
|
||||
{
|
||||
$Gmu = $g - 1;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
}
|
||||
elseif ($s == 1)
|
||||
{
|
||||
$Gmu = 15;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$Gmu = $g;
|
||||
$Smu = $s - 1;
|
||||
}
|
||||
if ($s == $VAR['nb_systeme'])
|
||||
{
|
||||
$Gpu = $g + 1;
|
||||
$Spu = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Gpu = $g;
|
||||
$Spu = $s + 1;
|
||||
}
|
||||
|
||||
//Erreur au cas où la zone soit trop lointaine par rapport au niveau de la technologie
|
||||
//if (($planete->technologies[1] < 1 && ($g != $planete->galaxie || $s != $planete->ss)) || ($planete->technologies[1] < 2 && $g != $planete->galaxie))
|
||||
// erreur('Pour afficher cette zone de la carte spatiale, vous devez plus développer votre technologie ');
|
||||
|
||||
//Génération de la carte à afficher
|
||||
$TEMP_carte = array();
|
||||
for ($i = 1; $i <= $VAR['nb_planete']; $i++)
|
||||
{
|
||||
//Cas d'un système à astéroïde
|
||||
if ($s%5 == 2 && $i == ceil($VAR['nb_planete']/2))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$d = $bdd->unique_query("SELECT race, nom_asteroide, debris_met, debris_cri, nom_alliance, image, tag, fondateur FROM $table_alliances WHERE galaxie = $g AND ss = $s;");
|
||||
$bdd->deconnexion();
|
||||
if($d)
|
||||
$TEMP_carte[] = array('A', $d['nom_asteroide'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['nom_alliance'], $d['tag'], $d['image'], 0);
|
||||
else
|
||||
$TEMP_carte[] = array('A');
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->query("SELECT id FROM $table_planete WHERE galaxie = $g AND ss = $s AND position = $i;");
|
||||
if($resultat) {
|
||||
$d = $bdd->unique_query("SELECT P.nom_planete, P.image, P.debris_met, P.debris_cri, U.pseudo, U.race, U.politique, U.id_alliance, A.tag FROM $table_planete P INNER JOIN $table_user U ON U.id = P.id_user LEFT OUTER JOIN $table_alliances A ON A.id = U.id_alliance WHERE P.galaxie = $g AND P.ss = $s AND P.position = $i;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$TEMP_carte[] = array($i, $d['nom_planete'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['pseudo'], $d['tag'], $d['image'], $d['politique']);
|
||||
}
|
||||
else {
|
||||
$bdd->deconnexion();
|
||||
$TEMP_carte[] = array($i);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('carte', $TEMP_carte);
|
||||
$template->assign('position', array($g, $s, $Gpu, $Spu, $Gmu, $Smu));
|
||||
|
||||
unset($TEMP_carte, $g, $s, $Gpu, $Spu, $Gmu, $Smu, $resultat, $d, $i);
|
||||
?>
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'caserne';
|
||||
$titre = $LANG[$planete->race]['batiments']['noms_sing'][9];
|
||||
|
||||
//Vérification que le joueur ait bien une caserne avant d'afficher la page
|
||||
if ($planete->batiments[9] <= 0)
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['batiments']['noms_sing'][9], "red", '?p=batiments', 3500);
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['c']) && ($id = intval(gpc('c'))) >= 0 && $nbc = floor(gpc('cas'.$id, 'post')))
|
||||
{
|
||||
$planete->file_cas->caserne_addObjet($id, $nbc, $planete);
|
||||
|
||||
redirection($VAR['menu']['caserne']);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_cas->caserne_delObjet(intval(gpc('a')), $n, $planete);
|
||||
|
||||
redirection($VAR['menu']['caserne']);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->casernes as $i => $nombre)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['caserne']['noms_sing'][$i]) && Donnee::neededCaserne($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => $casernei[$i],
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => Donnee::metalCaserne($i, $planete),
|
||||
'nec_cristal' => Donnee::cristalCaserne($i, $planete),
|
||||
'nec_hydrogene' => Donnee::hydrogeneCaserne($i, $planete),
|
||||
'temps' => sec(Donnee::tempsCaserne($i, $planete)),
|
||||
'enfile' => $planete->file_cas->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
$template->assign('file', $planete->file_cas->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau);
|
||||
?>
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'chantierspatial';
|
||||
if (SURFACE == "planete")
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][8]);
|
||||
else
|
||||
$titre = ucfirst($LANG[$planete->race]['alli_batiments']['noms_sing'][3]);
|
||||
|
||||
|
||||
//Si l'on est sur un astéroide, on vérifie que le joueur ait les permissions nécessaire
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &2))
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des vaisseaux de l'astéroide.");
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if (SURFACE == "planete" && $planete->batiments[8] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][8], "red", '?p=batiments', 3500);
|
||||
elseif(SURFACE == "asteroide" && $planete->batiments[3] <= 0)
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['alli_batiments']['noms_sing'][3], "red", '?p=batiments', 3500);
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('vais'.$id, 'post')))
|
||||
{
|
||||
$planete->file_vais->vaisseaux_addObjet($id, $nbv, $planete);
|
||||
|
||||
redirection($VAR['menu']['chantierspatial']);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_vais->vaisseaux_delObjet(intval(gpc('a')), $n, $planete);
|
||||
|
||||
redirection($VAR['menu']['chantierspatial']);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->vaisseaux as $i => $nombre)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['vaisseaux']['noms_sing'][$i]) && Donnee::neededVaisseaux($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => $nomvaisi[$i],
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => Donnee::metalVaisseaux($i, $planete),
|
||||
'nec_cristal' => Donnee::cristalVaisseaux($i, $planete),
|
||||
'nec_hydrogene' => Donnee::hydrogeneVaisseaux($i, $planete),
|
||||
'temps' => sec(Donnee::tempsVaisseaux($i, $planete)),
|
||||
'enfile' => $planete->file_vais->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('vaisseaux', $TEMP_liste);
|
||||
$template->assign('file', $planete->file_vais->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau);
|
||||
?>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = $p;
|
||||
$onglet = gpc('n');
|
||||
if (!empty($onglet))
|
||||
$template->assign('onglet', $onglet);
|
||||
else
|
||||
$template->assign('onglet', "unites");
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][7]);
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if ($planete->batiments[7] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][7], "red", '?p=batiments', 3500);
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('terr'.$id, 'post')))
|
||||
{
|
||||
$planete->file_ter->terrestre_addObjet($id, $nbv, $planete);
|
||||
|
||||
redirection($VAR['menu'][$p].'&n='.$onglet);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_ter->terrestre_delObjet(intval(gpc('a')), $n, $planete);
|
||||
|
||||
redirection($VAR['menu'][$p].'&n='.$onglet);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->terrestres as $i => $nombre)
|
||||
{
|
||||
$type = Donnee::typeTerrestre($i);
|
||||
|
||||
if (!empty($LANG[$planete->race]['terrestre']['noms_sing'][$i]) && (($onglet == "defenses" && !$type) || ($onglet != "defenses" && $type)) && Donnee::neededTerrestre($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => $nomterri[$i],
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => Donnee::metalTerrestre($i, $planete),
|
||||
'nec_cristal' => Donnee::cristalTerrestre($i, $planete),
|
||||
'nec_hydrogene' => Donnee::hydrogeneTerrestre($i, $planete),
|
||||
'temps' => sec(Donnee::tempsTerrestre($i, $planete)),
|
||||
'enfile' => $planete->file_ter->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
$template->assign('file', $planete->file_ter->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau, $onglet);
|
||||
?>
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'description';
|
||||
$titre = 'Détails';
|
||||
|
||||
function tableauProd($ibat,$nivo)
|
||||
{
|
||||
$return = array();
|
||||
$c = $nivo-2 < 1 ? 1 : $nivo-2;
|
||||
$a = $c + 6;
|
||||
|
||||
if ($ibat == 0)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 52 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 52 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 1)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 34 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 34 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 2)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 21 * ($c + 0.7));
|
||||
$production_diff = ceil(pow(1.1, $c) * 21 * ($c + 0.7)) - ceil(pow(1.1, $nivo) * 21 * ($nivo + 0.7));
|
||||
|
||||
$energie = ceil(exp(0.2849*$c)*13);
|
||||
$energie_diff = ceil(exp(0.2849*$c)*13) - ceil(exp(0.2849*$nivo)*13);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 3)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(exp(0.28*$c)*22);
|
||||
$production_diff = ceil(exp(0.28*$c)*22) - ceil(exp(0.28*$nivo)*22);
|
||||
|
||||
$return[] = array($c, $production, 0, $production_diff, 0);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 4) {
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(exp(0.297*$c)*25);
|
||||
$production_diff = ceil(exp(0.297*$c)*25) - ceil(exp(0.297*$nivo)*25);
|
||||
|
||||
$energie = ceil(pow(1.34,($c-1)) * 9);
|
||||
$energie_diff = ceil(pow(1.34,($c-1)) * 9) - ceil(pow(1.34,($nivo-1)) * 9);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
if (empty($_GET['r']) || ($_GET['r'] != 'humain' && $_GET['r'] != 'covenant'))
|
||||
$_GET['r'] = $planete->race;
|
||||
$race = gpc('r');
|
||||
$template->assign('raceAff', $race);
|
||||
|
||||
if (isset($_GET['t']) && is_numeric($_GET['t']) && !empty($LANG[$race]["technologies"]["noms_sing"][$_GET['b']][$_GET['t']]))
|
||||
{
|
||||
$template->assign('type', 'technologies');
|
||||
$b = intval(gpc('b'));
|
||||
$t = intval(gpc('t'));
|
||||
$template->assign('branche', $b);
|
||||
$template->assign('id', $t);
|
||||
|
||||
$template->assign('ressourcesNext', array(Donnee::creditsTechnologie($b, $t, $planete), Donnee::tempsTechnologie($b, $t, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededTechnologie($b, $t, $planete, $race));
|
||||
}
|
||||
elseif (isset($_GET['b']) && is_numeric($_GET['b']) && !empty($LANG[$race]["batiments"]["noms_sing"][$_GET['b']]))
|
||||
{
|
||||
$template->assign('type', 'batiments');
|
||||
$t = intval(gpc('b'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', $batimeni[$t]);
|
||||
$template->assign('tableau_prod', tableauProd($t, $planete->batiments[$t]));
|
||||
|
||||
$n = $planete->batiments[$t] + 1;
|
||||
$template->assign('ressourcesNext', array(Donnee::metalBatiments($t, $n, $planete), Donnee::cristalBatiments($t, $n, $planete), Donnee::hydrogeneBatiments($t, $n, $planete), Donnee::tempsBatiments($t, $n, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededBatiments($t, $planete, $race));
|
||||
}
|
||||
elseif (isset($_GET['v']) && is_numeric($_GET['v']) && !empty($LANG[$race]["vaisseaux"]["noms_sing"][$_GET['v']]))
|
||||
{
|
||||
$template->assign('type', 'vaisseaux');
|
||||
$t = intval(gpc('v'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', $nomvaisi[$t]);
|
||||
|
||||
$template->assign('ressourcesNext', array(Donnee::metalVaisseaux($t, $planete), Donnee::cristalVaisseaux($t, $planete), Donnee::hydrogeneVaisseaux($t, $planete), Donnee::tempsVaisseaux($t, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededVaisseaux($t, $planete, $race));
|
||||
$template->assign('caract', array($nomvais_at[$t], $nomvais_bc[$t], $nomvais_pv[$t], $nomvais_rs[$t]));
|
||||
}
|
||||
elseif (isset($_GET['d']) && is_numeric($_GET['d']) && !empty($LANG[$race]["terrestre"]["noms_sing"][$_GET['d']]))
|
||||
{
|
||||
$template->assign('type', 'terrestre');
|
||||
$t = gpc('d');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', $nomterri[$t]);
|
||||
|
||||
$template->assign('ressourcesNext', array(Donnee::metalTerrestre($t, $planete), Donnee::cristalTerrestre($t, $planete), Donnee::hydrogeneTerrestre($t, $planete), Donnee::tempsTerrestre($t, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededTerrestre($t, $planete, $race));
|
||||
if ($t-8 >= 0) {
|
||||
$t -= 8;
|
||||
$template->assign('caract', array($defense_at[$t], $defense_bc[$t], $defense_pv[$t]));
|
||||
}
|
||||
}
|
||||
elseif (isset($_GET['c']) && is_numeric($_GET['c']) && !empty($LANG[$race]["caserne"]["noms_sing"][$_GET['c']]))
|
||||
{
|
||||
$template->assign('type', 'caserne');
|
||||
$t = gpc('c');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', $casernei[$t]);
|
||||
|
||||
$template->assign('ressourcesNext', array(Donnee::metalCaserne($t, $planete), Donnee::cristalCaserne($t, $planete), Donnee::hydrogeneCaserne($t, $planete), Donnee::tempsCaserne($t, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededCaserne($t, $planete, $race));
|
||||
$template->assign('caract', array('!!', '!!', '!!'));
|
||||
}
|
||||
else
|
||||
redirection('?p=accueil');
|
||||
|
||||
unset($t, $race);
|
||||
?>
|
||||
|
|
@ -1,162 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
//Récupération des informations envoyées
|
||||
$idPrep = gpc("cds", "post");
|
||||
|
||||
$SESS->values["prepFlottes"][$idPrep]['nom'] = gpc('nomflotte', 'post');
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_galaxie'] = $end_galaxie = intval(gpc('amas', 'post'));
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_systeme'] = $end_ss = intval(gpc('ss', 'post'));
|
||||
$end_pos = gpc('pos', 'post');
|
||||
if ($end_pos != "A")
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = floor($end_pos);
|
||||
else
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = $end_pos;
|
||||
$SESS->values["prepFlottes"][$idPrep]['embarquer'] = array($EBmetal = floor(str_replace(' ', '', gpc('metal', 'post'))), $EBcristal = floor(str_replace(' ', '', gpc('cristal', 'post'))), $EBhydrogene = floor(str_replace(' ', '', gpc('hydrogene', 'post'))));
|
||||
$SESS->values["prepFlottes"][$idPrep]['mission'] = $mission = intval(gpc('mission', 'post'));
|
||||
$SESS->values["prepFlottes"][$idPrep]['vitesse'] = $vitesse = intval(gpc('vitesse', 'post'));
|
||||
|
||||
//On met à jour la session
|
||||
$SESS->put();
|
||||
|
||||
//Vérification du nombre de vaisseaux sur la planète
|
||||
foreach ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
//On vérifie qu'il y a suffisamment de vaisseaux sur la planète
|
||||
if ($planete->vaisseaux[$key] < $vaisseau)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//Vérification des conditions de mission
|
||||
if ($mission <= 0 || $mission > 7 || ($SESS->values["prepFlottes"][$idPrep]['type'] == 3 && $mission != 3 && $mission != 2))
|
||||
erreur("La mission sélectionnée est incorrecte !", "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//Vérification que le nombre de slots ne soit pas dépassé
|
||||
if (slots($planete->id_user) <= 0)
|
||||
erreur('Vous ne pouvez pas envoyer plus de flottes simultanément.', "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//Vérifications en cas de mission colonisation
|
||||
if ($mission == 2)
|
||||
{
|
||||
//On vérifie la mission, si elle est de coloniser, il faut qu'il y ait des vaisseaux de colonisation
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][2] <= 0)
|
||||
erreur('Vous ne pouvez pas coloniser sans vaisseau de colonisation !', "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//On vérifie qu'une colonisation d'asteroide soit bien faite par un fondateur d'alliance en cours de création
|
||||
if ($end_pos == "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
if (!$resultat)
|
||||
erreur('Fonder d\'abord une alliance avant de coloniser un astéroide !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
}
|
||||
|
||||
//On vérifie que les attaques soient bien activées
|
||||
if ($mission == 3 && !$VAR["attaques"])
|
||||
erreur('Les attaques sont désactivées pour le moment. Pour plus d\'informations, <a href="'.$VAR["menu"]["forums"].'">consultez le forum</a>.', "red", $VAR["menu"]["flotte"], 5000);
|
||||
|
||||
//On vérifie la mission, si elle est de recycler, il faut qu'il y ait des reclycleurs
|
||||
if ($mission == 4 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][3] <= 0)
|
||||
erreur('Vous ne pouvez pas recycler sans recycleur !', "red", $VAR["menu"]["flotte"]);
|
||||
|
||||
//On vérifie la mission, si elle est d'espionner, il faut qu'il y ait des sondes
|
||||
if ($mission == 5 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][6] <= 0 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][13] <= 0)
|
||||
erreur('Vous ne pouvez pas espionner sans sonde d\'espionnage !', "red", '?p=flotte');
|
||||
|
||||
//Vérification que la destination ne soit pas en dehors de la galaxie
|
||||
if ($end_galaxie > $VAR['nb_amas'] || $end_ss > $VAR['nb_systeme'] || $end_galaxie < 0 || $end_ss < 1 || (($end_pos > $VAR['nb_planete'] || $end_pos < 1) && $end_pos != "A") || ($end_galaxie < 1 && $SESS->level < 6))
|
||||
erreur('La destination de la flotte n\'est pas correcte.', "red", '?p=flotte');
|
||||
|
||||
//On vérifie que l'on possède assez de ressources
|
||||
if ((!empty($EBmetal) && !$EBmetal > $planete->metal) || (!empty($EBcristal) && !$EBcristal > $planete->cristal) || (!empty($EBhydrogene) && !$EBhydrogene > $planete->hydrogene))
|
||||
erreur('Vous ne pouvez pas envoyer plus de ressources que vous n\'en posséder.', "red", '?p=flotte');
|
||||
|
||||
//On vérifie que l'on n'envoie pas des ressources négatives
|
||||
if ((!empty($EBmetal) && $EBmetal < 0) || (!empty($EBcristal) && $EBcristal < 0) || (!empty($EBhydrogene) && $EBhydrogene < 0))
|
||||
erreur('Vous avez spécifié des valeurs de ressources à embarquer incorrectes !', "red", '?p=flotte', 4000);
|
||||
|
||||
//On vérifie la vitesse de la flotte
|
||||
if (!is_numeric($vitesse) || $vitesse < 0 || $vitesse > 100)
|
||||
erreur('La vitesse de votre flotte est incorrecte !', "red", '?p=flotte');
|
||||
|
||||
|
||||
//Recherche de la planète ou de l'astéroïde
|
||||
if ($end_pos == "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id AS id_user, debris_met, debris_cri FROM $table_alliances WHERE galaxie = $end_galaxie AND ss = $end_ss;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id_user, debris_met, debris_cri FROM $table_planete WHERE galaxie = $end_galaxie AND ss = $end_ss AND position = $end_pos;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une interaction entre deux multi-comptes
|
||||
if (count($multi) > 1 && ($mission == 1 || $mission == 6 || $mission == 7))
|
||||
{
|
||||
foreach($multi as $test)
|
||||
{
|
||||
if ($test['id_util'] == $resultat['id_user'])
|
||||
erreur('Vous ne pouvez pas avoir d\'interaction avec ce joueur pour raison de multi-compte (voir page d\'accueil).');
|
||||
}
|
||||
}
|
||||
|
||||
if ($mission == 1 && !$resultat)
|
||||
erreur('Impossible de transporter des ressources vers la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
elseif ($mission == 2 && $resultat)
|
||||
{
|
||||
if ($end_pos != "A")
|
||||
erreur('La planète que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
else
|
||||
erreur('L\'astéroide que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
}
|
||||
//Si la mission est d'attaquer, on vérifie que le joueur cible ne soit pas ne mode vacances ou qu'il soit tout jeune
|
||||
elseif ($mission == 3 && $end_pos != "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultatu = $bdd->unique_query("SELECT mv, time_inscription FROM $table_user WHERE id = ".$resultat['id_user'].";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($resultatu['mv'] > 0)
|
||||
erreur('Le joueur que vous tentez d\'attaquer est actuellement en mode vacances, vous ne pouvez donc pas l\'attaquer avant son retour de vacances.', "red", '?p=flotte', 3000); //TODO Mettre le numéro du mode vacances et non > 0 !!!
|
||||
elseif ($resultatu['time_inscription'] + 604800 > time())
|
||||
erreur('Le joueur que vous tentez d\'attaquer s\'est inscrit récemment, laissez-lui le temps de se préparer au combat !', "red", '?p=flotte', 3000);
|
||||
elseif (!$resultat)
|
||||
erreur('La planète que vous tentez d\'attaquer est inhabitée.', "red", '?p=flotte');
|
||||
elseif ($resultat['id_user'] == $planete->id_user)
|
||||
erreur('La planète que vous tentez d\'attaquer vous appartient.', "red", '?p=flotte');
|
||||
}
|
||||
elseif ($mission == 4 && ($resultat['debris_met'] <= 0 || $resultat['debris_cri'] <= 0) && empty($SESS->values['forceFlotte']))
|
||||
{
|
||||
$SESS->values['forceFlotte'] = true;
|
||||
$SESS->put();
|
||||
erreur('Il n\'y a rien à recycler sur la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'].<br />Vous pouvez forcer le lancement de la flotte en rechargeant cette page.', "orange");
|
||||
}
|
||||
//TODO Autoriser l'espionnage sur les planètes inhabités
|
||||
elseif ($mission == 5)
|
||||
{
|
||||
if (!$resultat)
|
||||
erreur('Impossible d\'espionner la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
elseif ($end_pos != "A" && $resultat['id_user'] == $planete->id_user)
|
||||
erreur('La planète que vous désirez espionner vous appartient !', "red", '?p=flotte', 3000);
|
||||
}
|
||||
|
||||
elseif ($mission == 6 && $resultat['id_user'] != $planete->id_user && $resultat['id_user'] != $planete->id_alliance)
|
||||
erreur('La planète sur laquelle vous désirez stationner ne vous appartient pas.', "red", '?p=flotte', 3000);
|
||||
elseif ($mission == 7 && !$resultat)
|
||||
erreur('La planète sur laquelle vous désirez donner vos vaisseaux n\'existe pas.', "red", '?p=flotte', 3000);
|
||||
|
||||
|
||||
//Création de la flotte
|
||||
$flotte = new flotte();
|
||||
$flotte->creer($planete, $SESS->values["prepFlottes"][$idPrep], $resultat);
|
||||
$SESS->values["prepFlottes"][$idPrep]["statut"] = 2;
|
||||
$SESS->put();
|
||||
|
||||
erreur('Votre flotte a été envoyée avec succès.', "green", '?p=flotte', 4000);
|
||||
?>
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
//Génération d'un ID unique pour identifier la flotte durant sa création
|
||||
$idPrep = random();
|
||||
|
||||
//Création du tableau de session
|
||||
$SESS->values["prepFlottes"][$idPrep] = array();
|
||||
|
||||
//On récupère les vaisseaux à envoyer
|
||||
$nombreVaisseau = 0;
|
||||
foreach ($planete->vaisseaux as $key => $vaisseau)
|
||||
{
|
||||
$v = gpc('v'.$key, 'post');
|
||||
if (!is_numeric($v) || $v < 0)
|
||||
$v = 0;
|
||||
|
||||
$SESS->values["prepFlottes"][$idPrep]['vaisseaux'][$key] = $v;
|
||||
$nombreVaisseau += $v;
|
||||
}
|
||||
//On vérifie que l'utilisateur a bien envoyé plus d'un vaisseau
|
||||
if ($nombreVaisseau <= 0)
|
||||
{
|
||||
unset($SESS->values["prepFlottes"][$idPrep]);
|
||||
erreur('Vous devez envoyer au moins un vaisseau.', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//On définit le type de la flotte (utilisateur ou alliance)
|
||||
if (!empty($_POST['envoie']))
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 1;
|
||||
elseif (!empty($_POST['groupe']))
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 2;
|
||||
else
|
||||
die ('Erreur !');
|
||||
|
||||
//On enregistre les paramètres en session
|
||||
$SESS->values["prepFlottes"][$idPrep]['nbVaisseaux'] = $nombreVaisseau;
|
||||
$SESS->values['forceFlotte'] = false;
|
||||
$SESS->values["prepFlottes"][$idPrep]['time'] = time();
|
||||
$SESS->values["prepFlottes"][$idPrep]['statut'] = 1;
|
||||
$SESS->put();
|
||||
|
||||
unset($nombreVaisseau, $key, $vaisseau, $v);
|
||||
|
||||
header('Location: ?p=flotte&c='.$idPrep);
|
||||
exit;
|
||||
?>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
|
||||
$idPrep = gpc('c');
|
||||
$template->assign('idPrep', $idPrep);
|
||||
$template->assign('restaure', $SESS->values["prepFlottes"][$idPrep]);
|
||||
|
||||
foreach ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
//On vérifie qu'il y a suffisamment de vaisseaux sur la planète
|
||||
if ($planete->vaisseaux[$key] < $vaisseau)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//Génération de la liste de mission possible avec les vaisseaux de la flotte
|
||||
$missions = array();
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['type'] == 1)
|
||||
$missions = array(6 => "Stationner", 7 => "Donner des vaisseaux", 1 => "Transporter");
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][2])
|
||||
$missions[2] = "Coloniser";
|
||||
if ($planete->technologies[7]& 16 && $VAR["attaques"])
|
||||
$missions[3] = "Attaquer";
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['type'] == 1 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][3])
|
||||
$missions[4] = "Recycler";
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['type'] == 1 && ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][6] || $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][13]))
|
||||
$missions[5] = "Espionner";
|
||||
|
||||
//S'il n'y a aucun choix de mission possible, on abandonne
|
||||
if (count($missions) == 0)
|
||||
erreur('Aucune mission disponible !', "red", '?p=flotte');
|
||||
$template->assign('missions', $missions);
|
||||
|
||||
$template->assign('scripth', '<script src="js/prototype.js" type="text/javascript"></script>');
|
||||
$template->assign('script', '<script type="text/javascript">document.getElementById(\'nom\').focus();</script><script src="js/flotte.js" type="text/javascript"></script>');
|
||||
$page = 'flotte2';
|
||||
|
||||
//Récupération des destinations favorites et des colonies
|
||||
$favoris = array();
|
||||
include_once("game/Class/class.tinyplanete.php");
|
||||
foreach ($planete->destinationsFavoris as $fav)
|
||||
{
|
||||
$fav_Planete = new TinyPlanete($fav);
|
||||
if (!empty($fav_Planete->nom_planete)) $favoris[$fav_Planete->id] = $fav_Planete->nom_planete;
|
||||
else $favoris[$fav_Planete->id] = '['.$fav_Planete->galaxie.':'.$fav_Planete->ss.':'.$fav_Planete->position.']';
|
||||
}
|
||||
$favorisC = array();
|
||||
foreach ($queryPlanetes as $fav)
|
||||
{
|
||||
if (!empty($fav['nom_planete'])) $favorisC[$fav['id']] = $fav['nom_planete'];
|
||||
else $favorisC[$fav['id']] = '['.$fav['galaxie'].':'.$fav['ss'].':'.$fav['position'].']';
|
||||
}
|
||||
$template->assign('favoris', $favoris);
|
||||
$template->assign('favorisColonies', $favorisC);
|
||||
|
||||
unset($idPrep, $missions, $fav, $vaisseau, $key, $favorisC, $favoris);
|
||||
?>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$page = 'laboratoire';
|
||||
$titre = ucfirst($LANG[$race]['batiments']['noms_sing'][6]);
|
||||
|
||||
//Si l'on est pas sur la planète mère, on bloque le laboratoire
|
||||
if ($queryPlanetes[0]['id'] != $planete->id)
|
||||
erreur('Vous devez être sur votre planète mère pour faire des recherches dans le '.$LANG[$race]['batiments']['noms_sing'][6]);
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if ($planete->batiments[6] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$race]['batiments']['noms_sing'][6], "red", '?p=batiments', 3500);
|
||||
|
||||
//Lancement d'une nouvelle recherche
|
||||
if (isset($_GET['t']) && isset($_GET['f'])) {
|
||||
//On vérifie que le laboratoire ne soit pas en construction
|
||||
if($planete->file_bat->batiment_objectInFile(6))
|
||||
erreur("Votre ".$LANG[$race]["batiments"]["noms_sing"][6]." est en travaux, vous ne pouvez pas faire de recherches pendant ce temps !");
|
||||
|
||||
$planete->file_tech->technologie_addObjet(intval(gpc('t')), intval(gpc('f')), $planete);
|
||||
|
||||
redirection($VAR['menu']['laboratoire']);
|
||||
}
|
||||
//Annulation d'une nouvelle recherche
|
||||
if (isset($_GET['a'])) {
|
||||
$planete->file_tech->technologie_delObjet(intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['laboratoire']);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->technologies as $i => $bits)
|
||||
{
|
||||
foreach($technoli[$i] as $j => $img)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['technologies']['noms_sing'][$i][$j]) && Donnee::neededTechnologie($i, $j, $planete) && ((int)$bits& pow(2, $j)) != pow(2, $j))
|
||||
{
|
||||
$nec = Donnee::donneeTechnologie($i, $j, "array" , $planete);
|
||||
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'tech' => $j,
|
||||
'image' => $img,
|
||||
'nec_metal' => $nec[0],
|
||||
'nec_cristal' => $nec[1],
|
||||
'nec_hydrogene' => $nec[2],
|
||||
'nec_credits' => $nec[3],
|
||||
'temps' => sec($nec[4]),
|
||||
'enfile' => $planete->file_tech->technologie_objectInFile($i, $j)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$template->assign('recherches', $TEMP_liste);
|
||||
$template->assign('file', $planete->file_tech->printFile($planete));
|
||||
?>
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$titre = 'Bourse';
|
||||
|
||||
$a = gpc('a');
|
||||
$v = gpc('v');
|
||||
if(is_numeric($a) && is_numeric(gpc('a'.$a, 'post'))){
|
||||
$nb = gpc('a'.$a, 'post');
|
||||
if ($nb <= 0 || $nb > 99999999) erreur("Nombre de ressources invalide !");
|
||||
|
||||
if ($a == 0) $var = 'metal';
|
||||
elseif ($a == 1) $var = 'cristal';
|
||||
elseif ($a == 2) $var = 'hydrogene';
|
||||
|
||||
$bdd->reconnexion();
|
||||
$action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $a;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
//On vérifie que la bourse ait suffisament de ressources à distribuer :
|
||||
if ($action['dispo'] <= $nb) erreur("Il n'y a pas assez de ressources dans la galaxie pour que vous puissiez en acheter autant.");
|
||||
|
||||
//On vérifie qu'il reste suffisamment de place dans les silos du joueur
|
||||
if ($planete->cap < $planete->$var + $nb) $nb = $planete->cap - $planete->$var;
|
||||
if ($nb <= 0) erreur("Vous n'avez pas assez de place pour stocker ces ressources !");
|
||||
|
||||
$prix = ceil(pow($action['dispo'], -0.1) * $nb * 2.20)/10;
|
||||
|
||||
//On vérifie que le joueur ait assez de crédits pour acheter
|
||||
if ($prix <= $planete->credits) {
|
||||
$planete->addCredits(-1*$prix);
|
||||
$planete->addModifUser('credits');
|
||||
$planete->$var += $nb;
|
||||
$planete->addModif('force');
|
||||
|
||||
if (empty($action['graph'])) $action['graph'] = array();
|
||||
else $action['graph'] = unserialize($action['graph']);
|
||||
$action['graph'][date('w')] = $action['dispo'];
|
||||
$graph = serialize($action['graph']);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($graph);
|
||||
$bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo - $nb, graph = '$graph' WHERE id = $a;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else erreur("Vous n'avez pas assez de crédits pour faire cet achat !");
|
||||
}
|
||||
elseif(is_numeric($v) && is_numeric(gpc('a'.$v, 'post'))){
|
||||
$nb = gpc('a'.$v, 'post');
|
||||
if ($nb <= 1000 || $nb > 99999999) erreur("Nombre de ressources invalide !<br />Vous pouvez vendre au minimum 1000 ressources !");
|
||||
|
||||
if ($v == 0) $var = 'metal';
|
||||
elseif ($v == 1) $var = 'cristal';
|
||||
elseif ($v == 2) $var = 'hydrogene';
|
||||
|
||||
//On vérifie que le joueur ait assez de ressources pour vendre, sinon, on ajuste à son maximum
|
||||
if ($nb > $planete->$var) $nb = $planete->$var;
|
||||
|
||||
$bdd->reconnexion();
|
||||
$action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $v;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$prix = ceil(pow($action['dispo'], -0.1) * $nb * 1.8)/10;
|
||||
$planete->addCredits($prix);
|
||||
$planete->addModifUser('credits');
|
||||
$planete->$var -= $nb;
|
||||
$planete->addModif('force');
|
||||
|
||||
if (empty($action['graph'])) $action['graph'] = array();
|
||||
else $action['graph'] = unserialize($action['graph']);
|
||||
$action['graph'][date('w')] = $action['dispo'];
|
||||
$graph = serialize($action['graph']);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($graph);
|
||||
$bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo + $nb, graph = '$graph' WHERE id = $v;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bourse = $bdd->query("SELECT id, dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
foreach($bourse as $key => $action){
|
||||
$bourse[$key]['prix'] = pow($action['dispo'], -0.1) * 200;
|
||||
$bourse[$key]['prixV'] = $bourse[$key]['prix'] * 0.9;
|
||||
$bourse[$key]['prixA'] = $bourse[$key]['prix'] * 1.07;
|
||||
}
|
||||
|
||||
$page = 'marche';
|
||||
$template->assign('bourse', $bourse);
|
||||
unset($a, $v, $var, $bourse, $graph, $key, $action, $nb, $prix);
|
||||
?>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$titre = 'Ressources';
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$page = 'ressources';
|
||||
if (isset($_POST['coeff_metal']) && isset($_POST['coeff_cs'])) {
|
||||
|
||||
$planete->coeff_bat[0] = floor($_POST['coeff_metal'])/100;
|
||||
if (isset($_POST['coeff_cristal'])) $planete->coeff_bat[1] = floor($_POST['coeff_cristal'])/100;
|
||||
if (isset($_POST['coeff_hydrogene'])) $planete->coeff_bat[2] = floor($_POST['coeff_hydrogene'])/100;
|
||||
$planete->coeff_bat[3] = floor($_POST['coeff_cs'])/100;
|
||||
if (isset($_POST['coeff_ce'])) $planete->coeff_bat[4] = floor($_POST['coeff_ce'])/100;
|
||||
$planete->addModif("coeff_bat");
|
||||
|
||||
redirection('?p=ressources');
|
||||
}
|
||||
|
||||
$tablo = $planete->production(3600, true);
|
||||
|
||||
$template->assign('ressources_prod', $tablo[1]);
|
||||
$template->assign('ressources_conso', $tablo[2]);
|
||||
$template->assign('ressources_coef', $tablo[0]);
|
||||
$template->assign('ressources_silo', array($planete->batiments[10], pow(2, $planete->batiments[10]) * 100000));
|
||||
$template->assign('ressources_toto', array($tablo[1][2] - $tablo[2][3], '(0)'));
|
||||
|
||||
$template->assign('ressources_tab', array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100));
|
||||
|
||||
unset($tablo);
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'ressources_alli';
|
||||
|
||||
$don_credits = intval(gpc("credits", "post"));
|
||||
if (!empty($don_credits) && $don_credits > 0)
|
||||
{
|
||||
//Si le joueur n'a pas assez de crédits
|
||||
if ($don_credits > $planete->credits)
|
||||
erreur('Vous n\'avez pas suffisamment de crédits pour en donner autant.', 'red', $VAR['menu']['ressources']);
|
||||
|
||||
$planete->addCreditsAlliance($don_credits);
|
||||
$planete->addCredits(-1 * $don_credits);
|
||||
|
||||
erreur('Votre don de '.$don_credits.' '.$LANG[$race]["ressources"]["noms"]["credits"].' a été effectué avec succès.', 'green', $VAR['menu']['ressources']);
|
||||
}
|
||||
|
||||
unset($don_credits);
|
||||
}
|
||||
?>
|
||||
131
onyx2/include/game/laboratoire.php
Normal file
131
onyx2/include/game/laboratoire.php
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header("Location: ./".$VAR["first_page"]); exit; }
|
||||
$page = "laboratoire";
|
||||
$titre = ucfirst($LANG[$race]["batiments"]["noms_sing"][6]);
|
||||
|
||||
/*
|
||||
Transformation des niveaux XML en tableau//
|
||||
for($n = 0; $n < 7; $n++)
|
||||
{
|
||||
foreach ($LANG[$planete->race]["technologies"]["niveau"][$n] as $key => $b)
|
||||
{
|
||||
$LANG[$planete->race]["technologies"]["niveau"][$n][$key] = intval($b);
|
||||
}
|
||||
|
||||
print var_export($LANG[$planete->race]["technologies"]["niveau"][$n], true);
|
||||
}
|
||||
exit;
|
||||
//*/
|
||||
//Si l'on est pas sur la planète mère, on bloque le laboratoire
|
||||
if ($queryPlanetes[0]["id"] != $planete->id)
|
||||
erreur("Vous devez être sur votre planète mère pour faire des recherches dans le ".$LANG[$race]["batiments"]["noms_sing"][6]);
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if ($planete->batiments[6] <= 0)
|
||||
erreur("Vous devez d'abord construire un ".$LANG[$race]["batiments"]["noms_sing"][6], "red", "?p=batiments", 3500);
|
||||
|
||||
//On vérifie la branche demandée
|
||||
if (isset($_GET["n"]) && is_numeric($_GET["n"]) && isset($planete->technologies[$_GET["n"]]))
|
||||
$onglet = gpc("n");
|
||||
else
|
||||
$onglet = 0;
|
||||
|
||||
|
||||
//Lancement d'une nouvelle recherche
|
||||
if (isset($_GET["n"]) && isset($_GET["t"])) {
|
||||
//On vérifie que le laboratoire ne soit pas en construction
|
||||
if($planete->file_bat->objectInFile(6))
|
||||
erreur("Votre ".$LANG[$race]["batiments"]["noms_sing"][6]." est en travaux, vous ne pouvez pas faire de recherches pendant ce temps !");
|
||||
|
||||
$planete->file_tech->addObjet(intval(gpc("n")), intval(gpc("t")), $planete);
|
||||
|
||||
redirection($VAR["menu"]["laboratoire"]);
|
||||
}
|
||||
//Annulation d'une nouvelle recherche
|
||||
if (isset($_GET["a"]) && isset($_GET["b"]))
|
||||
{
|
||||
$planete->file_tech->delObjet(intval(gpc("b")), 1, intval(gpc("a")), $planete);
|
||||
|
||||
redirection($VAR["menu"]["laboratoire"]);
|
||||
}
|
||||
|
||||
function traiterBranche($onglet, $branche, $start = false)
|
||||
{
|
||||
global $LANG, $planete, $template;
|
||||
|
||||
if ($start)
|
||||
$return = "<dl id=\"arbre\">";
|
||||
else
|
||||
$return = "<dl>";
|
||||
|
||||
foreach($branche as $key => $b)
|
||||
{
|
||||
if (is_array($b))
|
||||
{
|
||||
$return .= "<dd>";
|
||||
$return .= traiterBranche($onglet, $b);
|
||||
$return .= "</dd>";
|
||||
}
|
||||
else
|
||||
{
|
||||
//On recherche s'il s'agit d'une technologie à niveau multiple
|
||||
if ((dTechnologies::idToBit($b) & $planete->technologies[$onglet]) && isset($LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b+1]) && $LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b] == $LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b+1])
|
||||
{
|
||||
if ((dTechnologies::idToBit($b+1) & $planete->technologies[$onglet]) && isset($LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b+2]) && $LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b] == $LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b+2])
|
||||
$b = $b + 2;
|
||||
else
|
||||
$b = $b + 1;
|
||||
}
|
||||
|
||||
if ($key >= 1)
|
||||
$return .= "</dl><dl>";
|
||||
|
||||
if (dTechnologies::idToBit($b) & $planete->technologies[$onglet])
|
||||
$return .= '<dt><a href="#">';
|
||||
else
|
||||
$return .= '<dt class="lack"><a href="?p=laboratoire&n='.$onglet.'&t='.$b.'">';
|
||||
|
||||
$return .= $LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b].'</a><div><img src="'.$template->get_template_vars("url_images").'images/technologies/'.dTechnologies::image(array($onglet, $b), $planete).'" width="50" height="50" alt="'.$LANG[$planete->race]["technologies"]["noms_sing"][$onglet][$b].'" /><p><strong>Niveau :</strong> ';
|
||||
if (($niv = dTechnologies::niveau($onglet, $b)) > 0)
|
||||
{
|
||||
if (dTechnologies::idToBit($b) & $planete->technologies[$onglet])
|
||||
$return .= $niv;
|
||||
else
|
||||
$return .= ($niv-1);
|
||||
}
|
||||
else
|
||||
$return .= "unique";
|
||||
|
||||
if (!(dTechnologies::idToBit($b) & $planete->technologies[$onglet]))
|
||||
{
|
||||
if (($r = dTechnologies::metal($onglet, $b, $planete)) > 0)
|
||||
$return .= "<br /><strong>Coût ".$LANG[$planete->race]["ressources"]["noms"][0]." :</strong> ".$r;
|
||||
if (($r = dTechnologies::cristal($onglet, $b, $planete)) > 0)
|
||||
$return .= "<br /><strong>Coût ".$LANG[$planete->race]["ressources"]["noms"][1]." :</strong> ".$r;
|
||||
if (($r = dTechnologies::hydrogene($onglet, $b, $planete)) > 0)
|
||||
$return .= "<br /><strong>Coût ".$LANG[$planete->race]["ressources"]["noms"][2]." :</strong> ".$r;
|
||||
if (($r = dTechnologies::credits($onglet, $b, $planete)) > 0)
|
||||
$return .= "<br /><strong>Coût ".$LANG[$planete->race]["ressources"]["noms"][4]." :</strong> ".$r;
|
||||
|
||||
$return .= "<br /><strong>Temps :</strong> ".sec(dTechnologies::temps($onglet, $b, $planete));
|
||||
}
|
||||
|
||||
$return .= "</p></div></dt>";
|
||||
}
|
||||
}
|
||||
|
||||
return $return."</dl>";
|
||||
}
|
||||
|
||||
if ($onglet == 1 || $onglet == 2)
|
||||
$template->assign("arbre", traiterBranche(1, dTechnologies::type(1, $planete->race), true)."<br />".traiterBranche(2, dTechnologies::type(2, $planete->race), true));
|
||||
elseif ($onglet == 5 || $onglet == 6)
|
||||
$template->assign("arbre", traiterBranche(5, dTechnologies::type(5, $planete->race), true)."<br />".traiterBranche(6, dTechnologies::type(6, $planete->race), true));
|
||||
else
|
||||
$template->assign("arbre", traiterBranche($onglet, dTechnologies::type($onglet, $planete->race), true));
|
||||
|
||||
$template->assign("onglet", $onglet);
|
||||
$template->assign("files", $planete->file_tech->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $niveau, $i);
|
||||
?>
|
||||
190
onyx2/include/game/marche.php
Normal file
190
onyx2/include/game/marche.php
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$titre = 'Bourse';
|
||||
|
||||
//Récupération des données
|
||||
$ressource = intval(gpc("ressource", "post"));
|
||||
|
||||
if ($ressource == 0)
|
||||
$var = 'metal';
|
||||
elseif ($ressource == 1)
|
||||
$var = 'cristal';
|
||||
elseif ($ressource == 2)
|
||||
$var = 'hydrogene';
|
||||
|
||||
//On gère les achats
|
||||
if ((isset($_POST["buy"]) || empty($_POST["nbs"])) && !empty($_POST["nbb"]) && $nb = intval($_POST["nbb"]))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $ressource;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (empty($action))
|
||||
erreur("Impossible de trouver l'action dans la bourse !");
|
||||
|
||||
$nb = gpc("nbb", "post");
|
||||
|
||||
if ($action['dispo'] <= $nb)
|
||||
erreur("Il n'y a pas assez de ressources dans la galaxie pour que vous puissiez en acheter autant.");
|
||||
|
||||
//On vérifie qu'il reste suffisamment de place dans les silos du joueur
|
||||
if ($planete->cap < $planete->$var + $nb)
|
||||
$nb = $planete->cap - $planete->$var;
|
||||
if ($nb <= 0)
|
||||
erreur("Vous n'avez pas assez de place pour stocker ces ressources !");
|
||||
|
||||
//On calcul le prix
|
||||
$prix = bourse_calcPrixBase($action['dispo'], $nb, 2.2);
|
||||
|
||||
//On vérifie que le joueur ait assez de crédits pour acheter
|
||||
if ($prix <= $planete->credits)
|
||||
{
|
||||
$planete->addCredits(-1*$prix);
|
||||
$planete->addModifUser('credits');
|
||||
$planete->$var += $nb;
|
||||
$planete->addModif('force');
|
||||
|
||||
if (empty($action['graph']))
|
||||
$action['graph'] = array();
|
||||
else
|
||||
$action['graph'] = unserialize($action['graph']);
|
||||
$action['graph'][date('w')] = $action['dispo'];
|
||||
$graph = serialize($action['graph']);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($graph);
|
||||
$bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo - $nb, graph = '$graph' WHERE id = $ressource;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
erreur("Vous n'avez pas assez de crédits pour faire cet achat !");
|
||||
}
|
||||
//On gère les ventes
|
||||
elseif ((isset($_POST["sell"]) || empty($_POST["nbb"])) && !empty($_POST["nbs"]))
|
||||
{
|
||||
$nb = gpc("nbs", "post");
|
||||
if ($nb <= 1000 || $nb > 99999999)
|
||||
erreur("Nombre de ressource invalide !<br />Vous pouvez vendre au minimum 1000 ressources !");
|
||||
|
||||
//On vérifie que le joueur ait assez de ressources pour vendre, sinon, on ajuste à son maximum
|
||||
if ($nb > $planete->$var)
|
||||
$nb = $planete->$var;
|
||||
|
||||
if ($nb < 0)
|
||||
erreur("Vous n'avez pas assez de ressources en vendre autant !");
|
||||
|
||||
$bdd->reconnexion();
|
||||
$action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $ressource;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (empty($action))
|
||||
erreur("Impossible de trouver l'action dans la bourse !");
|
||||
|
||||
$prix = bourse_calcPrixBase($action['dispo'], $nb, 1.8);
|
||||
$planete->addCredits($prix);
|
||||
$planete->addModifUser('credits');
|
||||
$planete->$var -= $nb;
|
||||
$planete->addModif('force');
|
||||
|
||||
if (empty($action['graph']))
|
||||
$action['graph'] = array();
|
||||
else
|
||||
$action['graph'] = unserialize($action['graph']);
|
||||
$action['graph'][date('w')] = $action['dispo'];
|
||||
$graph = serialize($action['graph']);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($graph);
|
||||
$bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo + $nb, graph = '$graph' WHERE id = $ressource;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
/*
|
||||
if(is_numeric($a) && is_numeric(gpc('a'.$a, 'post')))
|
||||
{
|
||||
$nb = gpc('a'.$a, 'post');
|
||||
if ($nb <= 0 || $nb > 99999999) erreur("Nombre de ressources invalide !");
|
||||
|
||||
if ($a == 0) $var = 'metal';
|
||||
elseif ($a == 1) $var = 'cristal';
|
||||
elseif ($a == 2) $var = 'hydrogene';
|
||||
|
||||
$bdd->reconnexion();
|
||||
$action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $a;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
//On vérifie que la bourse ait suffisament de ressources à distribuer :
|
||||
if ($action['dispo'] <= $nb) erreur("Il n'y a pas assez de ressources dans la galaxie pour que vous puissiez en acheter autant.");
|
||||
|
||||
//On vérifie qu'il reste suffisamment de place dans les silos du joueur
|
||||
if ($planete->cap < $planete->$var + $nb) $nb = $planete->cap - $planete->$var;
|
||||
if ($nb <= 0) erreur("Vous n'avez pas assez de place pour stocker ces ressources !");
|
||||
|
||||
$prix = bourse_calcPrixBase($action['dispo'], $nb, 2.2);
|
||||
|
||||
//On vérifie que le joueur ait assez de crédits pour acheter
|
||||
if ($prix <= $planete->credits) {
|
||||
$planete->addCredits(-1*$prix);
|
||||
$planete->addModifUser('credits');
|
||||
$planete->$var += $nb;
|
||||
$planete->addModif('force');
|
||||
|
||||
if (empty($action['graph'])) $action['graph'] = array();
|
||||
else $action['graph'] = unserialize($action['graph']);
|
||||
$action['graph'][date('w')] = $action['dispo'];
|
||||
$graph = serialize($action['graph']);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($graph);
|
||||
$bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo - $nb, graph = '$graph' WHERE id = $a;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else erreur("Vous n'avez pas assez de crédits pour faire cet achat !");
|
||||
}
|
||||
elseif(is_numeric($v) && is_numeric(gpc('a'.$v, 'post')))
|
||||
{
|
||||
$nb = gpc('a'.$v, 'post');
|
||||
if ($nb <= 1000 || $nb > 99999999) erreur("Nombre de ressources invalide !<br />Vous pouvez vendre au minimum 1000 ressources !");
|
||||
|
||||
if ($v == 0) $var = 'metal';
|
||||
elseif ($v == 1) $var = 'cristal';
|
||||
elseif ($v == 2) $var = 'hydrogene';
|
||||
|
||||
//On vérifie que le joueur ait assez de ressources pour vendre, sinon, on ajuste à son maximum
|
||||
if ($nb > $planete->$var) $nb = $planete->$var;
|
||||
|
||||
$bdd->reconnexion();
|
||||
$action = $bdd->unique_query("SELECT dispo, graph FROM $table_bourse_ressources WHERE id = $v;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$prix = bourse_calcPrixBase($action['dispo'], $nb, 1.8);
|
||||
$planete->addCredits($prix);
|
||||
$planete->addModifUser('credits');
|
||||
$planete->$var -= $nb;
|
||||
$planete->addModif('force');
|
||||
|
||||
if (empty($action['graph'])) $action['graph'] = array();
|
||||
else $action['graph'] = unserialize($action['graph']);
|
||||
$action['graph'][date('w')] = $action['dispo'];
|
||||
$graph = serialize($action['graph']);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($graph);
|
||||
$bdd->query("UPDATE $table_bourse_ressources SET dispo = dispo + $nb, graph = '$graph' WHERE id = $v;");
|
||||
$bdd->deconnexion();
|
||||
}//*/
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bourse = $bdd->query("SELECT id, dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
foreach($bourse as $key => $action)
|
||||
{
|
||||
$bourse[$key]['prix'] = bourse_calcPrixBase($action['dispo']);
|
||||
$bourse[$key]['prixV'] = $bourse[$key]['prix'] * 0.9;
|
||||
$bourse[$key]['prixA'] = $bourse[$key]['prix'] * 1.07;
|
||||
}
|
||||
|
||||
$page = 'marche';
|
||||
$template->assign('bourse', $bourse);
|
||||
unset($a, $v, $var, $bourse, $graph, $key, $action, $nb, $prix);
|
||||
?>
|
||||
62
onyx2/include/game/ressources.php
Normal file
62
onyx2/include/game/ressources.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
$titre = 'Ressources';
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$page = 'ressources';
|
||||
if (isset($_POST['anb']) && $planete->batiments[4])
|
||||
{
|
||||
$anb = gpc("anb", "post");
|
||||
if ($planete->checkAndRetireRessources(0, 0, $anb*(7000-$planete->batiments[4]*1250), $anb*(7000-$planete->batiments[4]*1250), 0))
|
||||
{
|
||||
$planete->energieCentrale += $anb;
|
||||
$planete->addModif("energieCentrale");
|
||||
}
|
||||
else
|
||||
erreur("Vous n'avez pas assez de ressources pour augmenter la capacité de votre ".$LANG[$race]["batiments"]["noms_sing"][4]." !");
|
||||
}
|
||||
elseif (isset($_POST['coeff_metal']) && isset($_POST['coeff_cs'])) {
|
||||
|
||||
$planete->coeff_bat[0] = floor($_POST['coeff_metal'])/100;
|
||||
if (isset($_POST['coeff_cristal'])) $planete->coeff_bat[1] = floor($_POST['coeff_cristal'])/100;
|
||||
if (isset($_POST['coeff_hydrogene'])) $planete->coeff_bat[2] = floor($_POST['coeff_hydrogene'])/100;
|
||||
$planete->coeff_bat[3] = floor($_POST['coeff_cs'])/100;
|
||||
if (isset($_POST['coeff_ce'])) $planete->coeff_bat[4] = floor($_POST['coeff_ce'])/100;
|
||||
$planete->addModif("coeff_bat");
|
||||
|
||||
redirection('?p=ressources');
|
||||
}
|
||||
|
||||
$tablo = $planete->production(3600, true);
|
||||
|
||||
$template->assign('ressources_prod', $tablo[1]);
|
||||
$template->assign('ressources_conso', $tablo[2]);
|
||||
$template->assign('ressources_coef', $tablo[0]);
|
||||
$template->assign('ressources_silo', array($planete->batiments[10], pow(2, $planete->batiments[10]) * 100000));
|
||||
$template->assign('ressources_toto', array($tablo[1][2] - $tablo[2][3], '(0)'));
|
||||
|
||||
$template->assign('ressources_tab', array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100));
|
||||
|
||||
unset($tablo);
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'ressources_alli';
|
||||
|
||||
$don_credits = intval(gpc("credits", "post"));
|
||||
if (!empty($don_credits) && $don_credits > 0)
|
||||
{
|
||||
//Si le joueur n'a pas assez de crédits
|
||||
if ($don_credits > $planete->credits)
|
||||
erreur('Vous n\'avez pas suffisamment de crédits pour en donner autant.', 'red', $VAR['menu']['ressources']);
|
||||
|
||||
$planete->addCreditsAlliance($don_credits);
|
||||
$planete->addCredits(-1 * $don_credits);
|
||||
|
||||
erreur('Votre don de '.$don_credits.' '.$LANG[$race]["ressources"]["noms"]["credits"].' a été effectué avec succès.', 'green', $VAR['menu']['ressources']);
|
||||
}
|
||||
|
||||
unset($don_credits);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$page = 'messagerie';
|
||||
$titre = 'Messagerie';
|
||||
$template->assign("link_P", "messagerie");
|
||||
$template->assign("titreR", $titre);
|
||||
|
||||
//On interdit l'accès à la messagerie en cas de prise de contrôle d'un joueur
|
||||
if (!empty($sess->values['souscontrole'][0]))
|
||||
erreur('Vous êtes en mode prise de contrôle, vous ne pouvez pas accèder aux messages privés des joueurs.');
|
||||
|
||||
if ($id = intval(gpc('avertir')))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_mail SET statut = 1 WHERE destinataire = ".$planete->id_user." AND id = $id;");
|
||||
if ($bdd->affected())
|
||||
erreur('La demande de vérification de contenu par les opérateurs a été transmise avec succès.', 'green', '?p=messagerie');
|
||||
else
|
||||
erreur('Une demande est déjà en cours ou vous n\'êtes pas autorisé à avertir ce message.', 'red', '?p=messagerie');
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
//On récupére l'onglet demandé
|
||||
$onglet = gpc('n');
|
||||
$template->assign('onglet', $onglet);
|
||||
|
||||
if ($onglet == "rapports")
|
||||
{
|
||||
//Demande de supression des messages
|
||||
if (!empty($_POST))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
foreach($_POST as $value)
|
||||
$bdd->query("UPDATE $table_mail SET vu = 's' WHERE destinataire = ".$planete->id_user." AND id = ".intval($value).";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=messagerie&n='.$onglet);
|
||||
exit;
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT * FROM $table_mail WHERE destinataire = ".$planete->id_user." AND expediteur = false 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->deconnexion();
|
||||
|
||||
$template->assign('messages', $data);
|
||||
}
|
||||
elseif ($onglet == "send")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS destinataire FROM $table_mail M INNER JOIN $table_user U ON U.id = M.destinataire WHERE M.expediteur = ".$planete->id_user." ORDER BY M.id DESC;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('messages', $data);
|
||||
}
|
||||
elseif ($onglet == "envoyer")
|
||||
{
|
||||
$page = 'envoyer';
|
||||
$titre = 'Envoyer un message';
|
||||
|
||||
if (!empty($_POST['objet']) && !empty($_POST['destinataire']) && !empty($_POST['message']))
|
||||
{
|
||||
$utils = explode(';', gpc('destinataire', 'post'));
|
||||
$nbutil = count($utils);
|
||||
|
||||
$time = time();
|
||||
$message = htmlspecialchars(gpc('message', 'post'));
|
||||
$objet = htmlspecialchars(gpc('objet', 'post'));
|
||||
|
||||
if (strlen($message) > 99999)
|
||||
erreur('Le contenu de votre message est trop long. Limite : 99 999 caractères.');
|
||||
if (empty($utils))
|
||||
erreur('Aucun utilisateur sélectionné.');
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($message);
|
||||
$bdd->escape($objet);
|
||||
|
||||
$introuv = array();
|
||||
foreach($utils as $util)
|
||||
{
|
||||
if (empty($util))
|
||||
continue;
|
||||
$util = trim($util);
|
||||
$bdd->escape($util);
|
||||
|
||||
if ($util != $planete->pseudo && $env = $bdd->unique_query("SELECT id, pseudo, mail, envoyerMail FROM $table_user WHERE pseudo = '$util';"))
|
||||
send_mp($env['id'], $objet, $message, 0, $planete->id_user);
|
||||
else
|
||||
$introuv[] = htmlentities($util);
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($introuv[0]))
|
||||
erreur('Impossible de trouver le/les destinataire(s) suivant(s) : '.implode(', ', $introuv).'.<br />Les autres ont bien reçu votre message.', "red", '?p=messagerie&n=envoyer');
|
||||
else
|
||||
erreur('Votre message a été envoyé avec succès.', "green", '?p=messagerie');
|
||||
}
|
||||
|
||||
$amis = array();
|
||||
$amisn = array();
|
||||
$bdd->reconnexion();
|
||||
foreach($planete->amis as $ami) {
|
||||
$res = $bdd->unique_query("SELECT pseudo FROM $table_user WHERE id = ".$ami.";");
|
||||
if ($res != false) {
|
||||
$amis[] = $res['pseudo'];
|
||||
$amisn[] = $ami;
|
||||
}
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
$template->assign('amis', $amis);
|
||||
$template->assign('amisn', $amisn);
|
||||
|
||||
if (isset($_GET['d'])) $template->assign('destinataire', gpc('d'));
|
||||
if (isset($_GET['o'])) $template->assign('objet', gpc('o'));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Demande de supression des messages
|
||||
if (!empty($_POST))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
foreach($_POST as $value)
|
||||
$bdd->query("DELETE FROM $table_mail WHERE destinataire = ".$planete->id_user." AND id = ".intval($value).";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=messagerie&n='.$onglet);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($SESS->level >= 3)
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS expediteur FROM $table_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$bdd->query("UPDATE $table_mail M SET vu = 0 WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
//Calcul du nombre total de message enregistré
|
||||
$nbmax = $bdd->unique_query("SELECT COUNT(M.id) as nb FROM $table_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false;");
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS expediteur FROM $table_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC LIMIT 50;");
|
||||
$nb_view = $bdd->num_rows;
|
||||
$bdd->query("UPDATE $table_mail M SET vu = 0 WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC LIMIT 50;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
if ($SESS->level < 3 && $nbmax["nb"] > $nb_view)
|
||||
$template->assign('avertissement', '<p style="color: red;"><b>Vous avez des messages ('.($nbmax["nb"]-$nb_view).') en attente de réception. Libérez de la place dans votre messagerie pour les afficher.</b></p>');
|
||||
|
||||
$template->assign('messages', $data);
|
||||
}
|
||||
|
||||
unset($onglet, $data, $nbmax);
|
||||
|
||||
if ($bdd->num_rows)
|
||||
$template->assign('IM', $bdd->num_rows);
|
||||
?>
|
||||
|
|
@ -2,9 +2,7 @@
|
|||
if (!isset($race)) $race = $sess->values['race'];
|
||||
|
||||
if ($race == 'covenant') {
|
||||
$casernei = array('grunt1.jpg','jackal.jpg','94990342wb4.jpg','98004530fx3.jpg','88091275ja8.jpg','hunter1.jpg','81770345oo4.jpg','88218731ts1.jpg','72188202fg9.jpg');
|
||||
$alli_batimeni = array('batimentcovieux4.jpg','cristaloo3.png','powersupplycoviejq1.jpg','solaire.jpg','sanstitrevi7.jpg','oeilduprophetewj6.jpg','covielabocn5.jpg','chantierterrestrehg1.jpg','sanstitretruecolor09zn6.jpg','caserncov0ry.jpg','stockagebasement1cs10bl.jpg','ordianteur_hologramme.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg');
|
||||
$batimeni = array('batimentcovieux4.jpg','cristaloo3.png','powersupplycoviejq1.jpg','solaire.jpg','sanstitrevi7.jpg','oeilduprophetewj6.jpg','covielabocn5.jpg','chantierterrestrehg1.jpg','sanstitretruecolor09zn6.jpg','caserncov0ry.jpg','stockagebasement1cs10bl.jpg','ordianteur_hologramme.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg');
|
||||
$technoli = array(
|
||||
array('../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg'),
|
||||
array('../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg'),
|
||||
|
|
@ -17,8 +15,6 @@ if (!isset($race)) $race = $sess->values['race'];
|
|||
array('../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg'),
|
||||
array('../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg')
|
||||
);
|
||||
$nomvaisi = array('cargo2pb6.jpg','sanstitre2copiegw9.jpg','colocopiers4.jpg','sonde_despionnage1.jpg','charognard.jpg','chasseurlourd7id.jpg','contactharvestbynameleszk3.jpg','vaisseauuu0.jpg','vaisseaudebataille9na.jpg','pv.jpg','stationorbitalezt7.jpg','citecovenant.jpg', '../covenant_na.jpg', '../covenant_na.jpg');
|
||||
$nomterri = array('bansheeqp0.jpg', 'spirit1.jpg', 'phantomfu2.jpg', 'boardingcraft.jpg', 'ghostic1.jpg', 'shadow.jpg', 'spectre.jpg', 'wraith.jpg', 'shade.jpg', 'defcovie.jpg', 'tourellebarreau.jpg', 'tourelle.jpg', 'lanceur_torpilles.jpg', '../covenant_na.jpg', '../covenant_na.jpg', '../covenant_na.jpg');
|
||||
}
|
||||
elseif (isset($sess->values['auth_level']) && $sess->values['auth_level'] >= 6 && md5($race) == '34c19b21bd4a3dda389e767d32fe9779') {
|
||||
$ressourc = array('Métal','Cristal','Hydrogène','Énergie','Crédits');
|
||||
|
|
@ -52,7 +48,7 @@ if (!isset($race)) $race = $sess->values['race'];
|
|||
$technolo = array(
|
||||
array('Forage niveau 1', 'Forage niveau 2', 'Commerce galactique niveau 1', 'Rendement métal niveau 1', 'Rendement cristal niveau 1', 'Rendement hydrogène niveau 1', 'Forage niveau 3', 'Théorie du Marché niveau 1', 'Rendement métal niveau 2', 'Rendement métal niveau 3', 'Rendement cristal niveau 2', 'Rendement cristal niveau 3', 'Rendement hydrogène niveau 2', 'Fonderies avancées niveau 1', 'Rendement hydrogène niveau 3', 'Théorie du Marché niveau 2', 'Théorie du Marché niveau 3', 'Fonderies avancées niveau 2', 'Fonderies avancées niveau 3'),
|
||||
array('Maîtrise énergie niveau 1', 'Informatique', 'Constructions planétaires', 'Maîtrise énergie', 'Réacteur à combustion', 'Maîtrise énergie', 'Réacteur à combustion', 'Réacteur à fusion', 'Réacteur à combustion', 'Réacteur à fusion', 'Réacteur à fusion type II ', 'Réacteur à fusion', 'Réacteur à fusion type II ', 'Réacteur à fusion type II ', 'Informatique', 'IA ', 'Télécommunications', 'Espionnage', 'Contre-espionnage', 'Informatique', 'IA ', 'IA ', 'Télécommunications', 'Polymères radars', 'Télécommunications', 'Polymères radars', 'Polymères radars', 'Espionnage', 'Espionnage', 'Contre-espionnage', 'Contre-espionnage', 'Constructions planétaires', 'Construction optimisée', 'Ingénierie orbitale', 'Constructions planétaires', 'Aménagement territorial', 'Aménagement territorial', 'Aménagement territorial'),
|
||||
array('Immigration coloniale', 'Sciences politiques', 'Immigration coloniale', 'Urbanisme', 'Immigration coloniale', 'Urbanisme', 'Grandes surfaces', 'Centre de loisirs', 'Arcologie', 'Urbanisme', 'Sciences politiques', 'Stratégie militaire', 'Sciences politiques', 'Stratégie militaire', 'Stratégie militaire'),
|
||||
array('Immigration coloniale', 'Sciences politiques', 'Immigration coloniale', 'Urbanisme', 'Immigration coloniale', 'Urbanisme', 'Grandes SURFACEs', 'Centre de loisirs', 'Arcologie', 'Urbanisme', 'Sciences politiques', 'Stratégie militaire', 'Sciences politiques', 'Stratégie militaire', 'Stratégie militaire'),
|
||||
);
|
||||
$technode = array( 'L\'informatique vous permet de traiter les informations de façon très rapide réduisant ainsi les temps de réactions qui dans les combats peuvent s\'avérer fatales.',
|
||||
'La détection est cruciale pour préserver sa flotte et ses planètes. Développer cette technologie vous permet de construire une base « œil des prophètes » qui repèrera les vaisseaux s\'approchant de votre planète.',
|
||||
|
|
@ -98,9 +94,7 @@ if (!isset($race)) $race = $sess->values['race'];
|
|||
'~#DESCRIPTION MANQUANTE#~ Station de defense');
|
||||
}
|
||||
elseif ($race == 'humain' || $race == "none") {
|
||||
$casernei = array('marines.jpg','marinehf0.jpg','grenadier.jpg','TCAO2.jpg','sniper.jpg','spartan.jpg','medecin.jpg','ingenieurs.jpg','exosquelettehbpb2.jpg');
|
||||
$alli_batimeni = array('mine_m.jpg','mine_c.png','synchroniseur.jpg','centrale solaire.jpg','centrale electrique.jpg','baseradardl3.jpg','recherches.jpg','chantierterrestrecopybj8.jpg','chantier spatial.jpg','ecole militaire.jpg','stockage.jpg','search0yp.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg');
|
||||
$batimeni = array('mine_m.jpg','mine_c.png','synchroniseur.jpg','centrale solaire.jpg','centrale electrique.jpg','baseradardl3.jpg','recherches.jpg','chantierterrestrecopybj8.jpg','chantier spatial.jpg','ecole militaire.jpg','stockage.jpg','search0yp.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg');
|
||||
$technoli = array(
|
||||
array('../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg'),
|
||||
array('../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg'),
|
||||
|
|
@ -113,9 +107,6 @@ if (!isset($race)) $race = $sess->values['race'];
|
|||
array('../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg'),
|
||||
array('../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg', '../humain_na.jpg')
|
||||
);
|
||||
$nomvaisi = array('csnucargoparabola2mc9.jpg','csnucargoladen2al8.jpg','colonisation.jpg','../humain_na.jpg','longsworduf9.jpg','../humain_na.jpg','../humain_na.jpg','frgatecopiegw1.jpg','../humain_na.jpg','halcyo15.jpg','qsu169.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg');
|
||||
$nomterri = array('csnusparrowhawkkp4.jpg','pelican.jpg','csnushortswordad3.jpg','albatross.jpg','warthog-vrl.jpg','M12G1_LAAV_Warthog.jpg','M12A1_LAAV_Warthog.jpg','scorpionN.jpg',
|
||||
'../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg','../humain_na.jpg');
|
||||
}
|
||||
else {
|
||||
$template->assign("race", "humain");
|
||||
|
|
@ -14,6 +14,7 @@ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
|||
</script><br />');
|
||||
|
||||
//Google Analyst + XiTi
|
||||
//*
|
||||
$template->assign('analyst', '<script type="text/javascript">
|
||||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||
document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));
|
||||
|
|
@ -34,5 +35,6 @@ xtdi = ""; //implication degree
|
|||
//-->
|
||||
</script>
|
||||
<script type="text/javascript" src="http://www.monsite.fr/xtcore.js"></script>');
|
||||
//*/
|
||||
}
|
||||
?>
|
||||
20
onyx2/include/server/avert.php
Normal file
20
onyx2/include/server/avert.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
$page = 'vide';
|
||||
$titre = 'Avertissement de sécurité';
|
||||
|
||||
$template->assign('titreP', '<span style="color: red;">! AVERTISSEMENT !</span>');
|
||||
|
||||
$test = intval($SESS->values["avert"]);
|
||||
$contenu = "";
|
||||
|
||||
if ($SESS->values["avert"]& 1)
|
||||
$contenu .= "<h3 style=\"font-weight: bold;\">JavaScript désactivé !</h3>Nous avons détecté que le JavaScript n'était pas activé sur votre navigateur. Nous vous recommandons de l'activé pour avoir accès à l'ensemble du contenu du site, même si celui-ci fonctionne parfaitement sans cette technologie.<br />";
|
||||
if ($SESS->values["avert"]& 2)
|
||||
$contenu .= "<h3 style=\"font-weight: bold;\">Referer désactivé !</h3>Nous avons détecté que votre navigateur n'envoie pas d'informations sur sa navigation. Cela empêche le jeu de valider l'ensemble des requêtes faites par votre navigateur. Votre compte de jeu n'est donc pas protégé contre certaines attaques informatiques.<br />";
|
||||
|
||||
$template->assign("contenu", '<div class="error">'.$contenu.'<br /><br /><h3><a href="'.$_SERVER["REQUEST_URI"].'">Continuer</a></h3></div>');
|
||||
|
||||
unset($SESS->values["avert"]);
|
||||
$SESS->put();
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue