Passed
Push — master ( a3f1e4...14e4ba )
by Anthony
02:53
created
modules/bataille/app/controller/Batiment.php 1 patch
Braces   +28 added lines, -36 removed lines patch added patch discarded remove patch
@@ -86,8 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 					return $obj->niveau;
88 88
 				}
89
-			}
90
-			else {
89
+			} else {
91 90
 				return 0;
92 91
 			}
93 92
 		}
@@ -100,10 +99,18 @@  discard block
 block discarded – undo
100 99
 		public function getProduction($ressource) {
101 100
 			$dbc1 = Bataille::getDb();
102 101
 
103
-			if ($ressource == "eau") $nom_batiment = "centrale_eau";
104
-			if ($ressource == "electricite") $nom_batiment = "centrale_electrique";
105
-			if ($ressource == "fuel") $nom_batiment = "station_pompage_fuel";
106
-			if ($ressource == "fer") $nom_batiment = "station_forage";
102
+			if ($ressource == "eau") {
103
+				$nom_batiment = "centrale_eau";
104
+			}
105
+			if ($ressource == "electricite") {
106
+				$nom_batiment = "centrale_electrique";
107
+			}
108
+			if ($ressource == "fuel") {
109
+				$nom_batiment = "station_pompage_fuel";
110
+			}
111
+			if ($ressource == "fer") {
112
+				$nom_batiment = "station_forage";
113
+			}
107 114
 
108 115
 			$niveau = $this->getNiveauBatiment($nom_batiment);
109 116
 
@@ -124,15 +131,13 @@  discard block
 block discarded – undo
124 131
 						foreach ($query as $obj) {
125 132
 							$prod_addon = $obj->production;
126 133
 						}
127
-					}
128
-					else {
134
+					} else {
129 135
 						$prod_addon = 0;
130 136
 					}
131 137
 
132 138
 					return $prod + $prod_addon;
133 139
 				}
134
-			}
135
-			else {
140
+			} else {
136 141
 				return 20;
137 142
 			}
138 143
 		}
@@ -154,8 +159,7 @@  discard block
 block discarded – undo
154 159
 						return $obj->stockage;
155 160
 					}
156 161
 				}
157
-			}
158
-			else {
162
+			} else {
159 163
 				return 1000;
160 164
 			}
161 165
 		}
@@ -191,8 +195,7 @@  discard block
 block discarded – undo
191 195
 				}
192 196
 				$niveau_batiment_base = $this->niveau_batiment;
193 197
 				$max_level =  $this->getInfoUpgradeBatiment();
194
-			}
195
-			else {
198
+			} else {
196 199
 				//on test voir si le bat est au niveau max et si il peut avoir un addon
197 200
 				if (ChaineCaractere::FindInString($nom_batiment, "addon")) {
198 201
 					$query = $dbc1->select("nom_table")->from("liste_batiment")->where("nom", "=", $nom_batiment)->get();
@@ -206,12 +209,10 @@  discard block
 block discarded – undo
206 209
 
207 210
 						$max_level = $this->getInfoUpgradeBatiment();
208 211
 						$niveau_batiment_base = 10;
209
-					}
210
-					else {
212
+					} else {
211 213
 						$max_level = 0;
212 214
 					}
213
-				}
214
-				else {
215
+				} else {
215 216
 					$max_level = 0;
216 217
 				}
217 218
 			}
@@ -266,8 +267,7 @@  discard block
 block discarded – undo
266 267
 
267 268
 				if ($this->date_fin_construction-$today <= 0) {
268 269
 					$this->setTerminerConstruction($id_batiment);
269
-				}
270
-				else {
270
+				} else {
271 271
 					Bataille::setValues([
272 272
 						"date_fin_construction" => $this->date_fin_construction-$today,
273 273
 						"nom_batiment_construction" => $this->nom_batiment_construction
@@ -330,8 +330,7 @@  discard block
 block discarded – undo
330 330
 						foreach ($query as $obj) {
331 331
 							if ($obj->pour_construire != null) {
332 332
 								$pour_construire = unserialize($obj->pour_construire);
333
-							}
334
-							else {
333
+							} else {
335 334
 								$pour_construire = [];
336 335
 							}
337 336
 
@@ -354,8 +353,7 @@  discard block
 block discarded – undo
354 353
 								];
355 354
 							}
356 355
 						}
357
-					}
358
-					else if (count($pour_construire) > 1) {
356
+					} else if (count($pour_construire) > 1) {
359 357
 						$ok_construction = false;
360 358
 						//test si tous les batiments sont construits et on le niveau nécéssaire
361 359
 						for ($j=0 ; $j<count($pour_construire) ; $j++) {
@@ -377,8 +375,7 @@  discard block
 block discarded – undo
377 375
 								"temps_construction" => $temps_construction
378 376
 							];
379 377
 						}
380
-					}
381
-					else {
378
+					} else {
382 379
 						$ressource = $this->getRessourceConstruireBatiment($all_batiment[$i], 0);
383 380
 
384 381
 						$batiment_construire[] = [
@@ -488,8 +485,7 @@  discard block
 block discarded – undo
488 485
 							$this->info_batiment_next = $xml->$nom_batiment_sql->phrase_suivant.$obj->$champ;
489 486
 						}
490 487
 					}
491
-				}
492
-				else {
488
+				} else {
493 489
 					$this->info_batiment = "";
494 490
 					$this->info_batiment_next = "";
495 491
 				}
@@ -534,8 +530,7 @@  discard block
 block discarded – undo
534 530
 					$ressource = $this->getRessourceConstruireBatiment($nom_batiment_sql, 0);
535 531
 					$this->nom_batiment_sql = $nom_batiment_sql;
536 532
 					$this->niveau_batiment = 0;
537
-				}
538
-				else {
533
+				} else {
539 534
 					//si c'est le lvl 0 de l'addon
540 535
 					if ($this->niveau_batiment == 0) {
541 536
 						$un_batiment = 0;
@@ -546,8 +541,7 @@  discard block
 block discarded – undo
546 541
 				//si pas assez de ressource
547 542
 				if (in_array("rouge", $ressource[0])) {
548 543
 					FlashMessage::setFlash("Pas assez de ressources pour construire ce batiment");
549
-				}
550
-				else {
544
+				} else {
551 545
 					//recuperation du temps de construction
552 546
 					$query = $dbc1->select("ressource_construire")
553 547
 						->select("temps_construction")
@@ -572,8 +566,7 @@  discard block
 block discarded – undo
572 566
 							->set();
573 567
 
574 568
 						$this->id_batiment = $dbc->lastInsertId();
575
-					}
576
-					else {
569
+					} else {
577 570
 						$dbc->update("niveau", $this->niveau_batiment+1)
578 571
 							->update("construction", 1)
579 572
 							->from("_bataille_batiment")
@@ -601,8 +594,7 @@  discard block
 block discarded – undo
601 594
 					//on retire les ressources de la base
602 595
 					Bataille::getRessource()->setRetirerRessource($ressource_construction[2], $ressource_construction[3], $ressource_construction[0], $ressource_construction[1]);
603 596
 				}
604
-			}
605
-			else {
597
+			} else {
606 598
 				FlashMessage::setFlash("Un batiment est déjà en construction, vous ne pouvez pas en construire un autre !");
607 599
 			}
608 600
 		}
Please login to merge, or discard this patch.