Passed
Push — master ( 44c94d...e81c16 )
by Anthony
15:56
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
 					}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$this->niveau_batiment = 0;
203 203
 			}
204 204
 
205
-			$max_level =  $this->getInfoUpgradeBatiment();
205
+			$max_level = $this->getInfoUpgradeBatiment();
206 206
 
207 207
 			//permet de savoir si le batiment produit bien des ressoures
208 208
 			$batiment_production = [];
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
 					$id_batiment = $obj->ID_batiment;
251 251
 				}
252 252
 
253
-				if ($this->date_fin_construction-$today <= 0) {
253
+				if ($this->date_fin_construction - $today <= 0) {
254 254
 					$this->setTerminerConstruction($id_batiment);
255 255
 				}
256 256
 				else {
257 257
 					Bataille::setValues([
258
-						"date_fin_construction" => $this->date_fin_construction-$today,
258
+						"date_fin_construction" => $this->date_fin_construction - $today,
259 259
 						"nom_batiment_construction" => $this->nom_batiment_construction
260 260
 					]);
261 261
 				}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 			//et compare la liste des batiments qu'il faut pour construire le batiment
305 305
 			//a ceux qui sont deja construit dans la base
306 306
 			//si tous les batments qu'il faut son batis on autorise la construction du batiment
307
-			for ($i=0 ; $i<$c_all_batiment ; $i++) {
307
+			for ($i = 0; $i < $c_all_batiment; $i++) {
308 308
 				if (!in_array($all_batiment[$i], $batiment_construit)) {
309 309
 					$query = $dbc1->select("pour_construire")
310 310
 						->select("temps_construction")
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 					else if (count($pour_construire) > 1) {
345 345
 						$ok_construction = false;
346 346
 						//test si tous les batiments sont construits et on le niveau nécéssaire
347
-						for ($j=0 ; $j<count($pour_construire) ; $j++) {
347
+						for ($j = 0; $j < count($pour_construire); $j++) {
348 348
 							if (in_array($pour_construire[$j][1], $batiment_construit)) {
349 349
 								if ($pour_construire[$j][2] <= $this->getNiveauBatiment($pour_construire[$j][1])) {
350 350
 									$ok_construction = true;
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 			$case_depart = explode(",", $case_depart);
399 399
 			$posx = $case_depart[0];
400 400
 			$posy = $case_depart[1];
401
-			$finx = $width_batiment+$posx;
402
-			$finy = $height_batiment+$posy;
401
+			$finx = $width_batiment + $posx;
402
+			$finy = $height_batiment + $posy;
403 403
 
404 404
 			//récupération de tous les batiments
405 405
 			$query = $dbc->select("posx")
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 					$posx_batiment = $obj->posx;
416 416
 					$posy_batiment = $obj->posy;
417 417
 
418
-					$finx_batiment = $taille_batiment[0]+$posx_batiment;
419
-					$finy_batiment = $taille_batiment[1]+$posy_batiment;
418
+					$finx_batiment = $taille_batiment[0] + $posx_batiment;
419
+					$finy_batiment = $taille_batiment[1] + $posy_batiment;
420 420
 
421 421
 					//ok pour coin haut-gauche ++ coin bas-droite
422 422
 					if (((($posx >= $posx_batiment) && ($posx <= $finx_batiment)) &&
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		private function getRessourceConstruireBatiment($nom_batiment_sql, $niveau) {
462 462
 			$dbc1 = Bataille::getDb();
463 463
 
464
-			$niveau = $niveau+1;
464
+			$niveau = $niveau + 1;
465 465
 
466 466
 			$query = $dbc1->select("ressource_construire")->from($nom_batiment_sql)->where("ID_".$nom_batiment_sql, "=", $niveau)->get();
467 467
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		 */
495 495
 		private function getTestBatimentConstruction($nom_batiment) {
496 496
 			if (ChaineCaractere::FindInString($nom_batiment, " en construction") == true) {
497
-				return [substr($nom_batiment, 0, (0-strlen(" en construction"))), true];
497
+				return [substr($nom_batiment, 0, (0 - strlen(" en construction"))), true];
498 498
 			}
499 499
 
500 500
 			return [$nom_batiment, false];
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			$dbc1 = Bataille::getDb();
509 509
 
510 510
 			//récupération du temps et des ressources pour construire
511
-			$query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)->get();
511
+			$query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)->get();
512 512
 
513 513
 			//si on a quelque chose cela veut dire qu'on est pas encore au lvl max du batiment
514 514
 			if ((is_array($query)) && (count($query) > 0)) {
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment)
530 530
 						->get();
531 531
 
532
-					if ((is_array($query)) && (count($query) > 0)){
532
+					if ((is_array($query)) && (count($query) > 0)) {
533 533
 						foreach ($query as $obj) {
534 534
 							$this->info_batiment = $xml->$nom_batiment_sql->phrase.$obj->$champ.$xml->$nom_batiment_sql->complement;
535 535
 						}
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 					//récupération de la phrase pour le niveau suivant
539 539
 					$query = $dbc1->select($xml->$nom_batiment_sql->champ)
540 540
 						->from($this->nom_batiment_sql)
541
-						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)
541
+						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)
542 542
 						->get();
543 543
 
544
-					if ((is_array($query)) && (count($query) > 0)){
544
+					if ((is_array($query)) && (count($query) > 0)) {
545 545
 						foreach ($query as $obj) {
546 546
 							$this->info_batiment_next = $xml->$nom_batiment_sql->phrase_suivant.$obj->$champ.$xml->$nom_batiment_sql->complement;
547 547
 						}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 					$query = $dbc1->select("ressource_construire")
602 602
 						->select("temps_construction")
603 603
 						->from($this->nom_batiment_sql)
604
-						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)
604
+						->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)
605 605
 						->get();
606 606
 
607 607
 					foreach ($query as $obj) {
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 
612 612
 					//on insere la construction dans la table batiment si new batiment
613 613
 					if ($un_batiment == 0) {
614
-						$dbc->insert("niveau", $this->niveau_batiment+1)
614
+						$dbc->insert("niveau", $this->niveau_batiment + 1)
615 615
 							->insert("nom_batiment", $nom_batiment)
616 616
 							->insert("nom_batiment_sql", $this->nom_batiment_sql)
617 617
 							->insert("construction", 1)
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 						$this->id_batiment = $dbc->lastInsertId();
623 623
 					}
624 624
 					else {
625
-						$dbc->update("niveau", $this->niveau_batiment+1)
625
+						$dbc->update("niveau", $this->niveau_batiment + 1)
626 626
 							->update("construction", 1)
627 627
 							->from("_bataille_batiment")
628 628
 							->where("ID_batiment", "=", $this->id_batiment, "AND")
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 					$today = Bataille::getToday();
637 637
 
638 638
 					//date de la fin de la construction en seconde
639
-					$fin_construction = $today+$temps_construction;
639
+					$fin_construction = $today + $temps_construction;
640 640
 
641 641
 					$dbc->insert("date_fin", $fin_construction)
642 642
 						->insert("ID_base", Bataille::getIdBase())
Please login to merge, or discard this patch.