These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * infos.php |
||
5 | * |
||
6 | * Information about every aspect of in-game objects: buildings, officiers, techs etc |
||
7 | * |
||
8 | * @version 1.1st Security checks & tests by Gorlum for http://supernova.ws |
||
9 | * @version 1.1 |
||
10 | * @copyright 2008 By Chlorel for XNova |
||
11 | */ |
||
12 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
13 | |||
14 | $unit_id = sys_get_param_id('gid'); |
||
15 | if($unit_id == RES_DARK_MATTER) { |
||
16 | sys_redirect('dark_matter.php'); |
||
17 | } |
||
18 | |||
19 | if($unit_id == RES_METAMATTER) { |
||
20 | sys_redirect('metamatter.php'); |
||
21 | } |
||
22 | |||
23 | lng_include('infos'); |
||
24 | if(!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) { |
||
25 | sys_redirect('index.php?page=techtree'); |
||
26 | } |
||
27 | |||
28 | $template = gettemplate('novapedia', true); |
||
29 | |||
30 | $unit_data = get_unit_param($unit_id); |
||
31 | $unit_type = $unit_data['type']; |
||
32 | |||
33 | if($unit_type == UNIT_SHIPS) { |
||
34 | $template_result['UNIT_IS_SHIP'] = true; |
||
35 | |||
36 | $ship_data = get_ship_data($unit_id, $user); |
||
37 | |||
38 | $template_result += array( |
||
39 | 'BASE_SPEED' => pretty_number($ship_data['speed_base']), |
||
40 | 'ACTUAL_SPEED' => pretty_number($ship_data['speed']), |
||
41 | 'BASE_CONSUMPTION' => pretty_number($ship_data['consumption_base']), |
||
42 | 'ACTUAL_CONSUMPTION' => pretty_number($ship_data['consumption']), |
||
43 | |||
44 | 'BASE_CAPACITY' => pretty_number($unit_data['capacity']), |
||
45 | 'ACTUAL_CAPACITY' => pretty_number($ship_data['capacity']), |
||
46 | ); |
||
47 | |||
48 | $engine_template_info = array(); |
||
49 | foreach($unit_data['engine'] as $unit_engine_data) { |
||
50 | $unit_engine_data = get_engine_data($user, $unit_engine_data); |
||
51 | |||
52 | $engine_template_info[] = array( |
||
53 | 'NAME' => classLocale::$lang['tech'][$unit_engine_data['tech']], |
||
54 | 'MIN_LEVEL' => $unit_engine_data['min_level'], |
||
55 | 'USER_TECH_LEVEL' => mrc_get_level($user, null, $unit_engine_data['tech']), |
||
56 | 'BASE_SPEED' => pretty_number($unit_engine_data['speed_base']), |
||
57 | 'BASE_CONSUMPTION' => pretty_number($unit_engine_data['consumption_base']), |
||
58 | 'ACTUAL_SPEED' => pretty_number($unit_engine_data['speed']), |
||
59 | 'ACTUAL_CONSUMPTION' => pretty_number($unit_engine_data['consumption']), |
||
60 | ); |
||
61 | } |
||
62 | $template_result['.']['engine'] = $engine_template_info; |
||
63 | |||
64 | } |
||
65 | |||
66 | |||
67 | $sn_data_group_combat = sn_get_groups('combat'); |
||
68 | if(in_array($unit_id, $sn_data_group_combat)) { |
||
69 | $template_result['UNIT_IS_COMBAT'] = true; |
||
70 | |||
71 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
||
72 | |||
73 | $volley_arr = $rapid_to = $rapid_from = array(); |
||
74 | $str_rapid_from = ''; |
||
75 | $str_rapid_to = ''; |
||
76 | foreach($sn_data_group_combat as $enemy_id) { |
||
77 | $enemy_data = get_unit_param($enemy_id); |
||
78 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
||
79 | |||
80 | $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability; |
||
81 | if($rapid >= 1) { |
||
82 | $volley_arr[$enemy_id]['TO'] = floor($rapid); |
||
83 | } |
||
84 | |||
85 | $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability; |
||
86 | if($rapid >= 1) { |
||
87 | $volley_arr[$enemy_id]['FROM'] = floor($rapid); |
||
88 | } |
||
89 | } |
||
90 | foreach($volley_arr as $enemy_id => &$rapid) { |
||
91 | $rapid['ENEMY_ID'] = $enemy_id; |
||
92 | $rapid['ENEMY_NAME'] = classLocale::$lang['tech'][$enemy_id]; |
||
93 | } |
||
94 | $template_result['.']['volley'] = $volley_arr; |
||
95 | |||
96 | $template_result += array( |
||
97 | 'BASE_ARMOR' => pretty_number($unit_data['armor']), |
||
98 | 'BASE_SHIELD' => pretty_number($unit_data['shield']), |
||
99 | 'BASE_WEAPON' => pretty_number($unit_data['attack']), |
||
100 | |||
101 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_data['armor'])), |
||
102 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_data['shield'])), |
||
103 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_data['attack'])), |
||
104 | ); |
||
105 | |||
106 | } |
||
107 | |||
108 | if(classLocale::$lang['info'][$unit_id]['effect']) { |
||
109 | $template_result['UNIT_EFFECT'] = classLocale::$lang['info'][$unit_id]['effect']; |
||
110 | } |
||
111 | |||
112 | if($unit_data['bonus']) { |
||
113 | $unit_bonus = !$unit_data['bonus'] || $unit_data['bonus_type'] == BONUS_ABILITY ? '' : ( |
||
114 | ($unit_data['bonus'] >= 0 ? '+' : '') . $unit_data['bonus'] . ($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '') |
||
115 | ); |
||
116 | $template_result['UNIT_BONUS'] = $unit_bonus; |
||
117 | } |
||
118 | |||
119 | $template_result += array( |
||
120 | 'PAGE_HEADER' => classLocale::$lang['wiki_title'], |
||
121 | |||
122 | 'UNIT_ID' => $unit_id, |
||
123 | 'UNIT_NAME' => classLocale::$lang['tech'][$unit_id], |
||
124 | 'UNIT_TYPE' => $unit_type, |
||
125 | 'UNIT_TYPE_NAME' => classLocale::$lang['tech'][$unit_type], |
||
126 | 'UNIT_DESCRIPTION' => classLocale::$lang['info'][$unit_id]['description'], |
||
127 | ); |
||
128 | |||
129 | $template_result['.']['require'] = unit_requirements_render($user, $planetrow, $unit_id); |
||
130 | |||
131 | |||
132 | $template->assign_recursive($template_result); |
||
133 | display($template); |
||
134 | |||
135 | |||
136 | // ---------------------------------------------------------------------------------------------------------- |
||
137 | // Creation du tableau de production de ressources |
||
138 | // Tient compte du parametrage de la planete (si la production n'est pas affectée a 100% par exemple |
||
139 | // Tient compte aussi du multiplicateur de ressources |
||
140 | // |
||
141 | function ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $Template) { |
||
142 | $config_resource_multiplier = game_resource_multiplier(); |
||
143 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
||
144 | |||
145 | $CurrentBuildtLvl = mrc_get_level($CurrentUser, $CurrentPlanet, $BuildID); |
||
146 | |||
147 | $BuildLevel = ($CurrentBuildtLvl > 0) ? $CurrentBuildtLvl : 1; |
||
148 | |||
149 | $modifiers = sn_get_groups('modifiers'); |
||
150 | |||
151 | $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value( |
||
152 | $CurrentUser, |
||
153 | $CurrentPlanet, |
||
154 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
155 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_METAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
156 | )); |
||
157 | $Prod[STRUC_MINE_CRYSTAL] = floor(mrc_modify_value( |
||
158 | $CurrentUser, |
||
159 | $CurrentPlanet, |
||
160 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
161 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_CRYSTAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
162 | )); |
||
163 | $Prod[STRUC_MINE_DEUTERIUM] = floor(mrc_modify_value( |
||
164 | $CurrentUser, |
||
165 | $CurrentPlanet, |
||
166 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
167 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_DEUTERIUM]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
168 | )); |
||
169 | $Prod[STRUC_MINE_SOLAR] = floor(mrc_modify_value( |
||
170 | $CurrentUser, |
||
171 | $CurrentPlanet, |
||
172 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
173 | $config_resource_multiplier_plain * $unit_data[P_UNIT_PRODUCTION][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
174 | )); |
||
175 | |||
176 | $ActualProd = floor($Prod[$BuildID]); |
||
177 | View Code Duplication | if($BuildID != STRUC_MINE_FUSION) { |
|
178 | $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]); |
||
179 | } else { |
||
180 | $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]); |
||
181 | } |
||
182 | |||
183 | $BuildStartLvl = $CurrentBuildtLvl - 2; |
||
184 | if($BuildStartLvl < 1) { |
||
185 | $BuildStartLvl = 1; |
||
186 | } |
||
187 | $Table = ''; |
||
188 | $ProdFirst = 0; |
||
189 | for($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) { |
||
190 | if($BuildID != STRUC_MOON_PHALANX) { |
||
191 | $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value( |
||
192 | $CurrentUser, |
||
193 | $CurrentPlanet, |
||
194 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
195 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_METAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
196 | )); |
||
197 | $Prod[STRUC_MINE_CRYSTAL] = floor(mrc_modify_value( |
||
198 | $CurrentUser, |
||
199 | $CurrentPlanet, |
||
200 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
201 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_CRYSTAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
202 | )); |
||
203 | $Prod[STRUC_MINE_DEUTERIUM] = floor(mrc_modify_value( |
||
204 | $CurrentUser, |
||
205 | $CurrentPlanet, |
||
206 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
207 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_DEUTERIUM]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
208 | )); |
||
209 | $Prod[STRUC_MINE_SOLAR] = floor(mrc_modify_value( |
||
210 | $CurrentUser, |
||
211 | $CurrentPlanet, |
||
212 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
213 | $config_resource_multiplier_plain * $unit_data[P_UNIT_PRODUCTION][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
214 | )); |
||
215 | |||
216 | $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; |
||
217 | if($ProdFirst > 0) { |
||
218 | if($BuildID != STRUC_MINE_FUSION) { |
||
219 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>"; |
||
220 | } else { |
||
221 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>"; |
||
222 | } |
||
223 | } else { |
||
224 | $bloc['build_gain'] = ''; |
||
225 | } |
||
226 | if($BuildID != STRUC_MINE_FUSION) { |
||
227 | $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID])); |
||
228 | $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true); |
||
229 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true); |
||
230 | $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ActualNeed), true, true); |
||
231 | } else { |
||
232 | $bloc['build_prod'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR])); |
||
233 | $bloc['build_prod_diff'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ActualProd), true, true); |
||
234 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true); |
||
235 | $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true); |
||
236 | } |
||
237 | View Code Duplication | if($ProdFirst == 0) { |
|
238 | if($BuildID != STRUC_MINE_FUSION) { |
||
239 | $ProdFirst = floor($Prod[$BuildID]); |
||
240 | } else { |
||
241 | $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]); |
||
242 | } |
||
243 | } |
||
244 | } else { |
||
245 | // Cas particulier de la phalange |
||
246 | $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; |
||
247 | $bloc['build_range'] = ($BuildLevel * $BuildLevel) - 1; |
||
248 | } |
||
249 | $Table .= parsetemplate($Template, $bloc); |
||
250 | } |
||
251 | |||
252 | return $Table; |
||
253 | } |
||
254 | |||
255 | function eco_render_rapid_fire($unit_id) { |
||
256 | $classLocale = classLocale::$lang; |
||
257 | |||
258 | $unit_data = get_unit_param($unit_id); |
||
259 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
||
260 | |||
261 | $str_rapid_from = ''; |
||
262 | $str_rapid_to = ''; |
||
263 | foreach(sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) { |
||
264 | $enemy_data = get_unit_param($enemy_id); |
||
265 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
||
266 | |||
267 | $rapid = floor($unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability); |
||
268 | if($rapid >= 1) { |
||
269 | $str_rapid_to .= "{$classLocale['nfo_rf_again']} {$classLocale['tech'][$enemy_id]} <font color=\"#00ff00\">{$rapid}</font><br>"; |
||
270 | } |
||
271 | |||
272 | $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability); |
||
273 | if($rapid >= 1) { |
||
274 | $str_rapid_from .= "{$classLocale['tech'][$enemy_id]} {$classLocale['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>"; |
||
275 | } |
||
276 | } |
||
277 | |||
278 | if($str_rapid_to && $str_rapid_from) { |
||
279 | $str_rapid_to .= '<hr>'; |
||
280 | } |
||
281 | |||
282 | return array('to' => $str_rapid_to, 'from' => $str_rapid_from); |
||
283 | } |
||
284 | |||
285 | // ---------------------------------------------------------------------------------------------------------- |
||
286 | // Construit la page par rapport a l'information demandée ... |
||
287 | // Permet de faire la differance entre les divers types et les pages speciales |
||
288 | // |
||
289 | $unit_id = sys_get_param_int('gid'); |
||
290 | |||
291 | $unit_data = get_unit_param($unit_id); |
||
292 | |||
293 | lng_include('infos'); |
||
294 | |||
295 | $DestroyTPL = ''; |
||
296 | $TableHeadTPL = ''; |
||
297 | |||
298 | $parse = classLocale::$lang; |
||
299 | |||
300 | $unit_info = get_unit_param($unit_id); |
||
301 | |||
302 | if($unit_id >= 1 && $unit_id <= 3) { |
||
303 | // Cas des mines |
||
304 | $templatePage = gettemplate('info_buildings_table'); |
||
305 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
306 | $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_p_hour}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_energy}</td><td class=\"c\">{nfo_difference}</td></tr>"; |
||
307 | $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; |
||
308 | View Code Duplication | } elseif($unit_id == 4) { |
|
0 ignored issues
–
show
|
|||
309 | // Centrale Solaire |
||
310 | $templatePage = gettemplate('info_buildings_table'); |
||
311 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
312 | $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td></tr>"; |
||
313 | $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>"; |
||
314 | } elseif($unit_id == STRUC_MINE_FUSION) { |
||
315 | // Centrale Fusion |
||
316 | $templatePage = gettemplate('info_buildings_table'); |
||
317 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
318 | $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_deuter}</td><td class=\"c\">{nfo_difference}</td></tr>"; |
||
319 | $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; |
||
320 | } elseif($unit_id >= STRUC_FACTORY_ROBOT && $unit_id <= 32) { |
||
321 | // Batiments Generaux |
||
322 | $templatePage = gettemplate('info_buildings_general'); |
||
323 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
324 | } elseif($unit_id == STRUC_TERRAFORMER) { |
||
325 | // Batiments Terraformer |
||
326 | $templatePage = gettemplate('info_buildings_general'); |
||
327 | } elseif($unit_id == STRUC_ALLY_DEPOSIT) { |
||
328 | // Dépot d'alliance |
||
329 | $templatePage = gettemplate('info_buildings_general'); |
||
330 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
331 | } elseif($unit_id == STRUC_LABORATORY_NANO) { |
||
332 | // nano |
||
333 | $templatePage = gettemplate('info_buildings_general'); |
||
334 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
335 | } elseif($unit_id == STRUC_SILO) { |
||
336 | // Silo de missiles |
||
337 | $templatePage = gettemplate('info_buildings_general'); |
||
338 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
339 | } elseif($unit_id == STRUC_MOON_STATION) { |
||
340 | // Batiments lunaires |
||
341 | $templatePage = gettemplate('info_buildings_general'); |
||
342 | View Code Duplication | } elseif($unit_id == STRUC_MOON_PHALANX) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
343 | // Phalange |
||
344 | $templatePage = gettemplate('info_buildings_table'); |
||
345 | $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_range}</td></tr>"; |
||
346 | $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>"; |
||
347 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
348 | } elseif($unit_id == STRUC_MOON_GATE) { |
||
349 | // Porte de Saut |
||
350 | $templatePage = gettemplate('info_buildings_general'); |
||
351 | $DestroyTPL = gettemplate('info_buildings_destroy'); |
||
352 | } elseif(in_array($unit_id, sn_get_groups('tech'))) { |
||
353 | // Laboratoire |
||
354 | $templatePage = gettemplate('info_buildings_general'); |
||
355 | } elseif(in_array($unit_id, sn_get_groups('fleet'))) { |
||
356 | // Flotte |
||
357 | |||
358 | $templatePage = gettemplate('info_buildings_fleet'); |
||
359 | |||
360 | $parse['element_typ'] = classLocale::$lang['tech'][UNIT_SHIPS]; |
||
361 | $rapid_fire = eco_render_rapid_fire($unit_id); |
||
362 | $parse['rf_info_to'] = $rapid_fire['to']; // Rapid Fire vers |
||
363 | $parse['rf_info_fr'] = $rapid_fire['from']; // Rapid Fire de |
||
364 | |||
365 | $parse['hull_pt'] = pretty_number(($unit_info['metal'] + $unit_info['crystal']) / 10); // Points de Structure |
||
366 | $parse['shield_pt'] = pretty_number($unit_info['shield']); // Points de Bouclier |
||
367 | $parse['attack_pt'] = pretty_number($unit_info['attack']); // Points d'Attaque |
||
368 | $parse['capacity_pt'] = pretty_number($unit_info['capacity']); // Capacitée de fret |
||
369 | $parse['base_speed'] = pretty_number($unit_info['engine'][0]['speed']); // Vitesse de base |
||
370 | $parse['base_conso'] = pretty_number($unit_info['engine'][0]['consumption']); // Consommation de base |
||
371 | |||
372 | $parse['ACTUAL_ARMOR'] = pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), ($unit_info['metal'] + $unit_info['crystal']) / 10)); |
||
0 ignored issues
–
show
false is of type boolean , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
373 | $parse['ACTUAL_SHIELD'] = pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])); |
||
0 ignored issues
–
show
false is of type boolean , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
374 | $parse['ACTUAL_WEAPON'] = pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])); |
||
0 ignored issues
–
show
false is of type boolean , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
375 | |||
376 | $ship_data = get_ship_data($unit_id, $user); |
||
377 | $parse['ACTUAL_CAPACITY'] = pretty_number($ship_data['capacity']); |
||
378 | $parse['ACTUAL_SPEED'] = pretty_number($ship_data['speed']); |
||
379 | $parse['ACTUAL_CONSUMPTION'] = pretty_number($ship_data['consumption']); |
||
380 | if(count($unit_info['engine']) > 1) { |
||
381 | $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($unit_info['engine'][1]['speed']) . ")</font>"; // Vitesse rééquipée |
||
382 | $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($unit_info['engine'][1]['consumption']) . ")</font>"; // Consommation apres rééquipement |
||
383 | } |
||
384 | } elseif(in_array($unit_id, sn_get_groups('defense_active'))) { |
||
385 | // Defenses |
||
386 | $templatePage = gettemplate('info_buildings_defense'); |
||
387 | $parse['element_typ'] = classLocale::$lang['tech'][UNIT_DEFENCE]; |
||
388 | |||
389 | $rapid_fire = eco_render_rapid_fire($unit_id); |
||
390 | $parse['rf_info_to'] = $rapid_fire['to']; // Rapid Fire vers |
||
391 | $parse['rf_info_fr'] = $rapid_fire['from']; // Rapid Fire de |
||
392 | |||
393 | $parse['hull_pt'] = pretty_number(($unit_info['metal'] + $unit_info['crystal']) / 10); // Points de Structure |
||
394 | $parse['shield_pt'] = pretty_number($unit_info['shield']); // Points de Bouclier |
||
395 | $parse['attack_pt'] = pretty_number($unit_info['attack']); // Points d'Attaque |
||
396 | } elseif(in_array($unit_id, sn_get_groups('missile'))) { |
||
397 | // Misilles |
||
398 | $templatePage = gettemplate('info_buildings_defense'); |
||
399 | $parse['element_typ'] = classLocale::$lang['tech'][UNIT_DEFENCE]; |
||
400 | $parse['hull_pt'] = pretty_number($unit_info['metal'] + $unit_info['crystal']); // Points de Structure |
||
401 | $parse['shield_pt'] = pretty_number($unit_info['shield']); // Points de Bouclier |
||
402 | $parse['attack_pt'] = pretty_number($unit_info['attack']); // Points d'Attaque |
||
403 | } elseif(in_array($unit_id, sn_get_groups(array('mercenaries', 'governors', 'artifacts', 'resources_all')))) { |
||
404 | // Officiers |
||
405 | $templatePage = gettemplate('info_officiers_general'); |
||
406 | |||
407 | $mercenary = $unit_info; |
||
408 | $mercenary_bonus = $mercenary['bonus']; |
||
409 | $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; |
||
410 | View Code Duplication | switch($mercenary['bonus_type']) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
411 | case BONUS_PERCENT: |
||
412 | $mercenary_bonus = "{$mercenary_bonus}%"; |
||
413 | break; |
||
414 | |||
415 | case BONUS_ADD: |
||
416 | break; |
||
417 | |||
418 | case BONUS_ABILITY: |
||
419 | $mercenary_bonus = ''; |
||
420 | break; |
||
421 | |||
422 | default: |
||
423 | break; |
||
424 | } |
||
425 | |||
426 | $parse['EFFECT'] = classLocale::$lang['info'][$unit_id]['effect']; |
||
427 | $parse['mercenary_bonus'] = $mercenary_bonus; |
||
428 | if(!in_array($unit_id, sn_get_groups(array('artifacts', 'resources_all')))) { |
||
429 | $parse['max_level'] = classLocale::$lang['sys_level'] . ' ' . |
||
430 | (in_array($unit_id, sn_get_groups('mercenaries')) ? mrc_get_level($user, $planetrow, $unit_id) : ($mercenary['location'] == LOC_USER ? mrc_get_level($user, null, $unit_id) : ($planetrow['PLANET_GOVERNOR_ID'] == $unit_id ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0))) |
||
0 ignored issues
–
show
null is of type null , but the function expects a array .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
431 | . (isset($mercenary['max']) ? "/{$mercenary['max']}" : ''); |
||
432 | } |
||
433 | } |
||
434 | |||
435 | // ---- Tableau d'evolution |
||
436 | if($TableHeadTPL != '') { |
||
437 | $parse['table_head'] = parsetemplate($TableHeadTPL, classLocale::$lang); |
||
0 ignored issues
–
show
\classLocale::$lang is of type object<classLocale> , but the function expects a array|boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
438 | $parse['table_data'] = ShowProductionTable($user, $planetrow, $unit_id, $TableTPL); |
||
439 | } |
||
440 | |||
441 | // Données de base |
||
442 | $parse['dpath'] = $dpath; |
||
443 | $parse['name'] = classLocale::$lang['tech'][$unit_id]; |
||
444 | $parse['image'] = $unit_id; |
||
445 | $parse['description'] = classLocale::$lang['info'][$unit_id]['description']; |
||
446 | |||
447 | // La page principale |
||
448 | $page = parsetemplate($templatePage, $parse); |
||
0 ignored issues
–
show
$parse is of type object<classLocale> , but the function expects a array|boolean .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
449 | |||
450 | display($page, classLocale::$lang['nfo_page_title']); |
||
451 | |||
452 | // ----------------------------------------------------------------------------------------------------------- |
||
453 | // History version |
||
454 | // 2.0 - Using sn_timer instead of script generated by InsertScriptChronoApplet |
||
455 | // 1.1 - Ajout JumpGate pour la porte de saut comme la présente OGame ... Enfin un peu mieux quand meme ! |
||
456 | // 1.0 - Réécriture (réinventation de l'eau tiède) |
||
457 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.