@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -23,7 +23,9 @@ |
||
23 | 23 | * DO NOT CHANGE |
24 | 24 | */ |
25 | 25 | |
26 | -if (!defined('INSIDE')) die(); |
|
26 | +if (!defined('INSIDE')) { |
|
27 | + die(); |
|
28 | +} |
|
27 | 29 | |
28 | 30 | $a_lang_array = (array( |
29 | 31 | // Metamatter |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -4,16 +4,14 @@ discard block |
||
4 | 4 | return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
5 | 5 | } |
6 | 6 | |
7 | -function sn_floor($value) |
|
8 | -{ |
|
7 | +function sn_floor($value) { |
|
9 | 8 | return $value >= 0 ? floor($value) : ceil($value); |
10 | 9 | } |
11 | 10 | |
12 | 11 | // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma |
13 | 12 | // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma |
14 | 13 | // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера |
15 | -function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) |
|
16 | -{ |
|
14 | +function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
|
17 | 15 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
18 | 16 | // При $mu = 0 (график симметричный, цифры только для половины графика) |
19 | 17 | // От 0 до $sigma ~ 34.1% |
@@ -43,7 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return float|int |
45 | 43 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
44 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | 45 | if($cut_extreme) { |
48 | 46 | $range_start--; |
49 | 47 | $range_end++; |
@@ -56,8 +54,7 @@ discard block |
||
56 | 54 | return $result; |
57 | 55 | } |
58 | 56 | |
59 | -function median() |
|
60 | -{ |
|
57 | +function median() { |
|
61 | 58 | $args = func_get_args(); |
62 | 59 | |
63 | 60 | switch(func_num_args()) |
@@ -86,8 +83,7 @@ discard block |
||
86 | 83 | if($n % 2 == 0) |
87 | 84 | { |
88 | 85 | $median = ($args[$h] + $args[$h-1]) / 2; |
89 | - } |
|
90 | - else |
|
86 | + } else |
|
91 | 87 | { |
92 | 88 | $median = $args[$h]; |
93 | 89 | } |
@@ -97,12 +93,10 @@ discard block |
||
97 | 93 | |
98 | 94 | return $median; |
99 | 95 | } |
100 | -function average($arr) |
|
101 | -{ |
|
96 | +function average($arr) { |
|
102 | 97 | return is_array($arr) && count($arr) ? array_sum($arr) / count($arr) : 0; |
103 | 98 | } |
104 | -function linear_calc(&$linear, $from = 0, $debug = false) |
|
105 | -{ |
|
99 | +function linear_calc(&$linear, $from = 0, $debug = false) { |
|
106 | 100 | for($i = $from; $i < count($linear); $i++) |
107 | 101 | { |
108 | 102 | $eq = &$linear[$i]; |
@@ -111,7 +105,9 @@ discard block |
||
111 | 105 | $eq[$j] /= $eq[$from]; |
112 | 106 | } |
113 | 107 | } |
114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
108 | + if($debug) { |
|
109 | + pdump($linear, 'Нормализовано по х' . $from); |
|
110 | + } |
|
115 | 111 | |
116 | 112 | for($i = $from + 1; $i < count($linear); $i++) |
117 | 113 | { |
@@ -121,7 +117,9 @@ discard block |
||
121 | 117 | $eq[$j] -= $linear[$from][$j]; |
122 | 118 | } |
123 | 119 | } |
124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
120 | + if($debug) { |
|
121 | + pdump($linear, 'Подставили х' . $from); |
|
122 | + } |
|
125 | 123 | |
126 | 124 | if($from < count($linear) - 1) |
127 | 125 | { |
@@ -138,11 +136,14 @@ discard block |
||
138 | 136 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
139 | 137 | } |
140 | 138 | } |
141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | - } |
|
143 | - else |
|
139 | + if($debug) { |
|
140 | + pdump($linear, 'Подставили обратно х' . $from); |
|
141 | + } |
|
142 | + } else |
|
144 | 143 | { |
145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
144 | + if($debug) { |
|
145 | + pdump($linear, 'Результат' . $from); |
|
146 | + } |
|
146 | 147 | foreach($linear as $index => &$eq) |
147 | 148 | { |
148 | 149 | pdump($eq[count($linear)], 'x' . $index); |
@@ -2,12 +2,10 @@ |
||
2 | 2 | |
3 | 3 | // Эти функции будут переписаны по добавлению инфы в БД |
4 | 4 | |
5 | -function pname_factory_production_field_name($factory_unit_id) |
|
6 | -{ |
|
5 | +function pname_factory_production_field_name($factory_unit_id) { |
|
7 | 6 | return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
8 | 7 | } |
9 | 8 | |
10 | -function pname_resource_name($resource_id) |
|
11 | -{ |
|
9 | +function pname_resource_name($resource_id) { |
|
12 | 10 | return get_unit_param($resource_id, P_NAME); |
13 | 11 | } |
14 | 12 | \ No newline at end of file |
@@ -242,24 +242,24 @@ discard block |
||
242 | 242 | * 1 - copyright 2008 By Chlorel for XNova |
243 | 243 | * |
244 | 244 | */ |
245 | -function SetSelectedPlanet(&$user) |
|
246 | -{ |
|
245 | +function SetSelectedPlanet(&$user) { |
|
247 | 246 | $planet_row['id'] = $user['current_planet']; |
248 | 247 | |
249 | 248 | // Пытаемся переключить на новую планету |
250 | 249 | if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
251 | 250 | { |
252 | 251 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
253 | - } |
|
254 | - else |
|
252 | + } else |
|
255 | 253 | { |
256 | 254 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
257 | 255 | } |
258 | 256 | |
259 | 257 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
258 | + if(!isset($planet_row['id'])) { |
|
259 | + // || $planet_row['id'] != $user['current_planet'] |
|
261 | 260 | { |
262 | 261 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
262 | + } |
|
263 | 263 | // Если текущей планеты не существует - выставляем Столицу |
264 | 264 | if(!isset($planet_row['id'])) |
265 | 265 | { |
@@ -284,25 +284,21 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // ---------------------------------------------------------------------------------------------------------------- |
287 | -function uni_render_coordinates($from, $prefix = '') |
|
288 | -{ |
|
287 | +function uni_render_coordinates($from, $prefix = '') { |
|
289 | 288 | return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]"; |
290 | 289 | } |
291 | 290 | |
292 | -function uni_render_planet($from) |
|
293 | -{ |
|
291 | +function uni_render_planet($from) { |
|
294 | 292 | return "{$from['name']} [{$from['galaxy']}:{$from['system']}:{$from['planet']}]"; |
295 | 293 | } |
296 | 294 | |
297 | -function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) |
|
298 | -{ |
|
295 | +function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
|
299 | 296 | global $lang; |
300 | 297 | |
301 | 298 | if(!$from['id']) |
302 | 299 | { |
303 | 300 | $result = $lang['sys_planet_expedition']; |
304 | - } |
|
305 | - else |
|
301 | + } else |
|
306 | 302 | { |
307 | 303 | $from_planet_id = $include_id ? ( |
308 | 304 | 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
@@ -318,30 +314,25 @@ discard block |
||
318 | 314 | return $result; |
319 | 315 | } |
320 | 316 | |
321 | -function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') |
|
322 | -{ |
|
317 | +function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') { |
|
323 | 318 | return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}"; |
324 | 319 | } |
325 | 320 | |
326 | -function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') |
|
327 | -{ |
|
321 | +function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') { |
|
328 | 322 | return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>'; |
329 | 323 | } |
330 | 324 | |
331 | -function uni_get_time_to_jump($moon_row) |
|
332 | -{ |
|
325 | +function uni_get_time_to_jump($moon_row) { |
|
333 | 326 | $jump_gate_level = mrc_get_level($user, $moon_row, STRUC_MOON_GATE); |
334 | 327 | return $jump_gate_level ? max(0, $moon_row['last_jump_time'] + abs(60 * 60 / $jump_gate_level) - SN_TIME_NOW) : 0; |
335 | 328 | } |
336 | 329 | |
337 | -function uni_calculate_moon_chance($FleetDebris) |
|
338 | -{ |
|
330 | +function uni_calculate_moon_chance($FleetDebris) { |
|
339 | 331 | $MoonChance = $FleetDebris / 1000000; |
340 | 332 | return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance); |
341 | 333 | } |
342 | 334 | |
343 | -function uni_coordinates_valid($coordinates, $prefix = '') |
|
344 | -{ |
|
335 | +function uni_coordinates_valid($coordinates, $prefix = '') { |
|
345 | 336 | global $config; |
346 | 337 | |
347 | 338 | // array_walk($coordinates, 'intval'); |
@@ -4,8 +4,7 @@ discard block |
||
4 | 4 | // Open Source |
5 | 5 | // V1 |
6 | 6 | // |
7 | -function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') |
|
8 | -{ |
|
7 | +function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') { |
|
9 | 8 | // Here we select which part of defense should take damage: structure or shield |
10 | 9 | // $damageTo = P_SHIELD; |
11 | 10 | // $damageTo = P_STRUCTURE; |
@@ -34,8 +33,7 @@ discard block |
||
34 | 33 | $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
35 | 34 | $structures[$targetedStructure][0] -= $structsDestroyed; |
36 | 35 | $MIPDamage -= $structsDestroyed*$damageDone; |
37 | - } |
|
38 | - else |
|
36 | + } else |
|
39 | 37 | { |
40 | 38 | // REALLY random attack |
41 | 39 | $can_be_damaged = sn_get_groups('defense_active'); |
@@ -161,8 +161,7 @@ discard block |
||
161 | 161 | return $rows_affected; |
162 | 162 | } |
163 | 163 | |
164 | -function rpg_level_up(&$user, $type, $xp_to_add = 0) |
|
165 | -{ |
|
164 | +function rpg_level_up(&$user, $type, $xp_to_add = 0) { |
|
166 | 165 | $q = 1.03; |
167 | 166 | |
168 | 167 | switch($type) |
@@ -223,27 +222,22 @@ discard block |
||
223 | 222 | } |
224 | 223 | } |
225 | 224 | |
226 | -function rpg_xp_for_level($level, $b1, $q) |
|
227 | -{ |
|
225 | +function rpg_xp_for_level($level, $b1, $q) { |
|
228 | 226 | return floor($b1 * (pow($q, $level) - 1)/($q - 1)); |
229 | 227 | } |
230 | 228 | |
231 | -function rpg_get_miner_xp($level) |
|
232 | -{ |
|
229 | +function rpg_get_miner_xp($level) { |
|
233 | 230 | return rpg_xp_for_level($level, 50, 1.03); |
234 | 231 | } |
235 | 232 | |
236 | -function RPG_get_raider_xp($level) |
|
237 | -{ |
|
233 | +function RPG_get_raider_xp($level) { |
|
238 | 234 | return rpg_xp_for_level($level, 10, 1.03); |
239 | 235 | } |
240 | 236 | |
241 | -function rpg_get_tech_xp($level) |
|
242 | -{ |
|
237 | +function rpg_get_tech_xp($level) { |
|
243 | 238 | return rpg_xp_for_level($level, 50, 1.03); |
244 | 239 | } |
245 | 240 | |
246 | -function rpg_get_explore_xp($level) |
|
247 | -{ |
|
241 | +function rpg_get_explore_xp($level) { |
|
248 | 242 | return rpg_xp_for_level($level, 10, 1.05); |
249 | 243 | } |
@@ -458,8 +458,7 @@ |
||
458 | 458 | |
459 | 459 | if(is_numeric($planet['id'])) { |
460 | 460 | DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
461 | - } |
|
462 | - elseif(is_numeric($user['id'])) { |
|
461 | + } elseif(is_numeric($user['id'])) { |
|
463 | 462 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
464 | 463 | } |
465 | 464 |