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) public static function metal($id, $nombre, surface $planete)
{ {
switch ($id) { if ($planete->race == "humain") {
case 0: switch ($id) {
$cristal = 300; case 0:
break; $metal = 300;
case 1: break;
$cristal = 420; case 1:
break; $metal = 420;
case 2: break;
$cristal = 600; case 2:
break; $metal = 600;
case 3: break;
$cristal = 950; case 3:
break; $metal = 950;
case 4: break;
$cristal = 240; case 4:
break; $metal = 240;
case 5: break;
$cristal = 260; case 5:
break; $metal = 260;
case 6: break;
$cristal = 420; case 6:
break; $metal = 420;
case 7: break;
$cristal = 500; case 7:
break; $metal = 500;
case 8: break;
$cristal = 230; case 8:
break; $metal = 230;
case 9: break;
$cristal = 650; case 9:
break; $metal = 650;
case 10: break;
$cristal = 1750; case 10:
break; $metal = 1750;
case 11: break;
$cristal = 3750; case 11:
break; $metal = 3750;
case 12: break;
$cristal = 9500; case 12:
break; $metal = 9500;
case 13: break;
$cristal = 9500; case 13:
break; $metal = 9500;
case 14: break;
$cristal = 9500; case 14:
break; $metal = 9500;
case 15: break;
$cristal = 9500; case 15:
break; $metal = 9500;
default: break;
trigger_error("Unité ".$unite." introuvable dans les données", E_USER_ERROR); 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 //On tient compte des bonus
if (isset($planete->politique) && $planete->politique == 1) { 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) public static function cristal($id, $nombre, surface $planete)
{ {
switch ($id) { if ($planete->race == "humain") {
case 0: switch ($id) {
$cristal = 300; case 0:
break; $cristal = 300;
case 1: break;
$cristal = 420; case 1:
break; $cristal = 420;
case 2: break;
$cristal = 600; case 2:
break; $cristal = 600;
case 3: break;
$cristal = 950; case 3:
break; $cristal = 950;
case 4: break;
$cristal = 240; case 4:
break; $cristal = 240;
case 5: break;
$cristal = 260; case 5:
break; $cristal = 260;
case 6: break;
$cristal = 420; case 6:
break; $cristal = 420;
case 7: break;
$cristal = 500; case 7:
break; $cristal = 500;
case 8: break;
$cristal = 230; case 8:
break; $cristal = 230;
case 9: break;
$cristal = 650; case 9:
break; $cristal = 650;
case 10: break;
$cristal = 1750; case 10:
break; $cristal = 1750;
case 11: break;
$cristal = 3750; case 11:
break; $cristal = 3750;
case 12: break;
$cristal = 9500; case 12:
break; $cristal = 9500;
case 13: break;
$cristal = 9500; case 13:
break; $cristal = 9500;
case 14: break;
$cristal = 9500; case 14:
break; $cristal = 9500;
case 15: break;
$cristal = 9500; case 15:
break; $cristal = 9500;
default: break;
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR); 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 //On tient compte des bonus
if (isset($planete->politique) && $planete->politique == 1) { if (isset($planete->politique) && $planete->politique == 1) {
$cristal *= 0.9; $cristal *= 0.9;
@ -131,57 +152,68 @@ class dTerrestre implements Donnees
public static function hydrogene($id, $nombre, surface $planete) public static function hydrogene($id, $nombre, surface $planete)
{ {
switch ($id) { if ($planete->race == "humain") {
case 0: switch ($id) {
$hydrogene = 0; case 0:
break; $hydrogene = 0;
case 1: break;
$hydrogene = 0; case 1:
break; $hydrogene = 0;
case 2: break;
$hydrogene = 0; case 2:
break; $hydrogene = 0;
case 3: break;
$hydrogene = 0; case 3:
break; $hydrogene = 0;
case 4: break;
$hydrogene = 0; case 4:
break; $hydrogene = 0;
case 5: break;
$hydrogene = 0; case 5:
break; $hydrogene = 0;
case 6: break;
$hydrogene = 0; case 6:
break; $hydrogene = 0;
case 7: break;
$hydrogene = 0; case 7:
break; $hydrogene = 0;
case 8: break;
$hydrogene = 0; case 8:
break; $hydrogene = 0;
case 9: break;
$hydrogene = 80; case 9:
break; $hydrogene = 80;
case 10: break;
$hydrogene = 100; case 10:
break; $hydrogene = 100;
case 11: break;
$hydrogene = 120; case 11:
break; $hydrogene = 120;
case 12: break;
$hydrogene = 1500; case 12:
break; $hydrogene = 1500;
case 13: break;
$hydrogene = 1500; case 13:
break; $hydrogene = 1500;
case 14: break;
$hydrogene = 1500; case 14:
break; $hydrogene = 1500;
case 15: break;
$hydrogene = 1500; case 15:
break; $hydrogene = 1500;
default: break;
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR); 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 //On tient compte des bonus
@ -199,75 +231,86 @@ class dTerrestre implements Donnees
public static function temps($id, $nombre, surface $planete) public static function temps($id, $nombre, surface $planete)
{ {
switch ($id) { if ($planete->race == "humain") {
case 0: switch ($id) {
$temps = 720; case 0:
$moins = 1; $temps = 720;
break; $moins = 1;
case 1: break;
$temps = 2040; case 1:
$moins = 3; $temps = 2040;
break; $moins = 3;
case 2: break;
$temps = 7200; case 2:
$moins = 4; $temps = 7200;
break; $moins = 4;
case 3: break;
$temps = 3960; case 3:
$moins = 6; $temps = 3960;
break; $moins = 6;
case 4: break;
$temps = 600; case 4:
$moins = 1; $temps = 600;
break; $moins = 1;
case 5: break;
$temps = 1080; case 5:
$moins = 2; $temps = 1080;
break; $moins = 2;
case 6: break;
$temps = 2160; case 6:
$moins = 3; $temps = 2160;
break; $moins = 3;
case 7: break;
$temps = 4680; case 7:
$moins = 5; $temps = 4680;
break; $moins = 5;
case 8: break;
$temps = 1080; case 8:
$moins = 1; $temps = 1080;
break; $moins = 1;
case 9: break;
$temps = 2040; case 9:
$moins = 3; $temps = 2040;
break; $moins = 3;
case 10: break;
$temps = 7200; case 10:
$moins = 4; $temps = 7200;
break; $moins = 4;
case 11: break;
$temps = 3960; case 11:
$moins = 7; $temps = 3960;
break; $moins = 7;
case 12: break;
$temps = 3960; case 12:
$moins = 9; $temps = 3960;
break; $moins = 9;
case 13: break;
$temps = 3960; case 13:
$moins = 9; $temps = 3960;
break; $moins = 9;
case 14: break;
$temps = 3960; case 14:
$moins = 9; $temps = 3960;
break; $moins = 9;
case 15: break;
$temps = 3960; case 15:
$moins = 9; $temps = 3960;
break; $moins = 9;
default: break;
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR); 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 //On tient compte de la vitesse
$temps /= VITESSE; $temps /= VITESSE;
@ -275,124 +318,150 @@ class dTerrestre implements Donnees
return ceil($temps/pow(1.25, ($planete->batiments[7] - $moins))) * $nombre; 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) { if ($planete->race == "humain") {
case 0: switch ($id) {
case 1: case 0:
case 2: case 1:
case 3: case 2:
case 4: case 3:
case 5: case 4:
case 6: case 5:
case 7: case 6:
return true; case 7:
case 8: return true;
case 9: case 8:
case 10: case 9:
case 11: case 10:
case 12: case 11:
case 13: case 12:
case 14: case 13:
case 15: case 14:
return false; case 15:
default: return false;
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR); 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) public static function image($id, surface $planete)
{ {
if ($planete->race == "covenant") { if ($planete->race == "humain") {
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) { switch ($id) {
//Unités terrestres //Unités terrestres
case 0: case 0:
return "csnusparrowhawkkp4.jpg"; return "csnusparrowhawkkp4.jpg";
break; break;
case 1: case 1:
return "pelican.jpg"; return "pelican.jpg";
break; break;
case 2: case 2:
return "csnushortswordad3.jpg"; return "csnushortswordad3.jpg";
break; break;
case 3: case 3:
return "albatross.jpg"; return "albatross.jpg";
break; break;
case 4: case 4:
return "warthog-vrl.jpg"; return "warthog-vrl.jpg";
break; break;
case 5: case 5:
return "M12G1_LAAV_Warthog.jpg"; return "M12G1_LAAV_Warthog.jpg";
break; break;
case 6: case 6:
return "M12A1_LAAV_Warthog.jpg"; return "M12A1_LAAV_Warthog.jpg";
break; break;
case 7: case 7:
return "scorpionN.jpg"; return "scorpionN.jpg";
break; break;
//Défenses //Défenses
case 8: case 8:
//return ""; //return "";
break; break;
case 9: case 9:
//return ""; //return "";
break; break;
case 10: case 10:
//return ""; //return "";
break; break;
case 11: case 11:
//return ""; //return "";
break; break;
} }
return Donnees::image_humain_default; 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 { } else {
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR); 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) public static function needed($id, surface $planete, $print = false)
{ {
$neededTerrestre = array( if ($planete->race == "humain") {
array( $neededTerrestre = array(
array('batiments', 7, 1) array(
), array('batiments', 7, 1)
array( ),
array('batiments', 7, 3) array(
), array('batiments', 7, 3)
array( ),
array('batiments', 7, 4) array(
), array('batiments', 7, 4)
array( ),
array('batiments', 7, 6) array(
), array('batiments', 7, 6)
array( ),
array('batiments', 7, 1) array(
), array('batiments', 7, 1)
array( ),
array('batiments', 7, 2) array(
), array('batiments', 7, 2)
array( ),
array('batiments', 7, 3) array(
), array('batiments', 7, 3)
array( ),
array('batiments', 7, 5) array(
), array('batiments', 7, 5)
//Défenses ),
array( //Défenses
array('batiments', 7, 1), array(
array('technologies', 6, 0) array('batiments', 7, 1),
), array('technologies', 6, 0)
array( ),
array('batiments', 7, 3), array(
array('technologies', 6, 3) array('batiments', 7, 3),
), array('technologies', 6, 3)
array( ),
array('batiments', 7, 4), array(
array('technologies', 6, 1) array('batiments', 7, 4),
), array('technologies', 6, 1)
array( ),
array('batiments', 7, 4), array(
array('technologies', 6, 4) array('batiments', 7, 4),
), array('technologies', 6, 4)
array( ),
array('batiments', 7, 8), array(
array('technologies', 6, 2) array('batiments', 7, 8),
), array('technologies', 6, 2)
array( ),
array('batiments', 7, 8), array(
array('technologies', 6, 5) array('batiments', 7, 8),
), array('technologies', 6, 5)
array( ),
array('batiments', 7, 8), array(
array('technologies', 6, 6) array('batiments', 7, 8),
), array('technologies', 6, 6)
array( ),
array('batiments', 7, 10), array(
array('technologies', 7, 11) array('batiments', 7, 10),
) array('technologies', 7, 11)
); )
);
} else {
// Covenant
$neededTerrestre = array(
array(
array('batiments', 7, 1)
)
);
}
if ($print) { if ($print) {
return dDonnees::print_neededCheck($neededTerrestre[$id], $planete); return dDonnees::print_neededCheck($neededTerrestre[$id], $planete);

View File

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