@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | public function getRessourceConstruire() { |
| 47 | 47 | return $this->ressource_construire; |
| 48 | 48 | } |
| 49 | - public function getInfoBatiment(){ |
|
| 49 | + public function getInfoBatiment() { |
|
| 50 | 50 | return $this->info_batiment; |
| 51 | 51 | } |
| 52 | - public function getInfoBatimentNext(){ |
|
| 52 | + public function getInfoBatimentNext() { |
|
| 53 | 53 | return $this->info_batiment_next; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if ((is_array($query)) && (count($query) > 0)) { |
| 82 | 82 | foreach ($query as $obj) { |
| 83 | 83 | if ($obj->construction == 1) { |
| 84 | - return $obj->niveau-1; |
|
| 84 | + return $obj->niveau - 1; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return $obj->niveau; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | if ($niveau > 0) { |
| 150 | 150 | $query = $dbc1->select("stockage")->from("entrepot")->where("ID_entrepot", "=", $niveau)->get(); |
| 151 | 151 | |
| 152 | - if ((is_array($query)) && (count($query) > 0)){ |
|
| 152 | + if ((is_array($query)) && (count($query) > 0)) { |
|
| 153 | 153 | foreach ($query as $obj) { |
| 154 | 154 | return $obj->stockage; |
| 155 | 155 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $this->niveau_batiment = $this->niveau_batiment + 1; |
| 191 | 191 | } |
| 192 | 192 | $niveau_batiment_base = $this->niveau_batiment; |
| 193 | - $max_level = $this->getInfoUpgradeBatiment(); |
|
| 193 | + $max_level = $this->getInfoUpgradeBatiment(); |
|
| 194 | 194 | } |
| 195 | 195 | else { |
| 196 | 196 | //on test voir si le bat est au niveau max et si il peut avoir un addon |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | $id_batiment = $obj->ID_batiment; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ($this->date_fin_construction-$today <= 0) { |
|
| 267 | + if ($this->date_fin_construction - $today <= 0) { |
|
| 268 | 268 | $this->setTerminerConstruction($id_batiment); |
| 269 | 269 | } |
| 270 | 270 | else { |
| 271 | 271 | Bataille::setValues([ |
| 272 | - "date_fin_construction" => $this->date_fin_construction-$today, |
|
| 272 | + "date_fin_construction" => $this->date_fin_construction - $today, |
|
| 273 | 273 | "nom_batiment_construction" => $this->nom_batiment_construction |
| 274 | 274 | ]); |
| 275 | 275 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | //et compare la liste des batiments qu'il faut pour construire le batiment |
| 319 | 319 | //a ceux qui sont deja construit dans la base |
| 320 | 320 | //si tous les batments qu'il faut son batis on autorise la construction du batiment |
| 321 | - for ($i=0 ; $i<$c_all_batiment ; $i++) { |
|
| 321 | + for ($i = 0; $i < $c_all_batiment; $i++) { |
|
| 322 | 322 | if (!in_array($all_batiment[$i], $batiment_construit)) { |
| 323 | 323 | $query = $dbc1->select("pour_construire") |
| 324 | 324 | ->select("temps_construction") |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | else if (count($pour_construire) > 1) { |
| 359 | 359 | $ok_construction = false; |
| 360 | 360 | //test si tous les batiments sont construits et on le niveau nécéssaire |
| 361 | - for ($j=0 ; $j<count($pour_construire) ; $j++) { |
|
| 361 | + for ($j = 0; $j < count($pour_construire); $j++) { |
|
| 362 | 362 | if (in_array($pour_construire[$j][1], $batiment_construit)) { |
| 363 | 363 | if ($pour_construire[$j][2] <= $this->getNiveauBatiment($pour_construire[$j][1])) { |
| 364 | 364 | $ok_construction = true; |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | private function getRessourceConstruireBatiment($nom_batiment_sql, $niveau) { |
| 403 | 403 | $dbc1 = Bataille::getDb(); |
| 404 | 404 | |
| 405 | - $niveau = $niveau+1; |
|
| 405 | + $niveau = $niveau + 1; |
|
| 406 | 406 | |
| 407 | 407 | $query = $dbc1->select("ressource_construire")->from($nom_batiment_sql)->where("ID_".$nom_batiment_sql, "=", $niveau)->get(); |
| 408 | 408 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | private function getTestBatimentConstruction($nom_batiment) { |
| 437 | 437 | if (ChaineCaractere::FindInString($nom_batiment, " en construction") == true) { |
| 438 | - return [substr($nom_batiment, 0, (0-strlen(" en construction"))), true]; |
|
| 438 | + return [substr($nom_batiment, 0, (0 - strlen(" en construction"))), true]; |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | return [$nom_batiment, false]; |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | $dbc1 = Bataille::getDb(); |
| 451 | 451 | |
| 452 | 452 | //récupération du temps et des ressources pour construire |
| 453 | - $query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)->get(); |
|
| 453 | + $query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)->get(); |
|
| 454 | 454 | |
| 455 | 455 | //si on a quelque chose cela veut dire qu'on est pas encore au lvl max du batiment |
| 456 | 456 | if ((is_array($query)) && (count($query) > 0)) { |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment) |
| 472 | 472 | ->get(); |
| 473 | 473 | |
| 474 | - if ((is_array($query)) && (count($query) > 0)){ |
|
| 474 | + if ((is_array($query)) && (count($query) > 0)) { |
|
| 475 | 475 | foreach ($query as $obj) { |
| 476 | 476 | $this->info_batiment = $xml->$nom_batiment_sql->phrase.$obj->$champ; |
| 477 | 477 | } |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | //récupération de la phrase pour le niveau suivant |
| 481 | 481 | $query = $dbc1->select($xml->$nom_batiment_sql->champ) |
| 482 | 482 | ->from($this->nom_batiment_sql) |
| 483 | - ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1) |
|
| 483 | + ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1) |
|
| 484 | 484 | ->get(); |
| 485 | 485 | |
| 486 | - if ((is_array($query)) && (count($query) > 0)){ |
|
| 486 | + if ((is_array($query)) && (count($query) > 0)) { |
|
| 487 | 487 | foreach ($query as $obj) { |
| 488 | 488 | $this->info_batiment_next = $xml->$nom_batiment_sql->phrase_suivant.$obj->$champ; |
| 489 | 489 | } |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | $query = $dbc1->select("ressource_construire") |
| 553 | 553 | ->select("temps_construction") |
| 554 | 554 | ->from($this->nom_batiment_sql) |
| 555 | - ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1) |
|
| 555 | + ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1) |
|
| 556 | 556 | ->get(); |
| 557 | 557 | |
| 558 | 558 | foreach ($query as $obj) { |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | //on insere la construction dans la table batiment si new batiment |
| 564 | 564 | if ($un_batiment == 0) { |
| 565 | - $dbc->insert("niveau", $this->niveau_batiment+1) |
|
| 565 | + $dbc->insert("niveau", $this->niveau_batiment + 1) |
|
| 566 | 566 | ->insert("emplacement", $emplacement) |
| 567 | 567 | ->insert("nom_batiment", $nom_batiment) |
| 568 | 568 | ->insert("nom_batiment_sql", $this->nom_batiment_sql) |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | $this->id_batiment = $dbc->lastInsertId(); |
| 575 | 575 | } |
| 576 | 576 | else { |
| 577 | - $dbc->update("niveau", $this->niveau_batiment+1) |
|
| 577 | + $dbc->update("niveau", $this->niveau_batiment + 1) |
|
| 578 | 578 | ->update("construction", 1) |
| 579 | 579 | ->from("_bataille_batiment") |
| 580 | 580 | ->where("ID_batiment", "=", $this->id_batiment, "AND") |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | $today = $today->getTimestamp(); |
| 590 | 590 | |
| 591 | 591 | //date de la fin de la construction en seconde |
| 592 | - $fin_construction = $today+$temps_construction; |
|
| 592 | + $fin_construction = $today + $temps_construction; |
|
| 593 | 593 | |
| 594 | 594 | $dbc->insert("date_fin", $fin_construction) |
| 595 | 595 | ->insert("emplacement_construction", $emplacement) |
@@ -86,8 +86,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |