@@ -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 |
@@ -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 |
@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function sys_maintenance() |
|
4 | -{ |
|
3 | +function sys_maintenance() { |
|
5 | 4 | global $config; |
6 | 5 | |
7 | 6 | $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope; |
@@ -42,8 +41,7 @@ discard block |
||
42 | 41 | * TODO: 2. [<m|w|d|h|m|s>@]<time> |
43 | 42 | */ |
44 | 43 | |
45 | -function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) |
|
46 | -{ |
|
44 | +function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) { |
|
47 | 45 | static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',); |
48 | 46 | |
49 | 47 | $possible_schedules = array(); |
@@ -1,14 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // ---------------------------------------------------------------------------------------------------------------- |
4 | -function lng_try_filepath($path, $file_path_relative) |
|
5 | -{ |
|
4 | +function lng_try_filepath($path, $file_path_relative) { |
|
6 | 5 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
7 | 6 | return file_exists($file_path) ? $file_path : false; |
8 | 7 | } |
9 | 8 | |
10 | -function lng_die_not_an_object() |
|
11 | -{ |
|
9 | +function lng_die_not_an_object() { |
|
12 | 10 | print('Ошибка - $lang не объект! Сообщите Администратору сервера и приложите содержимое страницы'); |
13 | 11 | $trace = debug_backtrace(); |
14 | 12 | unset($trace[0]); |
@@ -17,32 +15,27 @@ discard block |
||
17 | 15 | } |
18 | 16 | |
19 | 17 | // ---------------------------------------------------------------------------------------------------------------- |
20 | -function lng_include($filename, $path = '', $ext = '.mo.php') |
|
21 | -{ |
|
18 | +function lng_include($filename, $path = '', $ext = '.mo.php') { |
|
22 | 19 | global $lang; |
23 | 20 | return is_object($lang) ? $lang->lng_include($filename, $path, $ext) : lng_die_not_an_object(); |
24 | 21 | } |
25 | 22 | |
26 | -function lng_get_list() |
|
27 | -{ |
|
23 | +function lng_get_list() { |
|
28 | 24 | global $lang; |
29 | 25 | return is_object($lang) ? $lang->lng_get_list() : lng_die_not_an_object(); |
30 | 26 | } |
31 | 27 | |
32 | -function lng_get_info($entry) |
|
33 | -{ |
|
28 | +function lng_get_info($entry) { |
|
34 | 29 | global $lang; |
35 | 30 | return is_object($lang) ? $lang->lng_get_info($entry) : lng_die_not_an_object(); |
36 | 31 | } |
37 | 32 | |
38 | -function lng_switch($language_new) |
|
39 | -{ |
|
33 | +function lng_switch($language_new) { |
|
40 | 34 | global $lang; |
41 | 35 | return is_object($lang) ? $lang->lng_switch($language_new) : lng_die_not_an_object(); |
42 | 36 | } |
43 | 37 | |
44 | -function lng_load_i18n($i18n) |
|
45 | -{ |
|
38 | +function lng_load_i18n($i18n) { |
|
46 | 39 | global $lang; |
47 | 40 | return is_object($lang) ? $lang->lng_load_i18n($i18n) : lng_die_not_an_object(); |
48 | 41 | } |