Ajoute la foret de if qui permet de gérer la race du joueur pour le chantier terrestre

This commit is contained in:
Nigel Sheldon 2020-11-26 09:43:07 +01:00
parent 04b5e6af76
commit 54afd20cd8
2 changed files with 467 additions and 389 deletions

View File

@ -5,122 +5,143 @@ 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);
if ($planete->race == "humain") {
switch ($id) {
case 0:
$metal = 300;
break;
case 1:
$metal = 420;
break;
case 2:
$metal = 600;
break;
case 3:
$metal = 950;
break;
case 4:
$metal = 240;
break;
case 5:
$metal = 260;
break;
case 6:
$metal = 420;
break;
case 7:
$metal = 500;
break;
case 8:
$metal = 230;
break;
case 9:
$metal = 650;
break;
case 10:
$metal = 1750;
break;
case 11:
$metal = 3750;
break;
case 12:
$metal = 9500;
break;
case 13:
$metal = 9500;
break;
case 14:
$metal = 9500;
break;
case 15:
$metal = 9500;
break;
default:
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
}
} else {
// Covenant
switch ($id) {
case 0:
$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) {
$cristal *= 0.9;
$metal *= 0.9;
}
return $cristal * $nombre;
return $metal * $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);
if ($planete->race == "humain") {
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);
}
} else {
// Covenant
switch ($id) {
case 0:
$cristal = 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) {
$cristal *= 0.9;
@ -131,57 +152,68 @@ class dTerrestre implements Donnees
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);
if ($planete->race == "humain") {
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);
}
} else {
// Covenant
switch ($id) {
case 0:
$hydrogene = 0;
break;
default:
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
}
}
//On tient compte des bonus
@ -199,75 +231,86 @@ class dTerrestre implements Donnees
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);
if ($planete->race == "humain") {
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);
}
} else {
// Covenant
switch ($id) {
case 0:
$temps = 0;
$moins = 9;
break;
default:
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
}
}
//On tient compte de la vitesse
$temps /= VITESSE;
@ -275,124 +318,150 @@ class dTerrestre implements Donnees
return ceil($temps/pow(1.25, ($planete->batiments[7] - $moins))) * $nombre;
}
public static function type($id)
public static function type($id, surface $planete)
{
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);
if ($planete->race == "humain") {
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);
}
} else {
// Covenant
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") {
if ($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;
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;
}
//Défenses
case 8:
//return "";
break;
case 9:
//return "";
break;
case 10:
//return "";
break;
case 11:
//return "";
break;
}
return Donnees::image_humain_default;
} elseif ($planete->race == "convenant") {
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;
} else {
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
}
@ -401,65 +470,74 @@ class dTerrestre implements Donnees
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)
),
array(
array('batiments', 7, 3),
array('technologies', 6, 3)
),
array(
array('batiments', 7, 4),
array('technologies', 6, 1)
),
array(
array('batiments', 7, 4),
array('technologies', 6, 4)
),
array(
array('batiments', 7, 8),
array('technologies', 6, 2)
),
array(
array('batiments', 7, 8),
array('technologies', 6, 5)
),
array(
array('batiments', 7, 8),
array('technologies', 6, 6)
),
array(
array('batiments', 7, 10),
array('technologies', 7, 11)
)
);
if ($planete->race == "humain") {
$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)
),
array(
array('batiments', 7, 3),
array('technologies', 6, 3)
),
array(
array('batiments', 7, 4),
array('technologies', 6, 1)
),
array(
array('batiments', 7, 4),
array('technologies', 6, 4)
),
array(
array('batiments', 7, 8),
array('technologies', 6, 2)
),
array(
array('batiments', 7, 8),
array('technologies', 6, 5)
),
array(
array('batiments', 7, 8),
array('technologies', 6, 6)
),
array(
array('batiments', 7, 10),
array('technologies', 7, 11)
)
);
} else {
// Covenant
$neededTerrestre = array(
array(
array('batiments', 7, 1)
)
);
}
if ($print) {
return dDonnees::print_neededCheck($neededTerrestre[$id], $planete);

View File

@ -41,7 +41,7 @@ if (isset($_GET['a']) && isset($_GET['b'])) {
$TEMP_liste = array();
foreach ($planete->terrestres as $i => $nombre) {
$type = dTerrestre::type($i);
$type = dTerrestre::type($i, $planete);
if (!empty($LANG[$planete->race]['terrestre']['noms_sing'][$i]) && (($onglet == "defenses" && !$type) || ($onglet != "defenses" && $type)) && dTerrestre::needed($i, $planete)) {
$TEMP_liste[] = array(