@@ -10,6 +10,7 @@ discard block |
||
10 | 10 | * |
11 | 11 | * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
12 | 12 | * @version 1.0 |
13 | + * @param integer $lab_require |
|
13 | 14 | */ |
14 | 15 | function eco_get_lab_max_effective_level(&$user, $lab_require) |
15 | 16 | { |
@@ -193,6 +194,9 @@ discard block |
||
193 | 194 | return $result; |
194 | 195 | } |
195 | 196 | |
197 | +/** |
|
198 | + * @param integer[] $unit_list |
|
199 | + */ |
|
196 | 200 | function eco_is_builds_in_que($planet_que, $unit_list) |
197 | 201 | { |
198 | 202 | $eco_is_builds_in_que = false; |
@@ -55,6 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | +/** |
|
59 | + * @param integer $build_mode |
|
60 | + */ |
|
58 | 61 | function que_build($user, $planet, $build_mode = BUILD_CREATE, $redirect = true) { |
59 | 62 | global $lang, $config; |
60 | 63 | |
@@ -378,6 +381,9 @@ discard block |
||
378 | 381 | return classSupernova::db_que_list_by_type_location($user_id, $planet_id, $que_type, $for_update); |
379 | 382 | } |
380 | 383 | |
384 | +/** |
|
385 | + * @param integer $unit_id |
|
386 | + */ |
|
381 | 387 | function que_add_unit($unit_id, $user = array(), $planet = array(), $build_data, $unit_level = 0, $unit_amount = 1, $build_mode = BUILD_CREATE) { |
382 | 388 | // TODO Унифицировать проверки |
383 | 389 |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | |
8 | 8 | function que_get_unit_que($unit_id) { |
9 | 9 | $que_type = false; |
10 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
11 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
10 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
11 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
12 | 12 | $que_type = $que_id; |
13 | 13 | break; |
14 | 14 | } |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
22 | - if(empty($que_data)) { |
|
22 | + if (empty($que_data)) { |
|
23 | 23 | $que_data = sn_get_groups('ques'); |
24 | 24 | $que_data = $que_data[$que_id]; |
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | $que_length = 1; |
29 | - switch($que_id) { |
|
29 | + switch ($que_id) { |
|
30 | 30 | case QUE_RESEARCH: |
31 | 31 | $que_length = classSupernova::$config->server_que_length_research + mrc_get_level($user, null, UNIT_PREMIUM); // TODO - вынести в модуль |
32 | 32 | break; |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | function eco_que_str2arr($que_str) { |
42 | 42 | $que_arr = explode(';', $que_str); |
43 | - foreach($que_arr as $que_index => &$que_item) { |
|
44 | - if($que_item) { |
|
43 | + foreach ($que_arr as $que_index => &$que_item) { |
|
44 | + if ($que_item) { |
|
45 | 45 | $que_item = explode(',', $que_item); |
46 | 46 | } else { |
47 | 47 | unset($que_arr[$que_index]); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | function eco_que_arr2str($que_arr) { |
55 | - foreach($que_arr as &$que_item) { |
|
55 | + foreach ($que_arr as &$que_item) { |
|
56 | 56 | $que_item = implode(',', $que_item); |
57 | 57 | } |
58 | 58 | |
@@ -64,28 +64,28 @@ discard block |
||
64 | 64 | $classLocale = classLocale::$lang; |
65 | 65 | |
66 | 66 | $is_autoconvert = false; |
67 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
67 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
68 | 68 | $build_mode = BUILD_CREATE; |
69 | 69 | $is_autoconvert = true; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $unit_amount_qued = 0; |
73 | 73 | try { |
74 | - if(!$user['id']) { |
|
74 | + if (!$user['id']) { |
|
75 | 75 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
76 | 76 | } |
77 | 77 | |
78 | 78 | $unit_id = sys_get_param_int('unit_id'); |
79 | - if(!$unit_id) { |
|
79 | + if (!$unit_id) { |
|
80 | 80 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
81 | 81 | } |
82 | 82 | |
83 | 83 | $que_id = que_get_unit_que($unit_id); |
84 | - if(!$que_id) { |
|
84 | + if (!$que_id) { |
|
85 | 85 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
86 | 86 | } |
87 | 87 | |
88 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
88 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
89 | 89 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
90 | 90 | } |
91 | 91 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $que_data = $que_data[$que_id]; |
94 | 94 | |
95 | 95 | // TODO Переделать под подочереди |
96 | - if($que_id == QUE_STRUCTURES) { |
|
96 | + if ($que_id == QUE_STRUCTURES) { |
|
97 | 97 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
98 | 98 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
99 | 99 | |
100 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
101 | - throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
100 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
101 | + throw new exception('{Это здание нельзя строить на '.($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | // TODO Разделить очереди для Верфи и Обороны |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
109 | 109 | $user = DBStaticUser::db_user_by_id($user['id']); |
110 | 110 | // Это нужно, что бы заблокировать планету от списания ресурсов |
111 | - if(isset($planet['id']) && $planet['id']) { |
|
111 | + if (isset($planet['id']) && $planet['id']) { |
|
112 | 112 | $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true); |
113 | 113 | } else { |
114 | 114 | $planet['id'] = 0; |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
121 | 121 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
122 | 122 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
123 | - if(count($in_que) >= $que_max_length) { |
|
123 | + if (count($in_que) >= $que_max_length) { |
|
124 | 124 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
125 | 125 | } |
126 | 126 | |
127 | 127 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
128 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
128 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
129 | 129 | case BUILD_ALLOWED: |
130 | 130 | break; |
131 | 131 | case BUILD_UNIT_BUSY: |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
134 | 134 | // case BUILD_REQUIRE_NOT_MEET: |
135 | 135 | default: |
136 | - if($build_mode == BUILD_CREATE) { |
|
136 | + if ($build_mode == BUILD_CREATE) { |
|
137 | 137 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
138 | 138 | } |
139 | 139 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -143,33 +143,33 @@ discard block |
||
143 | 143 | $unit_amount_qued = $unit_amount; |
144 | 144 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
145 | 145 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
146 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
147 | - if($unit_level >= $unit_max) { |
|
146 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
147 | + if ($unit_level >= $unit_max) { |
|
148 | 148 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
149 | 149 | } |
150 | 150 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
151 | 151 | } |
152 | 152 | |
153 | - if($unit_amount < 1) { |
|
153 | + if ($unit_amount < 1) { |
|
154 | 154 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
155 | 155 | } |
156 | 156 | |
157 | 157 | // TODO Переделать eco_unit_busy для всех типов зданий |
158 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
158 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
159 | 159 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
160 | - if(in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) { |
|
160 | + if (in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) { |
|
161 | 161 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
162 | 162 | $used_silo = 0; |
163 | - foreach($group_missile as $missile_id) { |
|
163 | + foreach ($group_missile as $missile_id) { |
|
164 | 164 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
165 | 165 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
166 | 166 | } |
167 | 167 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
168 | - if($free_silo <= 0) { |
|
168 | + if ($free_silo <= 0) { |
|
169 | 169 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
170 | 170 | } |
171 | 171 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
172 | - if($free_silo < $unit_size) { |
|
172 | + if ($free_silo < $unit_size) { |
|
173 | 173 | throw new exception("{В ракетной шахте нет места для {$classLocale['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
174 | 174 | } |
175 | 175 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | $unit_level = $new_unit_level = 0; |
178 | 178 | } else { |
179 | 179 | $unit_amount = 1; |
180 | - if($que_id == QUE_STRUCTURES) { |
|
180 | + if ($que_id == QUE_STRUCTURES) { |
|
181 | 181 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
182 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
182 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
183 | 183 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
184 | 184 | } |
185 | 185 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | |
192 | 192 | $exchange = array(); |
193 | 193 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
194 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
194 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
195 | 195 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
196 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
197 | - throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
196 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
197 | + throw new exception("{Нет хватает ".($market_get_autoconvert_cost - $dark_matter)."ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | !get_unit_param($unit_id, P_STACKABLE) ? $unit_amount = 1 : false; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $resource_exchange_rates = array(); |
204 | 204 | $resource_diff = array(); |
205 | 205 | $all_positive = true; |
206 | - foreach($resources_loot as $resource_id) { |
|
206 | + foreach ($resources_loot as $resource_id) { |
|
207 | 207 | $resource_db_name = pname_resource_name($resource_id); |
208 | 208 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
209 | 209 | $resource_exchange_rates[$resource_id] = classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
212 | 212 | } |
213 | 213 | // Нужна автоконвертация |
214 | - if($all_positive) { |
|
214 | + if ($all_positive) { |
|
215 | 215 | $is_autoconvert = false; |
216 | 216 | } else { |
217 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
218 | - if($resource_diff_amount >= 0) { |
|
217 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
218 | + if ($resource_diff_amount >= 0) { |
|
219 | 219 | continue; |
220 | 220 | } |
221 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
222 | - if($resource_got_amount <= 0) { |
|
221 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
222 | + if ($resource_got_amount <= 0) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | $is_autoconvert_ok = true; |
238 | - foreach($resource_diff as $resource_diff_amount2) { |
|
239 | - if($resource_diff_amount2 < 0) { |
|
238 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
239 | + if ($resource_diff_amount2 < 0) { |
|
240 | 240 | $is_autoconvert_ok = false; |
241 | 241 | break; |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | - if($is_autoconvert_ok) { |
|
245 | + if ($is_autoconvert_ok) { |
|
246 | 246 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
247 | 247 | $build_data['CAN'][$build_mode] = $unit_amount; |
248 | 248 | } else { |
@@ -251,19 +251,19 @@ discard block |
||
251 | 251 | } |
252 | 252 | } |
253 | 253 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
254 | - if($unit_amount <= 0) { |
|
254 | + if ($unit_amount <= 0) { |
|
255 | 255 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
256 | 256 | } |
257 | 257 | |
258 | - if($new_unit_level < 0) { |
|
258 | + if ($new_unit_level < 0) { |
|
259 | 259 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
260 | 260 | } |
261 | 261 | |
262 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
262 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
263 | 263 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
264 | 264 | } |
265 | 265 | |
266 | - if($is_autoconvert) { |
|
266 | + if ($is_autoconvert) { |
|
267 | 267 | ksort($exchange); |
268 | 268 | ksort($resource_got); |
269 | 269 | db_change_resources( |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | $unit_amount_qued = 0; |
285 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
285 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
286 | 286 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
287 | 287 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
288 | 288 | $unit_amount -= $place; |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | |
293 | 293 | sn_db_transaction_commit(); |
294 | 294 | |
295 | - if($redirect) { |
|
296 | - sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
|
295 | + if ($redirect) { |
|
296 | + sys_redirect("{$_SERVER['PHP_SELF']}?mode=".sys_get_param_str('mode')."&ally_id=".sys_get_param_id('ally_id')); |
|
297 | 297 | die(); |
298 | 298 | } |
299 | 299 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | 'STATUS' => ERR_NONE, |
302 | 302 | 'MESSAGE' => '{Строительство начато}', |
303 | 303 | ); |
304 | - } catch(Exception $e) { |
|
304 | + } catch (Exception $e) { |
|
305 | 305 | sn_db_transaction_rollback(); |
306 | 306 | $operation_result = array( |
307 | 307 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | ); |
310 | 310 | } |
311 | 311 | |
312 | - if(!empty($operation_result['MESSAGE'])) { |
|
313 | - $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . classLocale::$lang['tech'][$unit_id] . ']'; |
|
312 | + if (!empty($operation_result['MESSAGE'])) { |
|
313 | + $operation_result['MESSAGE'] .= ' '.($unit_amount_qued ? $unit_amount_qued : $unit_amount).'x['.classLocale::$lang['tech'][$unit_id].']'; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | return $operation_result; |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | function que_recalculate($old_que) { |
321 | 321 | $new_que = array(); |
322 | 322 | |
323 | - if(!is_array($old_que['items'])) { |
|
323 | + if (!is_array($old_que['items'])) { |
|
324 | 324 | return $new_que; |
325 | 325 | } |
326 | - foreach($old_que['items'] as $row) { |
|
327 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
326 | + foreach ($old_que['items'] as $row) { |
|
327 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
328 | 328 | continue; |
329 | 329 | } |
330 | 330 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | |
336 | 336 | $last_id = count($new_que['items']) - 1; |
337 | 337 | |
338 | - if($row['que_planet_id']) { |
|
338 | + if ($row['que_planet_id']) { |
|
339 | 339 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
340 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
340 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
341 | 341 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
342 | 342 | } |
343 | 343 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -375,14 +375,14 @@ discard block |
||
375 | 375 | $que_type = que_get_unit_que($unit_id); |
376 | 376 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
377 | 377 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
378 | - if(is_numeric($planet_id)) { |
|
378 | + if (is_numeric($planet_id)) { |
|
379 | 379 | DBStaticPlanet::db_planet_update_set_by_id( |
380 | 380 | $planet_id, |
381 | 381 | array( |
382 | 382 | 'que_processed' => SN_TIME_NOW, |
383 | 383 | ) |
384 | 384 | ); |
385 | - } elseif(is_numeric($user['id'])) { |
|
385 | + } elseif (is_numeric($user['id'])) { |
|
386 | 386 | DBStaticUser::db_user_set_by_id( |
387 | 387 | $user['id'], |
388 | 388 | array( |
@@ -417,17 +417,17 @@ discard block |
||
417 | 417 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
418 | 418 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
419 | 419 | |
420 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
420 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
421 | 421 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
422 | 422 | |
423 | - foreach($que as $que_item) { |
|
423 | + foreach ($que as $que_item) { |
|
424 | 424 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
425 | 425 | |
426 | - if($que_item['que_planet_id_origin']) { |
|
426 | + if ($que_item['que_planet_id_origin']) { |
|
427 | 427 | $planet['id'] = $que_item['que_planet_id_origin']; |
428 | 428 | } |
429 | 429 | |
430 | - if(!isset($planets_locked[$planet['id']])) { |
|
430 | + if (!isset($planets_locked[$planet['id']])) { |
|
431 | 431 | $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet; |
432 | 432 | } |
433 | 433 | |
@@ -443,19 +443,19 @@ discard block |
||
443 | 443 | ) |
444 | 444 | ); |
445 | 445 | |
446 | - if(!$clear) { |
|
446 | + if (!$clear) { |
|
447 | 447 | break; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if(is_numeric($planet['id'])) { |
|
451 | + if (is_numeric($planet['id'])) { |
|
452 | 452 | DBStaticPlanet::db_planet_update_set_by_id( |
453 | 453 | $planet['id'], |
454 | 454 | array( |
455 | 455 | 'que_processed' => SN_TIME_SQL, |
456 | 456 | ) |
457 | 457 | ); |
458 | - } elseif(is_numeric($user['id'])) { |
|
458 | + } elseif (is_numeric($user['id'])) { |
|
459 | 459 | DBStaticUser::db_user_set_by_id( |
460 | 460 | $user['id'], |
461 | 461 | array( |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } else { |
469 | 469 | sn_db_transaction_rollback(); |
470 | 470 | } |
471 | - header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}" . "&ally_id=" . sys_get_param_id('ally_id')); |
|
471 | + header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}"."&ally_id=".sys_get_param_id('ally_id')); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | |
@@ -507,21 +507,21 @@ discard block |
||
507 | 507 | // TODO: Переделать для $que_type === false |
508 | 508 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
509 | 509 | |
510 | - if(!is_array($que)) { |
|
510 | + if (!is_array($que)) { |
|
511 | 511 | $que = que_get($user['id'], $planet['id'], $que_type); |
512 | 512 | } |
513 | 513 | |
514 | - if(is_array($que) && isset($que['items'])) { |
|
514 | + if (is_array($que) && isset($que['items'])) { |
|
515 | 515 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
516 | 516 | } |
517 | 517 | |
518 | - if($que) { |
|
519 | - foreach($que as $que_element) { |
|
518 | + if ($que) { |
|
519 | + foreach ($que as $que_element) { |
|
520 | 520 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - if($que_type == QUE_RESEARCH) { |
|
524 | + if ($que_type == QUE_RESEARCH) { |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | $user = DBStaticUser::db_user_by_id($user['id'], true); |
546 | 546 | |
547 | 547 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
548 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
548 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
549 | 549 | return $que; |
550 | 550 | } |
551 | 551 | |
@@ -553,12 +553,12 @@ discard block |
||
553 | 553 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
554 | 554 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
555 | 555 | $que = que_get($user['id'], $planet, $que_type_id, true); |
556 | - if(empty($que['items'])) { |
|
556 | + if (empty($que['items'])) { |
|
557 | 557 | return $que; |
558 | 558 | } |
559 | 559 | |
560 | 560 | $planet_list = array(); |
561 | - if($planet !== null) { |
|
561 | + if ($planet !== null) { |
|
562 | 562 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
563 | 563 | // TODO - от них не надо ничего, кроме ID и que_processed |
564 | 564 | $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -567,20 +567,20 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
570 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
570 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
571 | 571 | return $que; |
572 | 572 | } |
573 | 573 | |
574 | 574 | $unit_changes = array(); |
575 | - foreach($que['items'] as &$que_item) { |
|
575 | + foreach ($que['items'] as &$que_item) { |
|
576 | 576 | $que_player_id = &$que_item['que_player_id']; |
577 | 577 | $que_planet_id = intval($que_item['que_planet_id']); |
578 | 578 | |
579 | 579 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
580 | - if(!isset($que_time_left)) { |
|
580 | + if (!isset($que_time_left)) { |
|
581 | 581 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
582 | 582 | } |
583 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
583 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
584 | 584 | continue; |
585 | 585 | } |
586 | 586 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
594 | 594 | |
595 | 595 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
596 | - if($que_time_left >= $que_item['que_time_left']) { |
|
596 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
597 | 597 | // Увеличиваем количество отстроенных юнитов |
598 | 598 | $unit_processed++; |
599 | 599 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | $que_item['que_unit_amount'] -= $unit_processed; |
607 | 607 | |
608 | 608 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
609 | - if($que_item['que_unit_amount'] > 0) { |
|
609 | + if ($que_item['que_unit_amount'] > 0) { |
|
610 | 610 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
611 | 611 | $que_time_left = 0; |
612 | 612 | } |
613 | 613 | |
614 | - if($que_item['que_unit_amount'] <= 0) { |
|
614 | + if ($que_item['que_unit_amount'] <= 0) { |
|
615 | 615 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
616 | 616 | } else { |
617 | 617 | classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
@@ -626,15 +626,15 @@ discard block |
||
626 | 626 | ); |
627 | 627 | } |
628 | 628 | |
629 | - if($unit_processed) { |
|
629 | + if ($unit_processed) { |
|
630 | 630 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
631 | 631 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | - foreach($time_left as $player_id => $planet_data) { |
|
636 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
637 | - if($planet_id) { |
|
635 | + foreach ($time_left as $player_id => $planet_data) { |
|
636 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
637 | + if ($planet_id) { |
|
638 | 638 | // update planet |
639 | 639 | classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
640 | 640 | LOC_PLANET, |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | ); |
657 | 657 | } |
658 | 658 | |
659 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
660 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
659 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
660 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
661 | 661 | DBStaticUnit::dbUpdateOrInsertUnit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
662 | 662 | } |
663 | 663 | } |
@@ -667,38 +667,38 @@ discard block |
||
667 | 667 | $que = que_recalculate($que); |
668 | 668 | |
669 | 669 | // TODO: Re-enable quests for Alliances |
670 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
670 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
671 | 671 | $quest_list = qst_get_quests($user['id']); |
672 | 672 | $quest_triggers = qst_active_triggers($quest_list); |
673 | 673 | $quest_rewards = array(); |
674 | 674 | |
675 | 675 | |
676 | 676 | $xp_incoming = array(); |
677 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
678 | - foreach($planet_changes as $planet_id => $changes) { |
|
677 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
678 | + foreach ($planet_changes as $planet_id => $changes) { |
|
679 | 679 | $planet_this = $planet_id ? classSupernova::$gc->cacheOperator->db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
680 | - foreach($changes as $unit_id => $unit_value) { |
|
680 | + foreach ($changes as $unit_id => $unit_value) { |
|
681 | 681 | $que_id = que_get_unit_que($unit_id); |
682 | 682 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
683 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
683 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
684 | 684 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
685 | 685 | $build_data = $build_data[BUILD_CREATE]; |
686 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
686 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
687 | 687 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
688 | 688 | } |
689 | 689 | } |
690 | 690 | |
691 | - if(is_array($quest_triggers)) { |
|
691 | + if (is_array($quest_triggers)) { |
|
692 | 692 | // TODO: Check mutiply condition quests |
693 | 693 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
694 | - if(is_array($quest_trigger_list)) { |
|
695 | - foreach($quest_trigger_list as $quest_id) { |
|
694 | + if (is_array($quest_trigger_list)) { |
|
695 | + foreach ($quest_trigger_list as $quest_id) { |
|
696 | 696 | $quest_unit_level = $unit_level_new; |
697 | - if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
697 | + if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
698 | 698 | $quest_unit_level = DBStaticUnit::db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id); |
699 | 699 | $quest_unit_level = $quest_unit_level[$unit_id]['qty']; |
700 | 700 | } |
701 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
701 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
702 | 702 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
703 | 703 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
704 | 704 | } |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
712 | 712 | qst_reward($user, $quest_rewards, $quest_list); |
713 | 713 | |
714 | - foreach($xp_incoming as $que_id => $xp) { |
|
714 | + foreach ($xp_incoming as $que_id => $xp) { |
|
715 | 715 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
716 | 716 | } |
717 | 717 | } |
@@ -141,6 +141,9 @@ |
||
141 | 141 | "); |
142 | 142 | } |
143 | 143 | |
144 | +/** |
|
145 | + * @param string $email_unsafe |
|
146 | + */ |
|
144 | 147 | function player_create($username_unsafe, $email_unsafe, $options) { |
145 | 148 | sn_db_transaction_check(true); |
146 | 149 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Vector\Vector; |
10 | 10 | |
11 | 11 | function sys_user_vacation($user) { |
12 | - if(sys_get_param_str('vacation') == 'leave') { |
|
12 | + if (sys_get_param_str('vacation') == 'leave') { |
|
13 | 13 | if ($user['vacation'] < SN_TIME_NOW) { |
14 | 14 | $user['vacation'] = 0; |
15 | 15 | $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | - if($user['vacation']) { |
|
26 | + if ($user['vacation']) { |
|
27 | 27 | // sn_sys_logout(false, true); |
28 | 28 | // core_auth::logout(false, true); |
29 | 29 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | // TODO: Full rewrite |
54 | 54 | sn_db_transaction_start(); |
55 | 55 | $TheUser = DBStaticUser::db_user_by_id($UserID); |
56 | - if ( $TheUser['ally_id'] != 0 ) { |
|
57 | - $TheAlly = classSupernova::$db->doSelectFetchArray("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';"); |
|
56 | + if ($TheUser['ally_id'] != 0) { |
|
57 | + $TheAlly = classSupernova::$db->doSelectFetchArray("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';"); |
|
58 | 58 | $TheAlly['ally_members'] -= 1; |
59 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
59 | + if ($TheAlly['ally_members'] > 0) { |
|
60 | 60 | classSupernova::$db->doUpdateRowSet( |
61 | 61 | TABLE_ALLIANCE, |
62 | 62 | array( |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | |
78 | 78 | classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_owner' => $UserID,)); |
79 | 79 | classSupernova::$gc->db->doDeleteWhere(TABLE_MESSAGES, array('message_sender' => $UserID,)); |
80 | - classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID ,)); |
|
80 | + classSupernova::$gc->db->doDeleteWhere(TABLE_NOTES, array('owner' => $UserID,)); |
|
81 | 81 | FleetList::db_fleet_list_delete_by_owner($UserID); |
82 | - classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID ,)); |
|
83 | - classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID ,)); |
|
82 | + classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_SENDER_ID' => $UserID,)); |
|
83 | + classSupernova::$gc->db->doDeleteWhere(TABLE_BUDDY, array('BUDDY_OWNER_ID' => $UserID,)); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_USER, $UserID); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | 'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], |
182 | 182 | |
183 | - 'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), |
|
183 | + 'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']), |
|
184 | 184 | |
185 | 185 | 'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), |
186 | 186 | 'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), |
@@ -191,28 +191,28 @@ discard block |
||
191 | 191 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
192 | 192 | |
193 | 193 | $user_new = classSupernova::$gc->cacheOperator->db_ins_field_set(LOC_USER, $field_set); |
194 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
194 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
195 | 195 | $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; |
196 | 196 | $options['system'] = classSupernova::$config->LastSettedSystemPos; |
197 | - $segment_size = floor(Vector::$knownPlanets/ 3); |
|
197 | + $segment_size = floor(Vector::$knownPlanets / 3); |
|
198 | 198 | $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); |
199 | 199 | $segment++; |
200 | 200 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
201 | 201 | |
202 | 202 | // $new_planet_id = 0; |
203 | - while(true) { |
|
204 | - if($options['planet'] > Vector::$knownPlanets) { |
|
203 | + while (true) { |
|
204 | + if ($options['planet'] > Vector::$knownPlanets) { |
|
205 | 205 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
206 | 206 | $options['system']++; |
207 | 207 | } |
208 | - if($options['system'] > Vector::$knownSystems) { |
|
208 | + if ($options['system'] > Vector::$knownSystems) { |
|
209 | 209 | $options['system'] = 1; |
210 | 210 | $options['galaxy']++; |
211 | 211 | } |
212 | - $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; |
|
212 | + $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false; |
|
213 | 213 | |
214 | 214 | $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
215 | - if(!$galaxy_row['id']) { |
|
215 | + if (!$galaxy_row['id']) { |
|
216 | 216 | classSupernova::$config->db_saveItem(array( |
217 | 217 | 'LastSettedGalaxyPos' => $options['galaxy'], |
218 | 218 | 'LastSettedSystemPos' => $options['system'], |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | db_player_name_history_replace($user_new['id'], $username_unsafe); |
242 | 242 | |
243 | - if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
243 | + if (!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
244 | 244 | db_referral_insert($options['partner_id'], $user_new['id']); |
245 | 245 | } |
246 | 246 |
@@ -1,5 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | +/** |
|
4 | + * @return double |
|
5 | + */ |
|
3 | 6 | function flt_fleet_speed($user, $fleet) |
4 | 7 | { |
5 | 8 | if (!is_array($fleet)) |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | use Vector\Vector; |
9 | 9 | |
10 | 10 | function flt_fleet_speed($user, $fleet) { |
11 | - if(!is_array($fleet)) { |
|
11 | + if (!is_array($fleet)) { |
|
12 | 12 | $fleet = array($fleet => 1); |
13 | 13 | } |
14 | 14 | |
15 | 15 | $speeds = array(); |
16 | - if(!empty($fleet)) { |
|
17 | - foreach($fleet as $ship_id => $amount) { |
|
18 | - if($amount && in_array($ship_id, classSupernova::$gc->groupFleetAndMissiles)) { |
|
16 | + if (!empty($fleet)) { |
|
17 | + foreach ($fleet as $ship_id => $amount) { |
|
18 | + if ($amount && in_array($ship_id, classSupernova::$gc->groupFleetAndMissiles)) { |
|
19 | 19 | $single_ship_data = get_ship_data($ship_id, $user); |
20 | 20 | $speeds[] = $single_ship_data['speed']; |
21 | 21 | } |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | |
48 | 48 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
49 | 49 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
50 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
50 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
51 | 51 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
52 | 52 | $real_speed = $speed_percent * sqrt($fleet_speed); |
53 | 53 | |
54 | 54 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
55 | 55 | |
56 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
57 | - if(!$ship_id || !$ship_count) { |
|
56 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
57 | + if (!$ship_id || !$ship_count) { |
|
58 | 58 | continue; |
59 | 59 | } |
60 | 60 | |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { |
83 | 83 | $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks; |
84 | 84 | $config_bashing_interval = classSupernova::$config->fleet_bashing_interval; |
85 | - if(!$config_bashing_attacks) { |
|
85 | + if (!$config_bashing_attacks) { |
|
86 | 86 | // Bashing allowed - protection disabled |
87 | 87 | return FLIGHT_ALLOWED; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING; |
91 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
91 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
92 | 92 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
93 | - if(!empty($relations)) { |
|
93 | + if (!empty($relations)) { |
|
94 | 94 | $relations = $relations[$enemy['ally_id']]; |
95 | - switch($relations['alliance_diplomacy_relation']) { |
|
95 | + switch ($relations['alliance_diplomacy_relation']) { |
|
96 | 96 | case ALLY_DIPLOMACY_WAR: |
97 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
97 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
98 | 98 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY; |
99 | 99 | } else { |
100 | 100 | return FLIGHT_ALLOWED; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | |
117 | 117 | // Retrieving flying fleets |
118 | 118 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
119 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
119 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
120 | 120 | // Checking for ACS - each ACS count only once |
121 | - if($fleetBashing->group_id) { |
|
121 | + if ($fleetBashing->group_id) { |
|
122 | 122 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
123 | 123 | } else { |
124 | 124 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
129 | - if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
129 | + if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
130 | 130 | return FLIGHT_ALLOWED; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $query = DBStaticFleetBashing::db_bashing_list_get($user, $planet_dst, $time_limit); |
134 | - while($bashing_row = db_fetch($query)) { |
|
134 | + while ($bashing_row = db_fetch($query)) { |
|
135 | 135 | $bashing_list[] = $bashing_row['bashing_time']; |
136 | 136 | } |
137 | 137 | |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | $last_attack = 0; |
141 | 141 | $wave = 0; |
142 | 142 | $attack = 1; |
143 | - foreach($bashing_list as &$bash_time) { |
|
143 | + foreach ($bashing_list as &$bash_time) { |
|
144 | 144 | $attack++; |
145 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
145 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
146 | 146 | $attack = 1; |
147 | 147 | $wave++; |
148 | 148 | } |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | //TODO: try..catch |
160 | 160 | global $user; |
161 | 161 | |
162 | - if($user['vacation']) { |
|
162 | + if ($user['vacation']) { |
|
163 | 163 | return $result = FLIGHT_PLAYER_VACATION_OWN; |
164 | 164 | } |
165 | 165 | |
166 | - if(empty($fleet) || !is_array($fleet)) { |
|
166 | + if (empty($fleet) || !is_array($fleet)) { |
|
167 | 167 | return $result = FLIGHT_SHIPS_NO_SHIPS; |
168 | 168 | } |
169 | 169 | |
170 | 170 | $sn_groups_mission = sn_get_groups('missions'); |
171 | - if(!isset($sn_groups_mission[$mission])) { |
|
171 | + if (!isset($sn_groups_mission[$mission])) { |
|
172 | 172 | return $result = FLIGHT_MISSION_UNKNOWN; |
173 | 173 | } |
174 | 174 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -187,32 +187,32 @@ discard block |
||
187 | 187 | $resources = 0; |
188 | 188 | $ship_ids = classSupernova::$gc->groupFleet; |
189 | 189 | $resource_ids = sn_get_groups('resources_loot'); |
190 | - foreach($fleet as $ship_id => $ship_count) { |
|
190 | + foreach ($fleet as $ship_id => $ship_count) { |
|
191 | 191 | $is_ship = in_array($ship_id, $ship_ids); |
192 | 192 | $is_resource = in_array($ship_id, $resource_ids); |
193 | - if(!$is_ship && !$is_resource) { |
|
193 | + if (!$is_ship && !$is_resource) { |
|
194 | 194 | // TODO Спецобработчик для Капитана и модулей |
195 | 195 | // return FLIGHT_SHIPS_UNIT_WRONG; |
196 | 196 | } |
197 | 197 | |
198 | - if($ship_count < 0) { |
|
198 | + if ($ship_count < 0) { |
|
199 | 199 | return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE; |
200 | 200 | } |
201 | 201 | |
202 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
202 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
203 | 203 | // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES |
204 | 204 | return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH; |
205 | 205 | } |
206 | 206 | |
207 | - if($is_ship) { |
|
207 | + if ($is_ship) { |
|
208 | 208 | $single_ship_data = get_ship_data($ship_id, $user); |
209 | - if($single_ship_data[P_SPEED] <= 0) { |
|
209 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
210 | 210 | return $result = FLIGHT_SHIPS_UNMOVABLE; |
211 | 211 | } |
212 | 212 | $ships += $ship_count; |
213 | 213 | $recyclers += in_array($ship_id, classSupernova::$gc->groupRecyclers) ? $ship_count : 0; |
214 | 214 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
215 | - } elseif($is_resource) { |
|
215 | + } elseif ($is_resource) { |
|
216 | 216 | $resources += $ship_count; |
217 | 217 | } |
218 | 218 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | */ |
225 | 225 | |
226 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
226 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
227 | 227 | return $result = FLIGHT_RESOURCES_FORBIDDEN; |
228 | 228 | } |
229 | 229 | |
@@ -235,78 +235,78 @@ discard block |
||
235 | 235 | */ |
236 | 236 | |
237 | 237 | $speed = $options['fleet_speed_percent']; |
238 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
238 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
239 | 239 | return $result = FLIGHT_FLEET_SPEED_WRONG; |
240 | 240 | } |
241 | 241 | |
242 | 242 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
243 | 243 | |
244 | 244 | |
245 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
245 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
246 | 246 | return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH; |
247 | 247 | } |
248 | 248 | |
249 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
249 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
250 | 250 | return $result = FLIGHT_FLEET_TOO_FAR; |
251 | 251 | } |
252 | 252 | |
253 | - if($travel_data['hold'] < $resources) { |
|
253 | + if ($travel_data['hold'] < $resources) { |
|
254 | 254 | return $result = FLIGHT_FLEET_OVERLOAD; |
255 | 255 | } |
256 | 256 | |
257 | 257 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
258 | 258 | |
259 | 259 | $fleet_group = $options['fleet_group']; |
260 | - if($fleet_group) { |
|
261 | - if($mission != MT_ACS) { |
|
260 | + if ($fleet_group) { |
|
261 | + if ($mission != MT_ACS) { |
|
262 | 262 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
263 | 263 | }; |
264 | 264 | |
265 | 265 | $acs = DBStaticFleetACS::db_acs_get_by_group_id($fleet_group); |
266 | - if(!$acs['id']) { |
|
266 | + if (!$acs['id']) { |
|
267 | 267 | return $result = FLIGHT_MISSION_ACS_NOT_EXISTS; |
268 | 268 | } |
269 | 269 | |
270 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
270 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
271 | 271 | return $result = FLIGHT_MISSION_ACS_WRONG_TARGET; |
272 | 272 | } |
273 | 273 | |
274 | - if($fleet_start_time > $acs['ankunft']) { |
|
274 | + if ($fleet_start_time > $acs['ankunft']) { |
|
275 | 275 | return $result = FLIGHT_MISSION_ACS_TOO_LATE; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | 279 | $flying_fleets = $options['flying_fleets']; |
280 | - if(!$flying_fleets) { |
|
280 | + if (!$flying_fleets) { |
|
281 | 281 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
282 | 282 | } |
283 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
283 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
284 | 284 | return $result = FLIGHT_FLEET_NO_SLOTS; |
285 | 285 | } |
286 | 286 | |
287 | 287 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
288 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
288 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
289 | 289 | return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES; |
290 | 290 | } |
291 | 291 | |
292 | 292 | // Checking for no planet |
293 | - if(!$planet_dst['id_owner']) { |
|
294 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
293 | + if (!$planet_dst['id_owner']) { |
|
294 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
295 | 295 | return $result = FLIGHT_SHIPS_NO_COLONIZER; |
296 | 296 | } |
297 | 297 | |
298 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
298 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
299 | 299 | return $result = FLIGHT_ALLOWED; |
300 | 300 | } |
301 | 301 | |
302 | 302 | return $result = FLIGHT_VECTOR_NO_TARGET; |
303 | 303 | } |
304 | 304 | |
305 | - if($mission == MT_RECYCLE) { |
|
306 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
305 | + if ($mission == MT_RECYCLE) { |
|
306 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
307 | 307 | return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS; |
308 | 308 | } |
309 | - if($recyclers <= 0) { |
|
309 | + if ($recyclers <= 0) { |
|
310 | 310 | return $result = FLIGHT_SHIPS_NO_RECYCLERS; |
311 | 311 | } |
312 | 312 | |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | } |
315 | 315 | |
316 | 316 | // Got planet. Checking if it is ours |
317 | - if($planet_dst['id_owner'] == $user['id']) { |
|
318 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
317 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
318 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
319 | 319 | return $result = FLIGHT_ALLOWED; |
320 | 320 | } |
321 | 321 | |
@@ -323,19 +323,19 @@ discard block |
||
323 | 323 | } |
324 | 324 | |
325 | 325 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
326 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
326 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
327 | 327 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
328 | 328 | } |
329 | 329 | |
330 | 330 | $enemy = DBStaticUser::db_user_by_id($planet_dst['id_owner']); |
331 | 331 | // We cannot attack or send resource to users in VACATION mode |
332 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
332 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
333 | 333 | return $result = FLIGHT_PLAYER_VACATION; |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Multi IP protection |
337 | 337 | // TODO: Here we need a procedure to check proxies |
338 | - if(sys_is_multiaccount($user, $enemy)) { |
|
338 | + if (sys_is_multiaccount($user, $enemy)) { |
|
339 | 339 | return $result = FLIGHT_PLAYER_SAME_IP; |
340 | 340 | } |
341 | 341 | |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | $enemy_points = $enemy['total_points']; |
344 | 344 | |
345 | 345 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
346 | - if($mission == MT_TRANSPORT) { |
|
347 | - if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
346 | + if ($mission == MT_TRANSPORT) { |
|
347 | + if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
348 | 348 | return $result = FLIGHT_ALLOWED; |
349 | 349 | } else { |
350 | 350 | return $result = FLIGHT_PLAYER_BUFFING; |
@@ -354,66 +354,66 @@ discard block |
||
354 | 354 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
355 | 355 | |
356 | 356 | // Is it admin with planet protection? |
357 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
357 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
358 | 358 | return $result = FLIGHT_PLAYER_ADMIN; |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Okay. Now skipping protection checks for inactive longer then 1 week |
362 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
363 | - if( |
|
362 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
363 | + if ( |
|
364 | 364 | ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points) |
365 | 365 | || |
366 | 366 | (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor) |
367 | 367 | ) { |
368 | - if($mission != MT_HOLD) { |
|
368 | + if ($mission != MT_HOLD) { |
|
369 | 369 | return $result = FLIGHT_PLAYER_NOOB; |
370 | 370 | } |
371 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
371 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
372 | 372 | return $result = FLIGHT_PLAYER_NOOB; |
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Is it HOLD mission? If yes - there should be ally deposit |
378 | - if($mission == MT_HOLD) { |
|
379 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
378 | + if ($mission == MT_HOLD) { |
|
379 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
380 | 380 | return $result = FLIGHT_ALLOWED; |
381 | 381 | } |
382 | 382 | |
383 | 383 | return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT; |
384 | 384 | } |
385 | 385 | |
386 | - if($mission == MT_SPY) { |
|
386 | + if ($mission == MT_SPY) { |
|
387 | 387 | return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES; |
388 | 388 | } |
389 | 389 | |
390 | 390 | // Is it MISSILE mission? |
391 | - if($mission == MT_MISSILE) { |
|
391 | + if ($mission == MT_MISSILE) { |
|
392 | 392 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
393 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
393 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
394 | 394 | return $result = FLIGHT_MISSION_MISSILE_NO_SILO; |
395 | 395 | } |
396 | 396 | |
397 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
397 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
398 | 398 | return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
402 | 402 | $mip_range = flt_get_missile_range($user); |
403 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
403 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
404 | 404 | return $result = FLIGHT_MISSION_MISSILE_TOO_FAR; |
405 | 405 | } |
406 | 406 | |
407 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
407 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
408 | 408 | return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE; |
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
412 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
413 | 413 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
414 | 414 | } |
415 | 415 | |
416 | - if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
416 | + if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
417 | 417 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
418 | 418 | } |
419 | 419 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | $from = $from['planet']; |
441 | 441 | |
442 | 442 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
443 | - if($can_attack != FLIGHT_ALLOWED) { |
|
443 | + if ($can_attack != FLIGHT_ALLOWED) { |
|
444 | 444 | $internal_transaction ? sn_db_transaction_rollback() : false; |
445 | 445 | |
446 | 446 | return $can_attack; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
452 | 452 | |
453 | 453 | $time_on_mission = 0; |
454 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
454 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
455 | 455 | // TODO - include some checks about maximum and minumum stay_duration |
456 | 456 | $time_on_mission = $options['stay_time'] * 3600; |
457 | 457 | } |
@@ -473,14 +473,14 @@ discard block |
||
473 | 473 | $sn_group_fleet = classSupernova::$gc->groupFleet; |
474 | 474 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
475 | 475 | $planetRowFieldChanges = array(); |
476 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
477 | - if(!$amount || !$unit_id) { |
|
476 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
477 | + if (!$amount || !$unit_id) { |
|
478 | 478 | continue; |
479 | 479 | } |
480 | 480 | |
481 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
481 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
482 | 482 | DBStaticUnit::dbUpdateOrInsertUnit($unit_id, -$amount, $user, $from['id']); |
483 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
483 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
484 | 484 | $planetRowFieldChanges[$unit_id] -= $amount; |
485 | 485 | } |
486 | 486 | } |
@@ -512,16 +512,16 @@ discard block |
||
512 | 512 | |
513 | 513 | $ship_data = array(); |
514 | 514 | $fleet_array = array(); |
515 | - foreach($ship_list as $transport_id => $cork) { |
|
515 | + foreach ($ship_list as $transport_id => $cork) { |
|
516 | 516 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
517 | 517 | } |
518 | 518 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
519 | 519 | |
520 | 520 | $fleet_capacity = 0; |
521 | 521 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
522 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
522 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
523 | 523 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
524 | - if($ship_loaded) { |
|
524 | + if ($ship_loaded) { |
|
525 | 525 | $fleet_array[$transport_id] = $ship_loaded; |
526 | 526 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
527 | 527 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |
@@ -29,6 +29,9 @@ |
||
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | +/** |
|
33 | + * @param string $group_name |
|
34 | + */ |
|
32 | 35 | function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array()) |
33 | 36 | { |
34 | 37 | global $lang; |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | */ |
16 | 16 | // ---------------------------------------------------------------------------------------------------------------- |
17 | 17 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
18 | - foreach($unit_group as $unit_id) { |
|
19 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
18 | + foreach ($unit_group as $unit_id) { |
|
19 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
20 | 20 | $compress_data[$unit_id] = $unit_count; |
21 | 21 | } |
22 | 22 | } |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $classLocale = classLocale::$lang; |
27 | 27 | |
28 | 28 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
29 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
30 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
29 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
30 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
31 | 31 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
32 | 32 | } |
33 | 33 | |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | |
57 | 57 | $objFleet = $mission_data->fleet; |
58 | 58 | |
59 | - if(empty($target_user_row['id']) || empty($spying_user_row['id'])) { |
|
59 | + if (empty($target_user_row['id']) || empty($spying_user_row['id'])) { |
|
60 | 60 | $objFleet->markReturnedAndSave(); |
61 | 61 | |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | 65 | $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY); |
66 | - if($spy_probes > 0) { |
|
66 | + if ($spy_probes > 0) { |
|
67 | 67 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
68 | 68 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
69 | 69 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -81,26 +81,26 @@ discard block |
||
81 | 81 | $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} "; |
82 | 82 | $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target); |
83 | 83 | $spy_message .= "</td></tr><tr>"; |
84 | - $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>"; |
|
85 | - $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>"; |
|
84 | + $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>"; |
|
85 | + $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>"; |
|
86 | 86 | $spy_message .= "</tr><tr>"; |
87 | - $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
|
88 | - $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
|
87 | + $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>"; |
|
88 | + $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>"; |
|
89 | 89 | $spy_message .= "</tr>"; |
90 | - if($spy_diff >= 2) { |
|
91 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
|
90 | + if ($spy_diff >= 2) { |
|
91 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>"; |
|
92 | 92 | coe_compress_add_units(classSupernova::$gc->groupFleet, $target_planet_row, $combat_pack[0]); |
93 | 93 | } |
94 | - if($spy_diff >= 3) { |
|
95 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
|
94 | + if ($spy_diff >= 3) { |
|
95 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>"; |
|
96 | 96 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
97 | 97 | } |
98 | - if($spy_diff >= 5) { |
|
99 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
|
98 | + if ($spy_diff >= 5) { |
|
99 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>"; |
|
100 | 100 | } |
101 | 101 | |
102 | - if($spy_diff_empire >= 0) { |
|
103 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
|
102 | + if ($spy_diff_empire >= 0) { |
|
103 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>"; |
|
104 | 104 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
105 | 105 | } |
106 | 106 | // TODO: Наемники, губернаторы, артефакты и прочее имперское |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
109 | 109 | |
110 | 110 | $target_unit_list = 0; |
111 | - foreach(classSupernova::$gc->groupFleet as $unit_id) { |
|
111 | + foreach (classSupernova::$gc->groupFleet as $unit_id) { |
|
112 | 112 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
116 | 116 | |
117 | - if(mt_rand(0, 99) > $spy_detected) { |
|
117 | + if (mt_rand(0, 99) > $spy_detected) { |
|
118 | 118 | $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected); |
119 | 119 | $spy_detected = false; |
120 | 120 | } else { |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | |
132 | 132 | DBStaticMessages::msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message); |
133 | 133 | |
134 | - $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
|
135 | - $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
|
134 | + $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3); |
|
135 | + $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row); |
|
136 | 136 | |
137 | - if($spy_detected) { |
|
137 | + if ($spy_detected) { |
|
138 | 138 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
139 | 139 | |
140 | 140 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message); |
157 | 157 | } |
158 | 158 | |
159 | - if($spy_detected) { |
|
159 | + if ($spy_detected) { |
|
160 | 160 | $objFleet->dbDelete(); |
161 | 161 | } else { |
162 | 162 | $objFleet->markReturnedAndSave(); |
@@ -26,6 +26,10 @@ |
||
26 | 26 | return true; |
27 | 27 | } |
28 | 28 | |
29 | +/** |
|
30 | + * @param integer $mode |
|
31 | + * @param integer $mercenary_id |
|
32 | + */ |
|
29 | 33 | function mrc_mercenary_hire($mode, $user, $mercenary_id) { |
30 | 34 | global $config, $lang, $sn_powerup_buy_discounts; |
31 | 35 |
@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | |
5 | 5 | function mrc_officer_accessible(&$user, $mercenary_id) { |
6 | 6 | $mercenary_info = get_unit_param($mercenary_id); |
7 | - if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { |
|
7 | + if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { |
|
8 | 8 | return true; |
9 | 9 | } |
10 | 10 | |
11 | - if(isset($mercenary_info[P_REQUIRE])) { |
|
12 | - foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { |
|
13 | - if(mrc_get_level($user, null, $unit_id) < $unit_level) { |
|
11 | + if (isset($mercenary_info[P_REQUIRE])) { |
|
12 | + foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { |
|
13 | + if (mrc_get_level($user, null, $unit_id) < $unit_level) { |
|
14 | 14 | return false; |
15 | 15 | } |
16 | 16 | } |
@@ -26,35 +26,35 @@ discard block |
||
26 | 26 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; |
27 | 27 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); |
28 | 28 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
29 | - if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
29 | + if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
30 | 30 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR); |
31 | 31 | } |
32 | 32 | |
33 | - if(!mrc_officer_accessible($user, $mercenary_id)) { |
|
33 | + if (!mrc_officer_accessible($user, $mercenary_id)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $mercenary_level = sys_get_param_int('mercenary_level'); |
38 | - if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
38 | + if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
39 | 39 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
42 | + if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
43 | 43 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR); |
44 | 44 | } |
45 | 45 | |
46 | 46 | sn_db_transaction_start(); |
47 | 47 | |
48 | 48 | $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true); |
49 | - if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
49 | + if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
50 | 50 | throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first |
51 | - } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
51 | + } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
52 | 52 | throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error |
53 | 53 | } |
54 | 54 | |
55 | - if($mercenary_level) { |
|
55 | + if ($mercenary_level) { |
|
56 | 56 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
57 | - if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
57 | + if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
58 | 58 | $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
59 | 59 | $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
60 | 60 | } |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | } |
65 | 65 | $darkmater_cost *= $cost_alliance_multiplyer; |
66 | 66 | |
67 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
67 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
68 | 68 | throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR); |
69 | 69 | } |
70 | 70 | |
71 | - if(($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
71 | + if (($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
72 | 72 | $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id); |
73 | - if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
73 | + if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
74 | 74 | $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']); |
75 | 75 | $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER]; |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id); |
84 | 84 | } |
85 | 85 | |
86 | - if($darkmater_cost && $mercenary_level) { |
|
86 | + if ($darkmater_cost && $mercenary_level) { |
|
87 | 87 | db_unit_set_insert( |
88 | 88 | "unit_player_id = {$user['id']}, |
89 | 89 | unit_location_type = " . LOC_USER . ", |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | sn_db_transaction_commit(); |
102 | 102 | sys_redirect($_SERVER['REQUEST_URI']); |
103 | - } catch(Exception $e) { |
|
103 | + } catch (Exception $e) { |
|
104 | 104 | sn_db_transaction_rollback(); |
105 | 105 | $operation_result = array( |
106 | 106 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES; |
119 | 119 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; |
120 | 120 | |
121 | - if($mercenary_id = sys_get_param_int('mercenary_id')) { |
|
121 | + if ($mercenary_id = sys_get_param_int('mercenary_id')) { |
|
122 | 122 | $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id); |
123 | 123 | } |
124 | 124 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | $template = gettemplate('mrc_mercenary_hire', true); |
128 | 128 | |
129 | - if(!empty($operation_result)) { |
|
129 | + if (!empty($operation_result)) { |
|
130 | 130 | $template->assign_block_vars('result', $operation_result); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) { |
|
133 | + foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) { |
|
134 | 134 | $template->assign_block_vars('period', array( |
135 | 135 | 'LENGTH' => $hire_period, |
136 | 136 | 'TEXT' => classLocale::$lang['mrc_period_list'][$hire_period], |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
143 | 143 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); |
144 | 144 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
145 | - foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { |
|
145 | + foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { |
|
146 | 146 | { |
147 | 147 | $mercenary = get_unit_param($mercenary_id); |
148 | 148 | $mercenary_bonus = $mercenary['bonus']; |
149 | 149 | $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; |
150 | - switch($mercenary['bonus_type']) { |
|
150 | + switch ($mercenary['bonus_type']) { |
|
151 | 151 | case BONUS_PERCENT: |
152 | 152 | $mercenary_bonus = "{$mercenary_bonus}% "; |
153 | 153 | break; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true); |
165 | 165 | $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level); |
166 | 166 | $total_cost_old = 0; |
167 | - if($is_permanent) { |
|
167 | + if ($is_permanent) { |
|
168 | 168 | $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level); |
169 | 169 | $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer; |
170 | 170 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | )); |
194 | 194 | |
195 | 195 | $upgrade_cost = 1; |
196 | - for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { |
|
196 | + for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { |
|
197 | 197 | $total_cost = eco_get_total_cost($mercenary_id, $i); |
198 | 198 | $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer; |
199 | 199 | $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old; |
@@ -2,7 +2,9 @@ discard block |
||
2 | 2 | |
3 | 3 | function dump($value,$varname = "",$level=0,$dumper = "") |
4 | 4 | { |
5 | - if ($varname) $varname .= " = "; |
|
5 | + if ($varname) { |
|
6 | + $varname .= " = "; |
|
7 | + } |
|
6 | 8 | |
7 | 9 | if ($level==-1) |
8 | 10 | { |
@@ -13,7 +15,9 @@ discard block |
||
13 | 15 | $trans["\0"]='⊕'; |
14 | 16 | return strtr(htmlspecialchars($value),$trans); |
15 | 17 | } |
16 | - if ($level==0) $dumper = '<pre>' . $varname; |
|
18 | + if ($level==0) { |
|
19 | + $dumper = '<pre>' . $varname; |
|
20 | + } |
|
17 | 21 | |
18 | 22 | $type = gettype($value); |
19 | 23 | $dumper .= $type; |
@@ -22,9 +26,9 @@ discard block |
||
22 | 26 | { |
23 | 27 | $dumper .= '('.strlen($value).')'; |
24 | 28 | $value = dump($value,"",-1); |
25 | - } |
|
26 | - elseif ($type=='boolean') $value= ($value?'true':'false'); |
|
27 | - elseif ($type=='object') |
|
29 | + } elseif ($type=='boolean') { |
|
30 | + $value= ($value?'true':'false'); |
|
31 | + } elseif ($type=='object') |
|
28 | 32 | { |
29 | 33 | $props= get_class_vars(get_class($value)); |
30 | 34 | $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
@@ -34,8 +38,7 @@ discard block |
||
34 | 38 | $dumper .= dump($value->$key,"",$level+1); |
35 | 39 | } |
36 | 40 | $value= ''; |
37 | - } |
|
38 | - elseif ($type=='array') |
|
41 | + } elseif ($type=='array') |
|
39 | 42 | { |
40 | 43 | $dumper .= '('.count($value).')'; |
41 | 44 | foreach($value as $key=>$val) |
@@ -46,7 +49,9 @@ discard block |
||
46 | 49 | $value= ''; |
47 | 50 | } |
48 | 51 | $dumper .= " <b>$value</b>"; |
49 | - if ($level==0) $dumper .= '</pre>'; |
|
52 | + if ($level==0) { |
|
53 | + $dumper .= '</pre>'; |
|
54 | + } |
|
50 | 55 | return $dumper; |
51 | 56 | } |
52 | 57 | |
@@ -70,8 +75,7 @@ discard block |
||
70 | 75 | if(substr(getcwd(), -4) != 'docs') |
71 | 76 | { |
72 | 77 | $path_prefix = 'docs/'; |
73 | -} |
|
74 | -else |
|
78 | +} else |
|
75 | 79 | { |
76 | 80 | $path_prefix = ''; |
77 | 81 | } |
@@ -119,8 +123,7 @@ discard block |
||
119 | 123 | $buffer['name'] = $chapter[0]; |
120 | 124 | } |
121 | 125 | $prev_chapter_is_header = true; |
122 | - } |
|
123 | - else |
|
126 | + } else |
|
124 | 127 | { |
125 | 128 | $prev_chapter_is_header = false; |
126 | 129 | foreach($chapter as &$note) |
@@ -150,8 +153,7 @@ discard block |
||
150 | 153 | if(!isset($note_out['name'])) |
151 | 154 | { |
152 | 155 | $note_out['name'] = $buf_str; |
153 | - } |
|
154 | - else |
|
156 | + } else |
|
155 | 157 | { |
156 | 158 | $note_out['lines'][] = $buf_str; |
157 | 159 | } |
@@ -228,36 +230,31 @@ discard block |
||
228 | 230 | if($matches[2]) |
229 | 231 | { |
230 | 232 | buf_print("<ol>\r\n"); |
231 | - } |
|
232 | - else |
|
233 | + } else |
|
233 | 234 | { |
234 | 235 | buf_print("<ul>\r\n"); |
235 | 236 | } |
236 | 237 | buf_print('<li>'); |
237 | 238 | $last_spaces = $matches[1]; |
238 | 239 | $depth[] = $matches[2]; |
239 | - } |
|
240 | - elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
240 | + } elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
241 | 241 | { |
242 | 242 | if(array_pop($depth)) |
243 | 243 | { |
244 | 244 | buf_print("</ol>\r\n"); |
245 | - } |
|
246 | - else |
|
245 | + } else |
|
247 | 246 | { |
248 | 247 | buf_print("</ul>\r\n"); |
249 | 248 | } |
250 | 249 | $last_spaces = $matches[1]; |
251 | 250 | buf_print('<li>'); |
252 | - } |
|
253 | - elseif(strlen($last_spaces) == strlen($matches[1])) |
|
251 | + } elseif(strlen($last_spaces) == strlen($matches[1])) |
|
254 | 252 | { |
255 | 253 | if($matches[2] == '' && $depth[count($depth) - 1] != '') |
256 | 254 | { |
257 | 255 | buf_print("</ol>\r\n"); |
258 | 256 | buf_print("<ul>\r\n"); |
259 | - } |
|
260 | - elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
257 | + } elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
261 | 258 | { |
262 | 259 | buf_print("</ul>\r\n"); |
263 | 260 | buf_print("<ol>\r\n"); |
@@ -274,8 +271,7 @@ discard block |
||
274 | 271 | if(array_pop($depth)) |
275 | 272 | { |
276 | 273 | buf_print("</ol>\r\n"); |
277 | - } |
|
278 | - else |
|
274 | + } else |
|
279 | 275 | { |
280 | 276 | buf_print("</ul>\r\n"); |
281 | 277 | } |
@@ -1,58 +1,58 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function dump($value,$varname = "",$level=0,$dumper = "") |
|
3 | +function dump($value, $varname = "", $level = 0, $dumper = "") |
|
4 | 4 | { |
5 | 5 | if ($varname) $varname .= " = "; |
6 | 6 | |
7 | - if ($level==-1) |
|
7 | + if ($level == -1) |
|
8 | 8 | { |
9 | - $trans[' ']='∴'; |
|
10 | - $trans["\t"]='⇒'; |
|
11 | - $trans["\n"]='¶;'; |
|
12 | - $trans["\r"]='⇐'; |
|
13 | - $trans["\0"]='⊕'; |
|
14 | - return strtr(htmlspecialchars($value),$trans); |
|
9 | + $trans[' '] = '∴'; |
|
10 | + $trans["\t"] = '⇒'; |
|
11 | + $trans["\n"] = '¶;'; |
|
12 | + $trans["\r"] = '⇐'; |
|
13 | + $trans["\0"] = '⊕'; |
|
14 | + return strtr(htmlspecialchars($value), $trans); |
|
15 | 15 | } |
16 | - if ($level==0) $dumper = '<pre>' . $varname; |
|
16 | + if ($level == 0) $dumper = '<pre>'.$varname; |
|
17 | 17 | |
18 | 18 | $type = gettype($value); |
19 | 19 | $dumper .= $type; |
20 | 20 | |
21 | - if ($type=='string') |
|
21 | + if ($type == 'string') |
|
22 | 22 | { |
23 | 23 | $dumper .= '('.strlen($value).')'; |
24 | - $value = dump($value,"",-1); |
|
24 | + $value = dump($value, "", -1); |
|
25 | 25 | } |
26 | - elseif ($type=='boolean') $value= ($value?'true':'false'); |
|
27 | - elseif ($type=='object') |
|
26 | + elseif ($type == 'boolean') $value = ($value ? 'true' : 'false'); |
|
27 | + elseif ($type == 'object') |
|
28 | 28 | { |
29 | - $props= get_class_vars(get_class($value)); |
|
29 | + $props = get_class_vars(get_class($value)); |
|
30 | 30 | $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
31 | - foreach($props as $key=>$val) |
|
31 | + foreach ($props as $key=>$val) |
|
32 | 32 | { |
33 | - $dumper .= "\n".str_repeat("\t",$level+1).$key.' => '; |
|
34 | - $dumper .= dump($value->$key,"",$level+1); |
|
33 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
34 | + $dumper .= dump($value->$key, "", $level + 1); |
|
35 | 35 | } |
36 | - $value= ''; |
|
36 | + $value = ''; |
|
37 | 37 | } |
38 | - elseif ($type=='array') |
|
38 | + elseif ($type == 'array') |
|
39 | 39 | { |
40 | 40 | $dumper .= '('.count($value).')'; |
41 | - foreach($value as $key=>$val) |
|
41 | + foreach ($value as $key=>$val) |
|
42 | 42 | { |
43 | - $dumper .= "\n".str_repeat("\t",$level+1).dump($key,"",-1).' => '; |
|
44 | - $dumper .= dump($val,"",$level+1); |
|
43 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, "", -1).' => '; |
|
44 | + $dumper .= dump($val, "", $level + 1); |
|
45 | 45 | } |
46 | - $value= ''; |
|
46 | + $value = ''; |
|
47 | 47 | } |
48 | 48 | $dumper .= " <b>$value</b>"; |
49 | - if ($level==0) $dumper .= '</pre>'; |
|
49 | + if ($level == 0) $dumper .= '</pre>'; |
|
50 | 50 | return $dumper; |
51 | 51 | } |
52 | 52 | |
53 | 53 | function pdump($value, $varname = '') |
54 | 54 | { |
55 | - print('<span style="text-align: left">' . dump($value, $varname) . '</span>'); |
|
55 | + print('<span style="text-align: left">'.dump($value, $varname).'</span>'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function debug($value, $varname = '') |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $output_buffer .= $string; |
68 | 68 | } |
69 | 69 | |
70 | -if(substr(getcwd(), -4) != 'docs') |
|
70 | +if (substr(getcwd(), -4) != 'docs') |
|
71 | 71 | { |
72 | 72 | $path_prefix = 'docs/'; |
73 | 73 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | |
81 | 81 | $filename = 'changelog'; |
82 | 82 | |
83 | -$input = file_get_contents($path_prefix . $filename . '.txt'); |
|
83 | +$input = file_get_contents($path_prefix.$filename.'.txt'); |
|
84 | 84 | //$input = iconv('CP1251', 'UTF-8', $input); |
85 | 85 | |
86 | 86 | $input = preg_replace("/\r\n\d\d\d\d\-\d\d\-\d\d\ \d\d\:\d\d/", "[D] $0", $input); |
87 | 87 | |
88 | -while(strpos($input, "\r\n\r\n") !== false) |
|
88 | +while (strpos($input, "\r\n\r\n") !== false) |
|
89 | 89 | { |
90 | 90 | $input = str_replace("\r\n\r\n", "\r\n", $input); |
91 | 91 | } |
92 | -while(strpos($input, "~~~") !== false) |
|
92 | +while (strpos($input, "~~~") !== false) |
|
93 | 93 | { |
94 | 94 | $input = str_replace("~~~", "~~", $input); |
95 | 95 | } |
96 | 96 | $input = str_replace("\r\n~~", "~~", $input); |
97 | 97 | |
98 | -while(strpos($input, "===") !== false) |
|
98 | +while (strpos($input, "===") !== false) |
|
99 | 99 | { |
100 | 100 | $input = str_replace("===", "==", $input); |
101 | 101 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $prev_chapter_is_header = false; |
107 | 107 | $output = array(); |
108 | 108 | $buffer = array(); |
109 | -foreach($input as &$chapter) |
|
109 | +foreach ($input as &$chapter) |
|
110 | 110 | { |
111 | 111 | $chapter = preg_split("/(\r\n[\[])/", $chapter, -1, PREG_SPLIT_NO_EMPTY); // , PREG_SPLIT_DELIM_CAPTURE |
112 | 112 | |
113 | - if(count($chapter) == 1 && !$prev_chapter_is_header) |
|
113 | + if (count($chapter) == 1 && !$prev_chapter_is_header) |
|
114 | 114 | { |
115 | - if(!empty($chapter)) |
|
115 | + if (!empty($chapter)) |
|
116 | 116 | { |
117 | 117 | $output[] = $buffer; |
118 | 118 | $buffer = array(); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | else |
124 | 124 | { |
125 | 125 | $prev_chapter_is_header = false; |
126 | - foreach($chapter as &$note) |
|
126 | + foreach ($chapter as &$note) |
|
127 | 127 | { |
128 | 128 | $note = explode("\r\n", $note); |
129 | 129 | $new_note = true; |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | |
132 | 132 | $note_out = array(); |
133 | 133 | |
134 | - foreach($note as &$line) |
|
134 | + foreach ($note as &$line) |
|
135 | 135 | { |
136 | - if(!$line) |
|
136 | + if (!$line) |
|
137 | 137 | { |
138 | 138 | continue; |
139 | 139 | } |
140 | - if($new_note) |
|
140 | + if ($new_note) |
|
141 | 141 | { |
142 | 142 | // 78 - 3 = 75 |
143 | 143 | $note_out['style'] = $line[0]; |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | $buf_str .= $line; |
148 | - if(mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
148 | + if (mb_strlen($line, 'utf-8') < ($new_note ? 75 : 79)) |
|
149 | 149 | { |
150 | - if(!isset($note_out['name'])) |
|
150 | + if (!isset($note_out['name'])) |
|
151 | 151 | { |
152 | 152 | $note_out['name'] = $buf_str; |
153 | 153 | } |
@@ -201,31 +201,31 @@ discard block |
||
201 | 201 | 'D' => 'date', |
202 | 202 | ); |
203 | 203 | |
204 | -foreach($output as $chapter) |
|
204 | +foreach ($output as $chapter) |
|
205 | 205 | { |
206 | - if(!$chapter) |
|
206 | + if (!$chapter) |
|
207 | 207 | { |
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | 211 | buf_print("<h1>{$chapter['name']}</h1>\r\n"); |
212 | - foreach($chapter['content'] as $block) |
|
212 | + foreach ($chapter['content'] as $block) |
|
213 | 213 | { |
214 | - buf_print("<div class=\"{$styles[$block['style']]}\">" . ($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
|
215 | - buf_print(preg_replace("/\s{2,10}/", " ", $block['name']) . '<br />'); |
|
216 | - if(isset($block['lines'])) |
|
214 | + buf_print("<div class=\"{$styles[$block['style']]}\">".($block['style'] != 'D' ? "[{$block['style']}] " : '')); |
|
215 | + buf_print(preg_replace("/\s{2,10}/", " ", $block['name']).'<br />'); |
|
216 | + if (isset($block['lines'])) |
|
217 | 217 | { |
218 | 218 | $last_spaces = ''; |
219 | 219 | $depth = array(); |
220 | - foreach($block['lines'] as $line) |
|
220 | + foreach ($block['lines'] as $line) |
|
221 | 221 | { |
222 | - if(preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
222 | + if (preg_match("/^(\s+)(\d*|\s)\.*\s*(.*)/", $line, $matches)) |
|
223 | 223 | { |
224 | 224 | //$line = strlen($matches[1]) . '/' . $matches[2] . '/' . $matches[3]; |
225 | 225 | $line = $matches[3]; |
226 | - if(strlen($matches[1]) > strlen($last_spaces)) |
|
226 | + if (strlen($matches[1]) > strlen($last_spaces)) |
|
227 | 227 | { |
228 | - if($matches[2]) |
|
228 | + if ($matches[2]) |
|
229 | 229 | { |
230 | 230 | buf_print("<ol>\r\n"); |
231 | 231 | } |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | $last_spaces = $matches[1]; |
238 | 238 | $depth[] = $matches[2]; |
239 | 239 | } |
240 | - elseif(strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
240 | + elseif (strlen($matches[1]) < strlen($last_spaces) && count($depth)) |
|
241 | 241 | { |
242 | - if(array_pop($depth)) |
|
242 | + if (array_pop($depth)) |
|
243 | 243 | { |
244 | 244 | buf_print("</ol>\r\n"); |
245 | 245 | } |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | $last_spaces = $matches[1]; |
251 | 251 | buf_print('<li>'); |
252 | 252 | } |
253 | - elseif(strlen($last_spaces) == strlen($matches[1])) |
|
253 | + elseif (strlen($last_spaces) == strlen($matches[1])) |
|
254 | 254 | { |
255 | - if($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
255 | + if ($matches[2] == '' && $depth[count($depth) - 1] != '') |
|
256 | 256 | { |
257 | 257 | buf_print("</ol>\r\n"); |
258 | 258 | buf_print("<ul>\r\n"); |
259 | 259 | } |
260 | - elseif($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
260 | + elseif ($matches[2] != '' && $depth[count($depth) - 1] == '') |
|
261 | 261 | { |
262 | 262 | buf_print("</ul>\r\n"); |
263 | 263 | buf_print("<ol>\r\n"); |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | } |
268 | 268 | } |
269 | 269 | $line = preg_replace("/\s{2,10}/", " ", $line); |
270 | - buf_print($line . "<br />\r\n"); |
|
270 | + buf_print($line."<br />\r\n"); |
|
271 | 271 | } |
272 | - while(count($depth)) |
|
272 | + while (count($depth)) |
|
273 | 273 | { |
274 | - if(array_pop($depth)) |
|
274 | + if (array_pop($depth)) |
|
275 | 275 | { |
276 | 276 | buf_print("</ol>\r\n"); |
277 | 277 | } |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | } |
287 | 287 | buf_print("</body>\r\n</html>\r\n"); |
288 | 288 | |
289 | -$html = file_get_contents($path_prefix . 'html/' . $filename . '.html'); |
|
290 | -if($html != $output_buffer) |
|
289 | +$html = file_get_contents($path_prefix.'html/'.$filename.'.html'); |
|
290 | +if ($html != $output_buffer) |
|
291 | 291 | { |
292 | - file_put_contents($path_prefix . 'html/' . $filename . '.html', $output_buffer); |
|
293 | - if(!$path_prefix) |
|
292 | + file_put_contents($path_prefix.'html/'.$filename.'.html', $output_buffer); |
|
293 | + if (!$path_prefix) |
|
294 | 294 | { |
295 | 295 | print($output_buffer); |
296 | 296 | } |
@@ -50,52 +50,52 @@ |
||
50 | 50 | stat_tpl_assign($template, $who, 'subject', $subject_list, $sn_group_stat_common); |
51 | 51 | |
52 | 52 | $stat_types = array( |
53 | - STAT_TOTAL => array( |
|
54 | - 'type' => 'total', |
|
55 | - ), |
|
53 | + STAT_TOTAL => array( |
|
54 | + 'type' => 'total', |
|
55 | + ), |
|
56 | 56 | |
57 | - STAT_FLEET => array( |
|
58 | - 'type' => 'fleet', |
|
59 | - ), |
|
57 | + STAT_FLEET => array( |
|
58 | + 'type' => 'fleet', |
|
59 | + ), |
|
60 | 60 | |
61 | - STAT_TECH => array( |
|
62 | - 'type' => 'tech', |
|
63 | - ), |
|
61 | + STAT_TECH => array( |
|
62 | + 'type' => 'tech', |
|
63 | + ), |
|
64 | 64 | |
65 | - STAT_BUILDING => array( |
|
66 | - 'type' => 'build', |
|
67 | - ), |
|
65 | + STAT_BUILDING => array( |
|
66 | + 'type' => 'build', |
|
67 | + ), |
|
68 | 68 | |
69 | - STAT_DEFENSE => array( |
|
70 | - 'type' => 'defs', |
|
71 | - ), |
|
69 | + STAT_DEFENSE => array( |
|
70 | + 'type' => 'defs', |
|
71 | + ), |
|
72 | 72 | |
73 | - STAT_RESOURCE => array( |
|
74 | - 'type' => 'res', |
|
75 | - ), |
|
73 | + STAT_RESOURCE => array( |
|
74 | + 'type' => 'res', |
|
75 | + ), |
|
76 | 76 | |
77 | - STAT_RAID_TOTAL => array( |
|
78 | - 'type' => 'raids', |
|
79 | - ), |
|
77 | + STAT_RAID_TOTAL => array( |
|
78 | + 'type' => 'raids', |
|
79 | + ), |
|
80 | 80 | |
81 | - STAT_RAID_WON => array( |
|
82 | - 'type' => 'raidswin', |
|
83 | - ), |
|
81 | + STAT_RAID_WON => array( |
|
82 | + 'type' => 'raidswin', |
|
83 | + ), |
|
84 | 84 | |
85 | - STAT_RAID_LOST => array( |
|
86 | - 'type' => 'raidsloose', |
|
87 | - ), |
|
85 | + STAT_RAID_LOST => array( |
|
86 | + 'type' => 'raidsloose', |
|
87 | + ), |
|
88 | 88 | |
89 | 89 | STAT_LVL_BUILDING => array( |
90 | - 'type' => 'lvl_minier', |
|
90 | + 'type' => 'lvl_minier', |
|
91 | 91 | ), |
92 | 92 | |
93 | 93 | STAT_LVL_TECH => array( |
94 | - 'type' => 'player_rpg_tech_level', |
|
94 | + 'type' => 'player_rpg_tech_level', |
|
95 | 95 | ), |
96 | 96 | |
97 | 97 | STAT_LVL_RAID => array( |
98 | - 'type' => 'lvl_raid', |
|
98 | + 'type' => 'lvl_raid', |
|
99 | 99 | ), |
100 | 100 | ); |
101 | 101 | stat_tpl_assign($template, $type, 'type', $stat_types, $sn_group_stat_common); |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | global $who; |
12 | 12 | |
13 | 13 | // $sn_group_stat_common = sn_get_groups('STAT_COMMON'); |
14 | - foreach($array as $key => $value) { |
|
15 | - if($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { |
|
14 | + foreach ($array as $key => $value) { |
|
15 | + if ($array_name == 'type' && $who == 2 && !in_array($key, $sn_group_stat_common)) { |
|
16 | 16 | continue; |
17 | 17 | } |
18 | 18 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $allow_anonymous = true; |
30 | 30 | |
31 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
31 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
32 | 32 | |
33 | 33 | lng_include('stat'); |
34 | 34 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $subject_list = array( |
45 | 45 | 1 => array('header' => classLocale::$lang['stat_player']), |
46 | 46 | ); |
47 | -if(!$source) { |
|
47 | +if (!$source) { |
|
48 | 48 | $subject_list[2] = array('header' => classLocale::$lang['stat_allys']); |
49 | 49 | } |
50 | 50 | stat_tpl_assign($template, $who, 'subject', $subject_list, $sn_group_stat_common); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $page_count = floor($record_count / 100); |
115 | 115 | $pages = array(); |
116 | -for($i = 0; $i <= $page_count; $i++) { |
|
116 | +for ($i = 0; $i <= $page_count; $i++) { |
|
117 | 117 | $first_element = $i * 100 + 1; |
118 | 118 | $last_element = $first_element + 99; |
119 | 119 | $pages[$first_element] = array( |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ); |
134 | 134 | //pdump($row); |
135 | 135 | |
136 | - if($who == 1) { |
|
136 | + if ($who == 1) { |
|
137 | 137 | $row_stat['ALLY_NAME'] = $row['ally_name']; |
138 | 138 | $row_stat['ALLY_ID'] = $row['ally_id']; |
139 | 139 | empty($row['username']) ? $row['username'] = $row['name'] : false; |
@@ -24,11 +24,11 @@ |
||
24 | 24 | |
25 | 25 | // require_once('includes/includes/scheduler_process.php'); |
26 | 26 | |
27 | -if(($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
27 | +if (($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
28 | 28 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
29 | 29 | print(json_encode($result)); |
30 | 30 | } |
31 | 31 | |
32 | -if(!defined('IN_ADMIN')) { |
|
32 | +if (!defined('IN_ADMIN')) { |
|
33 | 33 | die(); |
34 | 34 | } |