@@ -87,19 +87,19 @@ |
||
87 | 87 | * renvoi le ou les batiments nécéssaires pour la construction du batiment spécifié |
88 | 88 | */ |
89 | 89 | private function getPourConstruire($pour_construire) { |
90 | - for ($i=0 ; $i<count($pour_construire) ; $i++) { |
|
90 | + for ($i = 0; $i < count($pour_construire); $i++) { |
|
91 | 91 | //si plusieur batiment pour construire le batiment en question |
92 | 92 | $count = count($pour_construire[$i]); |
93 | 93 | if ($count > 1) { |
94 | - for ($j=0 ; $j<$count ; $j++) { |
|
95 | - $batiment[] = [ |
|
94 | + for ($j = 0; $j < $count; $j++) { |
|
95 | + $batiment[] = [ |
|
96 | 96 | "nom_batiment" => $pour_construire[$i][$j][0], |
97 | 97 | "niveau_batiment" => $pour_construire[$i][$j][2] |
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | else { |
102 | - $batiment[] = [ |
|
102 | + $batiment[] = [ |
|
103 | 103 | "nom_batiment" => $pour_construire[$i][0][0], |
104 | 104 | "niveau_batiment" => $pour_construire[$i][0][2] |
105 | 105 | ]; |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | $pour_construire[] = unserialize($obj->pour_construire); |
44 | 44 | |
45 | 45 | $pour_construire = $this->getPourConstruire($pour_construire); |
46 | - } |
|
47 | - else { |
|
46 | + } else { |
|
48 | 47 | $pour_construire = []; |
49 | 48 | } |
50 | 49 | |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | "niveau_batiment" => $pour_construire[$i][$j][2] |
98 | 97 | ]; |
99 | 98 | } |
100 | - } |
|
101 | - else { |
|
99 | + } else { |
|
102 | 100 | $batiment[] = [ |
103 | 101 | "nom_batiment" => $pour_construire[$i][0][0], |
104 | 102 | "niveau_batiment" => $pour_construire[$i][0][2] |
@@ -30,8 +30,7 @@ |
||
30 | 30 | |
31 | 31 | if (((is_array($query)) && (count($query) > 0)) || ($controller !== false)) { |
32 | 32 | return true; |
33 | - } |
|
34 | - else { |
|
33 | + } else { |
|
35 | 34 | $router = new RouterModule(); |
36 | 35 | |
37 | 36 | if ($router->getRouteModuleExist($url) !== true) { |
@@ -49,7 +49,7 @@ |
||
49 | 49 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
50 | 50 | /** |
51 | 51 | * @param $id_base |
52 | - * @param $type |
|
52 | + * @param string $type |
|
53 | 53 | * fonction qui ajoute des points à la base en fonction du type |
54 | 54 | * le type peut etre : batiment, attaque, defense, troupe |
55 | 55 | */ |
@@ -41,7 +41,9 @@ |
||
41 | 41 | |
42 | 42 | $query = $dbc->select("points_batiment")->from("configuration")->where("ID_configuration", "=", 1)->get(); |
43 | 43 | |
44 | - foreach ($query as $obj) return $obj->points_batiment; |
|
44 | + foreach ($query as $obj) { |
|
45 | + return $obj->points_batiment; |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
47 | 49 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $dbc = App::getDb(); |
58 | 58 | |
59 | 59 | if ($type == "batiment") { |
60 | - $points = self::getPointsBase($id_base)+self::getPointAjoutBatiment(); |
|
60 | + $points = self::getPointsBase($id_base) + self::getPointAjoutBatiment(); |
|
61 | 61 | |
62 | 62 | } |
63 | 63 |
@@ -119,6 +119,7 @@ |
||
119 | 119 | |
120 | 120 | /** |
121 | 121 | * fonction qui place le trajet en retour |
122 | + * @param double $date_retour |
|
122 | 123 | */ |
123 | 124 | private function setTrajetRetour($date_retour) { |
124 | 125 | $dbc = App::getDb(); |
@@ -67,17 +67,14 @@ discard block |
||
67 | 67 | //si le retour du trajet est également arrivé on finit le transport sinon on le place sur le retour |
68 | 68 | if ($date_retour < $today) { |
69 | 69 | $this->setTerminerTransport(); |
70 | - } |
|
71 | - else { |
|
70 | + } else { |
|
72 | 71 | $this->setTrajetRetour($date_retour); |
73 | 72 | $this->duree_restante_trajet = $date_retour-$today; |
74 | 73 | $set_array = true; |
75 | 74 | } |
76 | - } |
|
77 | - else if (($this->aller == 0) && (($this->date_arrivee-$today) <= 0)) { |
|
75 | + } else if (($this->aller == 0) && (($this->date_arrivee-$today) <= 0)) { |
|
78 | 76 | $this->setTerminerTransport(); |
79 | - } |
|
80 | - else { |
|
77 | + } else { |
|
81 | 78 | $this->duree_restante_trajet = $this->date_arrivee-$today; |
82 | 79 | $set_array = true; |
83 | 80 | } |
@@ -89,8 +86,7 @@ discard block |
||
89 | 86 | "date_arrivee" => $this->duree_restante_trajet, |
90 | 87 | "nom_base_dest" => $this->nom_base |
91 | 88 | ]; |
92 | - } |
|
93 | - else { |
|
89 | + } else { |
|
94 | 90 | $marche["retour"][] = [ |
95 | 91 | "id_marche_transport" => $this->id_marche_transport, |
96 | 92 | "date_arrivee" => $this->duree_restante_trajet, |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | echo $this->date_arrivee."<br>"; |
59 | 59 | |
60 | 60 | //on test si déja arrivé à destination |
61 | - if (($this->aller == 1) && (($this->date_arrivee-$today) <= 0)) { |
|
61 | + if (($this->aller == 1) && (($this->date_arrivee - $today) <= 0)) { |
|
62 | 62 | $this->setLivrerRessource(); |
63 | 63 | |
64 | 64 | //on calcul la date d'arrivée du retour |
65 | - $date_retour = Bataille::getDureeTrajet($this->id_base_dest)+$this->date_arrivee; |
|
65 | + $date_retour = Bataille::getDureeTrajet($this->id_base_dest) + $this->date_arrivee; |
|
66 | 66 | |
67 | 67 | //si le retour du trajet est également arrivé on finit le transport sinon on le place sur le retour |
68 | 68 | if ($date_retour < $today) { |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | } |
71 | 71 | else { |
72 | 72 | $this->setTrajetRetour($date_retour); |
73 | - $this->duree_restante_trajet = $date_retour-$today; |
|
73 | + $this->duree_restante_trajet = $date_retour - $today; |
|
74 | 74 | $set_array = true; |
75 | 75 | } |
76 | 76 | } |
77 | - else if (($this->aller == 0) && (($this->date_arrivee-$today) <= 0)) { |
|
77 | + else if (($this->aller == 0) && (($this->date_arrivee - $today) <= 0)) { |
|
78 | 78 | $this->setTerminerTransport(); |
79 | 79 | } |
80 | 80 | else { |
81 | - $this->duree_restante_trajet = $this->date_arrivee-$today; |
|
81 | + $this->duree_restante_trajet = $this->date_arrivee - $today; |
|
82 | 82 | $set_array = true; |
83 | 83 | } |
84 | 84 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | //si pas assez de ressources dispo dans la base pour l'envoi on renvoi erreur |
156 | 156 | foreach ($ressource as $tab) { |
157 | - if (in_array("rouge", $tab)) {echo $posy;echo $posx; |
|
157 | + if (in_array("rouge", $tab)) {echo $posy; echo $posx; |
|
158 | 158 | FlashMessage::setFlash("Vous n'avez pas autant de ressources disponibles à l'envoi"); |
159 | 159 | return false; |
160 | 160 | }; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | //sinon initialise le transport |
164 | 164 | //on recup la date d'arrivee dans la base de destintation |
165 | - $date_arrivee = Bataille::getDureeTrajet($id_base_dest)+Bataille::getToday(); |
|
165 | + $date_arrivee = Bataille::getDureeTrajet($id_base_dest) + Bataille::getToday(); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | echo("<pre>"); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $last_co = new \DateTime($last_co); |
99 | 99 | $last_co = $last_co->getTimestamp(); |
100 | 100 | |
101 | - $diff_temps = $today-$last_co; |
|
101 | + $diff_temps = $today - $last_co; |
|
102 | 102 | |
103 | 103 | //si la derniere actualisation ou connexion est supérieur à 30 sec |
104 | 104 | if ($diff_temps > 180) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | private function setAddRessource($nom_ressource, $ressrouce, $diff_temps) { |
119 | 119 | $dbc = App::getDb(); |
120 | 120 | |
121 | - $ressource = $ressrouce+(round((Bataille::getBatiment()->getProduction($nom_ressource)/3600)*$diff_temps)); |
|
121 | + $ressource = $ressrouce + (round((Bataille::getBatiment()->getProduction($nom_ressource) / 3600) * $diff_temps)); |
|
122 | 122 | $stockage_max = Bataille::getBatiment()->getStockageEntrepot(); |
123 | 123 | |
124 | 124 | if ($ressource > $stockage_max) { |
@@ -149,18 +149,18 @@ discard block |
||
149 | 149 | |
150 | 150 | //soit on enelve ou on ajoute |
151 | 151 | if ($signe == "-") { |
152 | - $eau = $this->getEau()-$eau; |
|
153 | - $electricite = $this->getElectricite()-$electricite; |
|
154 | - $fer = $this->getFer()-$fer; |
|
155 | - $fuel = $this->getFuel()-$fuel; |
|
156 | - $nourriture = $this->getNourriture()-$nourriture; |
|
152 | + $eau = $this->getEau() - $eau; |
|
153 | + $electricite = $this->getElectricite() - $electricite; |
|
154 | + $fer = $this->getFer() - $fer; |
|
155 | + $fuel = $this->getFuel() - $fuel; |
|
156 | + $nourriture = $this->getNourriture() - $nourriture; |
|
157 | 157 | } |
158 | 158 | else { |
159 | - $eau = $this->getEau()+$eau; |
|
160 | - $electricite = $this->getElectricite()+$electricite; |
|
161 | - $fer = $this->getFer()+$fer; |
|
162 | - $fuel = $this->getFuel()+$fuel; |
|
163 | - $nourriture = $this->getNourriture()+$nourriture; |
|
159 | + $eau = $this->getEau() + $eau; |
|
160 | + $electricite = $this->getElectricite() + $electricite; |
|
161 | + $fer = $this->getFer() + $fer; |
|
162 | + $fuel = $this->getFuel() + $fuel; |
|
163 | + $nourriture = $this->getNourriture() + $nourriture; |
|
164 | 164 | |
165 | 165 | $stockage_max = Bataille::getBatiment()->getStockageEntrepot(); |
166 | 166 |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | if ($id_base === null) { |
19 | 19 | $this->id_base = Bataille::getIdBase(); |
20 | - } |
|
21 | - else { |
|
20 | + } else { |
|
22 | 21 | $this->id_base = $id_base; |
23 | 22 | } |
24 | 23 | |
@@ -154,8 +153,7 @@ discard block |
||
154 | 153 | $fer = $this->getFer()-$fer; |
155 | 154 | $fuel = $this->getFuel()-$fuel; |
156 | 155 | $nourriture = $this->getNourriture()-$nourriture; |
157 | - } |
|
158 | - else { |
|
156 | + } else { |
|
159 | 157 | $eau = $this->getEau()+$eau; |
160 | 158 | $electricite = $this->getElectricite()+$electricite; |
161 | 159 | $fer = $this->getFer()+$fer; |
@@ -164,11 +162,21 @@ discard block |
||
164 | 162 | |
165 | 163 | $stockage_max = Bataille::getBatiment()->getStockageEntrepot(); |
166 | 164 | |
167 | - if ($eau > $stockage_max) $eau = $stockage_max; |
|
168 | - if ($electricite > $stockage_max) $electricite = $stockage_max; |
|
169 | - if ($fer > $stockage_max) $fer = $stockage_max; |
|
170 | - if ($fuel > $stockage_max) $fuel = $stockage_max; |
|
171 | - if ($nourriture > $stockage_max) $nourriture = $stockage_max; |
|
165 | + if ($eau > $stockage_max) { |
|
166 | + $eau = $stockage_max; |
|
167 | + } |
|
168 | + if ($electricite > $stockage_max) { |
|
169 | + $electricite = $stockage_max; |
|
170 | + } |
|
171 | + if ($fer > $stockage_max) { |
|
172 | + $fer = $stockage_max; |
|
173 | + } |
|
174 | + if ($fuel > $stockage_max) { |
|
175 | + $fuel = $stockage_max; |
|
176 | + } |
|
177 | + if ($nourriture > $stockage_max) { |
|
178 | + $nourriture = $stockage_max; |
|
179 | + } |
|
172 | 180 | } |
173 | 181 | |
174 | 182 |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <?php |
2 | - $marche = new \modules\bataille\app\controller\Marche(); |
|
2 | + $marche = new \modules\bataille\app\controller\Marche(); |
|
3 | 3 | |
4 | 4 | $marche->setCommencerTransport($_POST['eau'], $_POST['electricite'], $_POST['fer'], $_POST['fuel'], $_POST['nourriture'], $_POST['posx'], $_POST['posy']); |
5 | 5 | \ No newline at end of file |