Passed
Push — master ( bda723...5e421f )
by Anthony
02:41
created
modules/bataille/app/controller/Batiment.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 		public function getRessourceConstruire() {
48 48
 			return $this->ressource_construire;
49 49
 		}
50
-		public function getInfoBatiment(){
50
+		public function getInfoBatiment() {
51 51
 		    return $this->info_batiment;
52 52
 		}
53
-		public function getInfoBatimentNext(){
53
+		public function getInfoBatimentNext() {
54 54
 			return $this->info_batiment_next;
55 55
 		}
56 56
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			if ((is_array($query)) && (count($query) > 0)) {
87 87
 				foreach ($query as $obj) {
88 88
 					if ($obj->construction == 1) {
89
-						return $obj->niveau-1;
89
+						return $obj->niveau - 1;
90 90
 					}
91 91
 
92 92
 					return $obj->niveau;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			if ($niveau > 0) {
149 149
 				$query = $dbc1->select("stockage")->from("entrepot")->where("ID_entrepot", "=", $niveau)->get();
150 150
 
151
-				if ((is_array($query)) && (count($query) > 0)){
151
+				if ((is_array($query)) && (count($query) > 0)) {
152 152
 					foreach ($query as $obj) {
153 153
 						return $obj->stockage;
154 154
 					}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 					$this->niveau_batiment = $this->niveau_batiment + 1;
188 188
 				}
189 189
 
190
-				$max_level =  $this->getInfoUpgradeBatiment();
190
+				$max_level = $this->getInfoUpgradeBatiment();
191 191
 			}
192 192
 			else {
193 193
 				$query = $dbc1->select("nom_table")
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 					$id_batiment = $obj->ID_batiment;
253 253
 				}
254 254
 
255
-				if ($this->date_fin_construction-$today <= 0) {
255
+				if ($this->date_fin_construction - $today <= 0) {
256 256
 					$this->setTerminerConstruction($id_batiment);
257 257
 				}
258 258
 				else {
259 259
 					Bataille::setValues([
260
-						"date_fin_construction" => $this->date_fin_construction-$today,
260
+						"date_fin_construction" => $this->date_fin_construction - $today,
261 261
 						"nom_batiment_construction" => $this->nom_batiment_construction
262 262
 					]);
263 263
 				}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 			//et compare la liste des batiments qu'il faut pour construire le batiment
307 307
 			//a ceux qui sont deja construit dans la base
308 308
 			//si tous les batments qu'il faut son batis on autorise la construction du batiment
309
-			for ($i=0 ; $i<$c_all_batiment ; $i++) {
309
+			for ($i = 0; $i < $c_all_batiment; $i++) {
310 310
 				if (!in_array($all_batiment[$i], $batiment_construit)) {
311 311
 					$query = $dbc1->select("pour_construire")
312 312
 						->select("temps_construction")
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 					else if (count($pour_construire) > 1) {
350 350
 						$ok_construction = false;
351 351
 						//test si tous les batiments sont construits et on le niveau nécéssaire
352
-						for ($j=0 ; $j<count($pour_construire) ; $j++) {
352
+						for ($j = 0; $j < count($pour_construire); $j++) {
353 353
 							if (in_array($pour_construire[$j][1], $batiment_construit)) {
354 354
 								if ($pour_construire[$j][2] <= $this->getNiveauBatiment($pour_construire[$j][1])) {
355 355
 									$ok_construction = true;
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 			$case_depart = explode(",", $case_depart);
409 409
 			$posx = $case_depart[0];
410 410
 			$posy = $case_depart[1];
411
-			$finx = $width_batiment+$posx;
412
-			$finy = $height_batiment+$posy;
411
+			$finx = $width_batiment + $posx;
412
+			$finy = $height_batiment + $posy;
413 413
 
414 414
 			//récupération de tous les batiments
415 415
 			$query = $dbc->select("posx")
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 					$posx_batiment = $obj->posx;
426 426
 					$posy_batiment = $obj->posy;
427 427
 
428
-					$finx_batiment = $taille_batiment[0]+$posx_batiment;
429
-					$finy_batiment = $taille_batiment[1]+$posy_batiment;
428
+					$finx_batiment = $taille_batiment[0] + $posx_batiment;
429
+					$finy_batiment = $taille_batiment[1] + $posy_batiment;
430 430
 
431 431
 					//ok pour coin haut-gauche ++ coin bas-droite
432 432
 					if (((($posx >= $posx_batiment) && ($posx <= $finx_batiment)) &&
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		private function getRessourceConstruireBatiment($nom_batiment_sql, $niveau) {
483 483
 			$dbc1 = Bataille::getDb();
484 484
 
485
-			$niveau = $niveau+1;
485
+			$niveau = $niveau + 1;
486 486
 
487 487
 			$query = $dbc1->select("ressource_construire")->from($nom_batiment_sql)->where("ID_".$nom_batiment_sql, "=", $niveau)->get();
488 488
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 		 */
516 516
 		private function getTestBatimentConstruction($nom_batiment) {
517 517
 			if (ChaineCaractere::FindInString($nom_batiment, " en construction") == true) {
518
-				return [substr($nom_batiment, 0, (0-strlen(" en construction"))), true];
518
+				return [substr($nom_batiment, 0, (0 - strlen(" en construction"))), true];
519 519
 			}
520 520
 
521 521
 			return [$nom_batiment, false];
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 			$dbc1 = Bataille::getDb();
530 530
 
531 531
 			//récupération du temps et des ressources pour construire
532
-			$query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)->get();
532
+			$query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)->get();
533 533
 
534 534
 			//si on a quelque chose cela veut dire qu'on est pas encore au lvl max du batiment
535 535
 			if ((is_array($query)) && (count($query) > 0)) {
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment)
551 551
 						->get();
552 552
 
553
-					if ((is_array($query)) && (count($query) > 0)){
553
+					if ((is_array($query)) && (count($query) > 0)) {
554 554
 						foreach ($query as $obj) {
555 555
 							$this->info_batiment = $xml->$nom_batiment_sql->phrase.$obj->$champ.$xml->$nom_batiment_sql->complement;
556 556
 						}
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
 					//récupération de la phrase pour le niveau suivant
560 560
 					$query = $dbc1->select($xml->$nom_batiment_sql->champ)
561 561
 						->from($this->nom_batiment_sql)
562
-						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)
562
+						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)
563 563
 						->get();
564 564
 
565
-					if ((is_array($query)) && (count($query) > 0)){
565
+					if ((is_array($query)) && (count($query) > 0)) {
566 566
 						foreach ($query as $obj) {
567 567
 							$this->info_batiment_next = $xml->$nom_batiment_sql->phrase_suivant.$obj->$champ.$xml->$nom_batiment_sql->complement;
568 568
 						}
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 					$query = $dbc1->select("ressource_construire")
623 623
 						->select("temps_construction")
624 624
 						->from($this->nom_batiment_sql)
625
-						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)
625
+						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)
626 626
 						->get();
627 627
 
628 628
 					foreach ($query as $obj) {
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 
633 633
 					//on insere la construction dans la table batiment si new batiment
634 634
 					if ($un_batiment == 0) {
635
-						$dbc->insert("niveau", $this->niveau_batiment+1)
635
+						$dbc->insert("niveau", $this->niveau_batiment + 1)
636 636
 							->insert("nom_batiment", $nom_batiment)
637 637
 							->insert("nom_batiment_sql", $this->nom_batiment_sql)
638 638
 							->insert("posx", intval($posx))
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 						$this->id_batiment = $dbc->lastInsertId();
646 646
 					}
647 647
 					else {
648
-						$dbc->update("niveau", $this->niveau_batiment+1)
648
+						$dbc->update("niveau", $this->niveau_batiment + 1)
649 649
 							->update("construction", 1)
650 650
 							->from("_bataille_batiment")
651 651
 							->where("ID_batiment", "=", $this->id_batiment, "AND")
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 					$today = Bataille::getToday();
660 660
 
661 661
 					//date de la fin de la construction en seconde
662
-					$fin_construction = $today+$temps_construction;
662
+					$fin_construction = $today + $temps_construction;
663 663
 
664 664
 					$dbc->insert("date_fin", $fin_construction)
665 665
 						->insert("ID_base", Bataille::getIdBase())
Please login to merge, or discard this patch.