@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | |
16 | 16 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
17 | - public function getBatiments(){ |
|
17 | + public function getBatiments() { |
|
18 | 18 | return $this->batiments; |
19 | 19 | } |
20 | 20 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | $nombre_emplacement = Bataille::getNombreEmplacementBase(); |
68 | 68 | |
69 | - for ($i=1 ; $i<($nombre_emplacement+1) ; $i++) { |
|
69 | + for ($i = 1; $i < ($nombre_emplacement + 1); $i++) { |
|
70 | 70 | $query = $dbc->select()->from("_bataille_batiment")->where("ID_base", "=", Bataille::getIdBase(), "AND") |
71 | 71 | ->where("emplacement", "=", $i) |
72 | 72 | ->orderBy("emplacement") |
@@ -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 | } |
@@ -87,19 +87,19 @@ |
||
87 | 87 | * renvoi le ou les batiments nécéssaires pour la construction du batiment spécifié |
88 | 88 | */ |
89 | 89 | private function getPourConstruire($pour_construire) { |
90 | - for ($i=0 ; $i<count($pour_construire) ; $i++) { |
|
90 | + for ($i = 0; $i < count($pour_construire); $i++) { |
|
91 | 91 | //si plusieur batiment pour construire le batiment en question |
92 | 92 | $count = count($pour_construire[$i]); |
93 | 93 | if ($count > 1) { |
94 | - for ($j=0 ; $j<$count ; $j++) { |
|
95 | - $batiment[] = [ |
|
94 | + for ($j = 0; $j < $count; $j++) { |
|
95 | + $batiment[] = [ |
|
96 | 96 | "nom_batiment" => $pour_construire[$i][$j][0], |
97 | 97 | "niveau_batiment" => $pour_construire[$i][$j][2] |
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | else { |
102 | - $batiment[] = [ |
|
102 | + $batiment[] = [ |
|
103 | 103 | "nom_batiment" => $pour_construire[$i][0][0], |
104 | 104 | "niveau_batiment" => $pour_construire[$i][0][2] |
105 | 105 | ]; |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $dbc = App::getDb(); |
58 | 58 | |
59 | 59 | if ($type == "batiment") { |
60 | - $points = self::getPointsBase($id_base)+self::getPointAjoutBatiment(); |
|
60 | + $points = self::getPointsBase($id_base) + self::getPointAjoutBatiment(); |
|
61 | 61 | |
62 | 62 | } |
63 | 63 |
@@ -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) |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | - $marche = new \modules\bataille\app\controller\Marche(); |
|
2 | + $marche = new \modules\bataille\app\controller\Marche(); |
|
3 | 3 | |
4 | 4 | $marche->setCommencerTransport($_POST['eau'], $_POST['electricite'], $_POST['fer'], $_POST['fuel'], $_POST['nourriture'], $_POST['posx'], $_POST['posy']); |
5 | 5 |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $last_co = new \DateTime($last_co); |
98 | 98 | $last_co = $last_co->getTimestamp(); |
99 | 99 | |
100 | - $diff_temps = $today-$last_co; |
|
100 | + $diff_temps = $today - $last_co; |
|
101 | 101 | |
102 | 102 | //si la derniere actualisation ou connexion est supérieur à 30 sec |
103 | 103 | if ($diff_temps > 180) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | private function setAddRessource($nom_ressource, $ressrouce, $diff_temps) { |
118 | 118 | $dbc = App::getDb(); |
119 | 119 | |
120 | - $ressource = $ressrouce+(round((Bataille::getBatiment()->getProduction($nom_ressource, $this->id_base)/3600)*$diff_temps)); |
|
120 | + $ressource = $ressrouce + (round((Bataille::getBatiment()->getProduction($nom_ressource, $this->id_base) / 3600) * $diff_temps)); |
|
121 | 121 | $stockage_max = Bataille::getBatiment()->getStockageEntrepot($this->id_base); |
122 | 122 | |
123 | 123 | if ($ressource > $stockage_max) { |
@@ -148,18 +148,18 @@ discard block |
||
148 | 148 | |
149 | 149 | //soit on enelve ou on ajoute |
150 | 150 | if ($signe == "-") { |
151 | - $eau = $this->getEau()-$eau; |
|
152 | - $electricite = $this->getElectricite()-$electricite; |
|
153 | - $fer = $this->getFer()-$fer; |
|
154 | - $fuel = $this->getFuel()-$fuel; |
|
155 | - $nourriture = $this->getNourriture()-$nourriture; |
|
151 | + $eau = $this->getEau() - $eau; |
|
152 | + $electricite = $this->getElectricite() - $electricite; |
|
153 | + $fer = $this->getFer() - $fer; |
|
154 | + $fuel = $this->getFuel() - $fuel; |
|
155 | + $nourriture = $this->getNourriture() - $nourriture; |
|
156 | 156 | } |
157 | 157 | else { |
158 | - $eau = $this->getEau()+$eau; |
|
159 | - $electricite = $this->getElectricite()+$electricite; |
|
160 | - $fer = $this->getFer()+$fer; |
|
161 | - $fuel = $this->getFuel()+$fuel; |
|
162 | - $nourriture = $this->getNourriture()+$nourriture; |
|
158 | + $eau = $this->getEau() + $eau; |
|
159 | + $electricite = $this->getElectricite() + $electricite; |
|
160 | + $fer = $this->getFer() + $fer; |
|
161 | + $fuel = $this->getFuel() + $fuel; |
|
162 | + $nourriture = $this->getNourriture() + $nourriture; |
|
163 | 163 | |
164 | 164 | $stockage_max = Bataille::getBatiment()->getStockageEntrepot(); |
165 | 165 |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | $today = Bataille::getToday(); |
83 | 83 | |
84 | 84 | //on test si déja arrivé à destination |
85 | - if (($this->aller == 1) && (($this->date_arrivee-$today) <= 0)) { |
|
85 | + if (($this->aller == 1) && (($this->date_arrivee - $today) <= 0)) { |
|
86 | 86 | $this->setLivrerRessource(); |
87 | 87 | |
88 | 88 | //on calcul la date d'arrivée du retour |
89 | 89 | if ($this->id_base_dest == Bataille::getIdBase()) { |
90 | - $date_retour = Bataille::getDureeTrajet($this->id_base, Bataille::getParam("vitesse_marchand"))+$this->date_arrivee; |
|
90 | + $date_retour = Bataille::getDureeTrajet($this->id_base, Bataille::getParam("vitesse_marchand")) + $this->date_arrivee; |
|
91 | 91 | } |
92 | 92 | else { |
93 | - $date_retour = Bataille::getDureeTrajet($this->id_base_dest, Bataille::getParam("vitesse_marchand"))+$this->date_arrivee; |
|
93 | + $date_retour = Bataille::getDureeTrajet($this->id_base_dest, Bataille::getParam("vitesse_marchand")) + $this->date_arrivee; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | //si le retour du trajet est également arrivé on finit le transport sinon on le place sur le retour |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | } |
100 | 100 | else { |
101 | 101 | $this->setTrajetRetour($date_retour); |
102 | - $this->duree_restante_trajet = $date_retour-$today; |
|
102 | + $this->duree_restante_trajet = $date_retour - $today; |
|
103 | 103 | $set_array = true; |
104 | 104 | } |
105 | 105 | } |
106 | - else if (($this->aller == 0) && (($this->date_arrivee-$today) <= 0)) { |
|
106 | + else if (($this->aller == 0) && (($this->date_arrivee - $today) <= 0)) { |
|
107 | 107 | $this->setTerminerTransport(); |
108 | 108 | } |
109 | 109 | else { |
110 | - $this->duree_restante_trajet = $this->date_arrivee-$today; |
|
110 | + $this->duree_restante_trajet = $this->date_arrivee - $today; |
|
111 | 111 | $set_array = true; |
112 | 112 | } |
113 | 113 | |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | //on a le nombre de marchand dispo dans la base |
162 | - $nombre_marchand_dispo = $nombre_max_marchand-$marchand_transport; |
|
162 | + $nombre_marchand_dispo = $nombre_max_marchand - $marchand_transport; |
|
163 | 163 | |
164 | 164 | //on calcul savoir si on en a assez pour transport toutes les ressoures |
165 | 165 | //il faut 1 marchand pour 1000 ressource |
166 | - $nombre_marchand_trajet = ceil($all_ressource/1000); |
|
166 | + $nombre_marchand_trajet = ceil($all_ressource / 1000); |
|
167 | 167 | |
168 | 168 | //si on a assez de marchand on revoi true sinon false |
169 | 169 | if ($nombre_marchand_dispo >= $nombre_marchand_trajet) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | //on check si assez marchand dans la base, si pas assez on return false |
247 | - $nb_marchand = $this->getAssezMarchand($eau+$electricite+$fer+$fuel+$nourriture); |
|
247 | + $nb_marchand = $this->getAssezMarchand($eau + $electricite + $fer + $fuel + $nourriture); |
|
248 | 248 | |
249 | 249 | if ($nb_marchand === false) { |
250 | 250 | FlashMessage::setFlash("Vous n'avez pas assez de marchans disponibles pour effectuer ce trajet"); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | //sinon initialise le transport |
255 | 255 | //on recup la date d'arrivee dans la base de destintation |
256 | - $date_arrivee = Bataille::getDureeTrajet($id_base_dest, Bataille::getParam("vitesse_marchand"))+Bataille::getToday(); |
|
256 | + $date_arrivee = Bataille::getDureeTrajet($id_base_dest, Bataille::getParam("vitesse_marchand")) + Bataille::getToday(); |
|
257 | 257 | |
258 | 258 | $ressource = [ |
259 | 259 | "eau" => $eau, |
@@ -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 | } |