@@ -24,7 +24,9 @@ |
||
| 24 | 24 | * DO NOT CHANGE |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -if (!defined('INSIDE')) die(); |
|
| 27 | +if (!defined('INSIDE')) { |
|
| 28 | + die(); |
|
| 29 | +} |
|
| 28 | 30 | |
| 29 | 31 | |
| 30 | 32 | $a_lang_array = (array( |
@@ -24,7 +24,9 @@ |
||
| 24 | 24 | * DO NOT CHANGE |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -if (!defined('INSIDE')) die(); |
|
| 27 | +if (!defined('INSIDE')) { |
|
| 28 | + die(); |
|
| 29 | +} |
|
| 28 | 30 | |
| 29 | 31 | |
| 30 | 32 | $a_lang_array = (array( |
@@ -115,8 +115,7 @@ |
||
| 115 | 115 | )); |
| 116 | 116 | |
| 117 | 117 | display($template, $lang['tech'][STRUC_MOON_GATE]); |
| 118 | - } |
|
| 119 | - else |
|
| 118 | + } else |
|
| 120 | 119 | { |
| 121 | 120 | message($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10); |
| 122 | 121 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call(__FUNCTION__, array(&$template, &$admin_planet_edit_mode_list));} |
|
| 3 | +function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call(__FUNCTION__, array(&$template, &$admin_planet_edit_mode_list)); } |
|
| 4 | 4 | function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
| 5 | 5 | { |
| 6 | 6 | global $lang; |
@@ -19,19 +19,19 @@ discard block |
||
| 19 | 19 | return $mode; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call(__FUNCTION__, array(&$template, $edit_planet_row, $mode));} |
|
| 22 | +function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call(__FUNCTION__, array(&$template, $edit_planet_row, $mode)); } |
|
| 23 | 23 | function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) |
| 24 | 24 | { |
| 25 | 25 | global $lang; |
| 26 | 26 | |
| 27 | 27 | $unit_list = sn_get_groups($mode); |
| 28 | - if(empty($unit_list)) |
|
| 28 | + if (empty($unit_list)) |
|
| 29 | 29 | { |
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | $name_list = $lang['tech']; |
| 33 | 33 | |
| 34 | - foreach($unit_list as $unit_id) |
|
| 34 | + foreach ($unit_list as $unit_id) |
|
| 35 | 35 | { |
| 36 | 36 | $template->assign_block_vars('unit', array( |
| 37 | 37 | 'ID' => $unit_id, |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode));} |
|
| 45 | +function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); } |
|
| 46 | 46 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
| 47 | 47 | { |
| 48 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
| 48 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
| 49 | 49 | { |
| 50 | 50 | $unit_amount = round($unit_amount); |
| 51 | 51 | $unit_name = get_unit_param($unit_id, P_NAME); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * Добавляет юнит к списку бонусов |
| 26 | 26 | * |
| 27 | - * @param $unit_id |
|
| 27 | + * @param integer $unit_id |
|
| 28 | 28 | * @param $unit_level |
| 29 | 29 | */ |
| 30 | 30 | public function add_unit_by_snid($unit_id, $unit_level) { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * Выдает финальный бонус в виде множителя |
| 69 | 69 | * |
| 70 | - * @param string|int $param - ИД бонуса |
|
| 70 | + * @param string $param - ИД бонуса |
|
| 71 | 71 | * |
| 72 | 72 | * @return float |
| 73 | 73 | */ |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | * @param $unit_level |
| 29 | 29 | */ |
| 30 | 30 | public function add_unit_by_snid($unit_id, $unit_level) { |
| 31 | - if(!$unit_level) { |
|
| 31 | + if (!$unit_level) { |
|
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - foreach(static::$_bonus_group as $param_name => $unit_list) { |
|
| 36 | - if(!empty($unit_list[$unit_id])) { |
|
| 35 | + foreach (static::$_bonus_group as $param_name => $unit_list) { |
|
| 36 | + if (!empty($unit_list[$unit_id])) { |
|
| 37 | 37 | // Простейший вариант - мультипликатор по базе |
| 38 | 38 | // Общий мультипликатор добавляется в конец |
| 39 | 39 | $this->grants[$param_name][$unit_id] = $unit_level; |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | // $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;; |
| 83 | 83 | $value_add = floatval($base_value); |
| 84 | 84 | $cumulative = 1.0; // Для случая BONUS_PERCENT |
| 85 | - if(!empty($this->grants[$param]) && is_array($this->grants[$param])) { |
|
| 86 | - foreach($this->grants[$param] as $unit_id => $unit_level) { |
|
| 85 | + if (!empty($this->grants[$param]) && is_array($this->grants[$param])) { |
|
| 86 | + foreach ($this->grants[$param] as $unit_id => $unit_level) { |
|
| 87 | 87 | $unit_bonus = 0; |
| 88 | - if($unit_id < 0) { |
|
| 88 | + if ($unit_id < 0) { |
|
| 89 | 89 | // Meta-unit - leave as is |
| 90 | 90 | } else { |
| 91 | 91 | // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать |
| 92 | 92 | $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE); |
| 93 | 93 | $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE); |
| 94 | - switch($bonus_type) { |
|
| 94 | + switch ($bonus_type) { |
|
| 95 | 95 | case BONUS_PERCENT: |
| 96 | 96 | $unit_bonus = $unit_level * $bonus_value / 100; |
| 97 | 97 | $cumulative += $unit_bonus; |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * Преобразовывает данные симулятора в данные для расчета боя |
| 465 | 465 | * |
| 466 | 466 | * @param $side_info |
| 467 | - * @param $attacker |
|
| 467 | + * @param boolean $attacker |
|
| 468 | 468 | * @param int $player_id |
| 469 | 469 | * |
| 470 | 470 | * @version 41a6.22 |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
| 575 | - * @param $template |
|
| 575 | + * @param null|template $template |
|
| 576 | 576 | * |
| 577 | 577 | * @return template |
| 578 | 578 | */ |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER); |
| 148 | 148 | |
| 149 | 149 | $player_db_row = $this->players[$player_id]->getDbRow(); |
| 150 | - if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
| 150 | + if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
| 151 | 151 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $this->rounds[0] = new UBERound(0); |
| 180 | 180 | $this->rounds[0]->make_snapshot($this->fleet_list); |
| 181 | 181 | |
| 182 | - for($round = 1; $round <= 10; $round++) { |
|
| 182 | + for ($round = 1; $round <= 10; $round++) { |
|
| 183 | 183 | // Проводим раунд |
| 184 | 184 | defined('DEBUG_UBE') ? print("Round {$round}<br>") : false; |
| 185 | 185 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | // Анализируем итоги текущего раунда и готовим данные для следующего |
| 194 | 194 | $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round); |
| 195 | - if($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
| 195 | + if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
| 196 | 196 | break; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -221,11 +221,11 @@ discard block |
||
| 221 | 221 | // Генерируем результат боя |
| 222 | 222 | $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates); |
| 223 | 223 | |
| 224 | - if(!$this->is_ube_loaded) { |
|
| 224 | + if (!$this->is_ube_loaded) { |
|
| 225 | 225 | $this->moon_calculator->calculate_moon($this); |
| 226 | 226 | |
| 227 | 227 | // Лутаем ресурсы - если аттакер выиграл |
| 228 | - if($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
| 228 | + if ($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
| 229 | 229 | $this->sn_ube_combat_analyze_loot(); |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | RES_DEUTERIUM => 0, |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | - if( |
|
| 248 | + if ( |
|
| 249 | 249 | (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0) |
| 250 | 250 | && |
| 251 | 251 | (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0) |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | $planet_lootable_percent = $planet_lootable / $planet_resource_total; |
| 258 | 258 | |
| 259 | 259 | // Вычисляем сколько ресурсов вывезено |
| 260 | - foreach($this->fleet_list->_container as $fleet_id => $fleet) { |
|
| 260 | + foreach ($this->fleet_list->_container as $fleet_id => $fleet) { |
|
| 261 | 261 | $looted_in_metal = 0; |
| 262 | - foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
| 262 | + foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
| 263 | 263 | // Вычисляем какой процент общей емкости трюмов атакующих будет задействован |
| 264 | 264 | $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity; |
| 265 | 265 | $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent); |
@@ -325,16 +325,16 @@ discard block |
||
| 325 | 325 | $destination_user_id = $this->fleet_list[0]->owner_id; |
| 326 | 326 | |
| 327 | 327 | // Обновляем поле обломков на планете |
| 328 | - if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
| 328 | + if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
| 329 | 329 | db_planet_set_by_gspt($this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET, |
| 330 | 330 | "`debris_metal` = `debris_metal` + " . $this->debris->debris_get_resource(RES_METAL) . ", `debris_crystal` = `debris_crystal` + " . $this->debris->debris_get_resource(RES_CRYSTAL) |
| 331 | 331 | ); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
| 334 | + foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
| 335 | 335 | $ship_count_lost = $UBEFleet->unit_list->unitCountLost(); |
| 336 | 336 | |
| 337 | - if($fleet_id) { |
|
| 337 | + if ($fleet_id) { |
|
| 338 | 338 | // Флот |
| 339 | 339 | $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status()); |
| 340 | 340 | } else { |
@@ -342,19 +342,19 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | // Сохраняем изменения ресурсов - если они есть |
| 344 | 344 | $resource_delta = $UBEFleet->ube_combat_result_calculate_resources(); |
| 345 | - if(!empty($resource_delta)) { |
|
| 345 | + if (!empty($resource_delta)) { |
|
| 346 | 346 | $temp = array(); |
| 347 | - foreach($resource_delta as $resource_id => $resource_amount) { |
|
| 347 | + foreach ($resource_delta as $resource_id => $resource_amount) { |
|
| 348 | 348 | $resource_db_name = pname_resource_name($resource_id); |
| 349 | 349 | $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})"; |
| 350 | 350 | } |
| 351 | 351 | db_planet_set_by_id($this->ube_planet_info[PLANET_ID], implode(',', $temp)); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if($ship_count_lost) { |
|
| 354 | + if ($ship_count_lost) { |
|
| 355 | 355 | $db_changeset = array(); |
| 356 | 356 | $planet_row_cache = $this->players[$destination_user_id]->getDbRow(); |
| 357 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
| 357 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
| 358 | 358 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]); |
| 359 | 359 | } |
| 360 | 360 | db_changeset_apply($db_changeset); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL |
| 366 | 366 | // Для САБов |
| 367 | 367 | $fleet_group_id_list = $this->fleet_list->ube_get_groups(); |
| 368 | - if(!empty($fleet_group_id_list)) { |
|
| 368 | + if (!empty($fleet_group_id_list)) { |
|
| 369 | 369 | $fleet_group_id_list = implode(',', $fleet_group_id_list); |
| 370 | 370 | db_acs_delete_by_list($fleet_group_id_list); |
| 371 | 371 | } |
@@ -374,19 +374,19 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | $bashing_list = array(); |
| 376 | 376 | $players_sides = $this->players->get_player_sides(); |
| 377 | - foreach($players_sides as $player_id => $player_side) { |
|
| 378 | - if($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
| 377 | + foreach ($players_sides as $player_id => $player_side) { |
|
| 378 | + if ($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
| 379 | 379 | continue; |
| 380 | 380 | } |
| 381 | - if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
| 381 | + if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
| 382 | 382 | $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})"; |
| 383 | 383 | } |
| 384 | - if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
| 384 | + if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
| 385 | 385 | $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose'; |
| 386 | 386 | db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1"); |
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | - if(!empty($bashing_list)) { |
|
| 389 | + if (!empty($bashing_list)) { |
|
| 390 | 390 | $bashing_list = implode(',', $bashing_list); |
| 391 | 391 | db_bashing_insert($bashing_list); |
| 392 | 392 | } |
@@ -413,20 +413,19 @@ discard block |
||
| 413 | 413 | $planet_info[PLANET_SYSTEM], |
| 414 | 414 | $planet_info[PLANET_PLANET], |
| 415 | 415 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
| 416 | - $lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
| 417 | - ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
| 416 | + $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')] |
|
| 418 | 417 | ); |
| 419 | 418 | |
| 420 | 419 | $text_defender = ''; |
| 421 | 420 | $debris = $this->debris->get_debris(); |
| 422 | - foreach($debris as $resource_id => $resource_amount) { |
|
| 423 | - if($resource_id == RES_DEUTERIUM) { |
|
| 421 | + foreach ($debris as $resource_id => $resource_amount) { |
|
| 422 | + if ($resource_id == RES_DEUTERIUM) { |
|
| 424 | 423 | continue; |
| 425 | 424 | } |
| 426 | 425 | |
| 427 | 426 | $text_defender .= "{$lang['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />'; |
| 428 | 427 | } |
| 429 | - if($text_defender) { |
|
| 428 | + if ($text_defender) { |
|
| 430 | 429 | $text_defender = "{$lang['ube_report_msg_body_debris']}{$text_defender}<br />"; |
| 431 | 430 | } |
| 432 | 431 | |
@@ -436,7 +435,7 @@ discard block |
||
| 436 | 435 | |
| 437 | 436 | // TODO: Оптимизировать отсылку сообщений - отсылать пакетами |
| 438 | 437 | $player_sides = $this->players->get_player_sides(); |
| 439 | - foreach($player_sides as $player_id => $player_side) { |
|
| 438 | + foreach ($player_sides as $player_id => $player_side) { |
|
| 440 | 439 | $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? $lang['ube_report_msg_body_sfr'] : $text_defender); |
| 441 | 440 | msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $message); |
| 442 | 441 | } |
@@ -473,11 +472,11 @@ discard block |
||
| 473 | 472 | $player_id = $player_id == -1 ? $this->players->count() : $player_id; |
| 474 | 473 | $fleet_id = $player_id; // FOR SIMULATOR! |
| 475 | 474 | |
| 476 | - if(empty($this->players[$player_id])) { |
|
| 475 | + if (empty($this->players[$player_id])) { |
|
| 477 | 476 | $this->players[$player_id] = new UBEPlayer(); |
| 478 | 477 | } |
| 479 | 478 | |
| 480 | - foreach($side_info as $fleet_data) { |
|
| 479 | + foreach ($side_info as $fleet_data) { |
|
| 481 | 480 | $this->players[$player_id]->name = $player_id; |
| 482 | 481 | $this->players[$player_id]->setSide($attacker); |
| 483 | 482 | |
@@ -485,32 +484,32 @@ discard block |
||
| 485 | 484 | $this->fleet_list[$fleet_id] = $objFleet; |
| 486 | 485 | |
| 487 | 486 | $this->fleet_list[$fleet_id]->owner_id = $player_id; |
| 488 | - foreach($fleet_data as $unit_id => $unit_count) { |
|
| 489 | - if(!$unit_count) { |
|
| 487 | + foreach ($fleet_data as $unit_id => $unit_count) { |
|
| 488 | + if (!$unit_count) { |
|
| 490 | 489 | continue; |
| 491 | 490 | } |
| 492 | 491 | |
| 493 | 492 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
| 494 | 493 | |
| 495 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
| 494 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
| 496 | 495 | $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count); |
| 497 | - } elseif($unit_type == UNIT_RESOURCES) { |
|
| 496 | + } elseif ($unit_type == UNIT_RESOURCES) { |
|
| 498 | 497 | $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count; |
| 499 | - } elseif($unit_type == UNIT_TECHNOLOGIES) { |
|
| 500 | - if($unit_id == TECH_WEAPON) { |
|
| 498 | + } elseif ($unit_type == UNIT_TECHNOLOGIES) { |
|
| 499 | + if ($unit_id == TECH_WEAPON) { |
|
| 501 | 500 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count); |
| 502 | - } elseif($unit_id == TECH_SHIELD) { |
|
| 501 | + } elseif ($unit_id == TECH_SHIELD) { |
|
| 503 | 502 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count); |
| 504 | - } elseif($unit_id == TECH_ARMOR) { |
|
| 503 | + } elseif ($unit_id == TECH_ARMOR) { |
|
| 505 | 504 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count); |
| 506 | 505 | } |
| 507 | - } elseif($unit_type == UNIT_GOVERNORS) { |
|
| 508 | - if($unit_id == MRC_FORTIFIER) { |
|
| 506 | + } elseif ($unit_type == UNIT_GOVERNORS) { |
|
| 507 | + if ($unit_id == MRC_FORTIFIER) { |
|
| 509 | 508 | // Фортифаер даёт бонус ко всему |
| 510 | 509 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count); |
| 511 | 510 | } |
| 512 | - } elseif($unit_type == UNIT_MERCENARIES) { |
|
| 513 | - if($unit_id == MRC_ADMIRAL) { |
|
| 511 | + } elseif ($unit_type == UNIT_MERCENARIES) { |
|
| 512 | + if ($unit_id == MRC_ADMIRAL) { |
|
| 514 | 513 | $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count); |
| 515 | 514 | } |
| 516 | 515 | } |
@@ -581,7 +580,7 @@ discard block |
||
| 581 | 580 | |
| 582 | 581 | $ube_report = new UBEReport(); |
| 583 | 582 | $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher')); |
| 584 | - if($ube != UBE_REPORT_NOT_FOUND) { |
|
| 583 | + if ($ube != UBE_REPORT_NOT_FOUND) { |
|
| 585 | 584 | $ube_report->sn_ube_report_generate($ube, $template_result); |
| 586 | 585 | |
| 587 | 586 | $template = gettemplate('ube_combat_report', $template); |
@@ -614,9 +613,9 @@ discard block |
||
| 614 | 613 | // sn_ube_report_save($combat_data); |
| 615 | 614 | // } |
| 616 | 615 | |
| 617 | - if(sys_get_param_str('reload')) { |
|
| 616 | + if (sys_get_param_str('reload')) { |
|
| 618 | 617 | $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
| 619 | - if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
| 618 | + if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
| 620 | 619 | $ube = $ube_new; |
| 621 | 620 | } |
| 622 | 621 | } |
@@ -664,7 +663,7 @@ discard block |
||
| 664 | 663 | $this->debris->load_from_report_row($report_row); |
| 665 | 664 | |
| 666 | 665 | $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
| 667 | - while($player_row = db_fetch($query)) { |
|
| 666 | + while ($player_row = db_fetch($query)) { |
|
| 668 | 667 | $this->players->init_player_from_report_info($player_row); |
| 669 | 668 | } |
| 670 | 669 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | - * @param $moon_debris_left_part |
|
| 96 | + * @param double $moon_debris_left_part |
|
| 97 | 97 | */ |
| 98 | 98 | public function debris_adjust_proportional($moon_debris_left_part) { |
| 99 | 99 | foreach($this->debris as $resource_id => &$resource_amount) { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @param classConfig $config |
| 106 | 106 | * |
| 107 | - * @return int |
|
| 107 | + * @return double |
|
| 108 | 108 | */ |
| 109 | 109 | public function debris_in_metal($config) { |
| 110 | 110 | return floatval( |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function debris_add_resource($resource_id, $resource_amount) { |
| 32 | 32 | // В обломках может быть только металл или кристалл |
| 33 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
| 33 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | $this->debris[$resource_id] += $resource_amount; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param bool $is_simulator |
| 42 | 42 | */ |
| 43 | 43 | public function add_wrecks(array $wreckage, $is_simulator) { |
| 44 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
| 44 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
| 45 | 45 | $this->debris_add_resource($resource_id, floor($resource_amount * |
| 46 | 46 | ($is_simulator |
| 47 | 47 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param bool $is_simulator |
| 58 | 58 | */ |
| 59 | 59 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
| 60 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
| 60 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
| 61 | 61 | $this->debris_add_resource($resource_id, floor($resource_amount * |
| 62 | 62 | ($is_simulator |
| 63 | 63 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param $moon_debris_left_part |
| 97 | 97 | */ |
| 98 | 98 | public function debris_adjust_proportional($moon_debris_left_part) { |
| 99 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
| 99 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
| 100 | 100 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function report_generate_sql(classConfig $config) { |
| 123 | 123 | return " |
| 124 | - `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ", |
|
| 125 | - `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ", |
|
| 126 | - `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal($config) . ", "; |
|
| 124 | + `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL) . ", |
|
| 125 | + `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL) . ", |
|
| 126 | + `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal($config) . ", "; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -278,6 +278,9 @@ |
||
| 278 | 278 | return count($this->ube_side_present_at_round_start); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | + /** |
|
| 282 | + * @param integer $round |
|
| 283 | + */ |
|
| 281 | 284 | public function ubeAnalyzeFleetOutcome($round) { |
| 282 | 285 | $this->ube_actualize_sides(); |
| 283 | 286 | |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function ube_db_load_fleets_outcome($report_row) { |
| 84 | 84 | $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
| 85 | - while($row = db_fetch($query)) { |
|
| 85 | + while ($row = db_fetch($query)) { |
|
| 86 | 86 | $fleet_id = $row['ube_report_outcome_fleet_fleet_id']; |
| 87 | 87 | $this[$fleet_id]->load_outcome_from_report_row($row); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`"); |
| 91 | - while($row = db_fetch($query)) { |
|
| 91 | + while ($row = db_fetch($query)) { |
|
| 92 | 92 | $fleet_id = $row['ube_report_outcome_unit_fleet_id']; |
| 93 | 93 | $this[$fleet_id]->load_unit_outcome_from_row($row); |
| 94 | 94 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | UBE_PLAYER_IS_DEFENDER => array(), |
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
| 111 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
| 112 | 112 | $result[$UBEFleet->is_attacker][] = array( |
| 113 | 113 | 'ID' => $fleet_id, |
| 114 | 114 | 'NAME' => $ube->players[$UBEFleet->owner_id]->name, |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function ube_analyze_fleets($is_simulator, UBEDebris $debris, array $resource_exchange_rates) { |
| 133 | 133 | // Генерируем результат боя |
| 134 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
| 134 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
| 135 | 135 | // Инициализируем массив результатов для флота |
| 136 | 136 | // $this->init_fleet_outcome_and_link_to_side($UBEFleet); |
| 137 | 137 | |
| 138 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
| 138 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
| 139 | 139 | $UBEUnit->ube_analyze_unit($is_simulator); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | $this->resources_lost_in_metal = array( |
| 153 | 153 | RES_METAL => 0, |
| 154 | 154 | ); |
| 155 | - foreach($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) { |
|
| 155 | + foreach ($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) { |
|
| 156 | 156 | $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id]; |
| 157 | 157 | } |
| 158 | - foreach($UBEFleet->cargo_dropped as $resource_id => $resource_amount) { |
|
| 158 | + foreach ($UBEFleet->cargo_dropped as $resource_id => $resource_amount) { |
|
| 159 | 159 | $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id]; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function ube_get_groups() { |
| 168 | 168 | $result = array(); |
| 169 | - foreach($this->_container as $UBEFleet) { |
|
| 170 | - if($UBEFleet->group_id) { |
|
| 169 | + foreach ($this->_container as $UBEFleet) { |
|
| 170 | + if ($UBEFleet->group_id) { |
|
| 171 | 171 | $result[$UBEFleet->group_id] = $UBEFleet->group_id; |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function ube_get_capacity_attackers() { |
| 182 | 182 | $result = 0; |
| 183 | - foreach($this->_container as $UBEFleet) { |
|
| 184 | - if($UBEFleet->is_attacker) { |
|
| 183 | + foreach ($this->_container as $UBEFleet) { |
|
| 184 | + if ($UBEFleet->is_attacker) { |
|
| 185 | 185 | $result += $UBEFleet->fleet_capacity; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function ube_db_load_from_report_row(array $report_row, UBE $ube) { |
| 197 | 197 | $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
| 198 | - while($fleet_row = db_fetch($query)) { |
|
| 198 | + while ($fleet_row = db_fetch($query)) { |
|
| 199 | 199 | $objFleet = new UBEFleet(); |
| 200 | 200 | $objFleet->load_from_report($fleet_row, $ube); |
| 201 | 201 | $this[$objFleet->db_id] = $objFleet; |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | * @version 2016-02-25 23:42:45 41a4.68 |
| 210 | 210 | */ |
| 211 | 211 | public function ube_prepare_for_next_round($is_simulator) { |
| 212 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
| 212 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
| 213 | 213 | $UBEFleet->prepare_for_next_round($is_simulator); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Суммируем данные по атакующим и защитникам |
| 217 | 217 | $this->ube_total[UBE_PLAYER_IS_ATTACKER]->_reset(); |
| 218 | 218 | $this->ube_total[UBE_PLAYER_IS_DEFENDER]->_reset(); |
| 219 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
| 219 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
| 220 | 220 | $this->ube_total[$UBEFleet->is_attacker]->add_unit_stats_array($UBEFleet->total_stats); |
| 221 | 221 | } |
| 222 | 222 | //pvar_dump($this->ube_total); |
| 223 | 223 | |
| 224 | 224 | // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще |
| 225 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
| 225 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
| 226 | 226 | $UBEFleet->calculate_unit_partial_data($this->ube_total[$UBEFleet->is_attacker]); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function ube_calculate_attack_results(UBE $ube) { |
| 238 | 238 | // Каждый флот атакует все |
| 239 | - foreach($this->_container as $attack_fleet_data) { |
|
| 239 | + foreach ($this->_container as $attack_fleet_data) { |
|
| 240 | 240 | defined('DEBUG_UBE') ? print("Fleet {$attack_fleet_data->db_id} attacks<br /><div style='margin-left: 30px;'>") : false; |
| 241 | 241 | |
| 242 | 242 | $attack_fleet_data->attack_fleets($this, $ube->is_simulator); |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | * @version 2016-02-25 23:42:45 41a4.68 |
| 252 | 252 | */ |
| 253 | 253 | public function ube_actualize_sides() { |
| 254 | - foreach($this->_container as $UBEFleet) { |
|
| 255 | - if($UBEFleet->get_unit_count() > 0) { |
|
| 254 | + foreach ($this->_container as $UBEFleet) { |
|
| 255 | + if ($UBEFleet->get_unit_count() > 0) { |
|
| 256 | 256 | $this->ube_side_present_at_round_start[$UBEFleet->is_attacker] = 1; |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function ube_calculate_attack_reapers() { |
| 267 | 267 | $reapers = 0; |
| 268 | - foreach($this->_container as $fleet_id => $UBERoundFleetCombat) { |
|
| 269 | - if($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) { |
|
| 268 | + foreach ($this->_container as $fleet_id => $UBERoundFleetCombat) { |
|
| 269 | + if ($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) { |
|
| 270 | 270 | $reapers += $UBERoundFleetCombat->unit_list->unitCountReapers(); |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $result = UBE_COMBAT_RESULT_DRAW; |
| 285 | 285 | // Проверяем результат боя |
| 286 | - if($this->ube_get_sides_count() == 0 || $round >= 10) { |
|
| 286 | + if ($this->ube_get_sides_count() == 0 || $round >= 10) { |
|
| 287 | 287 | // Если кого-то не осталось или не осталось обоих - заканчиваем цикл |
| 288 | 288 | $result = UBE_COMBAT_RESULT_DRAW_END; |
| 289 | - } elseif($this->ube_get_sides_count() == 1) { |
|
| 289 | + } elseif ($this->ube_get_sides_count() == 1) { |
|
| 290 | 290 | // Если осталась одна сторона - она и выиграла |
| 291 | 291 | $result = isset($this->ube_side_present_at_round_start[UBE_PLAYER_IS_ATTACKER]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS; |
| 292 | 292 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @version 41a6.16 |
| 304 | 304 | */ |
| 305 | 305 | public function ubeInitGetAttackers(Fleet $objFleet, UBEPlayerList $players) { |
| 306 | - if($objFleet->group_id) { |
|
| 306 | + if ($objFleet->group_id) { |
|
| 307 | 307 | $fleets_added = $this->dbLoadWhere("`fleet_group` = {$objFleet->group_id}"); |
| 308 | 308 | } else { |
| 309 | 309 | $this->ube_insert_from_Fleet($objFleet); |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * @param UBE $ube |
| 9 | 9 | * |
| 10 | - * @return bool|string |
|
| 10 | + * @return false|string |
|
| 11 | 11 | * |
| 12 | 12 | * @version 2016-02-25 23:42:45 41a4.68 |
| 13 | 13 | */ |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | // ------------------------------------------------------------------------------------------------ |
| 187 | 187 | // Читает боевой отчет из БД |
| 188 | 188 | /** |
| 189 | - * @param $report_cypher |
|
| 189 | + * @param string $report_cypher |
|
| 190 | 190 | * |
| 191 | 191 | * @return string|UBE |
| 192 | 192 | */ |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | global $config; |
| 16 | 16 | |
| 17 | 17 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
| 18 | - if($ube->get_cypher()) { |
|
| 18 | + if ($ube->get_cypher()) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
| 23 | 23 | do { |
| 24 | 24 | $ube->report_cypher = sys_random_string(32); |
| 25 | - } while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
| 25 | + } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
| 26 | 26 | |
| 27 | 27 | // Инициализация таблицы для пакетной вставки информации |
| 28 | 28 | $sql_perform = array( |
@@ -113,21 +113,21 @@ discard block |
||
| 113 | 113 | `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "', |
| 114 | 114 | `ube_report_time_spent` = {$ube->time_spent}, |
| 115 | 115 | |
| 116 | - `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ", |
|
| 116 | + `ube_report_combat_admin` = " . (int) $ube->is_admin_in_combat . ", |
|
| 117 | 117 | `ube_report_mission_type` = {$ube->mission_type_id}, |
| 118 | 118 | |
| 119 | 119 | `ube_report_combat_result` = {$ube->combat_result}, |
| 120 | - `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ", |
|
| 120 | + `ube_report_combat_sfr` = " . (int) $ube->is_small_fleet_recce . ", |
|
| 121 | 121 | |
| 122 | - `ube_report_planet_id` = " . (int)$ube->ube_planet_info[PLANET_ID] . ", |
|
| 122 | + `ube_report_planet_id` = " . (int) $ube->ube_planet_info[PLANET_ID] . ", |
|
| 123 | 123 | `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "', |
| 124 | - `ube_report_planet_size` = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ", |
|
| 125 | - `ube_report_planet_galaxy` = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ", |
|
| 126 | - `ube_report_planet_system` = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
| 127 | - `ube_report_planet_planet` = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ", |
|
| 128 | - `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ", |
|
| 124 | + `ube_report_planet_size` = " . (int) $ube->ube_planet_info[PLANET_SIZE] . ", |
|
| 125 | + `ube_report_planet_galaxy` = " . (int) $ube->ube_planet_info[PLANET_GALAXY] . ", |
|
| 126 | + `ube_report_planet_system` = " . (int) $ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
| 127 | + `ube_report_planet_planet` = " . (int) $ube->ube_planet_info[PLANET_PLANET] . ", |
|
| 128 | + `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE] . ", |
|
| 129 | 129 | |
| 130 | - `ube_report_capture_result` = " . (int)$ube->capture_result . ", " |
|
| 130 | + `ube_report_capture_result` = " . (int) $ube->capture_result . ", " |
|
| 131 | 131 | . $ube->debris->report_generate_sql($config) |
| 132 | 132 | . $ube->moon_calculator->report_generate_sql(); |
| 133 | 133 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | // Сохраняем общую информацию по игрокам |
| 138 | 138 | $player_sides = $ube->players->get_player_sides(); |
| 139 | - foreach($player_sides as $player_id => $player_side) { |
|
| 139 | + foreach ($player_sides as $player_id => $player_side) { |
|
| 140 | 140 | $sql_perform['ube_report_player'][] = array( |
| 141 | 141 | $ube_report_id, |
| 142 | 142 | $player_id, |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | "'" . db_escape($ube->players[$player_id]->name) . "'", |
| 145 | 145 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
| 146 | 146 | |
| 147 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
| 148 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
| 149 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
| 147 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
| 148 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
| 149 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
| 150 | 150 | ); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Всякая информация по флотам |
| 154 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
| 154 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
| 155 | 155 | // Сохраняем общую информацию по флотам |
| 156 | 156 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
| 157 | 157 | |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
| 168 | 168 | |
| 169 | 169 | // Пакетная вставка данных |
| 170 | - foreach($sql_perform as $table_name => $table_data) { |
|
| 171 | - if(count($table_data) < 2) { |
|
| 170 | + foreach ($sql_perform as $table_name => $table_data) { |
|
| 171 | + if (count($table_data) < 2) { |
|
| 172 | 172 | continue; |
| 173 | 173 | } |
| 174 | - foreach($table_data as &$record_data) { |
|
| 174 | + foreach ($table_data as &$record_data) { |
|
| 175 | 175 | $record_data = '(' . implode(',', $record_data) . ')'; |
| 176 | 176 | } |
| 177 | 177 | $fields = $table_data[0]; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $report_cypher = db_escape($report_cypher); |
| 195 | 195 | |
| 196 | 196 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
| 197 | - if(!$report_row) { |
|
| 197 | + if (!$report_row) { |
|
| 198 | 198 | return UBE_REPORT_NOT_FOUND; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param $template_result |
| 211 | 211 | */ |
| 212 | 212 | function sn_ube_report_generate(UBE $ube, &$template_result) { |
| 213 | - if(!is_object($ube)) { |
|
| 213 | + if (!is_object($ube)) { |
|
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | // Координаты, тип и название планеты - если есть |
| 229 | 229 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
| 230 | - if(isset($ube->ube_planet_info)) { |
|
| 230 | + if (isset($ube->ube_planet_info)) { |
|
| 231 | 231 | $template_result += $ube->ube_planet_info; |
| 232 | 232 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // Обломки |
| 236 | 236 | $debris = array(); |
| 237 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
| 238 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
| 237 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
| 238 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
| 239 | 239 | $debris[] = array( |
| 240 | 240 | 'NAME' => $lang['tech'][$resource_id], |
| 241 | 241 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -188,6 +188,11 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | // OK v4 |
| 190 | 190 | // TODO - вынести в отдельный класс |
| 191 | +/** |
|
| 192 | + * @param string $db_id_field_name |
|
| 193 | + * @param string $db_table_name |
|
| 194 | + * @param string $db_value_field_name |
|
| 195 | + */ |
|
| 191 | 196 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
| 192 | 197 | $current_value_safe = db_escape($current_value_unsafe); |
| 193 | 198 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -220,7 +225,7 @@ discard block |
||
| 220 | 225 | |
| 221 | 226 | /** |
| 222 | 227 | * @param $user |
| 223 | - * @param $username_safe |
|
| 228 | + * @param string $username_safe |
|
| 224 | 229 | */ |
| 225 | 230 | function db_player_name_history_replace($user, $username_safe) { |
| 226 | 231 | doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'"); |
@@ -228,7 +233,7 @@ discard block |
||
| 228 | 233 | |
| 229 | 234 | |
| 230 | 235 | /** |
| 231 | - * @param $username_safe |
|
| 236 | + * @param string $username_safe |
|
| 232 | 237 | * |
| 233 | 238 | * @return array|bool|mysqli_result|null |
| 234 | 239 | */ |
@@ -488,9 +493,9 @@ discard block |
||
| 488 | 493 | * @param $user_id |
| 489 | 494 | * @param $change_type |
| 490 | 495 | * @param $dark_matter |
| 491 | - * @param $comment |
|
| 496 | + * @param string $comment |
|
| 492 | 497 | * @param $row |
| 493 | - * @param $page_url |
|
| 498 | + * @param string $page_url |
|
| 494 | 499 | */ |
| 495 | 500 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url) { |
| 496 | 501 | doquery( |
@@ -534,9 +539,9 @@ discard block |
||
| 534 | 539 | |
| 535 | 540 | // Quests *********************************************************************************************************** |
| 536 | 541 | /** |
| 537 | - * @param $query_add_select |
|
| 542 | + * @param string $query_add_select |
|
| 538 | 543 | * @param $query_add_from |
| 539 | - * @param $query_add_where |
|
| 544 | + * @param string $query_add_where |
|
| 540 | 545 | * |
| 541 | 546 | * @return array|bool|mysqli_result|null |
| 542 | 547 | */ |
@@ -580,11 +585,11 @@ discard block |
||
| 580 | 585 | } |
| 581 | 586 | |
| 582 | 587 | /** |
| 583 | - * @param $quest_name |
|
| 584 | - * @param $quest_type |
|
| 585 | - * @param $quest_description |
|
| 588 | + * @param string $quest_name |
|
| 589 | + * @param integer $quest_type |
|
| 590 | + * @param string $quest_description |
|
| 586 | 591 | * @param $quest_conditions |
| 587 | - * @param $quest_rewards |
|
| 592 | + * @param string $quest_rewards |
|
| 588 | 593 | * @param $quest_id |
| 589 | 594 | */ |
| 590 | 595 | function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -607,7 +612,7 @@ discard block |
||
| 607 | 612 | /** |
| 608 | 613 | * @param $banner |
| 609 | 614 | * @param $banned |
| 610 | - * @param $reason |
|
| 615 | + * @param string $reason |
|
| 611 | 616 | * @param $ban_until |
| 612 | 617 | */ |
| 613 | 618 | function db_ban_insert($banner, $banned, $reason, $ban_until) { |
@@ -630,7 +635,7 @@ discard block |
||
| 630 | 635 | /** |
| 631 | 636 | * @param $banner |
| 632 | 637 | * @param $banned |
| 633 | - * @param $reason |
|
| 638 | + * @param string $reason |
|
| 634 | 639 | */ |
| 635 | 640 | function db_ban_insert_unset($banner, $banned, $reason) { |
| 636 | 641 | doquery( |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
| 87 | 87 | // pdump($source); |
| 88 | - if(!$source) { |
|
| 88 | + if (!$source) { |
|
| 89 | 89 | $source = array( |
| 90 | 90 | 'statpoints' => 'statpoints', |
| 91 | 91 | 'users' => 'users', |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | 108 | // pdump($source); |
| 109 | - if($who == 1) { |
|
| 110 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
| 109 | + if ($who == 1) { |
|
| 110 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
| 111 | 111 | $query_str = |
| 112 | 112 | "SELECT |
| 113 | 113 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
| 192 | 192 | $current_value_safe = db_escape($current_value_unsafe); |
| 193 | 193 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
| 194 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
| 194 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
| 195 | 195 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
| 196 | 196 | $variable_id = db_insert_id(); |
| 197 | 197 | } else { |