1 | <?php |
||
5 | class Aide { |
||
6 | public static $parametre_router; |
||
7 | |||
8 | |||
9 | |||
10 | //-------------------------- BUILDER ----------------------------------------------------------------------------// |
||
11 | /** |
||
12 | * recupere la liste des batiments constructibles dans la catégorie spécifiée |
||
13 | */ |
||
14 | public function __construct() { |
||
15 | $dbc1 = Bataille::getDb(); |
||
16 | |||
17 | $parametre = explode("-", self::$parametre_router); |
||
18 | Bataille::setValues(["batiments" => $parametre[0], "type_batiments" => $parametre[1]]); |
||
19 | |||
20 | //recuperation de tous les batiments du type |
||
21 | $query = $dbc1->select()->from($this->getTable($parametre[0]))->where("actif", "=", 1, "AND")->where("type", "=", $parametre[1])->get(); |
||
22 | |||
23 | if ((is_array($query)) && (count($query) > 0)) { |
||
24 | $batiments = []; |
||
25 | |||
26 | foreach ($query as $obj) { |
||
27 | $nom_batiment = $obj->nom; |
||
28 | $nom_batiment_sql = $obj->nom_table; |
||
29 | |||
30 | //on recupere les infos concernant le temps de construction et les batiment qu'il faudra pour construire |
||
31 | $query = $dbc1->select()->from($obj->nom_table)->where("ID_".$obj->nom_table, "=", 1)->get(); |
||
32 | |||
33 | if ((is_array($query)) && (count($query) == 1)) { |
||
34 | $pour_construire = []; |
||
35 | |||
36 | foreach ($query as $obj) { |
||
37 | $ressource_tmp = explode(", ", $obj->ressource_construire); |
||
38 | |||
39 | $ressource = [ |
||
40 | "fer" => $ressource_tmp[0], |
||
41 | "fuel" => $ressource_tmp[1], |
||
42 | "eau" => $ressource_tmp[2], |
||
43 | "electricite" => $ressource_tmp[3] |
||
44 | ]; |
||
45 | |||
46 | if ($obj->pour_construire != null) { |
||
47 | $pour_construire[] = unserialize($obj->pour_construire); |
||
48 | |||
49 | $pour_construire = $this->getPourConstruire($pour_construire); |
||
50 | } |
||
51 | else { |
||
52 | $pour_construire = []; |
||
53 | } |
||
54 | |||
55 | $batiments[] = [ |
||
56 | "nom_batiment" => $nom_batiment, |
||
57 | "nom_batiment_sql" => $nom_batiment_sql, |
||
58 | "niveau_batiment" => 1, |
||
59 | "temps_construction" => gmdate("H:i:s", $obj->temps_construction), |
||
60 | "ressource" => $ressource, |
||
61 | "pour_construire" => $pour_construire |
||
62 | ]; |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 | |||
67 | Bataille::setValues(["liste_batiments" => $batiments]); |
||
68 | } |
||
69 | } |
||
70 | //-------------------------- END BUILDER ----------------------------------------------------------------------------// |
||
71 | |||
72 | |||
73 | |||
74 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
75 | /** |
||
76 | * renvoi la table dans laquelle il faut aller chercher les infos |
||
77 | * @param $param |
||
78 | * @return string |
||
79 | */ |
||
80 | private function getTable($param) { |
||
85 | |||
86 | /** |
||
87 | * @param $pour_construire |
||
88 | * @return array |
||
89 | * renvoi le ou les batiments nécéssaires pour la construction du batiment spécifié |
||
90 | */ |
||
91 | private function getPourConstruire($pour_construire) { |
||
117 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
||
118 | |||
119 | |||
120 | |||
121 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
122 | //-------------------------- END SETTER ----------------------------------------------------------------------------// |
||
123 | } |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.