@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function getRessourceConstruire() { |
46 | 46 | return $this->ressource_construire; |
47 | 47 | } |
48 | - public function getInfoBatiment(){ |
|
48 | + public function getInfoBatiment() { |
|
49 | 49 | return $this->info_batiment; |
50 | 50 | } |
51 | 51 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if ((is_array($query)) && (count($query) > 0)) { |
78 | 78 | foreach ($query as $obj) { |
79 | 79 | if ($obj->construction == 1) { |
80 | - return $obj->niveau-1; |
|
80 | + return $obj->niveau - 1; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return $obj->niveau; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if ($niveau > 0) { |
146 | 146 | $query = $dbc1->select("stockage")->from("entrepot")->where("ID_entrepot", "=", $niveau)->get(); |
147 | 147 | |
148 | - if ((is_array($query)) && (count($query) > 0)){ |
|
148 | + if ((is_array($query)) && (count($query) > 0)) { |
|
149 | 149 | foreach ($query as $obj) { |
150 | 150 | return $obj->stockage; |
151 | 151 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | if (($construction[1] == true) && ($this->niveau_batiment > 1)) { |
236 | 236 | $this->niveau_batiment = $this->niveau_batiment + 1; |
237 | 237 | } |
238 | - $max_level = $this->getInfoUpgradeBatiment(); |
|
238 | + $max_level = $this->getInfoUpgradeBatiment(); |
|
239 | 239 | } |
240 | 240 | else { |
241 | 241 | //on test voir si le bat est au niveau max et si il peut avoir un addon |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | $id_batiment = $obj->ID_batiment; |
308 | 308 | } |
309 | 309 | |
310 | - if ($this->date_fin_construction-$today <= 0) { |
|
310 | + if ($this->date_fin_construction - $today <= 0) { |
|
311 | 311 | $this->setTerminerConstruction($id_batiment); |
312 | 312 | } |
313 | 313 | else { |
314 | 314 | Bataille::setValues([ |
315 | - "date_fin_construction" => $this->date_fin_construction-$today, |
|
315 | + "date_fin_construction" => $this->date_fin_construction - $today, |
|
316 | 316 | "nom_batiment_construction" => $this->nom_batiment_construction |
317 | 317 | ]); |
318 | 318 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | //et compare la liste des batiments qu'il faut pour construire le batiment |
362 | 362 | //a ceux qui sont deja construit dans la base |
363 | 363 | //si tous les batments qu'il faut son batis on autorise la construction du batiment |
364 | - for ($i=0 ; $i<$c_all_batiment ; $i++) { |
|
364 | + for ($i = 0; $i < $c_all_batiment; $i++) { |
|
365 | 365 | if (!in_array($all_batiment[$i], $batiment_construit)) { |
366 | 366 | $query = $dbc1->select("pour_construire") |
367 | 367 | ->select("temps_construction") |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | private function getRessourceConstruireBatiment($nom_batiment_sql, $niveau) { |
426 | 426 | $dbc1 = Bataille::getDb(); |
427 | 427 | |
428 | - $niveau = $niveau+1; |
|
428 | + $niveau = $niveau + 1; |
|
429 | 429 | |
430 | 430 | $query = $dbc1->select("ressource_construire")->from($nom_batiment_sql)->where("ID_".$nom_batiment_sql, "=", $niveau)->get(); |
431 | 431 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | */ |
459 | 459 | private function getTestBatimentConstruction($nom_batiment) { |
460 | 460 | if (ChaineCaractere::FindInString($nom_batiment, " en construction") == true) { |
461 | - return [substr($nom_batiment, 0, (0-strlen(" en construction"))), true]; |
|
461 | + return [substr($nom_batiment, 0, (0 - strlen(" en construction"))), true]; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | return [$nom_batiment, false]; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $dbc1 = Bataille::getDb(); |
474 | 474 | |
475 | 475 | //récupération du temps et des ressources pour construire |
476 | - $query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)->get(); |
|
476 | + $query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)->get(); |
|
477 | 477 | |
478 | 478 | //si on a quelque chose cela veut dire qu'on est pas encore au lvl max du batiment |
479 | 479 | if ((is_array($query)) && (count($query) > 0)) { |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | |
485 | 485 | //récupération des éléments particulier à un batiment |
486 | 486 | if ($this->nom_batiment_sql == "entrepot") { |
487 | - $query = $dbc1->select("stockage")->from("entrepot")->where("ID_entrepot", "=", $this->niveau_batiment+1)->get(); |
|
487 | + $query = $dbc1->select("stockage")->from("entrepot")->where("ID_entrepot", "=", $this->niveau_batiment + 1)->get(); |
|
488 | 488 | |
489 | - if ((is_array($query)) && (count($query) > 0)){ |
|
489 | + if ((is_array($query)) && (count($query) > 0)) { |
|
490 | 490 | foreach ($query as $obj) { |
491 | - $this->info_batiment = "Capacité de l'entrepôt au prochain niveau : ". $obj->stockage; |
|
491 | + $this->info_batiment = "Capacité de l'entrepôt au prochain niveau : ".$obj->stockage; |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | } |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $query = $dbc1->select("ressource_construire") |
550 | 550 | ->select("temps_construction") |
551 | 551 | ->from($this->nom_batiment_sql) |
552 | - ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1) |
|
552 | + ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1) |
|
553 | 553 | ->get(); |
554 | 554 | |
555 | 555 | foreach ($query as $obj) { |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | |
560 | 560 | //on insere la construction dans la table batiment si new batiment |
561 | 561 | if ($un_batiment == 0) { |
562 | - $dbc->insert("niveau", $this->niveau_batiment+1) |
|
562 | + $dbc->insert("niveau", $this->niveau_batiment + 1) |
|
563 | 563 | ->insert("emplacement", $emplacement) |
564 | 564 | ->insert("nom_batiment", $nom_batiment) |
565 | 565 | ->insert("nom_batiment_sql", $this->nom_batiment_sql) |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $this->id_batiment = $dbc->lastInsertId(); |
572 | 572 | } |
573 | 573 | else { |
574 | - $dbc->update("niveau", $this->niveau_batiment+1) |
|
574 | + $dbc->update("niveau", $this->niveau_batiment + 1) |
|
575 | 575 | ->update("construction", 1) |
576 | 576 | ->from("_bataille_batiment") |
577 | 577 | ->where("ID_batiment", "=", $this->id_batiment, "AND") |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $today = $today->getTimestamp(); |
587 | 587 | |
588 | 588 | //date de la fin de la construction en seconde |
589 | - $fin_construction = $today+$temps_construction; |
|
589 | + $fin_construction = $today + $temps_construction; |
|
590 | 590 | |
591 | 591 | $dbc->insert("date_fin", $fin_construction) |
592 | 592 | ->insert("emplacement_construction", $emplacement) |
@@ -82,8 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | return $obj->niveau; |
84 | 84 | } |
85 | - } |
|
86 | - else { |
|
85 | + } else { |
|
87 | 86 | return 0; |
88 | 87 | } |
89 | 88 | } |
@@ -96,10 +95,18 @@ discard block |
||
96 | 95 | public function getProduction($ressource) { |
97 | 96 | $dbc1 = Bataille::getDb(); |
98 | 97 | |
99 | - if ($ressource == "eau") $nom_batiment = "centrale_eau"; |
|
100 | - if ($ressource == "electricite") $nom_batiment = "centrale_electrique"; |
|
101 | - if ($ressource == "fuel") $nom_batiment = "station_pompage_fuel"; |
|
102 | - if ($ressource == "fer") $nom_batiment = "station_forage"; |
|
98 | + if ($ressource == "eau") { |
|
99 | + $nom_batiment = "centrale_eau"; |
|
100 | + } |
|
101 | + if ($ressource == "electricite") { |
|
102 | + $nom_batiment = "centrale_electrique"; |
|
103 | + } |
|
104 | + if ($ressource == "fuel") { |
|
105 | + $nom_batiment = "station_pompage_fuel"; |
|
106 | + } |
|
107 | + if ($ressource == "fer") { |
|
108 | + $nom_batiment = "station_forage"; |
|
109 | + } |
|
103 | 110 | |
104 | 111 | $niveau = $this->getNiveauBatiment($nom_batiment); |
105 | 112 | |
@@ -120,15 +127,13 @@ discard block |
||
120 | 127 | foreach ($query as $obj) { |
121 | 128 | $prod_addon = $obj->production; |
122 | 129 | } |
123 | - } |
|
124 | - else { |
|
130 | + } else { |
|
125 | 131 | $prod_addon = 0; |
126 | 132 | } |
127 | 133 | |
128 | 134 | return $prod + $prod_addon; |
129 | 135 | } |
130 | - } |
|
131 | - else { |
|
136 | + } else { |
|
132 | 137 | return 20; |
133 | 138 | } |
134 | 139 | } |
@@ -150,8 +155,7 @@ discard block |
||
150 | 155 | return $obj->stockage; |
151 | 156 | } |
152 | 157 | } |
153 | - } |
|
154 | - else { |
|
158 | + } else { |
|
155 | 159 | return 1000; |
156 | 160 | } |
157 | 161 | } |
@@ -236,8 +240,7 @@ discard block |
||
236 | 240 | $this->niveau_batiment = $this->niveau_batiment + 1; |
237 | 241 | } |
238 | 242 | $max_level = $this->getInfoUpgradeBatiment(); |
239 | - } |
|
240 | - else { |
|
243 | + } else { |
|
241 | 244 | //on test voir si le bat est au niveau max et si il peut avoir un addon |
242 | 245 | if (ChaineCaractere::FindInString($nom_batiment, "addon")) { |
243 | 246 | $query = $dbc1->select("nom_table")->from("liste_batiment")->where("nom", "=", $nom_batiment)->get(); |
@@ -250,12 +253,10 @@ discard block |
||
250 | 253 | $this->niveau_batiment = 0; |
251 | 254 | |
252 | 255 | $max_level = $this->getInfoUpgradeBatiment(); |
253 | - } |
|
254 | - else { |
|
256 | + } else { |
|
255 | 257 | $max_level = 0; |
256 | 258 | } |
257 | - } |
|
258 | - else { |
|
259 | + } else { |
|
259 | 260 | $max_level = 0; |
260 | 261 | } |
261 | 262 | } |
@@ -309,8 +310,7 @@ discard block |
||
309 | 310 | |
310 | 311 | if ($this->date_fin_construction-$today <= 0) { |
311 | 312 | $this->setTerminerConstruction($id_batiment); |
312 | - } |
|
313 | - else { |
|
313 | + } else { |
|
314 | 314 | Bataille::setValues([ |
315 | 315 | "date_fin_construction" => $this->date_fin_construction-$today, |
316 | 316 | "nom_batiment_construction" => $this->nom_batiment_construction |
@@ -373,8 +373,7 @@ discard block |
||
373 | 373 | foreach ($query as $obj) { |
374 | 374 | if ($obj->pour_construire != null) { |
375 | 375 | $pour_construire = unserialize($obj->pour_construire); |
376 | - } |
|
377 | - else { |
|
376 | + } else { |
|
378 | 377 | $pour_construire = []; |
379 | 378 | } |
380 | 379 | |
@@ -397,11 +396,9 @@ discard block |
||
397 | 396 | ]; |
398 | 397 | } |
399 | 398 | } |
400 | - } |
|
401 | - else if (count($pour_construire) > 1) { |
|
399 | + } else if (count($pour_construire) > 1) { |
|
402 | 400 | //TODO si besoin de plus d'un seul batiment pour etre construit |
403 | - } |
|
404 | - else { |
|
401 | + } else { |
|
405 | 402 | $ressource = $this->getRessourceConstruireBatiment($all_batiment[$i], 0); |
406 | 403 | |
407 | 404 | $batiment_construire[] = [ |
@@ -531,8 +528,7 @@ discard block |
||
531 | 528 | $ressource = $this->getRessourceConstruireBatiment($nom_batiment_sql, 0); |
532 | 529 | $this->nom_batiment_sql = $nom_batiment_sql; |
533 | 530 | $this->niveau_batiment = 0; |
534 | - } |
|
535 | - else { |
|
531 | + } else { |
|
536 | 532 | //si c'est le lvl 0 de l'addon |
537 | 533 | if ($this->niveau_batiment == 0) { |
538 | 534 | $un_batiment = 0; |
@@ -543,8 +539,7 @@ discard block |
||
543 | 539 | //si pas assez de ressource |
544 | 540 | if (in_array("rouge", $ressource[0])) { |
545 | 541 | FlashMessage::setFlash("Pas assez de ressources pour construire ce batiment"); |
546 | - } |
|
547 | - else { |
|
542 | + } else { |
|
548 | 543 | //recuperation du temps de construction |
549 | 544 | $query = $dbc1->select("ressource_construire") |
550 | 545 | ->select("temps_construction") |
@@ -569,8 +564,7 @@ discard block |
||
569 | 564 | ->set(); |
570 | 565 | |
571 | 566 | $this->id_batiment = $dbc->lastInsertId(); |
572 | - } |
|
573 | - else { |
|
567 | + } else { |
|
574 | 568 | $dbc->update("niveau", $this->niveau_batiment+1) |
575 | 569 | ->update("construction", 1) |
576 | 570 | ->from("_bataille_batiment") |
@@ -598,8 +592,7 @@ discard block |
||
598 | 592 | //on retire les ressources de la base |
599 | 593 | Bataille::getRessource()->setRetirerRessource($ressource_construction[2], $ressource_construction[3], $ressource_construction[0], $ressource_construction[1]); |
600 | 594 | } |
601 | - } |
|
602 | - else { |
|
595 | + } else { |
|
603 | 596 | FlashMessage::setFlash("Un batiment est déjà en construction, vous ne pouvez pas en construire un autre !"); |
604 | 597 | } |
605 | 598 | } |