@@ -24,7 +24,7 @@ |
||
| 24 | 24 | |
| 25 | 25 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 26 | 26 | public static function getValues() { |
| 27 | - return ["bataille" => self::$values]; |
|
| 27 | + return ["bataille" => self::$values]; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | //initilisation of all classes of battle |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public static function getTestAssezRessourceBase($nom_ressource, $ressource) { |
| 198 | 198 | $f = "get".ucfirst($nom_ressource); |
| 199 | 199 | |
| 200 | - if ($ressource > Bataille::getRessource()->$f()) { |
|
| 200 | + if ($ressource > Bataille::getRessource()->$f()) { |
|
| 201 | 201 | /*echo("$nom_ressource $ressource ".Bataille::getRessource()->getEau()." ---");*/ |
| 202 | 202 | return [ |
| 203 | 203 | "ressource" => $ressource, |
@@ -224,10 +224,10 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | //calcul des distances séparant les deux bases en x et y |
| 226 | 226 | //cette dstance sera multipliée par 15 sur x et y puis ajoutée pour avoir le temps du trajte en seconde |
| 227 | - $calc_x = abs($base_joueur['posx']-$base_autre['posx']); |
|
| 228 | - $calc_y = abs($base_joueur['posy']-$base_autre['posy']); |
|
| 227 | + $calc_x = abs($base_joueur['posx'] - $base_autre['posx']); |
|
| 228 | + $calc_y = abs($base_joueur['posy'] - $base_autre['posy']); |
|
| 229 | 229 | |
| 230 | - $temps_voyage = (($calc_x*70)+($calc_y*70))/$vitesse; |
|
| 230 | + $temps_voyage = (($calc_x * 70) + ($calc_y * 70)) / $vitesse; |
|
| 231 | 231 | |
| 232 | 232 | return $temps_voyage; |
| 233 | 233 | } |
@@ -124,7 +124,9 @@ discard block |
||
| 124 | 124 | ->get(); |
| 125 | 125 | |
| 126 | 126 | if ((is_array($query)) && (count($query) == 1)) { |
| 127 | - foreach ($query as $obj) return $obj->ID_base; |
|
| 127 | + foreach ($query as $obj) { |
|
| 128 | + return $obj->ID_base; |
|
| 129 | + } |
|
| 128 | 130 | } |
| 129 | 131 | } |
| 130 | 132 | |
@@ -169,8 +171,7 @@ discard block |
||
| 169 | 171 | |
| 170 | 172 | if ($id_base === null) { |
| 171 | 173 | $query = $dbc->select()->from("_bataille_last_connexion")->where("ID_identite", "=", self::getIdIdentite())->get(); |
| 172 | - } |
|
| 173 | - else { |
|
| 174 | + } else { |
|
| 174 | 175 | $query = $dbc->select("_bataille_last_connexion.last_connexion")->from("_bataille_base") |
| 175 | 176 | ->from("_bataille_last_connexion") |
| 176 | 177 | ->from("identite") |
@@ -272,7 +273,9 @@ discard block |
||
| 272 | 273 | ->get(); |
| 273 | 274 | |
| 274 | 275 | if ((is_array($query)) && (count($query) == 1)) { |
| 275 | - foreach ($query as $obj) return $obj->ID_base; |
|
| 276 | + foreach ($query as $obj) { |
|
| 277 | + return $obj->ID_base; |
|
| 278 | + } |
|
| 276 | 279 | } |
| 277 | 280 | |
| 278 | 281 | return 0; |
@@ -288,7 +291,9 @@ discard block |
||
| 288 | 291 | $query = $dbc->select("nombre_joueur")->from("_bataille_nombre_joueur")->where("ID_nombre_joueur", "=", 1)->get(); |
| 289 | 292 | |
| 290 | 293 | if ((is_array($query)) && (count($query) == 1)) { |
| 291 | - foreach ($query as $obj) return $obj->nombre_joueur; |
|
| 294 | + foreach ($query as $obj) { |
|
| 295 | + return $obj->nombre_joueur; |
|
| 296 | + } |
|
| 292 | 297 | } |
| 293 | 298 | |
| 294 | 299 | return 0; |
@@ -306,7 +311,9 @@ discard block |
||
| 306 | 311 | $query = $dbc->select($param)->from("configuration")->where("ID_configuration", "=", 1)->get(); |
| 307 | 312 | |
| 308 | 313 | if ((is_array($query)) && (count($query) == 1)) { |
| 309 | - foreach ($query as $obj) return $obj->$param; |
|
| 314 | + foreach ($query as $obj) { |
|
| 315 | + return $obj->$param; |
|
| 316 | + } |
|
| 310 | 317 | } |
| 311 | 318 | } |
| 312 | 319 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
@@ -322,11 +329,12 @@ discard block |
||
| 322 | 329 | |
| 323 | 330 | if ($id_base === null) { |
| 324 | 331 | $id_identite = self::getIdIdentite(); |
| 325 | - } |
|
| 326 | - else { |
|
| 332 | + } else { |
|
| 327 | 333 | $query = $dbc->select("ID_identite")->from("_bataille_base")->where("ID_base", "=", $id_base)->get(); |
| 328 | 334 | |
| 329 | - foreach ($query as $obj) $id_identite = $obj->ID_identite; |
|
| 335 | + foreach ($query as $obj) { |
|
| 336 | + $id_identite = $obj->ID_identite; |
|
| 337 | + } |
|
| 330 | 338 | } |
| 331 | 339 | |
| 332 | 340 | $dbc->update("last_connexion", date("Y-m-d H:i:s")) |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * @param null $id_base -> sert si definit a recuperer l'id identite de la abse en question |
| 164 | - * @return mixed |
|
| 164 | + * @return string|null |
|
| 165 | 165 | * recupere la date de la derniere connexion |
| 166 | 166 | */ |
| 167 | 167 | public static function getLastConnexion($id_base = null) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * @param $nom_ressource |
|
| 191 | + * @param string $nom_ressource |
|
| 192 | 192 | * @param $ressource |
| 193 | 193 | * @return array |
| 194 | 194 | * fonction qui permet de renvyer la couleur rouge si pas assez de ressource pour construire le batiment |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | 215 | * @param $id_base |
| 216 | - * @param null $vitesse = vitesse de l'unité en question |
|
| 216 | + * @param integer $vitesse = vitesse de l'unité en question |
|
| 217 | 217 | * @return number |
| 218 | 218 | * fonction qui renvoi le temps de trajet entre la base du joueur et une autre base en secondes |
| 219 | 219 | */ |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | - * @param $param |
|
| 299 | - * @return mixed |
|
| 298 | + * @param string $param |
|
| 299 | + * @return integer |
|
| 300 | 300 | * fonction qui sert à récupérer un parametre spécifique pour un batiment |
| 301 | 301 | * par exemple la vitesse d'un marchand ou le nombred'emplacment de la base |
| 302 | 302 | */ |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 17 | 17 | public function getBatiments(){ |
| 18 | - return $this->batiments; |
|
| 18 | + return $this->batiments; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
| 17 | - public function getBatiments(){ |
|
| 17 | + public function getBatiments() { |
|
| 18 | 18 | return $this->batiments; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | return $this->ressource_construire; |
| 47 | 47 | } |
| 48 | 48 | public function getInfoBatiment(){ |
| 49 | - return $this->info_batiment; |
|
| 49 | + return $this->info_batiment; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function getNomBatimentConstruction() { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | use core\App; |
| 4 | 4 | use core\functions\ChaineCaractere; |
| 5 | 5 | use core\HTML\flashmessage\FlashMessage; |
| 6 | - use Nette\Utils\DateTime; |
|
| 7 | 6 | |
| 8 | 7 | class Batiment { |
| 9 | 8 | //pour quand on recup un batiment |
@@ -91,8 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | return $obj->niveau; |
| 93 | 93 | } |
| 94 | - } |
|
| 95 | - else { |
|
| 94 | + } else { |
|
| 96 | 95 | return 0; |
| 97 | 96 | } |
| 98 | 97 | } |
@@ -109,10 +108,18 @@ discard block |
||
| 109 | 108 | $id_base = Bataille::getIdBase(); |
| 110 | 109 | } |
| 111 | 110 | |
| 112 | - if ($ressource == "eau") $nom_batiment = "centrale_eau"; |
|
| 113 | - if ($ressource == "electricite") $nom_batiment = "centrale_electrique"; |
|
| 114 | - if ($ressource == "fuel") $nom_batiment = "station_pompage_fuel"; |
|
| 115 | - if ($ressource == "fer") $nom_batiment = "station_forage"; |
|
| 111 | + if ($ressource == "eau") { |
|
| 112 | + $nom_batiment = "centrale_eau"; |
|
| 113 | + } |
|
| 114 | + if ($ressource == "electricite") { |
|
| 115 | + $nom_batiment = "centrale_electrique"; |
|
| 116 | + } |
|
| 117 | + if ($ressource == "fuel") { |
|
| 118 | + $nom_batiment = "station_pompage_fuel"; |
|
| 119 | + } |
|
| 120 | + if ($ressource == "fer") { |
|
| 121 | + $nom_batiment = "station_forage"; |
|
| 122 | + } |
|
| 116 | 123 | |
| 117 | 124 | $niveau = $this->getNiveauBatiment($nom_batiment, $id_base); |
| 118 | 125 | |
@@ -126,8 +133,7 @@ discard block |
||
| 126 | 133 | |
| 127 | 134 | return $prod; |
| 128 | 135 | } |
| 129 | - } |
|
| 130 | - else { |
|
| 136 | + } else { |
|
| 131 | 137 | return 20; |
| 132 | 138 | } |
| 133 | 139 | } |
@@ -153,8 +159,7 @@ discard block |
||
| 153 | 159 | return $obj->stockage; |
| 154 | 160 | } |
| 155 | 161 | } |
| 156 | - } |
|
| 157 | - else { |
|
| 162 | + } else { |
|
| 158 | 163 | return 1000; |
| 159 | 164 | } |
| 160 | 165 | } |
@@ -190,8 +195,7 @@ discard block |
||
| 190 | 195 | } |
| 191 | 196 | $niveau_batiment_base = $this->niveau_batiment; |
| 192 | 197 | $max_level = $this->getInfoUpgradeBatiment(); |
| 193 | - } |
|
| 194 | - else { |
|
| 198 | + } else { |
|
| 195 | 199 | $max_level = 0; |
| 196 | 200 | } |
| 197 | 201 | |
@@ -244,8 +248,7 @@ discard block |
||
| 244 | 248 | |
| 245 | 249 | if ($this->date_fin_construction-$today <= 0) { |
| 246 | 250 | $this->setTerminerConstruction($id_batiment); |
| 247 | - } |
|
| 248 | - else { |
|
| 251 | + } else { |
|
| 249 | 252 | Bataille::setValues([ |
| 250 | 253 | "date_fin_construction" => $this->date_fin_construction-$today, |
| 251 | 254 | "nom_batiment_construction" => $this->nom_batiment_construction |
@@ -308,8 +311,7 @@ discard block |
||
| 308 | 311 | foreach ($query as $obj) { |
| 309 | 312 | if ($obj->pour_construire != null) { |
| 310 | 313 | $pour_construire = unserialize($obj->pour_construire); |
| 311 | - } |
|
| 312 | - else { |
|
| 314 | + } else { |
|
| 313 | 315 | $pour_construire = []; |
| 314 | 316 | } |
| 315 | 317 | |
@@ -332,21 +334,18 @@ discard block |
||
| 332 | 334 | ]; |
| 333 | 335 | } |
| 334 | 336 | } |
| 335 | - } |
|
| 336 | - else if (count($pour_construire) > 1) { |
|
| 337 | + } else if (count($pour_construire) > 1) { |
|
| 337 | 338 | $ok_construction = false; |
| 338 | 339 | //test si tous les batiments sont construits et on le niveau nécéssaire |
| 339 | 340 | for ($j=0 ; $j<count($pour_construire) ; $j++) { |
| 340 | 341 | if (in_array($pour_construire[$j][1], $batiment_construit)) { |
| 341 | 342 | if ($pour_construire[$j][2] <= $this->getNiveauBatiment($pour_construire[$j][1])) { |
| 342 | 343 | $ok_construction = true; |
| 343 | - } |
|
| 344 | - else { |
|
| 344 | + } else { |
|
| 345 | 345 | $ok_construction = false; |
| 346 | 346 | break; |
| 347 | 347 | } |
| 348 | - } |
|
| 349 | - else { |
|
| 348 | + } else { |
|
| 350 | 349 | $ok_construction = false; |
| 351 | 350 | break; |
| 352 | 351 | } |
@@ -363,8 +362,7 @@ discard block |
||
| 363 | 362 | "temps_construction" => $temps_construction |
| 364 | 363 | ]; |
| 365 | 364 | } |
| 366 | - } |
|
| 367 | - else { |
|
| 365 | + } else { |
|
| 368 | 366 | $ressource = $this->getRessourceConstruireBatiment($all_batiment[$i], 0); |
| 369 | 367 | |
| 370 | 368 | $batiment_construire[] = [ |
@@ -473,8 +471,7 @@ discard block |
||
| 473 | 471 | $this->info_batiment_next = $xml->$nom_batiment_sql->phrase_suivant.$obj->$champ; |
| 474 | 472 | } |
| 475 | 473 | } |
| 476 | - } |
|
| 477 | - else { |
|
| 474 | + } else { |
|
| 478 | 475 | $this->info_batiment = ""; |
| 479 | 476 | $this->info_batiment_next = ""; |
| 480 | 477 | } |
@@ -519,8 +516,7 @@ discard block |
||
| 519 | 516 | $ressource = $this->getRessourceConstruireBatiment($nom_batiment_sql, 0); |
| 520 | 517 | $this->nom_batiment_sql = $nom_batiment_sql; |
| 521 | 518 | $this->niveau_batiment = 0; |
| 522 | - } |
|
| 523 | - else { |
|
| 519 | + } else { |
|
| 524 | 520 | //si c'est le lvl 0 de l'addon |
| 525 | 521 | if ($this->niveau_batiment == 0) { |
| 526 | 522 | $un_batiment = 0; |
@@ -531,8 +527,7 @@ discard block |
||
| 531 | 527 | //si pas assez de ressource |
| 532 | 528 | if (in_array("rouge", $ressource[0])) { |
| 533 | 529 | FlashMessage::setFlash("Pas assez de ressources pour construire ce batiment"); |
| 534 | - } |
|
| 535 | - else { |
|
| 530 | + } else { |
|
| 536 | 531 | //recuperation du temps de construction |
| 537 | 532 | $query = $dbc1->select("ressource_construire") |
| 538 | 533 | ->select("temps_construction") |
@@ -557,8 +552,7 @@ discard block |
||
| 557 | 552 | ->set(); |
| 558 | 553 | |
| 559 | 554 | $this->id_batiment = $dbc->lastInsertId(); |
| 560 | - } |
|
| 561 | - else { |
|
| 555 | + } else { |
|
| 562 | 556 | $dbc->update("niveau", $this->niveau_batiment+1) |
| 563 | 557 | ->update("construction", 1) |
| 564 | 558 | ->from("_bataille_batiment") |
@@ -585,8 +579,7 @@ discard block |
||
| 585 | 579 | //on retire les ressources de la base |
| 586 | 580 | Bataille::getRessource()->setUpdateRessource($ressource_construction[2], $ressource_construction[3], $ressource_construction[0], $ressource_construction[1], 0, "-"); |
| 587 | 581 | } |
| 588 | - } |
|
| 589 | - else { |
|
| 582 | + } else { |
|
| 590 | 583 | FlashMessage::setFlash("Un batiment est déjà en construction, vous ne pouvez pas en construire un autre !"); |
| 591 | 584 | } |
| 592 | 585 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * @param $case_depart |
| 401 | 401 | * @param $nom_batiment |
| 402 | 402 | * @param $nom_batiment_sql |
| 403 | - * @return bool |
|
| 403 | + * @return false|null |
|
| 404 | 404 | * fonction qui test si un il y a la place de construire un batiment en fonction de sa case ou il a été laché en x et y |
| 405 | 405 | * et en fonction de sa taille et du positionnement des autres batiments |
| 406 | 406 | */ |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | /** |
| 484 | 484 | * @param $nom_batiment_sql |
| 485 | - * @param $niveau |
|
| 485 | + * @param integer $niveau |
|
| 486 | 486 | * @return array |
| 487 | 487 | * recuperation des ressources nécéssaire pour construire le batiment |
| 488 | 488 | */ |
@@ -47,10 +47,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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") |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $pour_construire = []; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $temps_construction = gmdate("H:i:s", round($obj->temps_construction-($obj->temps_construction*Bataille::getBatiment()->getNiveauBatiment("centre_commandement")/100))); |
|
| 326 | + $temps_construction = gmdate("H:i:s", round($obj->temps_construction - ($obj->temps_construction * Bataille::getBatiment()->getNiveauBatiment("centre_commandement") / 100))); |
|
| 327 | 327 | $taille_batiment = $this->getTailleBatiment($all_batiment[$i]); |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | else if (count($pour_construire) > 1) { |
| 349 | 349 | $ok_construction = false; |
| 350 | 350 | //test si tous les batiments sont construits et on le niveau nécéssaire |
| 351 | - for ($j=0 ; $j<count($pour_construire) ; $j++) { |
|
| 351 | + for ($j = 0; $j < count($pour_construire); $j++) { |
|
| 352 | 352 | if (in_array($pour_construire[$j][1], $batiment_construit)) { |
| 353 | 353 | if ($pour_construire[$j][2] <= $this->getNiveauBatiment($pour_construire[$j][1])) { |
| 354 | 354 | $ok_construction = true; |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | $case_depart = explode(",", $case_depart); |
| 416 | 416 | $posx = $case_depart[0]; |
| 417 | 417 | $posy = $case_depart[1]; |
| 418 | - $finx = $width_batiment+$posx; |
|
| 419 | - $finy = $height_batiment+$posy; |
|
| 418 | + $finx = $width_batiment + $posx; |
|
| 419 | + $finy = $height_batiment + $posy; |
|
| 420 | 420 | |
| 421 | 421 | //récupération de tous les batiments |
| 422 | 422 | $query = $dbc->select("posx") |
@@ -432,11 +432,11 @@ discard block |
||
| 432 | 432 | $posx_batiment = $obj->posx; |
| 433 | 433 | $posy_batiment = $obj->posy; |
| 434 | 434 | |
| 435 | - $finx_batiment = $taille_batiment[0]+$posx_batiment; |
|
| 436 | - $finy_batiment = $taille_batiment[1]+$posy_batiment; |
|
| 435 | + $finx_batiment = $taille_batiment[0] + $posx_batiment; |
|
| 436 | + $finy_batiment = $taille_batiment[1] + $posy_batiment; |
|
| 437 | 437 | |
| 438 | - for ($i=$posy ; $i<$finy ; $i++) { |
|
| 439 | - for ($j=$posx ; $j<$finx ; $j++) { |
|
| 438 | + for ($i = $posy; $i < $finy; $i++) { |
|
| 439 | + for ($j = $posx; $j < $finx; $j++) { |
|
| 440 | 440 | if ((($posx++ >= $posx_batiment) && ($posx++ <= $finx_batiment)) && (($posy++ >= $posy_batiment) && ($posy++ <= $finy_batiment))) { |
| 441 | 441 | FlashMessage::setFlash("Un batiment est déjà présent à cet emplacement, merci d'en choisir un autre"); |
| 442 | 442 | return false; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | private function getRessourceConstruireBatiment($nom_batiment_sql, $niveau) { |
| 489 | 489 | $dbc1 = Bataille::getDb(); |
| 490 | 490 | |
| 491 | - $niveau = $niveau+1; |
|
| 491 | + $niveau = $niveau + 1; |
|
| 492 | 492 | |
| 493 | 493 | $query = $dbc1->select("ressource_construire")->from($nom_batiment_sql)->where("ID_".$nom_batiment_sql, "=", $niveau)->get(); |
| 494 | 494 | |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | */ |
| 522 | 522 | private function getTestBatimentConstruction($nom_batiment) { |
| 523 | 523 | if (ChaineCaractere::FindInString($nom_batiment, " en construction") == true) { |
| 524 | - return [substr($nom_batiment, 0, (0-strlen(" en construction"))), true]; |
|
| 524 | + return [substr($nom_batiment, 0, (0 - strlen(" en construction"))), true]; |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | return [$nom_batiment, false]; |
@@ -535,13 +535,13 @@ discard block |
||
| 535 | 535 | $dbc1 = Bataille::getDb(); |
| 536 | 536 | |
| 537 | 537 | //récupération du temps et des ressources pour construire |
| 538 | - $query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1)->get(); |
|
| 538 | + $query = $dbc1->select()->from($this->nom_batiment_sql)->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1)->get(); |
|
| 539 | 539 | |
| 540 | 540 | //si on a quelque chose cela veut dire qu'on est pas encore au lvl max du batiment |
| 541 | 541 | if ((is_array($query)) && (count($query) > 0)) { |
| 542 | 542 | foreach ($query as $obj) { |
| 543 | 543 | $this->ressource_construire = $this->getRessourceConstruireBatiment($this->nom_batiment_sql, $this->niveau_batiment); |
| 544 | - $this->temps_construction = DateHeure::Secondeenheure(round($obj->temps_construction-($obj->temps_construction*Bataille::getBatiment()->getNiveauBatiment("centre_commandement")/100))); |
|
| 544 | + $this->temps_construction = DateHeure::Secondeenheure(round($obj->temps_construction - ($obj->temps_construction * Bataille::getBatiment()->getNiveauBatiment("centre_commandement") / 100))); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | //récupération des éléments particulier à un batiment |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment) |
| 557 | 557 | ->get(); |
| 558 | 558 | |
| 559 | - if ((is_array($query)) && (count($query) > 0)){ |
|
| 559 | + if ((is_array($query)) && (count($query) > 0)) { |
|
| 560 | 560 | foreach ($query as $obj) { |
| 561 | 561 | $this->info_batiment = $xml->$nom_batiment_sql->phrase.$obj->$champ.$xml->$nom_batiment_sql->complement; |
| 562 | 562 | } |
@@ -565,10 +565,10 @@ discard block |
||
| 565 | 565 | //récupération de la phrase pour le niveau suivant |
| 566 | 566 | $query = $dbc1->select($xml->$nom_batiment_sql->champ) |
| 567 | 567 | ->from($this->nom_batiment_sql) |
| 568 | - ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1) |
|
| 568 | + ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1) |
|
| 569 | 569 | ->get(); |
| 570 | 570 | |
| 571 | - if ((is_array($query)) && (count($query) > 0)){ |
|
| 571 | + if ((is_array($query)) && (count($query) > 0)) { |
|
| 572 | 572 | foreach ($query as $obj) { |
| 573 | 573 | $this->info_batiment_next = $xml->$nom_batiment_sql->phrase_suivant.$obj->$champ.$xml->$nom_batiment_sql->complement; |
| 574 | 574 | } |
@@ -629,17 +629,17 @@ discard block |
||
| 629 | 629 | $query = $dbc1->select("ressource_construire") |
| 630 | 630 | ->select("temps_construction") |
| 631 | 631 | ->from($this->nom_batiment_sql) |
| 632 | - ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment+1) |
|
| 632 | + ->where("ID_".$this->nom_batiment_sql, "=", $this->niveau_batiment + 1) |
|
| 633 | 633 | ->get(); |
| 634 | 634 | |
| 635 | 635 | foreach ($query as $obj) { |
| 636 | - $temps_construction = round($obj->temps_construction-($obj->temps_construction*Bataille::getBatiment()->getNiveauBatiment("centre_commandement")/100)); |
|
| 636 | + $temps_construction = round($obj->temps_construction - ($obj->temps_construction * Bataille::getBatiment()->getNiveauBatiment("centre_commandement") / 100)); |
|
| 637 | 637 | $ressource_construction = explode(", ", $obj->ressource_construire); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | //on insere la construction dans la table batiment si new batiment |
| 641 | 641 | if ($un_batiment == 0) { |
| 642 | - $dbc->insert("niveau", $this->niveau_batiment+1) |
|
| 642 | + $dbc->insert("niveau", $this->niveau_batiment + 1) |
|
| 643 | 643 | ->insert("nom_batiment", $nom_batiment) |
| 644 | 644 | ->insert("nom_batiment_sql", $this->nom_batiment_sql) |
| 645 | 645 | ->insert("posx", intval($posx)) |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | $this->id_batiment = $dbc->lastInsertId(); |
| 653 | 653 | } |
| 654 | 654 | else { |
| 655 | - $dbc->update("niveau", $this->niveau_batiment+1) |
|
| 655 | + $dbc->update("niveau", $this->niveau_batiment + 1) |
|
| 656 | 656 | ->update("construction", 1) |
| 657 | 657 | ->from("_bataille_batiment") |
| 658 | 658 | ->where("ID_batiment", "=", $this->id_batiment, "AND") |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | $today = Bataille::getToday(); |
| 667 | 667 | |
| 668 | 668 | //date de la fin de la construction en seconde |
| 669 | - $fin_construction = $today+$temps_construction; |
|
| 669 | + $fin_construction = $today + $temps_construction; |
|
| 670 | 670 | |
| 671 | 671 | $dbc->insert("date_fin", $fin_construction) |
| 672 | 672 | ->insert("ID_base", Bataille::getIdBase()) |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | return $this->message; |
| 77 | 77 | } |
| 78 | 78 | public function getDateMessage(){ |
| 79 | - return $this->date_message; |
|
| 79 | + return $this->date_message; |
|
| 80 | 80 | } |
| 81 | 81 | public function getUrl(){ |
| 82 | - return $this->url; |
|
| 82 | + return $this->url; |
|
| 83 | 83 | } |
| 84 | 84 | public function getIdExpediteur() { |
| 85 | 85 | return $this->id_expediteur; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $this->pseudo_receveur; |
| 95 | 95 | } |
| 96 | 96 | public function getValues(){ |
| 97 | - return ["messagerie" => $this->values]; |
|
| 97 | + return ["messagerie" => $this->values]; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | public function getMessage() { |
| 77 | 77 | return $this->message; |
| 78 | 78 | } |
| 79 | - public function getDateMessage(){ |
|
| 79 | + public function getDateMessage() { |
|
| 80 | 80 | return $this->date_message; |
| 81 | 81 | } |
| 82 | - public function getUrl(){ |
|
| 82 | + public function getUrl() { |
|
| 83 | 83 | return $this->url; |
| 84 | 84 | } |
| 85 | 85 | public function getIdExpediteur() { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | public function getPseudoReceveur() { |
| 95 | 95 | return $this->pseudo_receveur; |
| 96 | 96 | } |
| 97 | - public function getValues(){ |
|
| 97 | + public function getValues() { |
|
| 98 | 98 | return ["messagerie" => $this->values]; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | $destinataires = explode(",", $destinataire); |
| 292 | 292 | $c = count($destinataires); |
| 293 | 293 | |
| 294 | - for ($i=0 ; $i<$c ; $i++) { |
|
| 294 | + for ($i = 0; $i < $c; $i++) { |
|
| 295 | 295 | if ($this->getIdIdentiteExist($destinataires[$i]) !== false) { |
| 296 | 296 | $destinataires[] = $this->getIdIdentiteExist($destinataires[$i]); |
| 297 | 297 | } |
@@ -33,11 +33,9 @@ discard block |
||
| 33 | 33 | if ($type_boite !== null) { |
| 34 | 34 | if ($type_boite == "boite réception") { |
| 35 | 35 | $this->getBoiteReception(); |
| 36 | - } |
|
| 37 | - else if ($type_boite == "messages envoyés") { |
|
| 36 | + } else if ($type_boite == "messages envoyés") { |
|
| 38 | 37 | $this->getMessagesEnvoyes(); |
| 39 | - } |
|
| 40 | - else if ($type_boite == "messages supprimés") { |
|
| 38 | + } else if ($type_boite == "messages supprimés") { |
|
| 41 | 39 | $this->getMessageSupprimes(); |
| 42 | 40 | } |
| 43 | 41 | |
@@ -240,8 +238,7 @@ discard block |
||
| 240 | 238 | "supprimer" => $obj->supprimer |
| 241 | 239 | ]; |
| 242 | 240 | } |
| 243 | - } |
|
| 244 | - else { |
|
| 241 | + } else { |
|
| 245 | 242 | return false; |
| 246 | 243 | } |
| 247 | 244 | } |
@@ -294,17 +291,14 @@ discard block |
||
| 294 | 291 | for ($i=0 ; $i<$c ; $i++) { |
| 295 | 292 | if ($this->getIdIdentiteExist($destinataires[$i]) !== false) { |
| 296 | 293 | $destinataires[] = $this->getIdIdentiteExist($destinataires[$i]); |
| 297 | - } |
|
| 298 | - else { |
|
| 294 | + } else { |
|
| 299 | 295 | return false; |
| 300 | 296 | } |
| 301 | 297 | } |
| 302 | - } |
|
| 303 | - else { |
|
| 298 | + } else { |
|
| 304 | 299 | if ($this->getIdIdentiteExist($destinataire) !== false) { |
| 305 | 300 | $destinataires[] = $this->getIdIdentiteExist($destinataire); |
| 306 | - } |
|
| 307 | - else { |
|
| 301 | + } else { |
|
| 308 | 302 | return false; |
| 309 | 303 | } |
| 310 | 304 | } |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | if (isset($_GET['page'])) { |
| 36 | 36 | $titre_page = "Administration du site"; |
| 37 | 37 | $description_page = "Administration du site"; |
| 38 | - } |
|
| 39 | - else { |
|
| 38 | + } else { |
|
| 40 | 39 | $titre_page = "Administration du site"; |
| 41 | 40 | $description_page = "Administration du site"; |
| 42 | 41 | } |
@@ -66,25 +65,21 @@ discard block |
||
| 66 | 65 | //si c'est un controleur de base on va cerhcer dans core/admin |
| 67 | 66 | if ($core !== false) { |
| 68 | 67 | require_once(ROOT.$lien.".php"); |
| 69 | - } |
|
| 70 | - else if ($module !== false) { |
|
| 68 | + } else if ($module !== false) { |
|
| 71 | 69 | $explode = explode("/", $lien, 3); |
| 72 | 70 | |
| 73 | 71 | require_once(ROOT.$explode[0]."/".$explode[1]."/admin/controller/".$explode[2].".php"); |
| 74 | - } |
|
| 75 | - else { |
|
| 72 | + } else { |
|
| 76 | 73 | require_once("admin/controller/".$lien.".php"); |
| 77 | 74 | } |
| 78 | 75 | } |
| 79 | 76 | //pour la page de login |
| 80 | 77 | else if ($page == "login") { |
| 81 | 78 | require("admin/views/template/login_admin.php"); |
| 82 | - } |
|
| 83 | - else { |
|
| 79 | + } else { |
|
| 84 | 80 | if (!isset($_SESSION["idlogin".CLEF_SITE])) { |
| 85 | 81 | Connexion::setObgConnecte(WEBROOT."administrator/login"); |
| 86 | - } |
|
| 87 | - else { |
|
| 82 | + } else { |
|
| 88 | 83 | if (\core\functions\ChaineCaractere::FindInString($page, "modules/") == true) { |
| 89 | 84 | //utilisé pour initialiser les modules |
| 90 | 85 | $page_module = $page; |
@@ -99,8 +94,7 @@ discard block |
||
| 99 | 94 | if (($droit_acces->getDroitAccesPage("gestion-comptes/index") == false) && ($page == "gestion-comptes")) { |
| 100 | 95 | FlashMessage::setFlash("L'accès à cette page n'est pas activé, veuillez contacter votre administrateur pour y avoir accès"); |
| 101 | 96 | header("location:".WEBROOT."administrator"); |
| 102 | - } |
|
| 103 | - else if (($droit_acces->getDroitAccesPage("gestion-droits-acces/index") == false) && ($page == "gestion-droits-acces")) { |
|
| 97 | + } else if (($droit_acces->getDroitAccesPage("gestion-droits-acces/index") == false) && ($page == "gestion-droits-acces")) { |
|
| 104 | 98 | FlashMessage::setFlash("L'accès à cette page n'est pas activé, veuillez contacter votre administrateur pour y avoir accès"); |
| 105 | 99 | header("location:".WEBROOT."administrator"); |
| 106 | 100 | } |
@@ -108,8 +102,7 @@ discard block |
||
| 108 | 102 | if (($droit_acces->getDroitAccesPage($page) == false) && (!isset($page_module))) { |
| 109 | 103 | FlashMessage::setFlash("Vous n'avez pas les droits pour accéder à cette page, contacter votre gérant pour y avoir accès"); |
| 110 | 104 | header("location:".WEBROOT."administrator"); |
| 111 | - } |
|
| 112 | - else { |
|
| 105 | + } else { |
|
| 113 | 106 | $cache = new \core\Cache($page, 1); |
| 114 | 107 | $admin = new Admin($_SESSION["idlogin".CLEF_SITE]); |
| 115 | 108 | |
@@ -121,14 +114,12 @@ discard block |
||
| 121 | 114 | } |
| 122 | 115 | } |
| 123 | 116 | } |
| 124 | - } |
|
| 125 | - else { |
|
| 117 | + } else { |
|
| 126 | 118 | Connexion::setObgConnecte(WEBROOT."administrator/login"); |
| 127 | 119 | |
| 128 | 120 | if (!isset($_SESSION["idlogin".CLEF_SITE])) { |
| 129 | 121 | Connexion::setObgConnecte(WEBROOT."administrator/login"); |
| 130 | - } |
|
| 131 | - else { |
|
| 122 | + } else { |
|
| 132 | 123 | $page = "index"; |
| 133 | 124 | $admin = new Admin($_SESSION["idlogin".CLEF_SITE]); |
| 134 | 125 | require(ROOT."admin/controller/initialise_all.php"); |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | if ((isset($_GET['page'])) && ($_GET['page'] != null)) { |
| 36 | 36 | $page = $_GET['page']; |
| 37 | 37 | $contenu->getHeadPage(0, $page); |
| 38 | - } |
|
| 39 | - else { |
|
| 38 | + } else { |
|
| 40 | 39 | $contenu->getHeadPage(1); |
| 41 | 40 | } |
| 42 | 41 | |
@@ -70,17 +69,14 @@ discard block |
||
| 70 | 69 | //si c'est un controleur de base on va cerhcer dans core/admin |
| 71 | 70 | if ($core !== false) { |
| 72 | 71 | require_once(ROOT.$lien.".php"); |
| 73 | - } |
|
| 74 | - else if ($module !== false) { |
|
| 72 | + } else if ($module !== false) { |
|
| 75 | 73 | $explode = explode("/", $lien, 3); |
| 76 | 74 | |
| 77 | 75 | require_once(ROOT.$explode[0]."/".$explode[1]."/app/controller/".$explode[2].".php"); |
| 78 | - } |
|
| 79 | - else { |
|
| 76 | + } else { |
|
| 80 | 77 | require_once("app/controller/".$lien.".php"); |
| 81 | 78 | } |
| 82 | - } |
|
| 83 | - else { |
|
| 79 | + } else { |
|
| 84 | 80 | $cache = new \core\Cache($page); |
| 85 | 81 | |
| 86 | 82 | $router_module = new RouterModule(); |
@@ -98,8 +94,7 @@ discard block |
||
| 98 | 94 | echo("<pre>"); |
| 99 | 95 | print_r($arr); |
| 100 | 96 | echo("</pre>"); |
| 101 | - } |
|
| 102 | - else { |
|
| 97 | + } else { |
|
| 103 | 98 | $contenu->getContenuPage(); |
| 104 | 99 | $contenu_page = $contenu->getContenu(); |
| 105 | 100 | |
@@ -122,8 +117,7 @@ discard block |
||
| 122 | 117 | } |
| 123 | 118 | $cache->setEnd(); |
| 124 | 119 | } |
| 125 | - } |
|
| 126 | - else { |
|
| 120 | + } else { |
|
| 127 | 121 | $contenu->getContenuPage(); |
| 128 | 122 | $contenu_page = $contenu->getContenu(); |
| 129 | 123 | |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | if (isset($_POST['admin'])) { |
| 6 | 6 | \core\auth\Connexion::setLogin($pseudo, $mdp, WEBROOT."administrator/login", WEBROOT."administrator", 0); |
| 7 | - } |
|
| 8 | - else { |
|
| 7 | + } else { |
|
| 9 | 8 | \core\auth\Connexion::setLogin($pseudo, $mdp, WEBROOT."login", WEBROOT."index.php", 0); |
| 10 | 9 | } |
| 11 | 10 | \ No newline at end of file |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | if (isset($_POST['admin'])) { |
| 6 | 6 | \core\auth\Connexion::setLogin($pseudo, $mdp, WEBROOT."administrator/login", WEBROOT."administrator", 0); |
| 7 | - } |
|
| 8 | - else { |
|
| 7 | + } else { |
|
| 9 | 8 | \core\auth\Connexion::setLogin($pseudo, $mdp, WEBROOT."login", WEBROOT."index.php", 0); |
| 10 | 9 | } |
| 11 | 10 | \ No newline at end of file |
@@ -7,8 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | if ($validator->getErrors() !== null) { |
| 9 | 9 | \core\HTML\flashmessage\FlashMessage::setFlash($validator->getErrors()); |
| 10 | - } |
|
| 11 | - else { |
|
| 10 | + } else { |
|
| 12 | 11 | $type = $_POST["type"]; |
| 13 | 12 | $objet = $_POST['objet']." de la part de ".$_SERVER['HTTP_HOST']; |
| 14 | 13 | $demande = $_POST['demande']; |