Version 1.10c

This commit is contained in:
nemunaire 2008-11-19 12:00:00 +01:00
commit 2a066a7498
148 changed files with 2174 additions and 134960 deletions

View file

@ -9,6 +9,20 @@
*
***************************************************************************/
class File{
var $file;
function File($file){
$this->file = unserialize($file);
}
function reajusteVacances($timeVac){
if (isset($this->file[0])) {
$this->file[0] += time() - $timeVac;
}
return serialize($this->file);
}
/**
* Ajoute $nombre objets $objet dans la file $file
* @param int $file Nom de la file d'attente
@ -20,10 +34,13 @@ class File{
*/
function file_addObjet($file, $objet, $nombre = 1){
$planete = $this;
if ($nombre > 99999) erreur('Dépacement de capacité !<br />Vous ne pouvez pas mettre autant d\'unités en file d\'attente en une seule fois.');
switch($file){
case "alli_batiments": $court = "abat"; $calc = "alli_batiment"; global ${$calc.'LIMIT'}; $exist = $this->file_exist($objet, "file_".$court); break;
case "batiments": $court = "bat"; $calc = "batiment"; $exist = $this->file_exist($objet, "file_".$court); break;
case "technologies": $court = "tech"; $calc = "technolo"; $exist = $this->file_exist($objet, "file_".$court); break;
case "technologies": $court = "tech"; $calc = "technolo"; $exist = $this->file_exist($objet, $nombre); break;
case "casernes": $court = "cas"; $calc = "casernen"; $exist = false; break;
case "terrestres": $court = "ter"; $calc = "nomterrn"; $exist = false; break;
case "vaisseaux": $court = "vais"; $calc = "nomvaisn"; $exist = false; break;
@ -67,44 +84,52 @@ class File{
if ($exist) return 2;
//Vérification que le nombre ne soit pas négatif
if ($nombre < 0) return 5;
if ($nombre < 0 && ($file != "batiments" || $nombre < -1)) return 5;
//Actualisation du temps s'il n'y a pas d'objet en file
if (count($this->{"file_".$court}) < 2) $this->{"file_".$court}[0] = time();
if ($file == "alli_batiments" || $file == "batiments") {
eval(${$calc.'CALC'}[$objet][0]);
eval(${$calc.'CALC'}[$objet][1]);
eval(${$calc.'CALC'}[$objet][2]);
$d = 0;
}
elseif ($file == "technologies") {
$a = $b = $c = 0;
$d = $technologiesCALC[$file_tech][$objet][2];
if ($nombre > 0) {
if ($file == "alli_batiments" || $file == "batiments") {
eval(${$calc.'CALC'}[$objet][0]);
eval(${$calc.'CALC'}[$objet][1]);
eval(${$calc.'CALC'}[$objet][2]);
$d = 0;
}
elseif ($file == "technologies") {
$a = $b = $c = 0;
$d = $technologiesCALC[$file_tech][$objet][2];
}
else {
$a = ${$calc.'CALC'}[$objet][0];
$b = ${$calc.'CALC'}[$objet][1];
$c = ${$calc.'CALC'}[$objet][2];
$d = 0;
}
//On applique les bonus politiques aux temps et coûts
if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
$a *= 0.9;
$b *= 0.9;
$c *= 0.9;
}
//Vérification du nombre maximum d'entraînement possible de cette unité sur cette planète
if ($nombre > 1) {
if ($a) $nombre = min(floor($this->metal/$a), $nombre);
if ($b) $nombre = min(floor($this->cristal/$b), $nombre);
if ($c) $nombre = min(floor($this->hydrogene/$c), $nombre);
if ($d) $nombre = min(floor($this->credits/$d), $nombre);
}
}
else {
$a = ${$calc.'CALC'}[$objet][0];
$b = ${$calc.'CALC'}[$objet][1];
$c = ${$calc.'CALC'}[$objet][2];
$a = 0;
$b = 0;
$c = 0;
$d = 0;
}
//On applique les bonus politiques aux temps et coûts
if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
$a *= 0.9;
$b *= 0.9;
$c *= 0.9;
}
//Vérification du nombre maximum d'entraînement possible de cette unité sur cette planète
if ($nombre > 1) {
if ($a) $nombre = min(floor($this->metal/$a), $nombre);
if ($b) $nombre = min(floor($this->cristal/$b), $nombre);
if ($c) $nombre = min(floor($this->hydrogene/$c), $nombre);
if ($d) $nombre = min(floor($this->credits/$d), $nombre);
}
//Vérification des ressources de la planète
if ($this->metal < $a * $nombre) return 3;
elseif ($this->cristal < $b * $nombre) return 3;
@ -153,10 +178,10 @@ class File{
//On gère les files de type arbre
if ($file == "technologies") {
if (isset($this->{"file_".$court}[$objet])) {
if (isset($this->{"file_".$court}[$objet+1])) {
global ${$file.'CALC'};
//On réinitialise le temps si c'est la première
if ($objet == 1) $this->{"file_".$court}[0] = time();
if ($objet == 0) $this->{"file_".$court}[0] = time();
$i = $objet;
$filearbre = $this->{"file_".$court}[$objet+1][1];
@ -190,37 +215,40 @@ class File{
$n = $this->{$file}[$objet] + 1;
}
if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
if ($file == "batiments") {
eval(${$calc.'CALC'}[$objet][0]);
eval(${$calc.'CALC'}[$objet][1]);
eval(${$calc.'CALC'}[$objet][2]);
$d = 0;
}
elseif ($file == "technologies") {
$a = $b = $c = 0;
$d = $technologiesCALC[$filearbre][$objet][2];
}
else {
$a = ${$calc.'CALC'}[$objet][0];
$b = ${$calc.'CALC'}[$objet][1];
$c = ${$calc.'CALC'}[$objet][2];
$d = 0;
}
if ($nombre > 0) {
if ($file == "batiments") {
eval(${$calc.'CALC'}[$objet][0]);
eval(${$calc.'CALC'}[$objet][1]);
eval(${$calc.'CALC'}[$objet][2]);
$d = 0;
}
elseif ($file == "technologies") {
$a = $b = $c = 0;
$d = $technologiesCALC[$filearbre][$objet][2];
}
else {
$a = ${$calc.'CALC'}[$objet][0];
$b = ${$calc.'CALC'}[$objet][1];
$c = ${$calc.'CALC'}[$objet][2];
$d = 0;
}
//On applique les bonus politiques aux temps et coûts
if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
$a *= 0.9;
$b *= 0.9;
$c *= 0.9;
}
//On applique les bonus politiques aux temps et coûts
if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
$a *= 0.9;
$b *= 0.9;
$c *= 0.9;
}
//Mise à jour des ressources de la planète en conséquence à la construction
$this->metal += $a * $nombre;
$this->cristal += $b * $nombre;
$this->hydrogene += $c * $nombre;
$this->credits += $d * $nombre;
//Mise à jour des ressources de la planète en conséquence à la construction
$this->metal += $a * $nombre;
$this->cristal += $b * $nombre;
$this->hydrogene += $c * $nombre;
$this->credits += $d * $nombre;
}
return $nombre;
}
@ -259,7 +287,6 @@ class File{
* @access public
*/
function file_pret($file){
$nanite = 0;
$planete = $this;
switch($file){
case "alli_batiments": $court = "abat"; $calc = "alli_batiment"; $exist = $this->file_exist($objet, "file_".$court); break;
@ -283,7 +310,7 @@ class File{
if ($key == 0) continue;
//Récupération du temps de recherche
$sec = $technologiesCALC[$bout[1]][$bout[0]][3] / (1 + $planete->batiments[6] * 0.005);
$sec = $technologiesCALC[$bout[1]][$bout[0]][3] / (1 + $this->batiments[6] * 0.01);
//On applique les bonus politiques aux temps et coûts
if (isset($this->politique) && $this->politique == 1 && ($file == "casernes" || $file == "terrestres" || $file == "vaisseaux")) {
@ -296,9 +323,16 @@ class File{
if ($sec < $tps) {
$this->{$file}[$bout[1]] += $technologiesCALC[$bout[1]][$bout[0]][0];
$this->{"file_".$court}[0] += $sec;
unset($this->{"file_".$court}[$key]); //CAUSE DE PROBLEME POSSIBLE !
$tps -= $sec;
unset($this->{"file_".$court}[$key]);
$this->{"file_".$court} = array_merge($this->{"file_".$court});
//La déouverte de technologie est bénéfique pour le moral de la population
if ($this->moral) {
if ($this->politique == 3) $this->setMoral(0.1); //Démocratie : Découvrir une nouvelle technologie a plus d'effet bénéfique sur le moral
else $this->setMoral(0.05);
}
if (!in_array($file, $this->modifUser)) $this->modifUser[] = $file;
if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
}
@ -320,7 +354,31 @@ class File{
//Accélération du temps de construction
$sec = floor($sec/VITESSE);
if ($sec * $bout[1] < $tps) {
if ($bout[1] < 0) {
$n--;
eval(${$calc.'CALC'}[$bout[0]][3]);
$sec = floor($sec*0.6/VITESSE);
if ($sec < $tps) {
eval(${$calc.'CALC'}[$bout[0]][0]);
eval(${$calc.'CALC'}[$bout[0]][1]);
eval(${$calc.'CALC'}[$bout[0]][2]);
//On reçoit 70% des ressources en bonus
$this->metal += $a * 0.7;
$this->cristal += $b * 0.7;
$this->hydrogene += $c * 0.7;
$this->{$file}[$bout[0]]--;
$this->{"file_".$court}[0] += $bout[1] * $sec;
$tps -= $sec;
unset($this->{"file_".$court}[$key]);
if (!in_array($file, $this->modif)) $this->modif[] = $file;
if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
}
}
elseif ($sec * $bout[1] < $tps && $bout[1] > 0) {
//S'il s'agit d'un silo, on sauvegarde le temps pour utilisation par le script de production
if ($file == "batiments" && $bout[0] == 10) $timestamp_lastSilo = $this->{"file_".$court}[0];
if ($file == "batiments" && $bout[0] == 0) $timestamp_mineM = $this->{"file_".$court}[0];
@ -334,7 +392,7 @@ class File{
if (!in_array($file, $this->modif)) $this->modif[] = $file;
if (!in_array("file_".$court, $this->modif)) $this->modif[] = "file_".$court;
}
elseif ($sec < time() - $this->{"file_".$court}[0]) {
elseif ($sec < time() - $this->{"file_".$court}[0] && $bout[1] > 0) {
//TODO Trouver plus simple que la ligne en dessous
for($j=0 ; $j * $sec < $tps ; $j++) {}
$j--;

View file

@ -9,7 +9,7 @@
*
***************************************************************************/
class Flotte{
var $id_flotte,
var $id_flotte = 0,
$nom,
$start_planete,
$start_time,
@ -17,6 +17,7 @@ class Flotte{
$end_time,
$ret_planete,
$ret_time,
$nb_vais,
$vaisseaux = array(),
$tactique = 0,
$mission,
@ -57,14 +58,13 @@ class Flotte{
$this->mission = $flotte["mission"];
$this->statut = $flotte["statut"];
$this->last = $flotte["last"];
$this->nb_vais = $flotte["nb_vais"];
foreach($nomvaisnVAR as $vais){
$this->vaisseaux[] = $flotte[$vais];
}
foreach($ressoVAR as $contenu){
$this->contenu[] = $flotte[$contenu];
}
$this->contenu = array($flotte["contenu_metal"], $flotte["contenu_cristal"], $flotte["contenu_hydrogene"]);
$this->calculer();
}
@ -74,8 +74,11 @@ class Flotte{
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;
}
}
@ -161,6 +164,9 @@ class Flotte{
$conso[2] += $vais * $temps[2][$key] * $bonus / exp($vitesse/10);
}
if (!isset($this->vaisseaux[4])) $this->vaisseaux[4] = 0;
if (!isset($this->vaisseaux[5])) $this->vaisseaux[5] = 0;
//Si les chasseurs peuvent rentrer dans les cales des vaisseaux, on les enlèves
if ($this->contenuMax - ($this->contenu[0] + $this->contenu[1] + $this->contenu[2]) - ($this->vaisseaux[4] * $nomvais_rs[4] + $this->vaisseaux[5] * $nomvais_rs[5]) >= ($this->vaisseaux[4] + $this->vaisseaux[5]) * 200) {
$temps[2][4] = $temps[2][5] = $temps[1][4] = $temps[1][5] = $temps[0][4] = $temps[0][5] = 0;
@ -242,38 +248,42 @@ class Flotte{
$bdd->connexion();
if ($this->modifFlotte === "DELETE") $bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
else {
for($i = 0; $i < $nb; $i++){
if (!is_array($this->{$this->modifFlotte[$i]})) {
$bdd->escape($this->{$this->modifFlotte[$i]});
if (is_int($this->{$this->modifFlotte[$i]}) || is_float($this->{$this->modifFlotte[$i]})) $out[] .= $this->modifFlotte[$i]." = ".$this->{$this->modifFlotte[$i]};
else $out[] .= $this->modifFlotte[$i]." = '".$this->{$this->modifFlotte[$i]}."'";
if (empty($this->id_flotte)) {
if ($this->modifFlotte === "INSERT") {
$out1 = ''; $out2 = '';
global $nomvaisnVAR;
foreach ($this->vaisseaux as $key => $vais){
$out1 .= ', '.$nomvaisnVAR[$key];
$out2 .= ', '.$vais;
}
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_planete, end_time, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nbvais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom.", ".$nb_vais."'$out2);";
//var_dump($sql);
$bdd->query($sql);
}
else {
if ($this->modifFlotte[$i] == "contenu") $calc = "resso";
elseif ($this->modifFlotte[$i] == "vaisseaux") $calc = "nomvaisn";
}
else {
for($i = 0; $i < $nb; $i++){
if (!is_array($this->{$this->modifFlotte[$i]})) {
$bdd->escape($this->{$this->modifFlotte[$i]});
if (is_int($this->{$this->modifFlotte[$i]}) || is_float($this->{$this->modifFlotte[$i]})) $out[] .= $this->modifFlotte[$i]." = ".$this->{$this->modifFlotte[$i]};
else $out[] .= $this->modifFlotte[$i]." = '".$this->{$this->modifFlotte[$i]}."'";
}
else {
if ($this->modifFlotte[$i] == "contenu") $calc = "resso";
elseif ($this->modifFlotte[$i] == "vaisseaux") $calc = "nomvaisn";
if (!isset(${$calc.'VAR'})) global ${$calc.'VAR'};
if (!isset(${$calc.'VAR'})) global ${$calc.'VAR'};
$nombr = count(${$calc.'VAR'});
for($j = 0; $j < $nombr; $j++){
$bdd->escape($this->{$this->modifFlotte[$i]}[$j]);
$out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modifFlotte[$i]}[$j];
$nombr = count(${$calc.'VAR'});
for($j = 0; $j < $nombr; $j++){
$bdd->escape($this->{$this->modifFlotte[$i]}[$j]);
$out[] = ${$calc.'VAR'}[$j]." = ".$this->{$this->modifFlotte[$i]}[$j];
}
}
}
if (!empty($out)) $bdd->query("UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";");
else $bdd->query("UPDATE $table_flottes SET last = 0 WHERE id = ".$this->id_flotte.";");
}
if (empty($id_flotte)) {
$out1 = ''; $out2 = '';
global $nomvaisnVAR;
foreach ($this->vaisseaux as $key => $vais){
$out1 .= ', '.${$calc.'VAR'}[$key];
$out2 .= ', '.$vais;
}
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_planete, end_time, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom$out1) VALUES ('".$start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$start_planete->id."', '".$this->end_time."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."'$out2);";
var_dump($sql);
//$bdd->query($sql);
}
elseif (!empty($out)) $bdd->query("UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";");
else $bdd->query("UPDATE $table_flottes SET last = 0 WHERE id = ".$this->id_flotte.";");
}
$bdd->deconnexion();
}

View file

@ -24,6 +24,7 @@ class Planete extends User{
$cristal,
$hydrogene,
$population,
$moral,
$alert_ressources = array(false, false, false),
$timestamp,
$timestamp_lastSilo,
@ -51,7 +52,7 @@ class Planete extends User{
* @return void
* @access public
*/
function Planete($id = 0){
function Planete($id = 0, $first = false){
if (!empty($id)) {
global $var___db, $config, $table_planete;
global $batimentVAR, $casernenVAR, $nomterrnVAR, $nomvaisnVAR;
@ -77,6 +78,7 @@ class Planete extends User{
$this->cristal = $plan["cristal"];
$this->hydrogene = $plan["hydrogene"];
$this->population = $plan["population"];
$this->moral = $plan["moral"];
$this->timestamp = $plan["timestamp"];
foreach($batimentVAR as $bat){
@ -109,7 +111,7 @@ class Planete extends User{
if (!empty($plan["file_vais"])) $this->file_vais = unserialize($plan["file_vais"]);
else $this->file_vais = array();
$this->actualiser();
$this->actualiser(true, $first);
}
}
}
@ -120,7 +122,7 @@ class Planete extends User{
* @return void
* @access public
*/
function actualiser($actuFile = true){
function actualiser($actuFile = true, $first = false){
//Actualisation des files d'attentes
if ($actuFile) {
$this->file_pret("batiments");
@ -177,11 +179,24 @@ class Planete extends User{
}
}
//Vérification de la date pour faire les actions journalières
if (date('zya') != date('zya', $this->timestamp)) {
//On évalue le moral
$this->evalMoral($first);
//Si la population est à 0, on ajoute des habitants
if ($this->population <= 0) $this->population = 1000;
$this->population = $this->population * 1.0153^max(1, floor((time()-$this->timestamp)/86400));
$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->credits += $this->population/100*exp(0.01)*25;
$this->modif[] = 'population';
}
@ -196,6 +211,75 @@ class Planete extends User{
}
}
function setMoral($difference){
$this->moral += $difference;
//Ajustement du moral
if ($this->moral > 1) $this->moral = 1;
elseif ($this->moral < 0) $this->moral = 0;
if (!in_array("moral", $this->modif)) $this->modif[] = "moral";
}
function evalMoral($first = false){
//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;
if (!in_array('moral', $this->modif)) $this->modif[] = 'moral';
}
//Surpopulation
//Surlogement
//Ajustement du moral en fonction de la politique
if ($this->politique == 1 && $this->moral > 0.7) $this->moral = 0.7;
//Isolement si besoin
if ($this->moral < 0.1) {
//On vérifie qu'il ne s'agit pas de la planète mère
global $bdd, $table_planete;
$bdd->connexion();
$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.01 || $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->connexion();
$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 percistante 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.06 || $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);
if (!in_array('isolement', $this->modif)) $this->modif[] = '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.');
}
}
}
}
}
}
/**
* Vérifie si la planète est isolée ou non
*
@ -205,8 +289,8 @@ class Planete extends User{
function isolement(){
$return = false;
if (time() > $isolement[0]) {
if (!isset($isolement[1]) || (time() > $isolement[1] && date('dmY') != date('dmY', $isolement[0]))) {
if (time() > $this->isolement[0]) {
if (!isset($this->isolement[1]) || (time() > $this->isolement[1] && date('dmY') != date('dmY', $this->isolement[0]))) {
$nbPlan = count($queryPlanetes);
$numP = 0;
for ($i=0 ; $i<$nbPlan ; $i++) {
@ -226,25 +310,17 @@ class Planete extends User{
$debut = mktime(rand(0, 24-$tps), 0, 0, date('n'), date('j'), date('Y'));
$fin = $debut + $tps * 3600;
$bdd->connexion();
$bdd->query("UPDATE $table_planete SET isolement = '$debut $fin' WHERE id = '$idPlan';");
$bdd->deconnexion();
$isolement[0] = $debut;
if (time() > $isolement[0]) $isolement[1] = $fin;
$this->isolement[0] = $debut;
if (time() > $this->isolement[0]) $this->isolement[1] = $fin;
if (!in_array('isolement', $this->modif)) $this->modif[] = 'isolement';
}
}
$p = gpc('p');
if (isset($isolement[1]) && time() < $isolement[1]) {
if (isset($this->isolement[1]) && time() < $this->isolement[1]) {
$return = true;
}
}
//On applique les bonus politiques aux productions
if (isset($this->politique) && $this->politique == 1) {
$sec *= 0.9;
}
if (!in_array('isolement', $this->modif)) $this->modif[] = 'isolement';
return $return;
}
@ -301,7 +377,7 @@ class Planete extends User{
else $prod_cri = ((ceil(pow(1.1, $this->batiments[1]) * 23 * $this->batiments[1]) / 3600) * $temps_ecoule) * $this->coeff_bat[1] * 1.5;
if ($this->batiments[2] <= 0) $prod_hy = 0;
else $prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 14 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2] * 1.5 - $conso_h;
else $prod_hy = ((ceil(pow(1.1, $this->batiments[2]) * 14 * ($this->batiments[2] + 0.7)) / 3600) * $temps_ecoule) * $this->coeff_bat[2] * 1.5;
//Augmentation de la production en fonction des technologies
if ($this->technologies[0] & 4) {
@ -320,6 +396,28 @@ class Planete extends User{
$prod_hy *= 1.05;
}
//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;
@ -327,6 +425,9 @@ class Planete extends User{
$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);
}