@@ -48,74 +48,74 @@ |
||
| 48 | 48 | $gc = $this; |
| 49 | 49 | |
| 50 | 50 | // Default db |
| 51 | - $gc->db = function ($c) { |
|
| 51 | + $gc->db = function($c) { |
|
| 52 | 52 | classSupernova::$db = $db = new \db_mysql($c); |
| 53 | 53 | |
| 54 | 54 | return $db; |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | - $gc->debug = function ($c) { |
|
| 57 | + $gc->debug = function($c) { |
|
| 58 | 58 | return new \debug(); |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | - $gc->types = function ($c) { |
|
| 61 | + $gc->types = function($c) { |
|
| 62 | 62 | return new \Common\Types(); |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | - $gc->cache = function ($c) { |
|
| 65 | + $gc->cache = function($c) { |
|
| 66 | 66 | return new \classCache(classSupernova::$cache_prefix); |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | - $gc->config = function ($c) { |
|
| 69 | + $gc->config = function($c) { |
|
| 70 | 70 | return new \classConfig(classSupernova::$cache_prefix); |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | - $gc->localePlayer = function (GlobalContainer $c) { |
|
| 73 | + $gc->localePlayer = function(GlobalContainer $c) { |
|
| 74 | 74 | return new \classLocale($c->config->server_locale_log_usage); |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | - $gc->dbGlobalRowOperator = function (GlobalContainer $c) { |
|
| 77 | + $gc->dbGlobalRowOperator = function(GlobalContainer $c) { |
|
| 78 | 78 | return new \DbRowDirectOperator($c->db); |
| 79 | 79 | }; |
| 80 | 80 | |
| 81 | - $gc->query = $gc->factory(function (GlobalContainer $c) { |
|
| 81 | + $gc->query = $gc->factory(function(GlobalContainer $c) { |
|
| 82 | 82 | return new \DbQueryConstructor($c->db); |
| 83 | 83 | }); |
| 84 | 84 | |
| 85 | - $gc->cacheOperator = function (GlobalContainer $gc) { |
|
| 85 | + $gc->cacheOperator = function(GlobalContainer $gc) { |
|
| 86 | 86 | return new \SnDbCachedOperator($gc); |
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | 89 | $gc->snCacheClass = 'SnCache'; |
| 90 | - $gc->snCache = function (GlobalContainer $gc) { |
|
| 90 | + $gc->snCache = function(GlobalContainer $gc) { |
|
| 91 | 91 | return $gc->db->snCache; |
| 92 | 92 | }; |
| 93 | 93 | |
| 94 | 94 | $gc->buddyClass = 'Buddy\BuddyModel'; |
| 95 | - $gc->buddyModel = function (GlobalContainer $c) { |
|
| 95 | + $gc->buddyModel = function(GlobalContainer $c) { |
|
| 96 | 96 | return new $c->buddyClass($c); |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | - $gc->unitModel = function (GlobalContainer $c) { |
|
| 99 | + $gc->unitModel = function(GlobalContainer $c) { |
|
| 100 | 100 | return new \V2Unit\V2UnitModel($c); |
| 101 | 101 | }; |
| 102 | - $gc->unitList = $this->factory(function (GlobalContainer $c) { |
|
| 102 | + $gc->unitList = $this->factory(function(GlobalContainer $c) { |
|
| 103 | 103 | return new \V2Unit\V2UnitList($c); |
| 104 | 104 | }); |
| 105 | 105 | |
| 106 | - $gc->fleetModel = function (GlobalContainer $c) { |
|
| 106 | + $gc->fleetModel = function(GlobalContainer $c) { |
|
| 107 | 107 | return new V2FleetModel($c); |
| 108 | 108 | }; |
| 109 | 109 | |
| 110 | - $gc->groupFleet = function (GlobalContainer $c) { |
|
| 110 | + $gc->groupFleet = function(GlobalContainer $c) { |
|
| 111 | 111 | return sn_get_groups('fleet'); |
| 112 | 112 | }; |
| 113 | 113 | |
| 114 | - $gc->groupFleetAndMissiles = function (GlobalContainer $c) { |
|
| 114 | + $gc->groupFleetAndMissiles = function(GlobalContainer $c) { |
|
| 115 | 115 | return sn_get_groups(array('fleet', GROUP_STR_MISSILES)); |
| 116 | 116 | }; |
| 117 | 117 | |
| 118 | - $gc->groupRecyclers = function (GlobalContainer $c) { |
|
| 118 | + $gc->groupRecyclers = function(GlobalContainer $c) { |
|
| 119 | 119 | return sn_get_groups('flt_recyclers'); |
| 120 | 120 | }; |
| 121 | 121 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | use DBStatic\DBStaticPlanet; |
| 34 | 34 | use DBStatic\DBStaticUser; |
| 35 | 35 | |
| 36 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
| 36 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
| 37 | 37 | |
| 38 | 38 | //$ccc = 0; |
| 39 | 39 | //foreach(DBStatic\DBStaticUser::db_user_list_non_bots() as $ip) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $result = array(); |
| 54 | 54 | |
| 55 | -switch($mode = sys_get_param_str('mode')) { |
|
| 55 | +switch ($mode = sys_get_param_str('mode')) { |
|
| 56 | 56 | case 'manage': |
| 57 | 57 | sn_sys_sector_buy('overview.php?mode=manage'); |
| 58 | 58 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $template = gettemplate('planet_manage', true); |
| 63 | 63 | $planet_id = sys_get_param_id('planet_id'); |
| 64 | 64 | |
| 65 | - if(sys_get_param_str('rename') && ($new_name_unsafe = sys_get_param_str_unsafe('new_name'))) { |
|
| 65 | + if (sys_get_param_str('rename') && ($new_name_unsafe = sys_get_param_str_unsafe('new_name'))) { |
|
| 66 | 66 | $planetrow['name'] = $new_name_unsafe; |
| 67 | 67 | DBStaticPlanet::db_planet_update_set_by_id( |
| 68 | 68 | $planetrow['id'], |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | 'name' => $new_name_unsafe, |
| 71 | 71 | ) |
| 72 | 72 | ); |
| 73 | - } elseif(sys_get_param_str('action') == 'make_capital') { |
|
| 73 | + } elseif (sys_get_param_str('action') == 'make_capital') { |
|
| 74 | 74 | try { |
| 75 | 75 | sn_db_transaction_start(); |
| 76 | 76 | $user = DBStaticUser::db_user_by_id($user['id'], true, '*'); |
| 77 | 77 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*'); |
| 78 | 78 | |
| 79 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
| 79 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
| 80 | 80 | throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if($planetrow['id'] == $user['id_planet']) { |
|
| 83 | + if ($planetrow['id'] == $user['id_planet']) { |
|
| 84 | 84 | throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if($user_dark_matter < classSupernova::$config->planet_capital_cost) { |
|
| 87 | + if ($user_dark_matter < classSupernova::$config->planet_capital_cost) { |
|
| 88 | 88 | throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -109,16 +109,16 @@ discard block |
||
| 109 | 109 | ); |
| 110 | 110 | sn_db_transaction_commit(); |
| 111 | 111 | sys_redirect('overview.php?mode=manage'); |
| 112 | - } catch(exception $e) { |
|
| 112 | + } catch (exception $e) { |
|
| 113 | 113 | sn_db_transaction_rollback(); |
| 114 | 114 | $result[] = array( |
| 115 | 115 | 'STATUS' => $e->getCode(), |
| 116 | 116 | 'MESSAGE' => $e->getMessage(), |
| 117 | 117 | ); |
| 118 | 118 | } |
| 119 | - } elseif(sys_get_param_str('action') == 'planet_teleport') { |
|
| 119 | + } elseif (sys_get_param_str('action') == 'planet_teleport') { |
|
| 120 | 120 | try { |
| 121 | - if(!uni_coordinates_valid($new_coordinates = array( |
|
| 121 | + if (!uni_coordinates_valid($new_coordinates = array( |
|
| 122 | 122 | 'galaxy' => sys_get_param_int('new_galaxy'), |
| 123 | 123 | 'system' => sys_get_param_int('new_system'), |
| 124 | 124 | 'planet' => sys_get_param_int('new_planet'))) |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | // $planetrow = $global_data['planet']; |
| 136 | 136 | |
| 137 | 137 | $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates); |
| 138 | - if($can_teleport['result'] != ERR_NONE) { |
|
| 138 | + if ($can_teleport['result'] != ERR_NONE) { |
|
| 139 | 139 | throw new exception($can_teleport['message'], $can_teleport['result']); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | array() |
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | - if($planetrow['id'] == $user['id_planet']) { |
|
| 157 | + if ($planetrow['id'] == $user['id_planet']) { |
|
| 158 | 158 | DBStaticUser::db_user_set_by_id( |
| 159 | 159 | $user['id'], |
| 160 | 160 | array( |
@@ -174,17 +174,17 @@ discard block |
||
| 174 | 174 | 'MESSAGE' => classLocale::$lang['ov_teleport_err_none'], |
| 175 | 175 | ); |
| 176 | 176 | sys_redirect('overview.php?mode=manage'); |
| 177 | - } catch(exception $e) { |
|
| 177 | + } catch (exception $e) { |
|
| 178 | 178 | sn_db_transaction_rollback(); |
| 179 | 179 | $result[] = array( |
| 180 | 180 | 'STATUS' => $e->getCode(), |
| 181 | 181 | 'MESSAGE' => $e->getMessage(), |
| 182 | 182 | ); |
| 183 | 183 | } |
| 184 | - } elseif(sys_get_param_str('action') == 'planet_abandon') { |
|
| 184 | + } elseif (sys_get_param_str('action') == 'planet_abandon') { |
|
| 185 | 185 | // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) { |
| 186 | - if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) { |
|
| 187 | - if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) { |
|
| 186 | + if (classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) { |
|
| 187 | + if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) { |
|
| 188 | 188 | $destroyed = SN_TIME_NOW + 60 * 60 * 24; |
| 189 | 189 | DBStaticPlanet::db_planet_update_set_by_id( |
| 190 | 190 | $user['current_planet'], |
@@ -210,9 +210,9 @@ discard block |
||
| 210 | 210 | message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage'); |
| 211 | 211 | } |
| 212 | 212 | } else { |
| 213 | - message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage'); |
|
| 213 | + message(classLocale::$lang['ov_delete_wrong_pass'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage'); |
|
| 214 | 214 | } |
| 215 | - } elseif( |
|
| 215 | + } elseif ( |
|
| 216 | 216 | ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors')) |
| 217 | 217 | && ( |
| 218 | 218 | !get_unit_param($hire, P_MAX_STACK) || |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | $user = DBStaticUser::db_user_by_id($user['id'], true); |
| 228 | 228 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
| 229 | 229 | $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0); |
| 230 | - if($build_data['CAN'][BUILD_CREATE]) { |
|
| 231 | - if($planetrow['PLANET_GOVERNOR_ID'] == $hire) { |
|
| 230 | + if ($build_data['CAN'][BUILD_CREATE]) { |
|
| 231 | + if ($planetrow['PLANET_GOVERNOR_ID'] == $hire) { |
|
| 232 | 232 | $planetrow['PLANET_GOVERNOR_LEVEL']++; |
| 233 | 233 | } else { |
| 234 | 234 | $planetrow['PLANET_GOVERNOR_LEVEL'] = 1; |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | lng_include('mrc_mercenary'); |
| 262 | 262 | int_planet_pretemplate($planetrow, $template); |
| 263 | - foreach(sn_get_groups('governors') as $governor_id) { |
|
| 264 | - if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) { |
|
| 263 | + foreach (sn_get_groups('governors') as $governor_id) { |
|
| 264 | + if ($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) { |
|
| 265 | 265 | continue; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | 'PAGE_HINT' => classLocale::$lang['ov_manage_page_hint'], |
| 314 | 314 | )); |
| 315 | 315 | |
| 316 | - foreach($result as &$a_result) { |
|
| 316 | + foreach ($result as &$a_result) { |
|
| 317 | 317 | $template->assign_block_vars('result', $a_result); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | default: |
| 324 | 324 | sn_sys_sector_buy(); |
| 325 | 325 | |
| 326 | - if(sys_get_param_str('rename') && $new_name_unsafe = sys_get_param_str_unsafe('new_name')) { |
|
| 326 | + if (sys_get_param_str('rename') && $new_name_unsafe = sys_get_param_str_unsafe('new_name')) { |
|
| 327 | 327 | $planetrow['name'] = $new_name_unsafe; |
| 328 | 328 | DBStaticPlanet::db_planet_update_set_by_id( |
| 329 | 329 | $planetrow['id'], |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | $planet_count = 0; |
| 360 | 360 | $planets_query = DBStaticPlanet::db_planet_list_sorted($user, false, '*'); |
| 361 | - foreach($planets_query as $an_id => $UserPlanet) { |
|
| 361 | + foreach ($planets_query as $an_id => $UserPlanet) { |
|
| 362 | 362 | sn_db_transaction_start(); |
| 363 | 363 | $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true); |
| 364 | 364 | sn_db_transaction_commit(); |
@@ -369,16 +369,16 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | $planet_fleet_id = 0; |
| 371 | 371 | $fleet_list = $template_planet['fleet_list']; |
| 372 | - if($fleet_list['own']['count']) { |
|
| 372 | + if ($fleet_list['own']['count']) { |
|
| 373 | 373 | $planet_fleet_id = "p{$UserPlanet['id']}"; |
| 374 | 374 | $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
| 375 | 375 | // $fleet_id++;tpl_parse_fleet_sn |
| 376 | 376 | } |
| 377 | - if($UserPlanet['planet_type'] == PT_MOON) { |
|
| 377 | + if ($UserPlanet['planet_type'] == PT_MOON) { |
|
| 378 | 378 | continue; |
| 379 | 379 | } |
| 380 | 380 | $moon = DBStaticPlanet::db_planet_by_parent($UserPlanet['id']); |
| 381 | - if($moon) { |
|
| 381 | + if ($moon) { |
|
| 382 | 382 | $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100)); |
| 383 | 383 | } else { |
| 384 | 384 | $moon_fill = 0; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | tpl_assign_fleet($template, $fleets); |
| 419 | 419 | |
| 420 | 420 | $lune = $planetrow['planet_type'] == PT_PLANET ? DBStaticPlanet::db_planet_by_parent($planetrow['id']) : DBStaticPlanet::db_planet_by_id($planetrow['parent_planet']); |
| 421 | - if($lune) { |
|
| 421 | + if ($lune) { |
|
| 422 | 422 | $template->assign_vars(array( |
| 423 | 423 | 'MOON_ID' => $lune['id'], |
| 424 | 424 | 'MOON_IMG' => $lune['image'], |
@@ -430,15 +430,15 @@ discard block |
||
| 430 | 430 | $planet_fill = $planet_fill > 100 ? 100 : $planet_fill; |
| 431 | 431 | |
| 432 | 432 | $planet_recyclers_orbiting = 0; |
| 433 | - foreach(classSupernova::$gc->groupRecyclers as $recycler_id) { |
|
| 433 | + foreach (classSupernova::$gc->groupRecyclers as $recycler_id) { |
|
| 434 | 434 | $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id); |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | int_planet_pretemplate($planetrow, $template); |
| 438 | 438 | |
| 439 | 439 | $sn_group_ques = sn_get_groups('ques'); |
| 440 | - if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) { |
|
| 441 | - foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) { |
|
| 440 | + if (!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) { |
|
| 441 | + foreach (array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) { |
|
| 442 | 442 | $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']]; |
| 443 | 443 | $template->assign_block_vars('ques', array( |
| 444 | 444 | 'ID' => $que_id, |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | 'LENGTH' => empty($this_que) ? 0 : count($this_que), |
| 447 | 447 | )); |
| 448 | 448 | |
| 449 | - if(!empty($this_que)) { |
|
| 450 | - foreach($this_que as $que_item) { |
|
| 449 | + if (!empty($this_que)) { |
|
| 450 | + foreach ($this_que as $que_item) { |
|
| 451 | 451 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
| 452 | 452 | } |
| 453 | 453 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | 'LENGTH' => $que_hangar_length, |
| 462 | 462 | )); |
| 463 | 463 | |
| 464 | - if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) { |
|
| 464 | + if (!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) { |
|
| 465 | 465 | $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE); |
| 466 | 466 | $template->assign_block_vars('ques', array( |
| 467 | 467 | 'ID' => SUBQUE_DEFENSE, |
@@ -473,12 +473,12 @@ discard block |
||
| 473 | 473 | $overview_planet_rows = $user['opt_int_overview_planet_rows']; |
| 474 | 474 | $overview_planet_columns = $user['opt_int_overview_planet_columns']; |
| 475 | 475 | |
| 476 | - if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) { |
|
| 476 | + if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) { |
|
| 477 | 477 | $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows']; |
| 478 | 478 | $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns']; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if($overview_planet_rows > 0 && $overview_planet_columns <= 0) { |
|
| 481 | + if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) { |
|
| 482 | 482 | $overview_planet_columns = ceil($planet_count / $overview_planet_rows); |
| 483 | 483 | } |
| 484 | 484 | |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | )); |
| 536 | 536 | tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2); |
| 537 | 537 | |
| 538 | - foreach($result as &$a_result) { |
|
| 538 | + foreach ($result as &$a_result) { |
|
| 539 | 539 | $template->assign_block_vars('result', $a_result); |
| 540 | 540 | } |
| 541 | 541 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | use DBStatic\DBStaticUser; |
| 12 | 12 | use Vector\Vector; |
| 13 | 13 | |
| 14 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
| 14 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
| 15 | 15 | |
| 16 | 16 | lng_include('universe'); |
| 17 | 17 | lng_include('stat'); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $uni_system = sys_get_param_int('system', $planetrow['system']); |
| 22 | 22 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
| 23 | 23 | |
| 24 | -if($mode == 'name') { |
|
| 24 | +if ($mode == 'name') { |
|
| 25 | 25 | require_once('includes/includes/uni_rename.php'); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $flying_fleet_count = FleetList::fleet_count_flying($user['id']); |
| 44 | 44 | |
| 45 | -if($mode == 1) { |
|
| 46 | -} elseif($mode == 2 || $mode == 3) { |
|
| 45 | +if ($mode == 1) { |
|
| 46 | +} elseif ($mode == 2 || $mode == 3) { |
|
| 47 | 47 | $planet = $planetrow['planet']; |
| 48 | 48 | } else { |
| 49 | 49 | $uni_galaxy = $planetrow['galaxy']; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $planet = $planetrow['planet']; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies? Vector::$knownGalaxies: $uni_galaxy); |
|
| 54 | +$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies ? Vector::$knownGalaxies : $uni_galaxy); |
|
| 55 | 55 | $uni_system = $uni_system < 1 ? 1 : ($uni_system > Vector::$knownSystems ? Vector::$knownSystems : $uni_system); |
| 56 | 56 | $planet = $planet < 1 ? 1 : ($planet > Vector::$knownPlanets + 1 ? Vector::$knownPlanets + 1 : $planet); |
| 57 | 57 | |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | $PhalanxRange = GetPhalanxRange($HavePhalanx); |
| 70 | 70 | |
| 71 | 71 | $planet_precache_query = DBStaticPlanet::db_planet_list_in_system($uni_galaxy, $uni_system); |
| 72 | -if(!empty($planet_precache_query)) { |
|
| 73 | - foreach($planet_precache_query as $planet_row) { |
|
| 72 | +if (!empty($planet_precache_query)) { |
|
| 73 | + foreach ($planet_precache_query as $planet_row) { |
|
| 74 | 74 | $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row; |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | * @var Fleet[][][] $fleet_list |
| 89 | 89 | */ |
| 90 | 90 | $fleet_list = array(); |
| 91 | -foreach($system_fleet_list->_container as $objFleetSystem) { |
|
| 92 | - if(!$objFleetSystem->isReturning()) { |
|
| 91 | +foreach ($system_fleet_list->_container as $objFleetSystem) { |
|
| 92 | + if (!$objFleetSystem->isReturning()) { |
|
| 93 | 93 | $fleet_planet = $objFleetSystem->fleet_end_planet; |
| 94 | 94 | $fleet_type = $objFleetSystem->fleet_end_type; |
| 95 | 95 | } else { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $recycler_info = array(); |
| 105 | 105 | $planet_recyclers_orbiting = 0; |
| 106 | 106 | $recyclers_fleet = array(); |
| 107 | -foreach(classSupernova::$gc->groupRecyclers as $recycler_id) { |
|
| 107 | +foreach (classSupernova::$gc->groupRecyclers as $recycler_id) { |
|
| 108 | 108 | $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user); |
| 109 | 109 | $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id); |
| 110 | 110 | $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id]; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $fleet_id = 1; |
| 115 | 115 | $fleets = array(); |
| 116 | 116 | $config_game_max_planet = Vector::$knownPlanets + 1; |
| 117 | -for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
| 117 | +for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
| 118 | 118 | unset($uni_galaxyRowPlanet); |
| 119 | 119 | unset($uni_galaxyRowMoon); |
| 120 | 120 | unset($uni_galaxyRowUser); |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET]; |
| 125 | 125 | |
| 126 | 126 | $planet_fleet_id = 0; |
| 127 | - if($uni_galaxyRowPlanet['destruyed']) { |
|
| 127 | + if ($uni_galaxyRowPlanet['destruyed']) { |
|
| 128 | 128 | CheckAbandonPlanetState($uni_galaxyRowPlanet); |
| 129 | - } elseif($uni_galaxyRowPlanet['id']) { |
|
| 130 | - if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
| 129 | + } elseif ($uni_galaxyRowPlanet['id']) { |
|
| 130 | + if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
| 131 | 131 | $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']]; |
| 132 | 132 | } else { |
| 133 | 133 | $uni_galaxyRowUser = DBStaticUser::db_user_by_id($uni_galaxyRowPlanet['id_owner']); |
| 134 | 134 | $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if(!$uni_galaxyRowUser['id']) { |
|
| 137 | + if (!$uni_galaxyRowUser['id']) { |
|
| 138 | 138 | classSupernova::$debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503); |
| 139 | 139 | $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24; |
| 140 | 140 | $uni_galaxyRowPlanet['id_owner'] = 0; |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if($uni_galaxyRowUser['id']) { |
|
| 150 | + if ($uni_galaxyRowUser['id']) { |
|
| 151 | 151 | $planetcount++; |
| 152 | - if($uni_galaxyRowUser['ally_id']) { |
|
| 153 | - if($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
| 152 | + if ($uni_galaxyRowUser['ally_id']) { |
|
| 153 | + if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
| 154 | 154 | $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']]; |
| 155 | 155 | } else { |
| 156 | 156 | $allyquery = DBStaticAlly::db_ally_get_by_id($uni_galaxyRowUser['ally_id']); |
@@ -159,19 +159,19 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]); |
| 162 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
| 162 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
| 163 | 163 | $planet_fleet_id = $fleet_id; |
| 164 | 164 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
| 165 | 165 | $fleet_id++; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON]; |
| 169 | - if($uni_galaxyRowMoon['destruyed']) { |
|
| 169 | + if ($uni_galaxyRowMoon['destruyed']) { |
|
| 170 | 170 | CheckAbandonPlanetState($uni_galaxyRowMoon); |
| 171 | 171 | } else { |
| 172 | 172 | $moon_fleet_id = 0; |
| 173 | 173 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]); |
| 174 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
| 174 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
| 175 | 175 | $moon_fleet_id = $fleet_id; |
| 176 | 176 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
| 177 | 177 | $fleet_id++; |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $recyclers_incoming_capacity = 0; |
| 184 | 184 | $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal']; |
| 185 | - if($uni_galaxyRowPlanet['debris']) { |
|
| 186 | - if(!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
| 187 | - foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
| 188 | - if($objFleetToDebris->playerOwnerId == $user['id']) { |
|
| 185 | + if ($uni_galaxyRowPlanet['debris']) { |
|
| 186 | + if (!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
| 187 | + foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
| 188 | + if ($objFleetToDebris->playerOwnerId == $user['id']) { |
|
| 189 | 189 | $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -262,21 +262,21 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | tpl_assign_fleet($template, $fleets); |
| 264 | 264 | |
| 265 | -foreach(sn_get_groups('defense_active') as $unit_id) { |
|
| 265 | +foreach (sn_get_groups('defense_active') as $unit_id) { |
|
| 266 | 266 | $template->assign_block_vars('defense_active', array( |
| 267 | 267 | 'ID' => $unit_id, |
| 268 | 268 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
| 269 | 269 | )); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | -foreach($cached['users'] as $PlanetUser) { |
|
| 273 | - if(!$PlanetUser) { |
|
| 272 | +foreach ($cached['users'] as $PlanetUser) { |
|
| 273 | + if (!$PlanetUser) { |
|
| 274 | 274 | continue; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | $user_ally = $cached['allies'][$PlanetUser['ally_id']]; |
| 278 | - if(isset($user_ally)) { |
|
| 279 | - if($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
| 278 | + if (isset($user_ally)) { |
|
| 279 | + if ($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
| 280 | 280 | $user_rank_title = $user_ally['ally_owner_range']; |
| 281 | 281 | } else { |
| 282 | 282 | $ally_ranks = explode(';', $user_ally['ranklist']); |
@@ -299,8 +299,8 @@ discard block |
||
| 299 | 299 | )); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | -foreach($cached['allies'] as $PlanetAlly) { |
|
| 303 | - if($PlanetAlly) { |
|
| 302 | +foreach ($cached['allies'] as $PlanetAlly) { |
|
| 303 | + if ($PlanetAlly) { |
|
| 304 | 304 | $template->assign_block_vars('alliances', array( |
| 305 | 305 | 'ID' => $PlanetAlly['id'], |
| 306 | 306 | 'NAME_JS' => js_safe_string($PlanetAlly['ally_name']), |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | use DBStatic\DBStaticFleetACS; |
| 5 | 5 | |
| 6 | 6 | function tpl_assign_fleet_compare($a, $b) { |
| 7 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
| 8 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
| 7 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
| 8 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
| 9 | 9 | return 0; |
| 10 | 10 | } |
| 11 | 11 | |
@@ -21,17 +21,17 @@ discard block |
||
| 21 | 21 | * @param string $js_name |
| 22 | 22 | */ |
| 23 | 23 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
| 24 | - if(!$fleets) { |
|
| 24 | + if (!$fleets) { |
|
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | usort($fleets, 'tpl_assign_fleet_compare'); |
| 29 | 29 | |
| 30 | - foreach($fleets as $fleet_data) { |
|
| 30 | + foreach ($fleets as $fleet_data) { |
|
| 31 | 31 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
| 32 | 32 | |
| 33 | - if($fleet_data['ships']) { |
|
| 34 | - foreach($fleet_data['ships'] as $ship_data) { |
|
| 33 | + if ($fleet_data['ships']) { |
|
| 34 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
| 35 | 35 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 56 | - if(in_array($ship_id, classSupernova::$gc->groupFleet)) { |
|
| 55 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 56 | + if (in_array($ship_id, classSupernova::$gc->groupFleet)) { |
|
| 57 | 57 | $single_ship_data = get_ship_data($ship_id, $user_data); |
| 58 | 58 | $return['ships'][$ship_id] = array( |
| 59 | 59 | 'ID' => $ship_id, |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | $result = array(); |
| 94 | 94 | |
| 95 | - if(!$user_data) { |
|
| 95 | + if (!$user_data) { |
|
| 96 | 96 | $user_data = $user; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
| 99 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
| 100 | 100 | $aks = DBStaticFleetACS::db_acs_get_by_group_id($objFleet->group_id); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'MISSION' => $objFleet->mission_type, |
| 116 | 116 | 'MISSION_NAME' => classLocale::$lang['type_mission'][$objFleet->mission_type], |
| 117 | 117 | 'ACS' => !empty($aks['name']) ? $aks['name'] : (!empty($objFleet->group_id) ? $objFleet->group_id : ''), |
| 118 | - 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()) . (array_sum($fleet_resources) ? '+' : '')) : '?', |
|
| 118 | + 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()).(array_sum($fleet_resources) ? '+' : '')) : '?', |
|
| 119 | 119 | |
| 120 | 120 | 'METAL' => $spy_level >= 8 ? $fleet_resources[RES_METAL] : 0, |
| 121 | 121 | 'CRYSTAL' => $spy_level >= 8 ? $fleet_resources[RES_CRYSTAL] : 0, |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
| 140 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
| 141 | 141 | $result['START_NAME'] = $objFleet->fleet_start_name; |
| 142 | 142 | } |
| 143 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
| 143 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
| 144 | 144 | $result['END_NAME'] = $objFleet->fleet_end_name; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if(property_exists($objFleet, 'event_time')) { |
|
| 147 | + if (property_exists($objFleet, 'event_time')) { |
|
| 148 | 148 | $result['fleet'] = array_merge($result['fleet'], array( |
| 149 | 149 | 'OV_LABEL' => $objFleet->ov_label, |
| 150 | 150 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $ship_id = 0; |
| 157 | 157 | $result['ships'] = array(); |
| 158 | - if($spy_level >= 6) { |
|
| 159 | - foreach($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
| 160 | - if($spy_level >= 10) { |
|
| 158 | + if ($spy_level >= 6) { |
|
| 159 | + foreach ($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
| 160 | + if ($spy_level >= 10) { |
|
| 161 | 161 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
| 162 | 162 | $result['ships'][$ship_sn_id] = array( |
| 163 | 163 | 'ID' => $ship_sn_id, |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | function tpl_parse_planet_que($que, $planet, $que_id) { |
| 191 | 191 | $hangar_que = array(); |
| 192 | 192 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
| 193 | - if(!empty($que_hangar)) { |
|
| 194 | - foreach($que_hangar as $que_item) { |
|
| 193 | + if (!empty($que_hangar)) { |
|
| 194 | + foreach ($que_hangar as $que_item) { |
|
| 195 | 195 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
| 196 | 196 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
| 197 | 197 | } |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
| 254 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
| 255 | 255 | $result['building_que'] = array(); |
| 256 | 256 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
| 257 | - foreach($building_que as $que_element) { |
|
| 257 | + foreach ($building_que as $que_element) { |
|
| 258 | 258 | $result['building_que'][] = que_tpl_parse_element($que_element); |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | static $snGroupFleet; |
| 274 | 274 | !$snGroupFleet ? $snGroupFleet = classSupernova::$gc->groupFleet : false; |
| 275 | 275 | |
| 276 | - if(empty($array_of_Fleet)) { |
|
| 276 | + if (empty($array_of_Fleet)) { |
|
| 277 | 277 | return false; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $fleet_list = array(); |
| 281 | - foreach($array_of_Fleet as $fleet) { |
|
| 282 | - if($fleet->playerOwnerId == $user['id']) { |
|
| 283 | - if($fleet->mission_type == MT_MISSILE) { |
|
| 281 | + foreach ($array_of_Fleet as $fleet) { |
|
| 282 | + if ($fleet->playerOwnerId == $user['id']) { |
|
| 283 | + if ($fleet->mission_type == MT_MISSILE) { |
|
| 284 | 284 | continue; |
| 285 | 285 | } |
| 286 | 286 | $fleet_ownage = 'own'; |
| 287 | 287 | } else { |
| 288 | - switch($fleet->mission_type) { |
|
| 288 | + switch ($fleet->mission_type) { |
|
| 289 | 289 | case MT_ATTACK: |
| 290 | 290 | case MT_ACS: |
| 291 | 291 | case MT_DESTROY: |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
| 304 | 304 | |
| 305 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
| 306 | - foreach($fleet->shipsIterator() as $ship_id => $ship) { |
|
| 307 | - if(!empty($snGroupFleet[$ship_id])) { |
|
| 305 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
| 306 | + foreach ($fleet->shipsIterator() as $ship_id => $ship) { |
|
| 307 | + if (!empty($snGroupFleet[$ship_id])) { |
|
| 308 | 308 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship->count; |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | return $fleet_list; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
| 324 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
| 325 | 325 | $template->assign_vars(array( |
| 326 | 326 | 'RESOURCE_ROUNDING' => $round, |
| 327 | 327 | |
@@ -5,11 +5,11 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | $classLocale = classLocale::$lang; |
| 7 | 7 | |
| 8 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
| 8 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
| 9 | 9 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"]; |
|
| 12 | +$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"]; |
|
| 13 | 13 | |
| 14 | 14 | $template = gettemplate('market_fleet', true); |
| 15 | 15 | $template->assign_vars(array( |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | 'rpg_cost' => $rpg_cost, |
| 18 | 18 | )); |
| 19 | 19 | |
| 20 | -if(is_array($shipList)) { |
|
| 21 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
| 20 | +if (is_array($shipList)) { |
|
| 21 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
| 22 | 22 | $intError = MARKET_NO_DM; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -31,32 +31,32 @@ discard block |
||
| 31 | 31 | // Блокируем запись о запасах кораблей у трейдера |
| 32 | 32 | db_config_get_stockman_fleet(); |
| 33 | 33 | |
| 34 | - $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>'; |
|
| 34 | + $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>'; |
|
| 35 | 35 | $total = array(); |
| 36 | - foreach($shipList as $shipID => &$shipCount) { |
|
| 36 | + foreach ($shipList as $shipID => &$shipCount) { |
|
| 37 | 37 | $shipCount = ceil(floatval($shipCount)); |
| 38 | - if(!$shipCount) { |
|
| 38 | + if (!$shipCount) { |
|
| 39 | 39 | continue; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($shipCount < 0) { |
|
| 42 | + if ($shipCount < 0) { |
|
| 43 | 43 | classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
| 44 | 44 | $intError = MARKET_NEGATIVE_SHIPS; |
| 45 | 45 | break; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if($mode == MARKET_SCRAPPER) { |
|
| 48 | + if ($mode == MARKET_SCRAPPER) { |
|
| 49 | 49 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
| 50 | - } elseif($mode == MARKET_STOCKMAN) { |
|
| 50 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
| 51 | 51 | $amount = $stock[$shipID]; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if($amount < $shipCount) { |
|
| 54 | + if ($amount < $shipCount) { |
|
| 55 | 55 | $intError = $error_no_stock; |
| 56 | 56 | break; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if(!in_array($shipID, classSupernova::$gc->groupFleet)) { |
|
| 59 | + if (!in_array($shipID, classSupernova::$gc->groupFleet)) { |
|
| 60 | 60 | classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
| 61 | 61 | $intError = MARKET_NOT_A_SHIP; |
| 62 | 62 | break; |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
| 73 | 73 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
| 74 | 74 | |
| 75 | - foreach($resTemp as $resID => $resCount) { |
|
| 75 | + foreach ($resTemp as $resID => $resCount) { |
|
| 76 | 76 | $total[$resID] += $resCount; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
|
| 79 | + $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
| 83 | - foreach($total as $resID => $resCount) { |
|
| 84 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
| 82 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
| 83 | + foreach ($total as $resID => $resCount) { |
|
| 84 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
| 85 | 85 | $intError = MARKET_NO_RESOURCES; |
| 86 | 86 | classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
| 87 | 87 | break; |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
| 93 | 93 | |
| 94 | 94 | $qry = array(); |
| 95 | - if($intError == MARKET_DEAL) { |
|
| 96 | - $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
|
| 97 | - foreach($total as $resID => $resCount) { |
|
| 98 | - if(!$resCount) { |
|
| 95 | + if ($intError == MARKET_DEAL) { |
|
| 96 | + $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>'; |
|
| 97 | + foreach ($total as $resID => $resCount) { |
|
| 98 | + if (!$resCount) { |
|
| 99 | 99 | continue; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $qry[pname_resource_name($resID)] = $resCount; |
| 103 | - $message .= "<li>" . classLocale::$lang['sys_' . pname_resource_name($resID)] . ": " . pretty_number(abs($resCount)); |
|
| 103 | + $message .= "<li>".classLocale::$lang['sys_'.pname_resource_name($resID)].": ".pretty_number(abs($resCount)); |
|
| 104 | 104 | } |
| 105 | 105 | $message .= "</ul>"; |
| 106 | 106 | |
@@ -128,38 +128,38 @@ discard block |
||
| 128 | 128 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
| 129 | 129 | )); |
| 130 | 130 | |
| 131 | - foreach($shipList as $shipID => $shipCount) { |
|
| 131 | + foreach ($shipList as $shipID => $shipCount) { |
|
| 132 | 132 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | $message = ''; |
| 137 | 137 | |
| 138 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
| 139 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, classSupernova::$gc->groupFleet))); |
|
| 138 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
| 139 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, classSupernova::$gc->groupFleet))); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | tpl_set_resource_info($template, $planetrow, array()); |
| 143 | 143 | |
| 144 | -if(!$array) { |
|
| 144 | +if (!$array) { |
|
| 145 | 145 | $array = array(); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $group_fleet = classSupernova::$gc->groupFleet; |
| 149 | -foreach($array as $key => $value) { |
|
| 150 | - if($mode == MARKET_SCRAPPER) { |
|
| 149 | +foreach ($array as $key => $value) { |
|
| 150 | + if ($mode == MARKET_SCRAPPER) { |
|
| 151 | 151 | $shipID = $value; |
| 152 | 152 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
| 153 | - } elseif($mode == MARKET_STOCKMAN) { |
|
| 153 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
| 154 | 154 | $shipID = $key; |
| 155 | 155 | $amount = $value; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if(!in_array($shipID, $group_fleet)) { |
|
| 158 | + if (!in_array($shipID, $group_fleet)) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if($amount > 0) { |
|
| 162 | + if ($amount > 0) { |
|
| 163 | 163 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
| 164 | 164 | $template->assign_block_vars('ships', array( |
| 165 | 165 | 'ID' => $shipID, |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | // ---------------------------------------------------------------------------------------------------------------- |
| 17 | 17 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
| 18 | - foreach($unit_group as $unit_id) { |
|
| 19 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 18 | + foreach ($unit_group as $unit_id) { |
|
| 19 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 20 | 20 | $compress_data[$unit_id] = $unit_count; |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | $classLocale = classLocale::$lang; |
| 27 | 27 | |
| 28 | 28 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
| 29 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
| 30 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 29 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
| 30 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
| 31 | 31 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $objFleet = $mission_data->fleet; |
| 58 | 58 | |
| 59 | - if(empty($target_user_row['id']) || empty($spying_user_row['id'])) { |
|
| 59 | + if (empty($target_user_row['id']) || empty($spying_user_row['id'])) { |
|
| 60 | 60 | $objFleet->markReturnedAndSave(); |
| 61 | 61 | |
| 62 | 62 | return; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY); |
| 66 | - if($spy_probes > 0) { |
|
| 66 | + if ($spy_probes > 0) { |
|
| 67 | 67 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
| 68 | 68 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
| 69 | 69 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -81,26 +81,26 @@ discard block |
||
| 81 | 81 | $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} "; |
| 82 | 82 | $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target); |
| 83 | 83 | $spy_message .= "</td></tr><tr>"; |
| 84 | - $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>"; |
|
| 85 | - $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>"; |
|
| 84 | + $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>"; |
|
| 85 | + $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>"; |
|
| 86 | 86 | $spy_message .= "</tr><tr>"; |
| 87 | - $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
|
| 88 | - $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
|
| 87 | + $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>"; |
|
| 88 | + $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>"; |
|
| 89 | 89 | $spy_message .= "</tr>"; |
| 90 | - if($spy_diff >= 2) { |
|
| 91 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
|
| 90 | + if ($spy_diff >= 2) { |
|
| 91 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>"; |
|
| 92 | 92 | coe_compress_add_units(classSupernova::$gc->groupFleet, $target_planet_row, $combat_pack[0]); |
| 93 | 93 | } |
| 94 | - if($spy_diff >= 3) { |
|
| 95 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
|
| 94 | + if ($spy_diff >= 3) { |
|
| 95 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>"; |
|
| 96 | 96 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
| 97 | 97 | } |
| 98 | - if($spy_diff >= 5) { |
|
| 99 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
|
| 98 | + if ($spy_diff >= 5) { |
|
| 99 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>"; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if($spy_diff_empire >= 0) { |
|
| 103 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
|
| 102 | + if ($spy_diff_empire >= 0) { |
|
| 103 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>"; |
|
| 104 | 104 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
| 105 | 105 | } |
| 106 | 106 | // TODO: Наемники, губернаторы, артефакты и прочее имперское |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
| 109 | 109 | |
| 110 | 110 | $target_unit_list = 0; |
| 111 | - foreach(classSupernova::$gc->groupFleet as $unit_id) { |
|
| 111 | + foreach (classSupernova::$gc->groupFleet as $unit_id) { |
|
| 112 | 112 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
| 116 | 116 | |
| 117 | - if(mt_rand(0, 99) > $spy_detected) { |
|
| 117 | + if (mt_rand(0, 99) > $spy_detected) { |
|
| 118 | 118 | $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected); |
| 119 | 119 | $spy_detected = false; |
| 120 | 120 | } else { |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | DBStaticMessages::msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message); |
| 133 | 133 | |
| 134 | - $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
|
| 135 | - $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
|
| 134 | + $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3); |
|
| 135 | + $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row); |
|
| 136 | 136 | |
| 137 | - if($spy_detected) { |
|
| 137 | + if ($spy_detected) { |
|
| 138 | 138 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
| 139 | 139 | |
| 140 | 140 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if($spy_detected) { |
|
| 159 | + if ($spy_detected) { |
|
| 160 | 160 | $objFleet->dbDelete(); |
| 161 | 161 | } else { |
| 162 | 162 | $objFleet->markReturnedAndSave(); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | // TODO - Currently $ship_data is one for all players |
| 24 | 24 | static $shipCostInMetalPerPiece, $rates; |
| 25 | 25 | |
| 26 | - if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
| 26 | + if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | $outcome_value = &$result['$outcome_value']; |
| 49 | 49 | $outcome_list = &$result['$outcome_list']; |
| 50 | 50 | |
| 51 | - if(!$shipCostInMetalPerPiece) { |
|
| 51 | + if (!$shipCostInMetalPerPiece) { |
|
| 52 | 52 | $rates = get_resource_exchange(); |
| 53 | 53 | |
| 54 | - foreach(classSupernova::$gc->groupFleet as $unit_id) { |
|
| 54 | + foreach (classSupernova::$gc->groupFleet as $unit_id) { |
|
| 55 | 55 | $unit_info = get_unit_param($unit_id); |
| 56 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 56 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 57 | 57 | continue; |
| 58 | 58 | } |
| 59 | 59 | $shipCostInMetalPerPiece[$unit_id] = get_unit_cost_in($unit_info[P_COST], RES_METAL); |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
| 74 | 74 | |
| 75 | 75 | $chance_max = 0; |
| 76 | - foreach($outcome_list as $key => &$value) { |
|
| 77 | - if(!$value['chance']) { |
|
| 76 | + foreach ($outcome_list as $key => &$value) { |
|
| 77 | + if (!$value['chance']) { |
|
| 78 | 78 | unset($outcome_list[$key]); |
| 79 | 79 | continue; |
| 80 | 80 | } |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | $outcome_value = mt_rand(0, $chance_max); |
| 84 | 84 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
| 85 | - foreach($outcome_list as $key => &$value) { |
|
| 86 | - if(!$value['chance']) { |
|
| 85 | + foreach ($outcome_list as $key => &$value) { |
|
| 86 | + if (!$value['chance']) { |
|
| 87 | 87 | continue; |
| 88 | 88 | } |
| 89 | 89 | $mission_outcome = $key; |
| 90 | 90 | $outcome_description = $value; |
| 91 | - if($outcome_value <= $outcome_description['value']) { |
|
| 91 | + if ($outcome_value <= $outcome_description['value']) { |
|
| 92 | 92 | break; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | // $outcome_mission_sub = -1; |
| 106 | 106 | |
| 107 | 107 | $fleet_found = array(); |
| 108 | - switch($mission_outcome) { |
|
| 108 | + switch ($mission_outcome) { |
|
| 109 | 109 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
| 110 | 110 | $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000); |
| 111 | 111 | break; |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
| 128 | 128 | $can_be_found = array(); |
| 129 | - foreach($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
| 130 | - if($shipMetalCost < $max_metal_cost) { |
|
| 129 | + foreach ($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
| 130 | + if ($shipMetalCost < $max_metal_cost) { |
|
| 131 | 131 | $can_be_found[$ship_id] = $shipMetalCost; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | unset($can_be_found[SHIP_COLONIZER]); |
| 136 | 136 | unset($can_be_found[SHIP_SPY]); |
| 137 | 137 | |
| 138 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 138 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 139 | 139 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
| 140 | 140 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
| 141 | 141 | $found_ship_cost = reset($found_ship); |
| 142 | 142 | $found_ship_id = key($found_ship); |
| 143 | 143 | |
| 144 | - if($found_ship_cost > $found_in_metal) { |
|
| 144 | + if ($found_ship_cost > $found_in_metal) { |
|
| 145 | 145 | unset($can_be_found[$found_ship_id]); |
| 146 | 146 | } else { |
| 147 | 147 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if(empty($fleet_found)) { |
|
| 153 | + if (empty($fleet_found)) { |
|
| 154 | 154 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 155 | 155 | } else { |
| 156 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
| 156 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
| 157 | 157 | $objFleet->shipAdjustCount($unit_id, $unit_amount); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $objFleet->resourcesAdjust($resources_found); |
| 179 | 179 | |
| 180 | - if(array_sum($resources_found) == 0) { |
|
| 180 | + if (array_sum($resources_found) == 0) { |
|
| 181 | 181 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 182 | 182 | } |
| 183 | 183 | break; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // Рассчитываем количество найденной ТМ |
| 189 | 189 | $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
| 190 | 190 | |
| 191 | - if(!$found_dark_matter) { |
|
| 191 | + if (!$found_dark_matter) { |
|
| 192 | 192 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 193 | 193 | } |
| 194 | 194 | break; |
@@ -202,46 +202,45 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | mission_expedition_result_adjust($result); |
| 204 | 204 | |
| 205 | - if($found_dark_matter) { |
|
| 205 | + if ($found_dark_matter) { |
|
| 206 | 206 | rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
| 207 | 207 | $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if(!empty($fleet_lost)) { |
|
| 210 | + if (!empty($fleet_lost)) { |
|
| 211 | 211 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet']; |
| 212 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
| 213 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
| 212 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
| 213 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if(!empty($fleet_found)) { |
|
| 217 | + if (!empty($fleet_found)) { |
|
| 218 | 218 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet']; |
| 219 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
| 220 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
| 219 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
| 220 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 224 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 225 | 225 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources']; |
| 226 | - foreach($resources_found as $resource_id => $resource_amount) { |
|
| 227 | - $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n"; |
|
| 226 | + foreach ($resources_found as $resource_id => $resource_amount) { |
|
| 227 | + $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n"; |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if(!$msg_text) { |
|
| 231 | + if (!$msg_text) { |
|
| 232 | 232 | $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
| 233 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 233 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 234 | 234 | $messages = &$messages[$outcome_mission_sub]; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $msg_text = is_string($messages) ? $messages : |
|
| 238 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 237 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 239 | 238 | } |
| 240 | 239 | |
| 241 | 240 | $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type(); |
| 242 | 241 | |
| 243 | - $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) . |
|
| 244 | - ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
| 242 | + $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)). |
|
| 243 | + ($msg_text_addon ? "\r\n".$msg_text_addon : ''); |
|
| 245 | 244 | |
| 246 | 245 | DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
| 247 | 246 | |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | $RecyclerCapacity = 0; |
| 17 | 17 | $OtherFleetCapacity = 0; |
| 18 | 18 | |
| 19 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
| 20 | - if(in_array($unit_id, classSupernova::$gc->groupFleet)) { |
|
| 19 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
| 20 | + if (in_array($unit_id, classSupernova::$gc->groupFleet)) { |
|
| 21 | 21 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count; |
| 22 | - if(in_array($unit_id, classSupernova::$gc->groupRecyclers)) { |
|
| 22 | + if (in_array($unit_id, classSupernova::$gc->groupRecyclers)) { |
|
| 23 | 23 | $RecyclerCapacity += $capacity; |
| 24 | 24 | } else { |
| 25 | 25 | $OtherFleetCapacity += $capacity; |
@@ -28,33 +28,33 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $fleet_resources_amount = $objFleet->resourcesGetTotal(); |
| 31 | - if($fleet_resources_amount > $OtherFleetCapacity) { |
|
| 31 | + if ($fleet_resources_amount > $OtherFleetCapacity) { |
|
| 32 | 32 | // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков |
| 33 | 33 | // Уменьшаем ёмкость переработчиков на указанную величину |
| 34 | 34 | $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $resources_recycled = array(); |
| 38 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
| 38 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
| 39 | 39 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
| 40 | 40 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
| 41 | 41 | } else { |
| 42 | - if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
| 42 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
| 43 | 43 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2) |
| 44 | 44 | ) { |
| 45 | 45 | $resources_recycled[RES_METAL] = $RecyclerCapacity / 2; |
| 46 | 46 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2; |
| 47 | 47 | } else { |
| 48 | - if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
| 48 | + if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
| 49 | 49 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
| 50 | - if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
| 50 | + if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
| 51 | 51 | $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL]; |
| 52 | 52 | } else { |
| 53 | 53 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
| 54 | 54 | } |
| 55 | 55 | } else { |
| 56 | 56 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
| 57 | - if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
| 57 | + if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
| 58 | 58 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL]; |
| 59 | 59 | } else { |
| 60 | 60 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
@@ -8,14 +8,14 @@ discard block |
||
| 8 | 8 | use Vector\Vector; |
| 9 | 9 | |
| 10 | 10 | function flt_fleet_speed($user, $fleet) { |
| 11 | - if(!is_array($fleet)) { |
|
| 11 | + if (!is_array($fleet)) { |
|
| 12 | 12 | $fleet = array($fleet => 1); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $speeds = array(); |
| 16 | - if(!empty($fleet)) { |
|
| 17 | - foreach($fleet as $ship_id => $amount) { |
|
| 18 | - if($amount && in_array($ship_id, classSupernova::$gc->groupFleetAndMissiles)) { |
|
| 16 | + if (!empty($fleet)) { |
|
| 17 | + foreach ($fleet as $ship_id => $amount) { |
|
| 18 | + if ($amount && in_array($ship_id, classSupernova::$gc->groupFleetAndMissiles)) { |
|
| 19 | 19 | $single_ship_data = get_ship_data($ship_id, $user); |
| 20 | 20 | $speeds[] = $single_ship_data['speed']; |
| 21 | 21 | } |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
| 49 | 49 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
| 50 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 50 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 51 | 51 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
| 52 | 52 | $real_speed = $speed_percent * sqrt($fleet_speed); |
| 53 | 53 | |
| 54 | 54 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
| 55 | 55 | |
| 56 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
| 57 | - if(!$ship_id || !$ship_count) { |
|
| 56 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
| 57 | + if (!$ship_id || !$ship_count) { |
|
| 58 | 58 | continue; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { |
| 83 | 83 | $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks; |
| 84 | 84 | $config_bashing_interval = classSupernova::$config->fleet_bashing_interval; |
| 85 | - if(!$config_bashing_attacks) { |
|
| 85 | + if (!$config_bashing_attacks) { |
|
| 86 | 86 | // Bashing allowed - protection disabled |
| 87 | 87 | return FLIGHT_ALLOWED; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING; |
| 91 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
| 91 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
| 92 | 92 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
| 93 | - if(!empty($relations)) { |
|
| 93 | + if (!empty($relations)) { |
|
| 94 | 94 | $relations = $relations[$enemy['ally_id']]; |
| 95 | - switch($relations['alliance_diplomacy_relation']) { |
|
| 95 | + switch ($relations['alliance_diplomacy_relation']) { |
|
| 96 | 96 | case ALLY_DIPLOMACY_WAR: |
| 97 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
| 97 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
| 98 | 98 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY; |
| 99 | 99 | } else { |
| 100 | 100 | return FLIGHT_ALLOWED; |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | // Retrieving flying fleets |
| 118 | 118 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
| 119 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
| 119 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
| 120 | 120 | // Checking for ACS - each ACS count only once |
| 121 | - if($fleetBashing->group_id) { |
|
| 121 | + if ($fleetBashing->group_id) { |
|
| 122 | 122 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
| 123 | 123 | } else { |
| 124 | 124 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
| 129 | - if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 129 | + if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 130 | 130 | return FLIGHT_ALLOWED; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $query = DBStaticFleetBashing::db_bashing_list_get($user, $planet_dst, $time_limit); |
| 134 | - while($bashing_row = db_fetch($query)) { |
|
| 134 | + while ($bashing_row = db_fetch($query)) { |
|
| 135 | 135 | $bashing_list[] = $bashing_row['bashing_time']; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -140,9 +140,9 @@ discard block |
||
| 140 | 140 | $last_attack = 0; |
| 141 | 141 | $wave = 0; |
| 142 | 142 | $attack = 1; |
| 143 | - foreach($bashing_list as &$bash_time) { |
|
| 143 | + foreach ($bashing_list as &$bash_time) { |
|
| 144 | 144 | $attack++; |
| 145 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 145 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 146 | 146 | $attack = 1; |
| 147 | 147 | $wave++; |
| 148 | 148 | } |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | //TODO: try..catch |
| 160 | 160 | global $user; |
| 161 | 161 | |
| 162 | - if($user['vacation']) { |
|
| 162 | + if ($user['vacation']) { |
|
| 163 | 163 | return $result = FLIGHT_PLAYER_VACATION_OWN; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if(empty($fleet) || !is_array($fleet)) { |
|
| 166 | + if (empty($fleet) || !is_array($fleet)) { |
|
| 167 | 167 | return $result = FLIGHT_SHIPS_NO_SHIPS; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $sn_groups_mission = sn_get_groups('missions'); |
| 171 | - if(!isset($sn_groups_mission[$mission])) { |
|
| 171 | + if (!isset($sn_groups_mission[$mission])) { |
|
| 172 | 172 | return $result = FLIGHT_MISSION_UNKNOWN; |
| 173 | 173 | } |
| 174 | 174 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -187,32 +187,32 @@ discard block |
||
| 187 | 187 | $resources = 0; |
| 188 | 188 | $ship_ids = classSupernova::$gc->groupFleet; |
| 189 | 189 | $resource_ids = sn_get_groups('resources_loot'); |
| 190 | - foreach($fleet as $ship_id => $ship_count) { |
|
| 190 | + foreach ($fleet as $ship_id => $ship_count) { |
|
| 191 | 191 | $is_ship = in_array($ship_id, $ship_ids); |
| 192 | 192 | $is_resource = in_array($ship_id, $resource_ids); |
| 193 | - if(!$is_ship && !$is_resource) { |
|
| 193 | + if (!$is_ship && !$is_resource) { |
|
| 194 | 194 | // TODO Спецобработчик для Капитана и модулей |
| 195 | 195 | // return FLIGHT_SHIPS_UNIT_WRONG; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if($ship_count < 0) { |
|
| 198 | + if ($ship_count < 0) { |
|
| 199 | 199 | return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 202 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 203 | 203 | // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES |
| 204 | 204 | return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if($is_ship) { |
|
| 207 | + if ($is_ship) { |
|
| 208 | 208 | $single_ship_data = get_ship_data($ship_id, $user); |
| 209 | - if($single_ship_data[P_SPEED] <= 0) { |
|
| 209 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
| 210 | 210 | return $result = FLIGHT_SHIPS_UNMOVABLE; |
| 211 | 211 | } |
| 212 | 212 | $ships += $ship_count; |
| 213 | 213 | $recyclers += in_array($ship_id, classSupernova::$gc->groupRecyclers) ? $ship_count : 0; |
| 214 | 214 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
| 215 | - } elseif($is_resource) { |
|
| 215 | + } elseif ($is_resource) { |
|
| 216 | 216 | $resources += $ship_count; |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | */ |
| 225 | 225 | |
| 226 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 226 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 227 | 227 | return $result = FLIGHT_RESOURCES_FORBIDDEN; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -235,78 +235,78 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | |
| 237 | 237 | $speed = $options['fleet_speed_percent']; |
| 238 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 238 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 239 | 239 | return $result = FLIGHT_FLEET_SPEED_WRONG; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
| 243 | 243 | |
| 244 | 244 | |
| 245 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 245 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 246 | 246 | return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 249 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 250 | 250 | return $result = FLIGHT_FLEET_TOO_FAR; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if($travel_data['hold'] < $resources) { |
|
| 253 | + if ($travel_data['hold'] < $resources) { |
|
| 254 | 254 | return $result = FLIGHT_FLEET_OVERLOAD; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
| 258 | 258 | |
| 259 | 259 | $fleet_group = $options['fleet_group']; |
| 260 | - if($fleet_group) { |
|
| 261 | - if($mission != MT_ACS) { |
|
| 260 | + if ($fleet_group) { |
|
| 261 | + if ($mission != MT_ACS) { |
|
| 262 | 262 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 263 | 263 | }; |
| 264 | 264 | |
| 265 | 265 | $acs = DBStaticFleetACS::db_acs_get_by_group_id($fleet_group); |
| 266 | - if(!$acs['id']) { |
|
| 266 | + if (!$acs['id']) { |
|
| 267 | 267 | return $result = FLIGHT_MISSION_ACS_NOT_EXISTS; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 270 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 271 | 271 | return $result = FLIGHT_MISSION_ACS_WRONG_TARGET; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if($fleet_start_time > $acs['ankunft']) { |
|
| 274 | + if ($fleet_start_time > $acs['ankunft']) { |
|
| 275 | 275 | return $result = FLIGHT_MISSION_ACS_TOO_LATE; |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $flying_fleets = $options['flying_fleets']; |
| 280 | - if(!$flying_fleets) { |
|
| 280 | + if (!$flying_fleets) { |
|
| 281 | 281 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
| 282 | 282 | } |
| 283 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 283 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 284 | 284 | return $result = FLIGHT_FLEET_NO_SLOTS; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
| 288 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 288 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 289 | 289 | return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // Checking for no planet |
| 293 | - if(!$planet_dst['id_owner']) { |
|
| 294 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 293 | + if (!$planet_dst['id_owner']) { |
|
| 294 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 295 | 295 | return $result = FLIGHT_SHIPS_NO_COLONIZER; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 298 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 299 | 299 | return $result = FLIGHT_ALLOWED; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return $result = FLIGHT_VECTOR_NO_TARGET; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if($mission == MT_RECYCLE) { |
|
| 306 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 305 | + if ($mission == MT_RECYCLE) { |
|
| 306 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 307 | 307 | return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS; |
| 308 | 308 | } |
| 309 | - if($recyclers <= 0) { |
|
| 309 | + if ($recyclers <= 0) { |
|
| 310 | 310 | return $result = FLIGHT_SHIPS_NO_RECYCLERS; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | // Got planet. Checking if it is ours |
| 317 | - if($planet_dst['id_owner'] == $user['id']) { |
|
| 318 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 317 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
| 318 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 319 | 319 | return $result = FLIGHT_ALLOWED; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -323,19 +323,19 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
| 326 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 326 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 327 | 327 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $enemy = DBStaticUser::db_user_by_id($planet_dst['id_owner']); |
| 331 | 331 | // We cannot attack or send resource to users in VACATION mode |
| 332 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 332 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 333 | 333 | return $result = FLIGHT_PLAYER_VACATION; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Multi IP protection |
| 337 | 337 | // TODO: Here we need a procedure to check proxies |
| 338 | - if(sys_is_multiaccount($user, $enemy)) { |
|
| 338 | + if (sys_is_multiaccount($user, $enemy)) { |
|
| 339 | 339 | return $result = FLIGHT_PLAYER_SAME_IP; |
| 340 | 340 | } |
| 341 | 341 | |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | $enemy_points = $enemy['total_points']; |
| 344 | 344 | |
| 345 | 345 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
| 346 | - if($mission == MT_TRANSPORT) { |
|
| 347 | - if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
| 346 | + if ($mission == MT_TRANSPORT) { |
|
| 347 | + if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
| 348 | 348 | return $result = FLIGHT_ALLOWED; |
| 349 | 349 | } else { |
| 350 | 350 | return $result = FLIGHT_PLAYER_BUFFING; |
@@ -354,66 +354,66 @@ discard block |
||
| 354 | 354 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
| 355 | 355 | |
| 356 | 356 | // Is it admin with planet protection? |
| 357 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
| 357 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
| 358 | 358 | return $result = FLIGHT_PLAYER_ADMIN; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | // Okay. Now skipping protection checks for inactive longer then 1 week |
| 362 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 363 | - if( |
|
| 362 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 363 | + if ( |
|
| 364 | 364 | ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points) |
| 365 | 365 | || |
| 366 | 366 | (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor) |
| 367 | 367 | ) { |
| 368 | - if($mission != MT_HOLD) { |
|
| 368 | + if ($mission != MT_HOLD) { |
|
| 369 | 369 | return $result = FLIGHT_PLAYER_NOOB; |
| 370 | 370 | } |
| 371 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
| 371 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
| 372 | 372 | return $result = FLIGHT_PLAYER_NOOB; |
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Is it HOLD mission? If yes - there should be ally deposit |
| 378 | - if($mission == MT_HOLD) { |
|
| 379 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 378 | + if ($mission == MT_HOLD) { |
|
| 379 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 380 | 380 | return $result = FLIGHT_ALLOWED; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if($mission == MT_SPY) { |
|
| 386 | + if ($mission == MT_SPY) { |
|
| 387 | 387 | return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Is it MISSILE mission? |
| 391 | - if($mission == MT_MISSILE) { |
|
| 391 | + if ($mission == MT_MISSILE) { |
|
| 392 | 392 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
| 393 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 393 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 394 | 394 | return $result = FLIGHT_MISSION_MISSILE_NO_SILO; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 397 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 398 | 398 | return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
| 402 | 402 | $mip_range = flt_get_missile_range($user); |
| 403 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 403 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 404 | 404 | return $result = FLIGHT_MISSION_MISSILE_TOO_FAR; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 407 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 408 | 408 | return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE; |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 412 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 413 | 413 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
| 416 | + if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
| 417 | 417 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
| 418 | 418 | } |
| 419 | 419 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | $from = $from['planet']; |
| 441 | 441 | |
| 442 | 442 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
| 443 | - if($can_attack != FLIGHT_ALLOWED) { |
|
| 443 | + if ($can_attack != FLIGHT_ALLOWED) { |
|
| 444 | 444 | $internal_transaction ? sn_db_transaction_rollback() : false; |
| 445 | 445 | |
| 446 | 446 | return $can_attack; |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
| 452 | 452 | |
| 453 | 453 | $time_on_mission = 0; |
| 454 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 454 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 455 | 455 | // TODO - include some checks about maximum and minumum stay_duration |
| 456 | 456 | $time_on_mission = $options['stay_time'] * 3600; |
| 457 | 457 | } |
@@ -473,14 +473,14 @@ discard block |
||
| 473 | 473 | $sn_group_fleet = classSupernova::$gc->groupFleet; |
| 474 | 474 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
| 475 | 475 | $planetRowFieldChanges = array(); |
| 476 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
| 477 | - if(!$amount || !$unit_id) { |
|
| 476 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
| 477 | + if (!$amount || !$unit_id) { |
|
| 478 | 478 | continue; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
| 481 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
| 482 | 482 | DBStaticUnit::dbUpdateOrInsertUnit($unit_id, -$amount, $user, $from['id']); |
| 483 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
| 483 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
| 484 | 484 | $planetRowFieldChanges[$unit_id] -= $amount; |
| 485 | 485 | } |
| 486 | 486 | } |
@@ -512,16 +512,16 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $ship_data = array(); |
| 514 | 514 | $fleet_array = array(); |
| 515 | - foreach($ship_list as $transport_id => $cork) { |
|
| 515 | + foreach ($ship_list as $transport_id => $cork) { |
|
| 516 | 516 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
| 517 | 517 | } |
| 518 | 518 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
| 519 | 519 | |
| 520 | 520 | $fleet_capacity = 0; |
| 521 | 521 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
| 522 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
| 522 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
| 523 | 523 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
| 524 | - if($ship_loaded) { |
|
| 524 | + if ($ship_loaded) { |
|
| 525 | 525 | $fleet_array[$transport_id] = $ship_loaded; |
| 526 | 526 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
| 527 | 527 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |