@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | // Re-position template blocks |
629 | 629 | for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--) |
630 | 630 | { |
631 | - $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1]; |
|
631 | + $this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i - 1]; |
|
632 | 632 | $this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i; |
633 | 633 | } |
634 | 634 | |
@@ -710,13 +710,13 @@ discard block |
||
710 | 710 | */ |
711 | 711 | function assign_recursive($values, $name = '') |
712 | 712 | { |
713 | - if(isset($values['.'])) |
|
713 | + if (isset($values['.'])) |
|
714 | 714 | { |
715 | 715 | $values_extra = $values['.']; |
716 | 716 | unset($values['.']); |
717 | 717 | } |
718 | 718 | |
719 | - if(!$name) |
|
719 | + if (!$name) |
|
720 | 720 | { |
721 | 721 | $this->assign_vars($values); |
722 | 722 | } |
@@ -725,12 +725,12 @@ discard block |
||
725 | 725 | $this->assign_block_vars($name, $values); |
726 | 726 | } |
727 | 727 | |
728 | - if(isset($values_extra)) |
|
728 | + if (isset($values_extra)) |
|
729 | 729 | { |
730 | - foreach($values_extra as $sub_array_name => $sub_array) |
|
730 | + foreach ($values_extra as $sub_array_name => $sub_array) |
|
731 | 731 | { |
732 | 732 | $new_name = $name . ($name ? '.' : '') . $sub_array_name; |
733 | - foreach($sub_array as $sub_element) |
|
733 | + foreach ($sub_array as $sub_element) |
|
734 | 734 | { |
735 | 735 | $this->assign_recursive($sub_element, $new_name); |
736 | 736 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | */ |
142 | 142 | protected function setInsertCommand($replace) { |
143 | - switch($replace) { |
|
143 | + switch ($replace) { |
|
144 | 144 | case DB_INSERT_IGNORE: |
145 | 145 | $result = static::INSERT_IGNORE; |
146 | 146 | break; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $this->build = array(); |
161 | 161 | $this->buildCommand($this->setInsertCommand($replace)); |
162 | 162 | |
163 | - if(!$forceSingleInsert && is_array($this->fields) && !empty($this->fields)) { |
|
163 | + if (!$forceSingleInsert && is_array($this->fields) && !empty($this->fields)) { |
|
164 | 164 | // If there are fields - it's batch insert... unless it forced single insert |
165 | 165 | $this->build[] = " ("; |
166 | 166 | $this->buildFieldNames(); // used $this->fields |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return string |
311 | 311 | */ |
312 | 312 | protected function stringValue($value) { |
313 | - return "'" . $this->escape((string)$value) . "'"; |
|
313 | + return "'" . $this->escape((string) $value) . "'"; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @return string |
322 | 322 | */ |
323 | 323 | public function quote($fieldName) { |
324 | - return "`" . $this->escape((string)$fieldName) . "`"; |
|
324 | + return "`" . $this->escape((string) $fieldName) . "`"; |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | public function makeAdjustString($fieldValue, $fieldName) { |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * @return string |
346 | 346 | */ |
347 | 347 | protected function quoteTable($tableName) { |
348 | - return "`{{" . $this->escape((string)$tableName) . "}}`"; |
|
348 | + return "`{{" . $this->escape((string) $tableName) . "}}`"; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | public function castAsDbValue($value) { |
352 | - switch(gettype($value)) { |
|
352 | + switch (gettype($value)) { |
|
353 | 353 | case TYPE_INTEGER: |
354 | 354 | case TYPE_DOUBLE: |
355 | 355 | // do nothing |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | |
382 | 382 | protected function buildCommand($command) { |
383 | - switch($this->command = $command) { |
|
383 | + switch ($this->command = $command) { |
|
384 | 384 | case static::UPDATE: |
385 | 385 | $this->build[] = $this->command . " " . $this->quoteTable($this->table); |
386 | 386 | break; |
@@ -15,11 +15,11 @@ |
||
15 | 15 | * @return string |
16 | 16 | */ |
17 | 17 | public static function quoteComment($comment) { |
18 | - if($comment == '') { |
|
18 | + if ($comment == '') { |
|
19 | 19 | return ''; |
20 | 20 | } |
21 | 21 | |
22 | - $comment = str_replace(array('/*', '*/'), '__',$comment); |
|
22 | + $comment = str_replace(array('/*', '*/'), '__', $comment); |
|
23 | 23 | |
24 | 24 | return "\r\n/*" . $comment . "*/"; |
25 | 25 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | $this->prepare(); |
96 | 96 | |
97 | 97 | $this->manifest['active'] = false; |
98 | - if(!empty($this->config) && is_array($this->config['db'])) { |
|
98 | + if (!empty($this->config) && is_array($this->config['db'])) { |
|
99 | 99 | // БД, отличная от стандартной |
100 | 100 | $this->db = classSupernova::$gc->db; |
101 | 101 | |
102 | 102 | $this->db->sn_db_connect($this->config['db']); |
103 | - if($this->manifest['active'] = $this->db->connected) { |
|
103 | + if ($this->manifest['active'] = $this->db->connected) { |
|
104 | 104 | $this->provider_id = ACCOUNT_PROVIDER_CENTRAL; |
105 | 105 | |
106 | 106 | $this->domain = $this->config['domain']; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | // Fallback to local DB |
117 | - if(!$this->manifest['active']) { |
|
117 | + if (!$this->manifest['active']) { |
|
118 | 118 | $this->db = classSupernova::$db; |
119 | 119 | |
120 | 120 | $this->provider_id = ACCOUNT_PROVIDER_LOCAL; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // OK v4.5 |
167 | 167 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
168 | 168 | $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe); |
169 | - if($result) { |
|
169 | + if ($result) { |
|
170 | 170 | $this->cookie_set(); |
171 | 171 | } |
172 | 172 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | */ |
195 | 195 | // OK v4.6 |
196 | 196 | protected function password_reset_send_code() { |
197 | - if(!$this->is_password_reset) { |
|
197 | + if (!$this->is_password_reset) { |
|
198 | 198 | return $this->account_login_status; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // Проверяем поддержку сброса пароля |
202 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
202 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
203 | 203 | return $this->account_login_status; |
204 | 204 | } |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | unset($this->account); |
210 | 210 | $this->account = new Account($this->db); |
211 | 211 | |
212 | - if(!$this->account->db_get_by_email($email_unsafe)) { |
|
212 | + if (!$this->account->db_get_by_email($email_unsafe)) { |
|
213 | 213 | throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR); |
214 | 214 | // return $this->account_login_status; |
215 | 215 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | |
220 | 220 | // TODO - Проверять уровень доступа аккаунта! |
221 | 221 | // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ! |
222 | - foreach($user_list as $user_id => $user_data) { |
|
223 | - if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
222 | + foreach ($user_list as $user_id => $user_data) { |
|
223 | + if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) { |
|
224 | 224 | throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5 |
229 | - if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
229 | + if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) { |
|
230 | 230 | throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR); |
231 | 231 | } |
232 | 232 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | ); |
244 | 244 | |
245 | 245 | $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING; |
246 | - } catch(Exception $e) { |
|
246 | + } catch (Exception $e) { |
|
247 | 247 | sn_db_transaction_rollback(); |
248 | 248 | $result = $e->getMessage(); |
249 | 249 | } |
@@ -256,46 +256,46 @@ discard block |
||
256 | 256 | * @return int|string |
257 | 257 | */ |
258 | 258 | protected function password_reset_confirm() { |
259 | - if(!$this->is_password_reset_confirm) { |
|
259 | + if (!$this->is_password_reset_confirm) { |
|
260 | 260 | return $this->account_login_status; |
261 | 261 | } |
262 | 262 | |
263 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
263 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
264 | 264 | return $this->account_login_status; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Проверяем поддержку сброса пароля |
268 | - if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
268 | + if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) { |
|
269 | 269 | return $this->account_login_status; |
270 | 270 | } |
271 | 271 | |
272 | 272 | try { |
273 | 273 | $code_unsafe = sys_get_param_str_unsafe('password_reset_code'); |
274 | - if(empty($code_unsafe)) { |
|
274 | + if (empty($code_unsafe)) { |
|
275 | 275 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR); |
276 | 276 | } |
277 | 277 | |
278 | 278 | sn_db_transaction_start(); |
279 | 279 | $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5 |
280 | 280 | |
281 | - if(empty($confirmation)) { |
|
281 | + if (empty($confirmation)) { |
|
282 | 282 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR); |
283 | 283 | } |
284 | 284 | |
285 | - if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
285 | + if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) { |
|
286 | 286 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR); |
287 | 287 | } |
288 | 288 | |
289 | 289 | unset($this->account); |
290 | 290 | $this->account = new Account($this->db); |
291 | 291 | |
292 | - if(!$this->account->db_get_by_email($confirmation['email'])) { |
|
292 | + if (!$this->account->db_get_by_email($confirmation['email'])) { |
|
293 | 293 | throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR); |
294 | 294 | } |
295 | 295 | |
296 | 296 | $new_password_unsafe = $this->make_random_password(); |
297 | 297 | $salt_unsafe = $this->password_salt_generate(); |
298 | - if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
298 | + if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) { |
|
299 | 299 | // Ошибка смены пароля |
300 | 300 | throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR); |
301 | 301 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $this->cookie_set(); |
306 | 306 | $this->login_cookie(); |
307 | 307 | |
308 | - if($this->account_login_status == LOGIN_SUCCESS) { |
|
308 | + if ($this->account_login_status == LOGIN_SUCCESS) { |
|
309 | 309 | // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!! |
310 | 310 | $message_header = sprintf(classLocale::$lang['log_lost_email_title'], classSupernova::$config->game_name); |
311 | 311 | $message = sprintf(classLocale::$lang['log_lost_email_pass'], classSupernova::$config->game_name, $this->account->account_name, $new_password_unsafe); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | mymail($confirmation['email'], $message_header, htmlspecialchars($message)); |
314 | 314 | |
315 | 315 | $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5 |
316 | - if(!empty($users_translated)) { |
|
316 | + if (!empty($users_translated)) { |
|
317 | 317 | // Отправляем в лички письмо о сбросе пароля |
318 | 318 | |
319 | 319 | // ПО ОПРЕДЕЛЕНИЮ в $users_translated только |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $message = sprintf(classLocale::$lang['sys_password_reset_message_body'], $new_password_unsafe); |
325 | 325 | $message = sys_bbcodeParse($message) . '<br><br>'; |
326 | 326 | |
327 | - foreach($users_translated as $user_id => $providers_list) { |
|
327 | + foreach ($users_translated as $user_id => $providers_list) { |
|
328 | 328 | DBStaticMessages::msgSendFromAdmin($user_id, classLocale::$lang['sys_login_register_message_title'], $message); |
329 | 329 | } |
330 | 330 | } else { |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id); |
378 | 378 | |
379 | 379 | try { |
380 | - if(!$this->is_register) { |
|
380 | + if (!$this->is_register) { |
|
381 | 381 | $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем'); |
382 | 382 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
383 | 383 | } |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | sn_db_transaction_start(); |
388 | 388 | |
389 | 389 | $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe); |
390 | - if($this->account->is_exists) { |
|
391 | - if($this->account->account_email == $this->input_email_unsafe) { |
|
390 | + if ($this->account->is_exists) { |
|
391 | + if ($this->account->account_email == $this->input_email_unsafe) { |
|
392 | 392 | throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR); |
393 | 393 | } else { |
394 | 394 | throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth |
411 | 411 | // $this->register_account(); |
412 | 412 | sn_db_transaction_commit(); |
413 | - } catch(Exception $e) { |
|
413 | + } catch (Exception $e) { |
|
414 | 414 | sn_db_transaction_rollback(); |
415 | 415 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
416 | 416 | } |
@@ -424,19 +424,19 @@ discard block |
||
424 | 424 | * @return int Результат попытки |
425 | 425 | */ |
426 | 426 | protected function login_cookie() { |
427 | - if($this->account_login_status != LOGIN_UNDEFINED) { |
|
427 | + if ($this->account_login_status != LOGIN_UNDEFINED) { |
|
428 | 428 | return $this->account_login_status; |
429 | 429 | } |
430 | 430 | |
431 | 431 | // Пытаемся войти по куке |
432 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
433 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
432 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
433 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
434 | 434 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
435 | 435 | } else { |
436 | 436 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
437 | 437 | } |
438 | 438 | |
439 | - if( |
|
439 | + if ( |
|
440 | 440 | $this->account->db_get_by_id($account_id_unsafe) |
441 | 441 | && ($this->password_encode_for_cookie($this->account->account_password) == $cookie_password_hash_salted) |
442 | 442 | ) { |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | } |
447 | 447 | |
448 | - if($this->account_login_status != LOGIN_SUCCESS) { |
|
448 | + if ($this->account_login_status != LOGIN_SUCCESS) { |
|
449 | 449 | // Невалидная кука - чистим |
450 | 450 | $this->cookie_clear(); |
451 | 451 | } |
@@ -462,29 +462,29 @@ discard block |
||
462 | 462 | protected function login_username() { |
463 | 463 | // TODO - Логин по старым именам |
464 | 464 | try { |
465 | - if(!$this->is_login) { |
|
465 | + if (!$this->is_login) { |
|
466 | 466 | $this->flog('Логин: не выставлен флаг входа в игру - это не логин'); |
467 | 467 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
468 | 468 | } |
469 | 469 | |
470 | 470 | // TODO Пустое имя аккаунта |
471 | - if(!$this->input_login_unsafe) { |
|
471 | + if (!$this->input_login_unsafe) { |
|
472 | 472 | throw new Exception(LOGIN_UNDEFINED, ERR_ERROR); |
473 | 473 | } |
474 | 474 | |
475 | 475 | $this->login_validate_input(); |
476 | 476 | |
477 | - if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
477 | + if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) { |
|
478 | 478 | throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR); |
479 | 479 | } |
480 | 480 | |
481 | - if(!$this->account->password_check($this->input_login_password_raw)) { |
|
481 | + if (!$this->account->password_check($this->input_login_password_raw)) { |
|
482 | 482 | throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR); |
483 | 483 | } |
484 | 484 | |
485 | 485 | $this->cookie_set(); |
486 | 486 | $this->account_login_status = LOGIN_SUCCESS; |
487 | - } catch(Exception $e) { |
|
487 | + } catch (Exception $e) { |
|
488 | 488 | $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false; |
489 | 489 | } |
490 | 490 | |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | protected function cookie_set($account_to_impersonate = null) { |
507 | 507 | $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account; |
508 | 508 | |
509 | - if(!is_object($this_account) || !$this_account->is_exists) { |
|
509 | + if (!is_object($this_account) || !$this_account->is_exists) { |
|
510 | 510 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
511 | 511 | } |
512 | 512 | |
513 | - if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
513 | + if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) { |
|
514 | 514 | sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
515 | 515 | } |
516 | 516 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | // OK v4.1 |
529 | 529 | protected function cookie_clear() { |
530 | 530 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
531 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
531 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
532 | 532 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain); |
533 | 533 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $this->domain); |
534 | 534 | } else { |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | protected function login_validate_input() { |
548 | 548 | // Проверяем, что бы в начале и конце не было пустых символов |
549 | 549 | // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию! |
550 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
550 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
551 | 551 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
552 | 552 | } |
553 | - if(!$this->input_login_password_raw) { |
|
553 | + if (!$this->input_login_password_raw) { |
|
554 | 554 | throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR); |
555 | 555 | } |
556 | 556 | } |
@@ -566,37 +566,37 @@ discard block |
||
566 | 566 | $this->login_validate_input(); |
567 | 567 | |
568 | 568 | // Если нет имени пользователя - NO GO! |
569 | - if(!$this->input_login_unsafe) { |
|
569 | + if (!$this->input_login_unsafe) { |
|
570 | 570 | throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR); |
571 | 571 | } |
572 | 572 | // Если логин имеет запрещенные символы - NO GO! |
573 | - if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
573 | + if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
574 | 574 | throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
575 | 575 | } |
576 | 576 | // Если логин меньше минимальной длины - NO GO! |
577 | - if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
577 | + if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) { |
|
578 | 578 | throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR); |
579 | 579 | } |
580 | 580 | // Если пароль меньше минимальной длины - NO GO! |
581 | - if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
581 | + if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) { |
|
582 | 582 | throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR); |
583 | 583 | } |
584 | 584 | // Если пароль имеет пробельные символы в начале или конце - NO GO! |
585 | - if($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
585 | + if ($this->input_login_password_raw != trim($this->input_login_password_raw)) { |
|
586 | 586 | throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR); |
587 | 587 | } |
588 | 588 | // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше |
589 | 589 | //Если они есть у повтора - значит пароль и повтор не совпадут |
590 | - if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
590 | + if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) { |
|
591 | 591 | throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR); |
592 | 592 | } |
593 | 593 | // Если нет емейла - NO GO! |
594 | 594 | // TODO - регистрация без емейла |
595 | - if(!$this->input_email_unsafe) { |
|
595 | + if (!$this->input_email_unsafe) { |
|
596 | 596 | throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR); |
597 | 597 | } |
598 | 598 | // Если емейл не является емейлом - NO GO! |
599 | - if(!is_email($this->input_email_unsafe)) { |
|
599 | + if (!is_email($this->input_email_unsafe)) { |
|
600 | 600 | throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR); |
601 | 601 | } |
602 | 602 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | return core_auth::make_random_password(); |
626 | 626 | } |
627 | 627 | protected function flog($message, $die = false) { |
628 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
628 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
629 | 629 | return; |
630 | 630 | } |
631 | 631 | list($called, $caller) = debug_backtrace(false); |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
640 | 640 | |
641 | 641 | classSupernova::log_file("$message - $caller_name"); |
642 | - if($die) { |
|
642 | + if ($die) { |
|
643 | 643 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
644 | 644 | } |
645 | 645 | } |
@@ -159,20 +159,20 @@ discard block |
||
159 | 159 | $this->owner_id, |
160 | 160 | $this->db_id, |
161 | 161 | |
162 | - (float)$this->UBE_PLANET[PLANET_ID], |
|
162 | + (float) $this->UBE_PLANET[PLANET_ID], |
|
163 | 163 | "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'", |
164 | - (int)$this->UBE_PLANET[PLANET_GALAXY], |
|
165 | - (int)$this->UBE_PLANET[PLANET_SYSTEM], |
|
166 | - (int)$this->UBE_PLANET[PLANET_PLANET], |
|
167 | - (int)$this->UBE_PLANET[PLANET_TYPE], |
|
168 | - |
|
169 | - (float)$this->resource_list[RES_METAL], |
|
170 | - (float)$this->resource_list[RES_CRYSTAL], |
|
171 | - (float)$this->resource_list[RES_DEUTERIUM], |
|
172 | - |
|
173 | - (float)$this->fleet_bonus->calcBonus(P_ATTACK), |
|
174 | - (float)$this->fleet_bonus->calcBonus(P_SHIELD), |
|
175 | - (float)$this->fleet_bonus->calcBonus(P_ARMOR), |
|
164 | + (int) $this->UBE_PLANET[PLANET_GALAXY], |
|
165 | + (int) $this->UBE_PLANET[PLANET_SYSTEM], |
|
166 | + (int) $this->UBE_PLANET[PLANET_PLANET], |
|
167 | + (int) $this->UBE_PLANET[PLANET_TYPE], |
|
168 | + |
|
169 | + (float) $this->resource_list[RES_METAL], |
|
170 | + (float) $this->resource_list[RES_CRYSTAL], |
|
171 | + (float) $this->resource_list[RES_DEUTERIUM], |
|
172 | + |
|
173 | + (float) $this->fleet_bonus->calcBonus(P_ATTACK), |
|
174 | + (float) $this->fleet_bonus->calcBonus(P_SHIELD), |
|
175 | + (float) $this->fleet_bonus->calcBonus(P_ARMOR), |
|
176 | 176 | ); |
177 | 177 | } |
178 | 178 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | $this->owner_id = $objFleet->playerOwnerId; |
186 | 186 | $this->group_id = $objFleet->group_id; |
187 | 187 | |
188 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
189 | - if(!$unit->count) { |
|
188 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
189 | + if (!$unit->count) { |
|
190 | 190 | continue; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
194 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
194 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
195 | 195 | $this->unit_list->unitAdjustCount($unit_id, $unit->count); |
196 | 196 | } |
197 | 197 | } |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | // } |
228 | 228 | // } |
229 | 229 | |
230 | - foreach($sn_group_combat as $unit_id) { |
|
231 | - if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
230 | + foreach ($sn_group_combat as $unit_id) { |
|
231 | + if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
232 | 232 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
236 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
237 | 237 | $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id)); |
238 | 238 | } |
239 | 239 | |
@@ -292,27 +292,27 @@ discard block |
||
292 | 292 | $ube_report_id, |
293 | 293 | $this->db_id, |
294 | 294 | |
295 | - (float)$this->resources_lost_on_units[RES_METAL], |
|
296 | - (float)$this->resources_lost_on_units[RES_CRYSTAL], |
|
297 | - (float)$this->resources_lost_on_units[RES_DEUTERIUM], |
|
298 | - (float)$this->cargo_dropped[RES_METAL], |
|
299 | - (float)$this->cargo_dropped[RES_CRYSTAL], |
|
300 | - (float)$this->cargo_dropped[RES_DEUTERIUM], |
|
301 | - (float)$this->resources_looted[RES_METAL], |
|
302 | - (float)$this->resources_looted[RES_CRYSTAL], |
|
303 | - (float)$this->resources_looted[RES_DEUTERIUM], |
|
304 | - (float)$this->resources_lost_in_metal[RES_METAL], |
|
295 | + (float) $this->resources_lost_on_units[RES_METAL], |
|
296 | + (float) $this->resources_lost_on_units[RES_CRYSTAL], |
|
297 | + (float) $this->resources_lost_on_units[RES_DEUTERIUM], |
|
298 | + (float) $this->cargo_dropped[RES_METAL], |
|
299 | + (float) $this->cargo_dropped[RES_CRYSTAL], |
|
300 | + (float) $this->cargo_dropped[RES_DEUTERIUM], |
|
301 | + (float) $this->resources_looted[RES_METAL], |
|
302 | + (float) $this->resources_looted[RES_CRYSTAL], |
|
303 | + (float) $this->resources_looted[RES_DEUTERIUM], |
|
304 | + (float) $this->resources_lost_in_metal[RES_METAL], |
|
305 | 305 | ); |
306 | 306 | } |
307 | 307 | |
308 | 308 | public function report_render_outcome_side_fleet() { |
309 | 309 | $UBE_DEFENCE_RESTORE = array(); |
310 | 310 | $UBE_UNITS_LOST = array(); |
311 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
312 | - if($UBEUnit->units_restored) { |
|
311 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
312 | + if ($UBEUnit->units_restored) { |
|
313 | 313 | $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored; |
314 | 314 | } |
315 | - if($UBEUnit->units_lost) { |
|
315 | + if ($UBEUnit->units_lost) { |
|
316 | 316 | $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost; |
317 | 317 | } |
318 | 318 | } |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | */ |
338 | 338 | protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) { |
339 | 339 | $result = array(); |
340 | - if(!empty($array)) { |
|
341 | - foreach($array as $unit_id => $unit_count) { |
|
342 | - if($unit_count) { |
|
340 | + if (!empty($array)) { |
|
341 | + foreach ($array as $unit_id => $unit_count) { |
|
342 | + if ($unit_count) { |
|
343 | 343 | $result[] = array( |
344 | 344 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
345 | 345 | 'LOSS' => pretty_number($unit_count), |
346 | 346 | ); |
347 | 347 | } |
348 | 348 | } |
349 | - if($lang_header_index && count($result)) { |
|
349 | + if ($lang_header_index && count($result)) { |
|
350 | 350 | array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index])); |
351 | 351 | } |
352 | 352 | } |
@@ -359,16 +359,16 @@ discard block |
||
359 | 359 | $fleet_id = $this->db_id; |
360 | 360 | |
361 | 361 | $unit_sort_order = 0; |
362 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
363 | - if($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
362 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
363 | + if ($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
364 | 364 | $unit_sort_order++; |
365 | 365 | $sql_perform_report_unit[] = array( |
366 | 366 | $ube_report_id, |
367 | 367 | $fleet_id, |
368 | 368 | |
369 | 369 | $UBEUnit->unitId, |
370 | - (float)$UBEUnit->units_restored, |
|
371 | - (float)$UBEUnit->units_lost, |
|
370 | + (float) $UBEUnit->units_restored, |
|
371 | + (float) $UBEUnit->units_lost, |
|
372 | 372 | |
373 | 373 | $unit_sort_order, |
374 | 374 | ); |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | public function ube_combat_result_calculate_resources() { |
385 | 385 | $resource_delta_fleet = array(); |
386 | 386 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
387 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
388 | - $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id]; |
|
389 | - if($resource_change) { |
|
387 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
388 | + $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id]; |
|
389 | + if ($resource_change) { |
|
390 | 390 | $resource_delta_fleet[$resource_id] = -($resource_change); |
391 | 391 | } |
392 | 392 | } |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | ); |
420 | 420 | |
421 | 421 | $this->fleet_capacity = 0; |
422 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
422 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
423 | 423 | $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->count; |
424 | 424 | |
425 | - if($UBEUnit->units_lost) { |
|
426 | - foreach($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
427 | - if(!$unit_resource_price) { |
|
425 | + if ($UBEUnit->units_lost) { |
|
426 | + foreach ($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
427 | + if (!$unit_resource_price) { |
|
428 | 428 | continue; |
429 | 429 | } |
430 | 430 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $this->resources_lost_on_units[$resource_id] += $resources_lost; |
433 | 433 | // Если это корабль - прибавляем потери к обломкам на орбите |
434 | 434 | // TODO - опция выбрасывания обороны в обломки |
435 | - if($UBEUnit->getType() == UNIT_SHIPS) { |
|
435 | + if ($UBEUnit->getType() == UNIT_SHIPS) { |
|
436 | 436 | $this->resources_lost_on_ships[$resource_id] += $resources_lost; |
437 | 437 | } |
438 | 438 | } |
@@ -444,11 +444,11 @@ discard block |
||
444 | 444 | |
445 | 445 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
446 | 446 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
447 | - if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
447 | + if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
448 | 448 | $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена |
449 | - foreach($this->resource_list as $resource_id => &$resource_amount) { |
|
449 | + foreach ($this->resource_list as $resource_id => &$resource_amount) { |
|
450 | 450 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
451 | - if(!$resource_amount) { |
|
451 | + if (!$resource_amount) { |
|
452 | 452 | continue; |
453 | 453 | } |
454 | 454 | |
@@ -469,19 +469,19 @@ discard block |
||
469 | 469 | $objFleet2->dbId = $this->db_id; |
470 | 470 | |
471 | 471 | // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли |
472 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
472 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
473 | 473 | $objFleet2->dbDelete(); |
474 | - } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
474 | + } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
475 | 475 | $objFleet2->dbDelete(); |
476 | 476 | } else { |
477 | - if($ship_count_lost) { |
|
477 | + if ($ship_count_lost) { |
|
478 | 478 | // Просматриваем результаты изменения флотов |
479 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
479 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
480 | 480 | // Перебираем аутком на случай восстановления юнитов |
481 | 481 | // if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) { |
482 | 482 | // $fleet_real_array[$UBEUnit->unitId] = $units_left; |
483 | 483 | // }; |
484 | - if(floatval($UBEUnit->units_lost) != 0) { |
|
484 | + if (floatval($UBEUnit->units_lost) != 0) { |
|
485 | 485 | $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost)); |
486 | 486 | }; |
487 | 487 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | $objFleet2->resourcesAdjust($resource_delta_fleet); |
492 | 492 | |
493 | 493 | // Если защитник и не РМФ - отправляем флот назад |
494 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
494 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
495 | 495 | $objFleet2->is_returning = 1; |
496 | 496 | } |
497 | 497 | $objFleet2->dbSave(); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | public function calculate_unit_partial_data(UBEASA $side_ASA) { |
522 | 522 | $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor(); |
523 | 523 | |
524 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
524 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
525 | 525 | $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor(); |
526 | 526 | } |
527 | 527 | } |
@@ -533,9 +533,9 @@ discard block |
||
533 | 533 | * @version 2016-02-25 23:42:45 41a4.68 |
534 | 534 | */ |
535 | 535 | public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) { |
536 | - foreach($fleet_list->_container as $defending_fleet) { |
|
536 | + foreach ($fleet_list->_container as $defending_fleet) { |
|
537 | 537 | // Не атакуются флоты на своей стороне |
538 | - if($this->is_attacker == $defending_fleet->is_attacker) { |
|
538 | + if ($this->is_attacker == $defending_fleet->is_attacker) { |
|
539 | 539 | continue; |
540 | 540 | } |
541 | 541 | $this->attack_fleet($defending_fleet, $is_simulator); |
@@ -550,12 +550,12 @@ discard block |
||
550 | 550 | public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) { |
551 | 551 | UBEDebug::unit_dump_header(); |
552 | 552 | |
553 | - foreach($this->unit_list->_container as $attacking_unit_pool) { |
|
553 | + foreach ($this->unit_list->_container as $attacking_unit_pool) { |
|
554 | 554 | UBEDebug::unit_dump($attacking_unit_pool, 'attacker'); |
555 | 555 | |
556 | 556 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
557 | - foreach($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
558 | - if($defending_unit_pool->isEmpty()) { |
|
557 | + foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
558 | + if ($defending_unit_pool->isEmpty()) { |
|
559 | 559 | continue; |
560 | 560 | } |
561 | 561 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @version 41a6.0 |
12 | 12 | */ |
13 | 13 | public static function unit_dump_header() { |
14 | - if(!defined('DEBUG_UBE')) { |
|
14 | + if (!defined('DEBUG_UBE')) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @version 41a6.0 |
49 | 49 | */ |
50 | 50 | public static function unit_dump(UBEUnit $unit, $desc = '', UBEUnit $before = null) { |
51 | - if(!defined('DEBUG_UBE')) { |
|
51 | + if (!defined('DEBUG_UBE')) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @version 41a6.0 |
87 | 87 | */ |
88 | 88 | public static function unit_dump_footer() { |
89 | - if(!defined('DEBUG_UBE')) { |
|
89 | + if (!defined('DEBUG_UBE')) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return UBEUnit |
102 | 102 | */ |
103 | 103 | public static function unit_dump_defender(UBEUnit $attacking_unit_pool, UBEUnit $defending_unit_pool, $defending_fleet_id) { |
104 | - if(!defined('DEBUG_UBE')) { |
|
104 | + if (!defined('DEBUG_UBE')) { |
|
105 | 105 | return null; |
106 | 106 | } |
107 | 107 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @version 41a6.0 |
128 | 128 | */ |
129 | 129 | public static function unit_dump_delta(UBEUnit $unit, $field, UBEUnit $before = null) { |
130 | - if(!defined('DEBUG_UBE')) { |
|
130 | + if (!defined('DEBUG_UBE')) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | print(pretty_number($unit->$field)); |
137 | 137 | print("</td>"); |
138 | 138 | print("<td>"); |
139 | - if(!empty($before)) { |
|
139 | + if (!empty($before)) { |
|
140 | 140 | print('' . pretty_number($unit->$field - $before->$field) . ''); |
141 | 141 | } |
142 | 142 | print("</td>"); |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function sn_ube_report_save($ube) { |
15 | 15 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
16 | - if($ube->get_cypher()) { |
|
16 | + if ($ube->get_cypher()) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
20 | 20 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
21 | 21 | do { |
22 | 22 | $ube->report_cypher = sys_random_string(32); |
23 | - } while(classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
23 | + } while (classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
24 | 24 | |
25 | 25 | // Инициализация таблицы для пакетной вставки информации |
26 | 26 | $sql_perform = array( |
@@ -106,21 +106,21 @@ discard block |
||
106 | 106 | |
107 | 107 | // Сохраняем общую информацию о бое |
108 | 108 | classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array( |
109 | - 'ube_report_cypher' => (string)$ube->report_cypher, |
|
110 | - 'ube_report_time_combat' => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | - 'ube_report_time_spent' => (float)$ube->time_spent, |
|
112 | - 'ube_report_combat_admin' => (int)$ube->is_admin_in_combat, |
|
113 | - 'ube_report_mission_type' => (int)$ube->mission_type_id, |
|
114 | - 'ube_report_combat_result' => (int)$ube->combat_result, |
|
115 | - 'ube_report_combat_sfr' => (int)$ube->is_small_fleet_recce, |
|
116 | - 'ube_report_planet_id' => (int)$ube->ube_planet_info[PLANET_ID], |
|
117 | - 'ube_report_planet_name' => (string)$ube->ube_planet_info[PLANET_NAME], |
|
118 | - 'ube_report_planet_size' => (int)$ube->ube_planet_info[PLANET_SIZE], |
|
119 | - 'ube_report_planet_galaxy' => (int)$ube->ube_planet_info[PLANET_GALAXY], |
|
120 | - 'ube_report_planet_system' => (int)$ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | - 'ube_report_planet_planet' => (int)$ube->ube_planet_info[PLANET_PLANET], |
|
122 | - 'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE], |
|
123 | - 'ube_report_capture_result' => (int)$ube->capture_result, |
|
109 | + 'ube_report_cypher' => (string) $ube->report_cypher, |
|
110 | + 'ube_report_time_combat' => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | + 'ube_report_time_spent' => (float) $ube->time_spent, |
|
112 | + 'ube_report_combat_admin' => (int) $ube->is_admin_in_combat, |
|
113 | + 'ube_report_mission_type' => (int) $ube->mission_type_id, |
|
114 | + 'ube_report_combat_result' => (int) $ube->combat_result, |
|
115 | + 'ube_report_combat_sfr' => (int) $ube->is_small_fleet_recce, |
|
116 | + 'ube_report_planet_id' => (int) $ube->ube_planet_info[PLANET_ID], |
|
117 | + 'ube_report_planet_name' => (string) $ube->ube_planet_info[PLANET_NAME], |
|
118 | + 'ube_report_planet_size' => (int) $ube->ube_planet_info[PLANET_SIZE], |
|
119 | + 'ube_report_planet_galaxy' => (int) $ube->ube_planet_info[PLANET_GALAXY], |
|
120 | + 'ube_report_planet_system' => (int) $ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | + 'ube_report_planet_planet' => (int) $ube->ube_planet_info[PLANET_PLANET], |
|
122 | + 'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE], |
|
123 | + 'ube_report_capture_result' => (int) $ube->capture_result, |
|
124 | 124 | ) |
125 | 125 | + $ube->debris->report_generate_array() |
126 | 126 | + $ube->moon_calculator->report_generate_array() |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | // Сохраняем общую информацию по игрокам |
131 | 131 | $player_sides = $ube->players->get_player_sides(); |
132 | - foreach($player_sides as $player_id => $player_side) { |
|
132 | + foreach ($player_sides as $player_id => $player_side) { |
|
133 | 133 | $sql_perform['ube_report_player'][] = array( |
134 | 134 | $ube_report_id, |
135 | 135 | $player_id, |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | "'" . db_escape($ube->players[$player_id]->name) . "'", |
138 | 138 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
139 | 139 | |
140 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
140 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Всякая информация по флотам |
147 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
147 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
148 | 148 | // Сохраняем общую информацию по флотам |
149 | 149 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
150 | 150 | |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | |
161 | 161 | // Пакетная вставка данных |
162 | 162 | // First row is a list of field names |
163 | - foreach($sql_perform as $table_name => &$table_data) { |
|
163 | + foreach ($sql_perform as $table_name => &$table_data) { |
|
164 | 164 | // If only field names in this table - doing nothing |
165 | - if(count($table_data) < 2) { |
|
165 | + if (count($table_data) < 2) { |
|
166 | 166 | continue; |
167 | 167 | } |
168 | 168 | // Picking up field names |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $report_cypher = db_escape($report_cypher); |
186 | 186 | |
187 | 187 | $report_row = classSupernova::$db->doSelectFetchArray("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1"); |
188 | - if(!$report_row) { |
|
188 | + if (!$report_row) { |
|
189 | 189 | return UBE_REPORT_NOT_FOUND; |
190 | 190 | } |
191 | 191 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param $template_result |
202 | 202 | */ |
203 | 203 | public function sn_ube_report_generate(UBE $ube, &$template_result) { |
204 | - if(!is_object($ube)) { |
|
204 | + if (!is_object($ube)) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
@@ -216,15 +216,15 @@ discard block |
||
216 | 216 | |
217 | 217 | // Координаты, тип и название планеты - если есть |
218 | 218 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
219 | - if(isset($ube->ube_planet_info)) { |
|
219 | + if (isset($ube->ube_planet_info)) { |
|
220 | 220 | $template_result += $ube->ube_planet_info; |
221 | 221 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
222 | 222 | } |
223 | 223 | |
224 | 224 | // Обломки |
225 | 225 | $debris = array(); |
226 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
227 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
226 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
227 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
228 | 228 | $debris[] = array( |
229 | 229 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
230 | 230 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $debris_for_moon = $debris->debris_total(); |
74 | 74 | |
75 | - if(!$debris_for_moon) { |
|
75 | + if (!$debris_for_moon) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
81 | 81 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
82 | 82 | $this->create_chance = $moon_chance; |
83 | - if($moon_chance) { |
|
84 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | + if ($moon_chance) { |
|
84 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
85 | 85 | $this->status = UBE_MOON_CREATE_SUCCESS; |
86 | 86 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
87 | 87 | |
88 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
88 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
89 | 89 | $debris->_reset(); |
90 | 90 | } else { |
91 | 91 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function moon_destroy_try($reapers) { |
106 | 106 | // TODO: $is_simulator |
107 | - if($reapers <= 0) { |
|
107 | + if ($reapers <= 0) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @version 2016-02-25 23:42:45 41a4.68 |
123 | 123 | */ |
124 | 124 | public function calculate_moon(UBE $ube) { |
125 | - if(UBE_MOON_EXISTS == $this->status) { |
|
126 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | + if (UBE_MOON_EXISTS == $this->status) { |
|
126 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
127 | 127 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
128 | 128 | $this->moon_destroy_try($reapers); |
129 | 129 | } |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function report_generate_array() { |
139 | 139 | return array( |
140 | - 'ube_report_moon' => (int)$this->status, |
|
141 | - 'ube_report_moon_chance' => (int)$this->create_chance, |
|
142 | - 'ube_report_moon_size' => (float)$this->moon_diameter, |
|
143 | - 'ube_report_moon_reapers' => (int)$this->reapers_status, |
|
144 | - 'ube_report_moon_destroy_chance' => (int)$this->destroy_chance, |
|
145 | - 'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance, |
|
140 | + 'ube_report_moon' => (int) $this->status, |
|
141 | + 'ube_report_moon_chance' => (int) $this->create_chance, |
|
142 | + 'ube_report_moon_size' => (float) $this->moon_diameter, |
|
143 | + 'ube_report_moon_reapers' => (int) $this->reapers_status, |
|
144 | + 'ube_report_moon_destroy_chance' => (int) $this->destroy_chance, |
|
145 | + 'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance, |
|
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @param $planet_id |
174 | 174 | */ |
175 | 175 | public function db_apply_result($planet_info, $destination_user_id) { |
176 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
176 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
177 | 177 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
178 | 178 | $this->moon_name = $moon_row['name']; |
179 | 179 | unset($moon_row); |
180 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
180 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
181 | 181 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
182 | 182 | } |
183 | 183 | } |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | $classLocale = classLocale::$lang; |
187 | 187 | |
188 | 188 | $text_defender = ''; |
189 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
189 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
190 | 190 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
191 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
191 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
192 | 192 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
193 | 193 | } |
194 | 194 | |
195 | - if($ube->mission_type_id == MT_DESTROY) { |
|
196 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
195 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
196 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
197 | 197 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
198 | 198 | } else { |
199 | 199 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @version 2016-02-25 23:42:45 41a4.68 |
223 | 223 | */ |
224 | 224 | public function ubeInitLoadStatis($destination_planet) { |
225 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
225 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
226 | 226 | $this->status = UBE_MOON_EXISTS; |
227 | 227 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
228 | 228 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER); |
151 | 151 | |
152 | 152 | $player_db_row = $this->players[$player_id]->getDbRow(); |
153 | - if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
153 | + if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
154 | 154 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level); |
155 | 155 | } |
156 | 156 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->rounds[0] = new UBERound(0); |
182 | 182 | $this->rounds[0]->make_snapshot($this->fleet_list); |
183 | 183 | |
184 | - for($round = 1; $round <= 10; $round++) { |
|
184 | + for ($round = 1; $round <= 10; $round++) { |
|
185 | 185 | // Проводим раунд |
186 | 186 | defined('DEBUG_UBE') ? print("Round {$round}<br>") : false; |
187 | 187 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | // Анализируем итоги текущего раунда и готовим данные для следующего |
196 | 196 | $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round); |
197 | - if($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
197 | + if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
198 | 198 | break; |
199 | 199 | } |
200 | 200 | |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | // Генерируем результат боя |
224 | 224 | $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates); |
225 | 225 | |
226 | - if(!$this->is_ube_loaded) { |
|
226 | + if (!$this->is_ube_loaded) { |
|
227 | 227 | $this->moon_calculator->calculate_moon($this); |
228 | 228 | |
229 | 229 | // Лутаем ресурсы - если аттакер выиграл |
230 | - if($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
230 | + if ($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
231 | 231 | $this->sn_ube_combat_analyze_loot(); |
232 | 232 | } |
233 | 233 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | RES_DEUTERIUM => 0, |
248 | 248 | ); |
249 | 249 | |
250 | - if( |
|
250 | + if ( |
|
251 | 251 | (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0) |
252 | 252 | && |
253 | 253 | (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0) |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | $planet_lootable_percent = $planet_lootable / $planet_resource_total; |
260 | 260 | |
261 | 261 | // Вычисляем сколько ресурсов вывезено |
262 | - foreach($this->fleet_list->_container as $fleet_id => $fleet) { |
|
262 | + foreach ($this->fleet_list->_container as $fleet_id => $fleet) { |
|
263 | 263 | $looted_in_metal = 0; |
264 | - foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
264 | + foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
265 | 265 | // Вычисляем какой процент общей емкости трюмов атакующих будет задействован |
266 | 266 | $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity; |
267 | 267 | $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $destination_user_id = $this->fleet_list[0]->owner_id; |
327 | 327 | |
328 | 328 | // Обновляем поле обломков на планете |
329 | - if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
329 | + if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
330 | 330 | DBStaticPlanet::db_planet_update_by_gspt( |
331 | 331 | $this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET, |
332 | 332 | array(), |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
340 | - foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
340 | + foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
341 | 341 | $ship_count_lost = $UBEFleet->unit_list->unitCountLost(); |
342 | 342 | |
343 | - if($fleet_id) { |
|
343 | + if ($fleet_id) { |
|
344 | 344 | // Флот |
345 | 345 | $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status()); |
346 | 346 | } else { |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | |
349 | 349 | // Сохраняем изменения ресурсов - если они есть |
350 | 350 | $resource_delta = $UBEFleet->ube_combat_result_calculate_resources(); |
351 | - if(!empty($resource_delta)) { |
|
351 | + if (!empty($resource_delta)) { |
|
352 | 352 | $temp = array(); |
353 | - foreach($resource_delta as $resource_id => $resource_amount) { |
|
353 | + foreach ($resource_delta as $resource_id => $resource_amount) { |
|
354 | 354 | $resource_db_name = pname_resource_name($resource_id); |
355 | 355 | $temp[$resource_db_name] = $resource_amount; |
356 | 356 | } |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | ); |
361 | 361 | } |
362 | 362 | |
363 | - if($ship_count_lost) { |
|
363 | + if ($ship_count_lost) { |
|
364 | 364 | $planet_row_cache = $this->players[$destination_user_id]->getDbRow(); |
365 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
365 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
366 | 366 | DBStaticUnit::dbUpdateOrInsertUnit($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]); |
367 | 367 | } |
368 | 368 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL |
373 | 373 | // Для САБов |
374 | 374 | $fleet_group_id_list = $this->fleet_list->ube_get_groups(); |
375 | - if(!empty($fleet_group_id_list)) { |
|
375 | + if (!empty($fleet_group_id_list)) { |
|
376 | 376 | $fleet_group_id_list = implode(',', $fleet_group_id_list); |
377 | 377 | DBStaticFleetACS::db_acs_delete_by_list($fleet_group_id_list); |
378 | 378 | } |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | $this->moon_calculator->db_apply_result($this->ube_planet_info, $destination_user_id); |
381 | 381 | |
382 | 382 | $bashing_list = array(); |
383 | - foreach($this->players->get_player_sides() as $player_id => $player_side) { |
|
384 | - if($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
383 | + foreach ($this->players->get_player_sides() as $player_id => $player_side) { |
|
384 | + if ($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
385 | 385 | continue; |
386 | 386 | } |
387 | - if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
387 | + if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
388 | 388 | $bashing_list[] = array($player_id, $this->ube_planet_info[PLANET_ID], $this->combat_timestamp); |
389 | 389 | } |
390 | - if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
390 | + if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
391 | 391 | $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose'; |
392 | 392 | DBStaticUser::db_user_adjust_by_id( |
393 | 393 | $player_id, |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | ); |
400 | 400 | } |
401 | 401 | } |
402 | - if(!empty($bashing_list)) { |
|
402 | + if (!empty($bashing_list)) { |
|
403 | 403 | DBStaticFleetBashing::db_bashing_insert($bashing_list); |
404 | 404 | } |
405 | 405 | |
@@ -425,20 +425,19 @@ discard block |
||
425 | 425 | $planet_info[PLANET_SYSTEM], |
426 | 426 | $planet_info[PLANET_PLANET], |
427 | 427 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
428 | - classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
429 | - ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
428 | + classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
430 | 429 | ); |
431 | 430 | |
432 | 431 | $text_defender = ''; |
433 | 432 | $debris = $this->debris->get_debris(); |
434 | - foreach($debris as $resource_id => $resource_amount) { |
|
435 | - if($resource_id == RES_DEUTERIUM) { |
|
433 | + foreach ($debris as $resource_id => $resource_amount) { |
|
434 | + if ($resource_id == RES_DEUTERIUM) { |
|
436 | 435 | continue; |
437 | 436 | } |
438 | 437 | |
439 | 438 | $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />'; |
440 | 439 | } |
441 | - if($text_defender) { |
|
440 | + if ($text_defender) { |
|
442 | 441 | $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />"; |
443 | 442 | } |
444 | 443 | |
@@ -448,7 +447,7 @@ discard block |
||
448 | 447 | |
449 | 448 | // TODO: Оптимизировать отсылку сообщений - отсылать пакетами |
450 | 449 | $player_sides = $this->players->get_player_sides(); |
451 | - foreach($player_sides as $player_id => $player_side) { |
|
450 | + foreach ($player_sides as $player_id => $player_side) { |
|
452 | 451 | $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
453 | 452 | DBStaticMessages::msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message); |
454 | 453 | } |
@@ -484,11 +483,11 @@ discard block |
||
484 | 483 | $player_id = $player_id == -1 ? $this->players->count() : $player_id; |
485 | 484 | $fleet_id = $player_id; // FOR SIMULATOR! |
486 | 485 | |
487 | - if(empty($this->players[$player_id])) { |
|
486 | + if (empty($this->players[$player_id])) { |
|
488 | 487 | $this->players[$player_id] = new UBEPlayer(); |
489 | 488 | } |
490 | 489 | |
491 | - foreach($side_info as $fleet_data) { |
|
490 | + foreach ($side_info as $fleet_data) { |
|
492 | 491 | $this->players[$player_id]->name = $player_id; |
493 | 492 | $this->players[$player_id]->setSide($attacker); |
494 | 493 | |
@@ -496,32 +495,32 @@ discard block |
||
496 | 495 | $this->fleet_list[$fleet_id] = $objFleet; |
497 | 496 | |
498 | 497 | $this->fleet_list[$fleet_id]->owner_id = $player_id; |
499 | - foreach($fleet_data as $unit_id => $unit_count) { |
|
500 | - if(!$unit_count) { |
|
498 | + foreach ($fleet_data as $unit_id => $unit_count) { |
|
499 | + if (!$unit_count) { |
|
501 | 500 | continue; |
502 | 501 | } |
503 | 502 | |
504 | 503 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
505 | 504 | |
506 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
505 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
507 | 506 | $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count); |
508 | - } elseif($unit_type == UNIT_RESOURCES) { |
|
507 | + } elseif ($unit_type == UNIT_RESOURCES) { |
|
509 | 508 | $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count; |
510 | - } elseif($unit_type == UNIT_TECHNOLOGIES) { |
|
511 | - if($unit_id == TECH_WEAPON) { |
|
509 | + } elseif ($unit_type == UNIT_TECHNOLOGIES) { |
|
510 | + if ($unit_id == TECH_WEAPON) { |
|
512 | 511 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count); |
513 | - } elseif($unit_id == TECH_SHIELD) { |
|
512 | + } elseif ($unit_id == TECH_SHIELD) { |
|
514 | 513 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count); |
515 | - } elseif($unit_id == TECH_ARMOR) { |
|
514 | + } elseif ($unit_id == TECH_ARMOR) { |
|
516 | 515 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count); |
517 | 516 | } |
518 | - } elseif($unit_type == UNIT_GOVERNORS) { |
|
519 | - if($unit_id == MRC_FORTIFIER) { |
|
517 | + } elseif ($unit_type == UNIT_GOVERNORS) { |
|
518 | + if ($unit_id == MRC_FORTIFIER) { |
|
520 | 519 | // Фортифаер даёт бонус ко всему |
521 | 520 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count); |
522 | 521 | } |
523 | - } elseif($unit_type == UNIT_MERCENARIES) { |
|
524 | - if($unit_id == MRC_ADMIRAL) { |
|
522 | + } elseif ($unit_type == UNIT_MERCENARIES) { |
|
523 | + if ($unit_id == MRC_ADMIRAL) { |
|
525 | 524 | $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count); |
526 | 525 | } |
527 | 526 | } |
@@ -590,7 +589,7 @@ discard block |
||
590 | 589 | |
591 | 590 | $ube_report = new UBEReport(); |
592 | 591 | $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher')); |
593 | - if($ube != UBE_REPORT_NOT_FOUND) { |
|
592 | + if ($ube != UBE_REPORT_NOT_FOUND) { |
|
594 | 593 | $ube_report->sn_ube_report_generate($ube, $template_result); |
595 | 594 | |
596 | 595 | $template = gettemplate('ube_combat_report', $template); |
@@ -618,9 +617,9 @@ discard block |
||
618 | 617 | $ube->sn_ube_combat(); |
619 | 618 | $ube_report = new UBEReport(); |
620 | 619 | |
621 | - if(sys_get_param_str('reload')) { |
|
620 | + if (sys_get_param_str('reload')) { |
|
622 | 621 | $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
623 | - if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
622 | + if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
624 | 623 | $ube = $ube_new; |
625 | 624 | } |
626 | 625 | } |
@@ -668,7 +667,7 @@ discard block |
||
668 | 667 | $this->debris->load_from_report_row($report_row); |
669 | 668 | |
670 | 669 | $query = classSupernova::$db->doSelect("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
671 | - while($player_row = db_fetch($query)) { |
|
670 | + while ($player_row = db_fetch($query)) { |
|
672 | 671 | $this->players->init_player_from_report_info($player_row); |
673 | 672 | } |
674 | 673 |