@@ -14,14 +14,14 @@ |
||
14 | 14 | global $lang, $user, $planetrow; |
15 | 15 | |
16 | 16 | $tech_tree = array(); |
17 | - foreach(get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
17 | + foreach (get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
18 | 18 | { |
19 | 19 | $tech_tree[] = array( |
20 | 20 | 'NAME' => $lang['tech'][$unit_group_id], |
21 | 21 | 'GROUP_ID' => $unit_group_id, |
22 | 22 | ); |
23 | 23 | |
24 | - foreach($unit_list as $unit_id) |
|
24 | + foreach ($unit_list as $unit_id) |
|
25 | 25 | { |
26 | 26 | $sn_data_unit = get_unit_param($unit_id); |
27 | 27 | $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC"); |
19 | 19 | |
20 | 20 | // while($row = db_fetch($query)) |
21 | - foreach($query as $row) |
|
21 | + foreach ($query as $row) |
|
22 | 22 | { |
23 | 23 | $template_result['.']['contact'][] = array( |
24 | 24 | 'NAME' => $row['username'], |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | $sn_group_factories = sn_get_groups('factories'); |
23 | 23 | $planet_density = sn_get_groups('planet_density'); |
24 | 24 | |
25 | - if(sys_get_param('save_production')) { |
|
25 | + if (sys_get_param('save_production')) { |
|
26 | 26 | $production = sys_get_param('percent'); |
27 | - if(is_array($production) && !empty($production)) { |
|
27 | + if (is_array($production) && !empty($production)) { |
|
28 | 28 | // sn_db_transaction_start(); |
29 | 29 | $query = array(); |
30 | 30 | $planet_row_list = db_planet_list_sorted($user, false, '*'); |
31 | 31 | // while($planet = db_fetch($planet_row_list)) |
32 | - foreach($planet_row_list as $planet) { |
|
33 | - foreach($sn_group_factories as $factory_unit_id) { |
|
32 | + foreach ($planet_row_list as $planet) { |
|
33 | + foreach ($sn_group_factories as $factory_unit_id) { |
|
34 | 34 | $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id); |
35 | - if( |
|
35 | + if ( |
|
36 | 36 | get_unit_param($factory_unit_id, P_MINING_IS_MANAGED) |
37 | 37 | && isset($production[$factory_unit_id][$planet['id']]) |
38 | 38 | && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | - foreach($query as $planet_id => $query_data) { |
|
46 | + foreach ($query as $planet_id => $query_data) { |
|
47 | 47 | db_planet_set_by_id($planet_id, implode(',', $query_data)); |
48 | 48 | } |
49 | 49 | // sn_db_transaction_commit(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $planet_row_list = db_planet_list_sorted($user); |
54 | 54 | // while ($planet = db_fetch($planet_row_list)) |
55 | - foreach($planet_row_list as $planet) { |
|
55 | + foreach ($planet_row_list as $planet) { |
|
56 | 56 | sn_db_transaction_start(); |
57 | 57 | $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true); |
58 | 58 | $planets[$planet['id']] = $global_data['planet']; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $template = gettemplate('imperium', $template); |
65 | 65 | $template->assign_var('amount', count($planets) + 2); |
66 | 66 | |
67 | - for($i = 100; $i >= 0; $i -= 10) { |
|
67 | + for ($i = 100; $i >= 0; $i -= 10) { |
|
68 | 68 | $template->assign_block_vars('percent', array('PERCENT' => $i)); |
69 | 69 | } |
70 | 70 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $planet_template = tpl_parse_planet($planet); |
80 | 80 | |
81 | 81 | $planet_fleet_id = 0; |
82 | - $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet); |
|
83 | - if($fleet_list['own']['count']) |
|
82 | + $fleet_list = $planet_template['fleet_list']; //flt_get_fleets_to_planet($planet); |
|
83 | + if ($fleet_list['own']['count']) |
|
84 | 84 | { |
85 | 85 | $planet_fleet_id = "p{$fleet_id}"; |
86 | 86 | $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | UNIT_DEFENCE => 'defense', |
143 | 143 | ); |
144 | 144 | |
145 | - foreach($show_groups as $unit_group_id => $mode) |
|
145 | + foreach ($show_groups as $unit_group_id => $mode) |
|
146 | 146 | { |
147 | 147 | $template->assign_block_vars('prods', array( |
148 | 148 | 'NAME' => $lang['tech'][$unit_group_id], |
149 | 149 | )); |
150 | 150 | $unit_group = get_unit_param('techtree', $unit_group_id); |
151 | - foreach($unit_group as $unit_id) |
|
151 | + foreach ($unit_group as $unit_id) |
|
152 | 152 | { |
153 | 153 | $unit_count = $unit_count_abs = 0; |
154 | 154 | $block_vars = array(); |
155 | 155 | $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED); |
156 | 156 | // $unit_db_name = pname_resource_name($unit_id); |
157 | - foreach($planets as $planet) |
|
157 | + foreach ($planets as $planet) |
|
158 | 158 | { |
159 | 159 | $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true); |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $level_plus['LEVEL_PLUS_GREEN'] = 0; |
164 | 164 | |
165 | 165 | $level_plus['PERCENT'] = $unit_is_factory ? ($unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1) : -1; |
166 | - switch($mode) |
|
166 | + switch ($mode) |
|
167 | 167 | { |
168 | 168 | /* |
169 | 169 | case 'structures': |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | |
179 | 179 | /** @noinspection PhpMissingBreakStatementInspection */ |
180 | 180 | case 'fleet': |
181 | - $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id]<=0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
181 | + $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id] <= 0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
182 | 182 | $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'] += $level_plus['LEVEL_PLUS_YELLOW']; |
183 | 183 | |
184 | 184 | case 'structures': |
185 | 185 | case 'defense': |
186 | 186 | $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id]; |
187 | - if($level_plus_build) |
|
187 | + if ($level_plus_build) |
|
188 | 188 | { |
189 | 189 | $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}"; |
190 | 190 | // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}"; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']); |
206 | 206 | } |
207 | 207 | |
208 | - if($unit_count_abs) |
|
208 | + if ($unit_count_abs) |
|
209 | 209 | { |
210 | 210 | $template->assign_block_vars('prods', array( |
211 | 211 | 'ID' => $unit_id, |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | 'MODE' => $mode, |
215 | 215 | )); |
216 | 216 | |
217 | - foreach($block_vars as $block_var) |
|
217 | + foreach ($block_vars as $block_var) |
|
218 | 218 | { |
219 | 219 | $template->assign_block_vars('prods.planet', $block_var); |
220 | 220 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'factor' => 1.5, |
16 | 16 | ), |
17 | 17 | P_UNIT_PRODUCTION => array( |
18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | 20 | ), |
21 | 21 | P_MINING_IS_MANAGED => true, |
22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'factor' => 1.6, |
34 | 34 | ), |
35 | 35 | P_UNIT_PRODUCTION => array( |
36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | 38 | ), |
39 | 39 | P_MINING_IS_MANAGED => true, |
40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'factor' => 1.5, |
52 | 52 | ), |
53 | 53 | P_UNIT_PRODUCTION => array( |
54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
56 | 56 | ), |
57 | 57 | P_MINING_IS_MANAGED => true, |
58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'factor' => 1.5, |
70 | 70 | ), |
71 | 71 | P_UNIT_PRODUCTION => array( |
72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | 73 | ), |
74 | 74 | P_MINING_IS_MANAGED => true, |
75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'factor' => 1.8, |
88 | 88 | ), |
89 | 89 | P_UNIT_PRODUCTION => array( |
90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
92 | 92 | ), |
93 | 93 | P_MINING_IS_MANAGED => true, |
94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'factor' => 2, |
106 | 106 | ), |
107 | 107 | 'storage' => array( |
108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | 109 | ), |
110 | 110 | ), |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'factor' => 2, |
122 | 122 | ), |
123 | 123 | 'storage' => array( |
124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'factor' => 2, |
138 | 138 | ), |
139 | 139 | 'storage' => array( |
140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | 141 | ), |
142 | 142 | ), |
143 | 143 |
@@ -2,25 +2,25 @@ discard block |
||
2 | 2 | |
3 | 3 | // ------------------------------------------------------------------------------------------------------------------------------ |
4 | 4 | function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) { |
5 | - if(file_exists($dir_name)) { |
|
5 | + if (file_exists($dir_name)) { |
|
6 | 6 | $dir = opendir($dir_name); |
7 | - while(($file = readdir($dir)) !== false) { |
|
8 | - if($file == '..' || $file == '.') { |
|
7 | + while (($file = readdir($dir)) !== false) { |
|
8 | + if ($file == '..' || $file == '.') { |
|
9 | 9 | continue; |
10 | 10 | } |
11 | 11 | |
12 | 12 | $full_filename = $dir_name . $file; |
13 | - if($modules && is_dir($full_filename)) { |
|
14 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
13 | + if ($modules && is_dir($full_filename)) { |
|
14 | + if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
15 | 15 | require_once($full_filename); |
16 | 16 | // Registering module |
17 | - if(class_exists($file)) { |
|
17 | + if (class_exists($file)) { |
|
18 | 18 | new $file($full_filename); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $extension = substr($full_filename, -strlen($load_extension)); |
23 | - if($extension == $load_extension) { |
|
23 | + if ($extension == $load_extension) { |
|
24 | 24 | require_once($full_filename); |
25 | 25 | } |
26 | 26 | } |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function init_update(&$config) { |
41 | 41 | $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; |
42 | - if(file_exists($update_file)) { |
|
43 | - if(filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | - if(defined('IN_ADMIN')) { |
|
42 | + if (file_exists($update_file)) { |
|
43 | + if (filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | + if (defined('IN_ADMIN')) { |
|
45 | 45 | sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована |
46 | - if(SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { |
|
46 | + if (SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { |
|
47 | 47 | $config->db_saveItem('var_db_update_end', SN_TIME_NOW + ($config->upd_lock_time ? $config->upd_lock_time : 300)); |
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $current_time = time(); |
54 | 54 | $config->db_saveItem('var_db_update', $current_time); |
55 | 55 | $config->db_saveItem('var_db_update_end', $current_time); |
56 | - } elseif(filemtime($update_file) > $config->var_db_update) { |
|
56 | + } elseif (filemtime($update_file) > $config->var_db_update) { |
|
57 | 57 | $timeout = $config->var_db_update_end - SN_TIME_NOW; |
58 | 58 | die( |
59 | 59 | "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br /> |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | |
15 | 15 | $no_data = array('user' => false, 'planet' => false, 'que' => false); |
16 | 16 | |
17 | - if(!$planet) { |
|
17 | + if (!$planet) { |
|
18 | 18 | return $no_data; |
19 | 19 | } |
20 | 20 | |
21 | - if(!$no_user_update) { |
|
21 | + if (!$no_user_update) { |
|
22 | 22 | $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user); |
23 | - if(!$user) { |
|
23 | + if (!$user) { |
|
24 | 24 | // TODO - Убрать позже |
25 | 25 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>'); |
26 | 26 | $backtrace = debug_backtrace(); |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | $user = db_user_by_id($user, !$simulation, '*', true); |
33 | 33 | } |
34 | 34 | |
35 | - if(empty($user['id'])) { |
|
35 | + if (empty($user['id'])) { |
|
36 | 36 | return $no_data; |
37 | 37 | } |
38 | 38 | |
39 | - if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
39 | + if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
40 | 40 | $planet = db_planet_by_vector($planet, '', !$simulation); |
41 | 41 | } else { |
42 | 42 | $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet); |
43 | 43 | $planet = db_planet_by_id($planet, !$simulation); |
44 | 44 | } |
45 | - if(!is_array($planet) || !isset($planet['id'])) { |
|
45 | + if (!is_array($planet) || !isset($planet['id'])) { |
|
46 | 46 | return $no_data; |
47 | 47 | } |
48 | 48 | |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | RES_DEUTERIUM => 0, |
66 | 66 | ); |
67 | 67 | |
68 | - switch($planet['planet_type']) { |
|
68 | + switch ($planet['planet_type']) { |
|
69 | 69 | case PT_PLANET: |
70 | - foreach($resources_increase as $resource_id => &$increment) { |
|
70 | + foreach ($resources_increase as $resource_id => &$increment) { |
|
71 | 71 | $resource_name = pname_resource_name($resource_id); |
72 | 72 | $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600; |
73 | 73 | $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name]; |
74 | 74 | $increment = min($increment, max(0, $store_free)); |
75 | 75 | |
76 | - if($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
76 | + if ($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
77 | 77 | global $debug; |
78 | 78 | $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501); |
79 | 79 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора |
96 | 96 | $planet['field_current'] = 0; |
97 | 97 | $sn_group_build_allow = sn_get_groups('build_allow'); |
98 | - if(is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
99 | - foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
98 | + if (is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
99 | + foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
100 | 100 | $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true); |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if($simulation) { |
|
104 | + if ($simulation) { |
|
105 | 105 | return array('user' => $user, 'planet' => $planet, 'que' => $que); |
106 | 106 | } |
107 | 107 |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | |
13 | 13 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
14 | 14 | |
15 | - if($in_admin) |
|
15 | + if ($in_admin) |
|
16 | 16 | { |
17 | 17 | $quest_id = sys_get_param_id('id'); |
18 | 18 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
19 | - if(!empty($quest_name)) |
|
19 | + if (!empty($quest_name)) |
|
20 | 20 | { |
21 | 21 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
22 | 22 | try |
23 | 23 | { |
24 | 24 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
25 | 25 | $quest_rewards = array(); |
26 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) |
|
26 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) |
|
27 | 27 | { |
28 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) |
|
28 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) |
|
29 | 29 | { |
30 | 30 | throw new Exception($lang['qst_adm_err_reward_type']); |
31 | 31 | } |
32 | 32 | |
33 | - if($quest_rewards_amount < 0) |
|
33 | + if ($quest_rewards_amount < 0) |
|
34 | 34 | { |
35 | 35 | throw new Exception($lang['qst_adm_err_reward_amount']); |
36 | 36 | } |
37 | - elseif($quest_rewards_amount > 0) |
|
37 | + elseif ($quest_rewards_amount > 0) |
|
38 | 38 | { |
39 | 39 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
40 | 40 | } |
41 | 41 | } |
42 | - if(empty($quest_rewards)) |
|
42 | + if (empty($quest_rewards)) |
|
43 | 43 | { |
44 | 44 | throw new Exception($lang['qst_adm_err_reward_empty']); |
45 | 45 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | $quest_rewards = implode(';', $quest_rewards); |
48 | 48 | |
49 | 49 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
50 | - if(!in_array($quest_unit_id, $quest_units_allowed)) |
|
50 | + if (!in_array($quest_unit_id, $quest_units_allowed)) |
|
51 | 51 | { |
52 | 52 | throw new Exception($lang['qst_adm_err_unit_id']); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
56 | - if($quest_unit_amount <= 0) |
|
56 | + if ($quest_unit_amount <= 0) |
|
57 | 57 | { |
58 | 58 | throw new Exception($lang['qst_adm_err_unit_amount']); |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // TODO: Change quest type |
63 | 63 | $quest_type = 0; |
64 | 64 | |
65 | - if($mode == 'edit') |
|
65 | + if ($mode == 'edit') |
|
66 | 66 | { |
67 | 67 | $quest_name = db_escape($quest_name); |
68 | 68 | $quest_description = db_escape($quest_description); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $mode = ''; |
104 | 104 | }; |
105 | 105 | |
106 | - switch($mode) |
|
106 | + switch ($mode) |
|
107 | 107 | { |
108 | 108 | case 'del': |
109 | 109 | doquery("DELETE FROM {{quest}} WHERE `quest_id` = {$quest_id} LIMIT 1;"); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true); |
121 | 121 | $config->db_saveItem('quest_total', $query['count']); |
122 | 122 | } |
123 | - elseif(!$user_id) |
|
123 | + elseif (!$user_id) |
|
124 | 124 | { |
125 | 125 | $user_id = $user['id']; |
126 | 126 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'IN_ADMIN' => $in_admin, |
135 | 135 | )); |
136 | 136 | |
137 | - if($quest) |
|
137 | + if ($quest) |
|
138 | 138 | { |
139 | 139 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
140 | 140 | } |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | $quest_templatized['quest_rewards_list'] = array(); |
144 | 144 | } |
145 | 145 | |
146 | - foreach($quest_reward_allowed as $unit_id) |
|
146 | + foreach ($quest_reward_allowed as $unit_id) |
|
147 | 147 | { |
148 | 148 | $found = false; |
149 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) |
|
149 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) |
|
150 | 150 | { |
151 | - if($quest_templatized_reward['ID'] == $unit_id) |
|
151 | + if ($quest_templatized_reward['ID'] == $unit_id) |
|
152 | 152 | { |
153 | 153 | $found = true; |
154 | 154 | break; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - if(!$found) |
|
158 | + if (!$found) |
|
159 | 159 | { |
160 | 160 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
161 | 161 | 'ID' => $unit_id, |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | |
168 | 168 | qst_assign_to_template($template, $quest_templatized); |
169 | 169 | |
170 | - foreach($quest_list as $quest_data) |
|
170 | + foreach ($quest_list as $quest_data) |
|
171 | 171 | { |
172 | 172 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
173 | 173 | } |
174 | 174 | |
175 | - foreach($quest_units_allowed as $unit_id) |
|
175 | + foreach ($quest_units_allowed as $unit_id) |
|
176 | 176 | { |
177 | 177 | $template->assign_block_vars('allowed_unit', array( |
178 | 178 | 'ID' => $unit_id, |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | { |
186 | 186 | $quest_list = array(); |
187 | 187 | |
188 | - if($user_id) |
|
188 | + if ($user_id) |
|
189 | 189 | { |
190 | - if($status !== false) |
|
190 | + if ($status !== false) |
|
191 | 191 | { |
192 | 192 | $query_add_where = "AND qs.quest_status_status "; |
193 | - if($status == null) |
|
193 | + if ($status == null) |
|
194 | 194 | { |
195 | 195 | $query_add_where .= "IS NULL"; |
196 | 196 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ;" |
211 | 211 | ); |
212 | 212 | |
213 | - while($quest = db_fetch($query)) |
|
213 | + while ($quest = db_fetch($query)) |
|
214 | 214 | { |
215 | 215 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
216 | 216 | } |
@@ -220,16 +220,16 @@ discard block |
||
220 | 220 | |
221 | 221 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) |
222 | 222 | { |
223 | - if($block_name) |
|
223 | + if ($block_name) |
|
224 | 224 | { |
225 | 225 | $template->assign_block_vars($block_name, $quest_templatized); |
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | 229 | $template->assign_vars($quest_templatized); |
230 | - if(!empty($quest_templatized['quest_rewards_list'])) |
|
230 | + if (!empty($quest_templatized['quest_rewards_list'])) |
|
231 | 231 | { |
232 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) |
|
232 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) |
|
233 | 233 | { |
234 | 234 | $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
235 | 235 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | global $lang; |
252 | 252 | |
253 | 253 | $tmp = array(); |
254 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) |
|
254 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) |
|
255 | 255 | { |
256 | 256 | $tmp[] = array( |
257 | 257 | 'ID' => $quest_reward_id, |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | function qst_active_triggers($quest_list) |
279 | 279 | { |
280 | 280 | $quest_triggers = array(); |
281 | - foreach($quest_list as $quest_id => $quest) |
|
281 | + foreach ($quest_list as $quest_id => $quest) |
|
282 | 282 | { |
283 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) |
|
283 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) |
|
284 | 284 | { |
285 | 285 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
286 | 286 | $quest_triggers[$quest_id] = $quest_unit_id; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | function qst_reward(&$user, &$rewards, &$quest_list) |
294 | 294 | { |
295 | - if(empty($rewards)) return; |
|
295 | + if (empty($rewards)) return; |
|
296 | 296 | |
297 | 297 | global $lang; |
298 | 298 | |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | $total_rewards = array(); |
301 | 301 | $comment_dm = ''; |
302 | 302 | |
303 | - foreach($rewards as $quest_id => $user_data) |
|
304 | - foreach($user_data as $user_id => $planet_data) |
|
305 | - foreach($planet_data as $planet_id => $reward_list) |
|
303 | + foreach ($rewards as $quest_id => $user_data) |
|
304 | + foreach ($user_data as $user_id => $planet_data) |
|
305 | + foreach ($planet_data as $planet_id => $reward_list) |
|
306 | 306 | { |
307 | 307 | $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
308 | 308 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
309 | 309 | |
310 | 310 | $comment_reward = array(); |
311 | - foreach($reward_list as $unit_id => $unit_amount) |
|
311 | + foreach ($reward_list as $unit_id => $unit_amount) |
|
312 | 312 | { |
313 | 313 | $comment_reward[] = $unit_amount . ' ' . $lang['tech'][$unit_id]; |
314 | 314 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
@@ -326,23 +326,23 @@ discard block |
||
326 | 326 | |
327 | 327 | $group_resources = sn_get_groups('resources_loot'); |
328 | 328 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
329 | - if(!empty($total_rewards)) |
|
329 | + if (!empty($total_rewards)) |
|
330 | 330 | { |
331 | - foreach($total_rewards as $user_id => $planet_data) |
|
331 | + foreach ($total_rewards as $user_id => $planet_data) |
|
332 | 332 | { |
333 | 333 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
334 | - foreach($planet_data as $planet_id => $unit_data) |
|
334 | + foreach ($planet_data as $planet_id => $unit_data) |
|
335 | 335 | { |
336 | 336 | $local_changeset = array(); |
337 | - foreach($unit_data as $unit_id => $unit_amount) |
|
337 | + foreach ($unit_data as $unit_id => $unit_amount) |
|
338 | 338 | { |
339 | - if(!isset($quest_rewards_allowed[$unit_id])) continue; |
|
339 | + if (!isset($quest_rewards_allowed[$unit_id])) continue; |
|
340 | 340 | |
341 | - if($unit_id == RES_DARK_MATTER) |
|
341 | + if ($unit_id == RES_DARK_MATTER) |
|
342 | 342 | { |
343 | 343 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
344 | 344 | } |
345 | - elseif(isset($group_resources[$unit_id])) |
|
345 | + elseif (isset($group_resources[$unit_id])) |
|
346 | 346 | { |
347 | 347 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
348 | 348 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | // unit |
354 | 354 | } |
355 | 355 | |
356 | - if(!empty($local_changeset)) |
|
356 | + if (!empty($local_changeset)) |
|
357 | 357 | { |
358 | 358 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
359 | 359 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
@@ -85,28 +85,28 @@ discard block |
||
85 | 85 | function rpg_points_change($user_id, $change_type, $dark_matter, $comment = false, $already_changed = false) { |
86 | 86 | global $debug, $config, $dm_change_legit, $user; |
87 | 87 | |
88 | - if(!$user_id) { |
|
88 | + if (!$user_id) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | 92 | $dm_change_legit = true; |
93 | 93 | $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER); |
94 | 94 | |
95 | - if($already_changed) { |
|
95 | + if ($already_changed) { |
|
96 | 96 | $rows_affected = 1; |
97 | 97 | } else { |
98 | 98 | $changeset = array(); |
99 | 99 | $a_user = db_user_by_id($user_id, true); |
100 | - if($dark_matter < 0) { |
|
100 | + if ($dark_matter < 0) { |
|
101 | 101 | $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true); |
102 | 102 | $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false; |
103 | 103 | $metamatter_to_reduce = -$dark_matter - $dark_matter_exists; |
104 | - if($metamatter_to_reduce > 0) { |
|
104 | + if ($metamatter_to_reduce > 0) { |
|
105 | 105 | $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER); |
106 | - if($metamatter_exists < $metamatter_to_reduce) { |
|
106 | + if ($metamatter_exists < $metamatter_to_reduce) { |
|
107 | 107 | $debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER); |
108 | 108 | } |
109 | - if(is_array($comment)) { |
|
109 | + if (is_array($comment)) { |
|
110 | 110 | $comment = call_user_func_array('sprintf', $comment); |
111 | 111 | } |
112 | 112 | // mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment); |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | $rows_affected = classSupernova::$db->db_affected_rows(); |
122 | 122 | } |
123 | 123 | |
124 | - if($rows_affected || !$dark_matter) { |
|
124 | + if ($rows_affected || !$dark_matter) { |
|
125 | 125 | $page_url = db_escape($_SERVER['SCRIPT_NAME']); |
126 | - if(is_array($comment)) { |
|
126 | + if (is_array($comment)) { |
|
127 | 127 | $comment = call_user_func_array('sprintf', $comment); |
128 | 128 | } |
129 | 129 | $comment = db_escape($comment); |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | {$dark_matter}, '{$comment}', '{$page_url}', {$user_id} |
138 | 138 | );"); |
139 | 139 | |
140 | - if($user['id'] == $user_id) { |
|
140 | + if ($user['id'] == $user_id) { |
|
141 | 141 | $user['dark_matter'] += $dark_matter; |
142 | 142 | } |
143 | 143 | |
144 | - if($dark_matter > 0) { |
|
144 | + if ($dark_matter > 0) { |
|
145 | 145 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1 FOR UPDATE;", '', true); |
146 | - if($old_referral['id']) { |
|
146 | + if ($old_referral['id']) { |
|
147 | 147 | doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter}' WHERE `id` = {$user_id} LIMIT 1;"); |
148 | 148 | $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1;", '', true); |
149 | 149 | |
150 | 150 | $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0); |
151 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
151 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
152 | 152 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}"); |
153 | 153 | } |
154 | 154 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | $q = 1.03; |
167 | 167 | |
168 | - switch($type) |
|
168 | + switch ($type) |
|
169 | 169 | { |
170 | 170 | case RPG_STRUCTURE: |
171 | 171 | $field_level = 'lvl_minier'; |
@@ -203,19 +203,19 @@ discard block |
||
203 | 203 | |
204 | 204 | $xp = &$user[$field_xp]; |
205 | 205 | |
206 | - if($xp_to_add) |
|
206 | + if ($xp_to_add) |
|
207 | 207 | { |
208 | 208 | $xp += $xp_to_add; |
209 | 209 | db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'"); |
210 | 210 | } |
211 | 211 | |
212 | 212 | $level = $user[$field_level]; |
213 | - while($xp > rpg_xp_for_level($level + 1, $b1, $q)) |
|
213 | + while ($xp > rpg_xp_for_level($level + 1, $b1, $q)) |
|
214 | 214 | { |
215 | 215 | $level++; |
216 | 216 | } |
217 | 217 | $level -= $user[$field_level]; |
218 | - if($level > 0) |
|
218 | + if ($level > 0) |
|
219 | 219 | { |
220 | 220 | db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'"); |
221 | 221 | rpg_points_change($user['id'], $type, $level * 1000, $comment); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | function rpg_xp_for_level($level, $b1, $q) |
227 | 227 | { |
228 | - return floor($b1 * (pow($q, $level) - 1)/($q - 1)); |
|
228 | + return floor($b1 * (pow($q, $level) - 1) / ($q - 1)); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | function rpg_get_miner_xp($level) |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
27 | 27 | false, 'id, username'); |
28 | 28 | // while ($u = db_fetch($query)) |
29 | - foreach($query as $u) |
|
29 | + foreach ($query as $u) |
|
30 | 30 | { |
31 | 31 | $sendList[] = $u['id']; |
32 | 32 | $list .= "<br>{$u['username']} "; |
@@ -41,19 +41,19 @@ discard block |
||
41 | 41 | { |
42 | 42 | global $config, $user, $sn_message_class_list; |
43 | 43 | |
44 | - if(!$owners) |
|
44 | + if (!$owners) |
|
45 | 45 | { |
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $timestamp = $timestamp ? $timestamp : SN_TIME_NOW; |
50 | 50 | $sender = intval($sender); |
51 | - if(!is_array($owners)) |
|
51 | + if (!is_array($owners)) |
|
52 | 52 | { |
53 | 53 | $owners = array($owners); |
54 | 54 | } |
55 | 55 | |
56 | - if(!$escaped) |
|
56 | + if (!$escaped) |
|
57 | 57 | { |
58 | 58 | $from = db_escape($from); |
59 | 59 | $subject = db_escape($subject); |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | |
70 | 70 | $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name']; |
71 | 71 | |
72 | - if($owners[0] == '*') |
|
72 | + if ($owners[0] == '*') |
|
73 | 73 | { |
74 | - if($user['authlevel'] < 3) |
|
74 | + if ($user['authlevel'] < 3) |
|
75 | 75 | { |
76 | 76 | return false; |
77 | 77 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | foreach ($owners as $owner) |
89 | 89 | { |
90 | - if($user['id'] != $owner) |
|
90 | + if ($user['id'] != $owner) |
|
91 | 91 | { |
92 | 92 | $owner_row = db_user_by_id($owner); |
93 | 93 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | } |
98 | 98 | sys_user_options_unpack($owner_row); |
99 | 99 | |
100 | - if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
100 | + if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
101 | 101 | { |
102 | 102 | $insert_values[] = sprintf($insert_template, $owner); |
103 | 103 | } |
104 | 104 | |
105 | - if($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
105 | + if ($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
106 | 106 | { |
107 | 107 | @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true); |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - if(empty($insert_values)) |
|
111 | + if (empty($insert_values)) |
|
112 | 112 | { |
113 | 113 | return; |
114 | 114 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1"); |
120 | 120 | |
121 | - if(in_array($user['id'], $owners) || $owners[0] == '*') |
|
121 | + if (in_array($user['id'], $owners) || $owners[0] == '*') |
|
122 | 122 | { |
123 | 123 | $user[$message_class_name]++; |
124 | 124 | $user[$message_class_name_total]++; |