@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | 'factor' => 1.5, |
| 16 | 16 | ), |
| 17 | 17 | P_UNIT_PRODUCTION => array( |
| 18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 20 | 20 | ), |
| 21 | 21 | P_MINING_IS_MANAGED => true, |
| 22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | 'factor' => 1.6, |
| 34 | 34 | ), |
| 35 | 35 | P_UNIT_PRODUCTION => array( |
| 36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 38 | 38 | ), |
| 39 | 39 | P_MINING_IS_MANAGED => true, |
| 40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | 'factor' => 1.5, |
| 52 | 52 | ), |
| 53 | 53 | P_UNIT_PRODUCTION => array( |
| 54 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);}, |
|
| 55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 54 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
| 55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 56 | 56 | ), |
| 57 | 57 | P_MINING_IS_MANAGED => true, |
| 58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'factor' => 1.5, |
| 70 | 70 | ), |
| 71 | 71 | P_UNIT_PRODUCTION => array( |
| 72 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 72 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 73 | 73 | ), |
| 74 | 74 | P_MINING_IS_MANAGED => true, |
| 75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | 'factor' => 1.8, |
| 88 | 88 | ), |
| 89 | 89 | P_UNIT_PRODUCTION => array( |
| 90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
| 91 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor);}, |
|
| 90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 91 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
| 92 | 92 | ), |
| 93 | 93 | P_MINING_IS_MANAGED => true, |
| 94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'factor' => 2, |
| 106 | 106 | ), |
| 107 | 107 | 'storage' => array( |
| 108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
| 108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 109 | 109 | ), |
| 110 | 110 | ), |
| 111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'factor' => 2, |
| 122 | 122 | ), |
| 123 | 123 | 'storage' => array( |
| 124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
| 124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 125 | 125 | ), |
| 126 | 126 | ), |
| 127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'factor' => 2, |
| 138 | 138 | ), |
| 139 | 139 | 'storage' => array( |
| 140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
| 140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 141 | 141 | ), |
| 142 | 142 | ), |
| 143 | 143 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | 'GROUP BY `unit_snid`' |
| 27 | 27 | ); |
| 28 | 28 | $result = array(); |
| 29 | - while($row = db_fetch($query)) { |
|
| 29 | + while ($row = db_fetch($query)) { |
|
| 30 | 30 | $result[$row['unit_snid']] = $row; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
| 37 | 37 | |
| 38 | 38 | $mode = sys_get_param_int('mode'); |
| 39 | - switch($mode) { |
|
| 39 | + switch ($mode) { |
|
| 40 | 40 | case CHAT_MODE_ALLY: |
| 41 | 41 | $template_result['ALLY'] = intval($user['ally_id']); |
| 42 | 42 | $page_title = classLocale::$lang['chat_ally']; |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $template_result['.']['smiles'] = array(); |
| 52 | - foreach($supernova->design['smiles'] as $auth_level => $replaces) { |
|
| 53 | - if($auth_level > $user_auth_level) { |
|
| 52 | + foreach ($supernova->design['smiles'] as $auth_level => $replaces) { |
|
| 53 | + if ($auth_level > $user_auth_level) { |
|
| 54 | 54 | continue; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - foreach($replaces as $bbcode => $filename) { |
|
| 57 | + foreach ($replaces as $bbcode => $filename) { |
|
| 58 | 58 | $template_result['.']['smiles'][] = array( |
| 59 | 59 | 'BBCODE' => $bbcode, |
| 60 | 60 | 'FILENAME' => $filename, |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | define('IN_AJAX', true); |
| 78 | 78 | $skip_fleet_update = true; |
| 79 | 79 | |
| 80 | - if(classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
| 80 | + if (classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
| 81 | 81 | die(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if(($message = sys_get_param_str('message')) && $user['username']) { |
|
| 84 | + if (($message = sys_get_param_str('message')) && $user['username']) { |
|
| 85 | 85 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
| 86 | 86 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
| 87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $skip_fleet_update = true; |
| 104 | 104 | |
| 105 | 105 | $history = sys_get_param_str('history'); |
| 106 | - if(!$history) { |
|
| 106 | + if (!$history) { |
|
| 107 | 107 | classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $last_message = ''; |
| 112 | 112 | $alliance = 0; |
| 113 | 113 | $template_result['.']['chat'] = array(); |
| 114 | - if(!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
| 114 | + if (!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
| 115 | 115 | $result['disable'] = true; |
| 116 | 116 | $template_result['.']['chat'][] = array( |
| 117 | 117 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $where_add = ''; |
| 126 | 126 | $last_message = 0; |
| 127 | - if($history) { |
|
| 127 | + if ($history) { |
|
| 128 | 128 | $rows = db_chat_message_count_by_ally($alliance); |
| 129 | 129 | $page_count = ceil($rows['CNT'] / $page_limit); |
| 130 | 130 | |
| 131 | - for($i = 0; $i < $page_count; $i++) { |
|
| 131 | + for ($i = 0; $i < $page_count; $i++) { |
|
| 132 | 132 | $template_result['.']['page'][] = array( |
| 133 | 133 | 'NUMBER' => $i |
| 134 | 134 | ); |
@@ -142,12 +142,12 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $start_row = $page * $page_limit; |
| 144 | 144 | $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
| 145 | - while($chat_row = db_fetch($query)) { |
|
| 145 | + while ($chat_row = db_fetch($query)) { |
|
| 146 | 146 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
| 147 | 147 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
| 148 | 148 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
| 149 | 149 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
| 150 | - if(!$history) { |
|
| 150 | + if (!$history) { |
|
| 151 | 151 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $template = gettemplate('chat_messages', $template); |
| 173 | 173 | $template->assign_recursive($template_result); |
| 174 | 174 | |
| 175 | - if($history) { |
|
| 175 | + if ($history) { |
|
| 176 | 176 | display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
| 177 | 177 | } else { |
| 178 | 178 | $result['last_message'] = $last_message; |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | * @return int|mixed |
| 229 | 229 | */ |
| 230 | 230 | public function calcColonyMaxCount($astrotech = -1) { |
| 231 | - if($astrotech == -1) { |
|
| 232 | - if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 231 | + if ($astrotech == -1) { |
|
| 232 | + if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 233 | 233 | |
| 234 | 234 | $expeditions = get_player_max_expeditons($this->_dbRow); |
| 235 | 235 | $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | public function expeditionsMax() { |
| 305 | - if($this->expeditionsMax === null) { |
|
| 305 | + if ($this->expeditionsMax === null) { |
|
| 306 | 306 | $this->expeditionsMax = get_player_max_expeditons($this->_dbRow); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | public function expeditionsFlying() { |
| 313 | - if($this->expeditionsFlying === null) { |
|
| 313 | + if ($this->expeditionsFlying === null) { |
|
| 314 | 314 | $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | |
| 321 | 321 | public function fleetsMax() { |
| 322 | - if($this->fleetMax === null) { |
|
| 322 | + if ($this->fleetMax === null) { |
|
| 323 | 323 | $this->fleetMax = GetMaxFleets($this->_dbRow); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | public function fleetsFlying() { |
| 330 | - if($this->fleetFlying === null) { |
|
| 330 | + if ($this->fleetFlying === null) { |
|
| 331 | 331 | $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | |
| 338 | 338 | public function coloniesMax() { |
| 339 | - if($this->coloniesMax === null) { |
|
| 339 | + if ($this->coloniesMax === null) { |
|
| 340 | 340 | $this->coloniesMax = get_player_max_colonies($this->_dbRow); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | public function coloniesCurrent() { |
| 347 | - if($this->coloniesCurrent === null) { |
|
| 347 | + if ($this->coloniesCurrent === null) { |
|
| 348 | 348 | $this->coloniesCurrent = get_player_current_colonies($this->_dbRow); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | **/ |
| 14 | 14 | |
| 15 | -if(SN_IN_FLEET !== true) { |
|
| 15 | +if (SN_IN_FLEET !== true) { |
|
| 16 | 16 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $planet_list = array(); |
| 27 | 27 | |
| 28 | - if(is_array($resources_taken)) |
|
| 28 | + if (is_array($resources_taken)) |
|
| 29 | 29 | { |
| 30 | 30 | $query = implode(',', array_keys($resources_taken)); |
| 31 | 31 | $query = " AND `destruyed` = 0 AND `id` IN ({$query})"; |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | $query = ''; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach(sn_get_groups('flt_transports') as $transport_id) { |
|
| 36 | + foreach (sn_get_groups('flt_transports') as $transport_id) { |
|
| 37 | 37 | $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY); |
| 38 | 38 | } |
| 39 | 39 | arsort($transports); |
| 40 | 40 | |
| 41 | 41 | $planets_db_list = db_planet_list_sorted($user, $planetrow['id'], '*', $query); |
| 42 | 42 | !is_array($planets_db_list) ? $planets_db_list = array() : false; |
| 43 | - foreach($planets_db_list as $planet_db_data) { |
|
| 43 | + foreach ($planets_db_list as $planet_db_data) { |
|
| 44 | 44 | // begin planet loop |
| 45 | - if(!$query) { |
|
| 45 | + if (!$query) { |
|
| 46 | 46 | $resources_taken[$planet_db_data['id']] = 1; |
| 47 | 47 | } |
| 48 | 48 | sn_db_transaction_start(); |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $planet_id = $planet_db_data['id']; |
| 55 | 55 | |
| 56 | 56 | $planet_resources = 0; |
| 57 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 58 | - if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) { |
|
| 57 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 58 | + if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) { |
|
| 59 | 59 | $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $fleet_capacity = 0; |
| 87 | 87 | $ship_loadout = array(); |
| 88 | 88 | $fleet = array(); |
| 89 | - foreach($transports as $ship_id => $ship_capacity) { |
|
| 90 | - if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) { |
|
| 89 | + foreach ($transports as $ship_id => $ship_capacity) { |
|
| 90 | + if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) { |
|
| 91 | 91 | $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity; |
| 92 | 92 | $ship_loadout[$ship_id]['taken'] = 0; |
| 93 | 93 | $fleet_capacity += $ship_loadout[$ship_id]['capacity']; |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $will_take = min($planet_resources, $fleet_capacity); |
| 100 | 100 | |
| 101 | - foreach($ship_loadout as $ship_id => &$planet_ship) { |
|
| 101 | + foreach ($ship_loadout as $ship_id => &$planet_ship) { |
|
| 102 | 102 | $can_take = min($will_take, $planet_ship['capacity']); |
| 103 | - if($can_take <= 0) { |
|
| 103 | + if ($can_take <= 0) { |
|
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | $planet_ship['capacity'] -= $can_take; |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]); |
| 109 | 109 | |
| 110 | 110 | $will_take -= $can_take; |
| 111 | - if($will_take <= 0) { |
|
| 111 | + if ($will_take <= 0) { |
|
| 112 | 112 | break; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if(!empty($fleet)) { |
|
| 116 | + if (!empty($fleet)) { |
|
| 117 | 117 | $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10); |
| 118 | 118 | $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed']; |
| 119 | 119 | $planet_data['DISTANCE'] = $travel_data['distance']; |
| 120 | 120 | $planet_data['DURATION'] = $travel_data['duration']; |
| 121 | 121 | $planet_data['CONSUMPTION'] = $travel_data['consumption']; |
| 122 | 122 | |
| 123 | - if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) { |
|
| 123 | + if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) { |
|
| 124 | 124 | $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION']; |
| 125 | 125 | |
| 126 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 127 | - if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) { |
|
| 126 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 127 | + if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) { |
|
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $fleet[$resource_id] = min($will_take, $resource_amount); |
| 134 | 134 | $will_take -= $resource_amount; |
| 135 | 135 | |
| 136 | - if($will_take <= 0) { |
|
| 136 | + if ($will_take <= 0) { |
|
| 137 | 137 | break; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -157,19 +157,19 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $resources_taken = sys_get_param('resources'); |
| 159 | 159 | |
| 160 | -if(!empty($resources_taken)) { // begin processing parameters |
|
| 160 | +if (!empty($resources_taken)) { // begin processing parameters |
|
| 161 | 161 | $planet_list = flt_build_gathering($resources_taken); |
| 162 | 162 | |
| 163 | - foreach($planet_list as $planet_id => $planet_data) { |
|
| 164 | - if($planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 163 | + foreach ($planet_list as $planet_id => $planet_data) { |
|
| 164 | + if ($planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 165 | 165 | $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $planet_data['MESSAGE'] = classLocale::$lang['fl_attack_error'][$planet_data['RESULT']]; |
| 169 | 169 | |
| 170 | 170 | $template->assign_block_vars('results', $planet_data); |
| 171 | - if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 172 | - foreach($planet_data['FLEET'] as $unit_id => $amount) { |
|
| 171 | + if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
| 172 | + foreach ($planet_data['FLEET'] as $unit_id => $amount) { |
|
| 173 | 173 | $template->assign_block_vars('results.units', array( |
| 174 | 174 | 'ID' => $unit_id, |
| 175 | 175 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | // Building list of own planets & moons |
| 184 | 184 | $planet_list = flt_build_gathering(); |
| 185 | -foreach($planet_list as $planet_data) { |
|
| 185 | +foreach ($planet_list as $planet_data) { |
|
| 186 | 186 | $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : classLocale::$lang['flt_no_fuel']; |
| 187 | 187 | $template->assign_block_vars('colonies', $planet_data); |
| 188 | 188 | } |
@@ -1,14 +1,14 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | function flt_fleet_speed($user, $fleet) { |
| 4 | - if(!is_array($fleet)) { |
|
| 4 | + if (!is_array($fleet)) { |
|
| 5 | 5 | $fleet = array($fleet => 1); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | $speeds = array(); |
| 9 | - if(!empty($fleet)) { |
|
| 10 | - foreach($fleet as $ship_id => $amount) { |
|
| 11 | - if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 9 | + if (!empty($fleet)) { |
|
| 10 | + foreach ($fleet as $ship_id => $amount) { |
|
| 11 | + if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 12 | 12 | $single_ship_data = get_ship_data($ship_id, $user); |
| 13 | 13 | $speeds[] = $single_ship_data['speed']; |
| 14 | 14 | } |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
| 53 | 53 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
| 54 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 54 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
| 55 | 55 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
| 56 | 56 | $real_speed = $speed_percent * sqrt($fleet_speed); |
| 57 | 57 | |
| 58 | 58 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
| 59 | 59 | |
| 60 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
| 61 | - if(!$ship_id || !$ship_count) { |
|
| 60 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
| 61 | + if (!$ship_id || !$ship_count) { |
|
| 62 | 62 | continue; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { |
| 87 | 87 | $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks; |
| 88 | 88 | $config_bashing_interval = classSupernova::$config->fleet_bashing_interval; |
| 89 | - if(!$config_bashing_attacks) { |
|
| 89 | + if (!$config_bashing_attacks) { |
|
| 90 | 90 | // Bashing allowed - protection disabled |
| 91 | 91 | return FLIGHT_ALLOWED; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING; |
| 95 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
| 95 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
| 96 | 96 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
| 97 | - if(!empty($relations)) { |
|
| 97 | + if (!empty($relations)) { |
|
| 98 | 98 | $relations = $relations[$enemy['ally_id']]; |
| 99 | - switch($relations['alliance_diplomacy_relation']) { |
|
| 99 | + switch ($relations['alliance_diplomacy_relation']) { |
|
| 100 | 100 | case ALLY_DIPLOMACY_WAR: |
| 101 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
| 101 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
| 102 | 102 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY; |
| 103 | 103 | } else { |
| 104 | 104 | return FLIGHT_ALLOWED; |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | // Retrieving flying fleets |
| 122 | 122 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
| 123 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
| 123 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
| 124 | 124 | // Checking for ACS - each ACS count only once |
| 125 | - if($fleetBashing->group_id) { |
|
| 125 | + if ($fleetBashing->group_id) { |
|
| 126 | 126 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
| 127 | 127 | } else { |
| 128 | 128 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
| 133 | - if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 133 | + if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
| 134 | 134 | return FLIGHT_ALLOWED; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $query = db_bashing_list_get($user, $planet_dst, $time_limit); |
| 138 | - while($bashing_row = db_fetch($query)) { |
|
| 138 | + while ($bashing_row = db_fetch($query)) { |
|
| 139 | 139 | $bashing_list[] = $bashing_row['bashing_time']; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | $last_attack = 0; |
| 145 | 145 | $wave = 0; |
| 146 | 146 | $attack = 1; |
| 147 | - foreach($bashing_list as &$bash_time) { |
|
| 147 | + foreach ($bashing_list as &$bash_time) { |
|
| 148 | 148 | $attack++; |
| 149 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 149 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
| 150 | 150 | $attack = 1; |
| 151 | 151 | $wave++; |
| 152 | 152 | } |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | //TODO: try..catch |
| 164 | 164 | global $user; |
| 165 | 165 | |
| 166 | - if($user['vacation']) { |
|
| 166 | + if ($user['vacation']) { |
|
| 167 | 167 | return $result = FLIGHT_PLAYER_VACATION_OWN; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(empty($fleet) || !is_array($fleet)) { |
|
| 170 | + if (empty($fleet) || !is_array($fleet)) { |
|
| 171 | 171 | return $result = FLIGHT_SHIPS_NO_SHIPS; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $sn_groups_mission = sn_get_groups('missions'); |
| 175 | - if(!isset($sn_groups_mission[$mission])) { |
|
| 175 | + if (!isset($sn_groups_mission[$mission])) { |
|
| 176 | 176 | return $result = FLIGHT_MISSION_UNKNOWN; |
| 177 | 177 | } |
| 178 | 178 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -191,32 +191,32 @@ discard block |
||
| 191 | 191 | $resources = 0; |
| 192 | 192 | $ship_ids = sn_get_groups('fleet'); |
| 193 | 193 | $resource_ids = sn_get_groups('resources_loot'); |
| 194 | - foreach($fleet as $ship_id => $ship_count) { |
|
| 194 | + foreach ($fleet as $ship_id => $ship_count) { |
|
| 195 | 195 | $is_ship = in_array($ship_id, $ship_ids); |
| 196 | 196 | $is_resource = in_array($ship_id, $resource_ids); |
| 197 | - if(!$is_ship && !$is_resource) { |
|
| 197 | + if (!$is_ship && !$is_resource) { |
|
| 198 | 198 | // TODO Спецобработчик для Капитана и модулей |
| 199 | 199 | // return FLIGHT_SHIPS_UNIT_WRONG; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if($ship_count < 0) { |
|
| 202 | + if ($ship_count < 0) { |
|
| 203 | 203 | return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 206 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
| 207 | 207 | // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES |
| 208 | 208 | return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if($is_ship) { |
|
| 211 | + if ($is_ship) { |
|
| 212 | 212 | $single_ship_data = get_ship_data($ship_id, $user); |
| 213 | - if($single_ship_data[P_SPEED] <= 0) { |
|
| 213 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
| 214 | 214 | return $result = FLIGHT_SHIPS_UNMOVABLE; |
| 215 | 215 | } |
| 216 | 216 | $ships += $ship_count; |
| 217 | 217 | $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; |
| 218 | 218 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
| 219 | - } elseif($is_resource) { |
|
| 219 | + } elseif ($is_resource) { |
|
| 220 | 220 | $resources += $ship_count; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | */ |
| 229 | 229 | |
| 230 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 230 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
| 231 | 231 | return $result = FLIGHT_RESOURCES_FORBIDDEN; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -239,78 +239,78 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | |
| 241 | 241 | $speed = $options['fleet_speed_percent']; |
| 242 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 242 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
| 243 | 243 | return $result = FLIGHT_FLEET_SPEED_WRONG; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 249 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
| 250 | 250 | return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 253 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
| 254 | 254 | return $result = FLIGHT_FLEET_TOO_FAR; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if($travel_data['hold'] < $resources) { |
|
| 257 | + if ($travel_data['hold'] < $resources) { |
|
| 258 | 258 | return $result = FLIGHT_FLEET_OVERLOAD; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
| 262 | 262 | |
| 263 | 263 | $fleet_group = $options['fleet_group']; |
| 264 | - if($fleet_group) { |
|
| 265 | - if($mission != MT_ACS) { |
|
| 264 | + if ($fleet_group) { |
|
| 265 | + if ($mission != MT_ACS) { |
|
| 266 | 266 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 267 | 267 | }; |
| 268 | 268 | |
| 269 | 269 | $acs = db_acs_get_by_group_id($fleet_group); |
| 270 | - if(!$acs['id']) { |
|
| 270 | + if (!$acs['id']) { |
|
| 271 | 271 | return $result = FLIGHT_MISSION_ACS_NOT_EXISTS; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 274 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
| 275 | 275 | return $result = FLIGHT_MISSION_ACS_WRONG_TARGET; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if($fleet_start_time > $acs['ankunft']) { |
|
| 278 | + if ($fleet_start_time > $acs['ankunft']) { |
|
| 279 | 279 | return $result = FLIGHT_MISSION_ACS_TOO_LATE; |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $flying_fleets = $options['flying_fleets']; |
| 284 | - if(!$flying_fleets) { |
|
| 284 | + if (!$flying_fleets) { |
|
| 285 | 285 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
| 286 | 286 | } |
| 287 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 287 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
| 288 | 288 | return $result = FLIGHT_FLEET_NO_SLOTS; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
| 292 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 292 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
| 293 | 293 | return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Checking for no planet |
| 297 | - if(!$planet_dst['id_owner']) { |
|
| 298 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 297 | + if (!$planet_dst['id_owner']) { |
|
| 298 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
| 299 | 299 | return $result = FLIGHT_SHIPS_NO_COLONIZER; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 302 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
| 303 | 303 | return $result = FLIGHT_ALLOWED; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | return $result = FLIGHT_VECTOR_NO_TARGET; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if($mission == MT_RECYCLE) { |
|
| 310 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 309 | + if ($mission == MT_RECYCLE) { |
|
| 310 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
| 311 | 311 | return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS; |
| 312 | 312 | } |
| 313 | - if($recyclers <= 0) { |
|
| 313 | + if ($recyclers <= 0) { |
|
| 314 | 314 | return $result = FLIGHT_SHIPS_NO_RECYCLERS; |
| 315 | 315 | } |
| 316 | 316 | |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Got planet. Checking if it is ours |
| 321 | - if($planet_dst['id_owner'] == $user['id']) { |
|
| 322 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 321 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
| 322 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
| 323 | 323 | return $result = FLIGHT_ALLOWED; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
| 330 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 330 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
| 331 | 331 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $enemy = db_user_by_id($planet_dst['id_owner']); |
| 335 | 335 | // We cannot attack or send resource to users in VACATION mode |
| 336 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 336 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
| 337 | 337 | return $result = FLIGHT_PLAYER_VACATION; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Multi IP protection |
| 341 | 341 | // TODO: Here we need a procedure to check proxies |
| 342 | - if(sys_is_multiaccount($user, $enemy)) { |
|
| 342 | + if (sys_is_multiaccount($user, $enemy)) { |
|
| 343 | 343 | return $result = FLIGHT_PLAYER_SAME_IP; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | $enemy_points = $enemy['total_points']; |
| 348 | 348 | |
| 349 | 349 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
| 350 | - if($mission == MT_TRANSPORT) { |
|
| 351 | - if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
| 350 | + if ($mission == MT_TRANSPORT) { |
|
| 351 | + if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
| 352 | 352 | return $result = FLIGHT_ALLOWED; |
| 353 | 353 | } else { |
| 354 | 354 | return $result = FLIGHT_PLAYER_BUFFING; |
@@ -358,66 +358,66 @@ discard block |
||
| 358 | 358 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
| 359 | 359 | |
| 360 | 360 | // Is it admin with planet protection? |
| 361 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
| 361 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
| 362 | 362 | return $result = FLIGHT_PLAYER_ADMIN; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Okay. Now skipping protection checks for inactive longer then 1 week |
| 366 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 367 | - if( |
|
| 366 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
| 367 | + if ( |
|
| 368 | 368 | ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points) |
| 369 | 369 | || |
| 370 | 370 | (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor) |
| 371 | 371 | ) { |
| 372 | - if($mission != MT_HOLD) { |
|
| 372 | + if ($mission != MT_HOLD) { |
|
| 373 | 373 | return $result = FLIGHT_PLAYER_NOOB; |
| 374 | 374 | } |
| 375 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
| 375 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
| 376 | 376 | return $result = FLIGHT_PLAYER_NOOB; |
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // Is it HOLD mission? If yes - there should be ally deposit |
| 382 | - if($mission == MT_HOLD) { |
|
| 383 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 382 | + if ($mission == MT_HOLD) { |
|
| 383 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
| 384 | 384 | return $result = FLIGHT_ALLOWED; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if($mission == MT_SPY) { |
|
| 390 | + if ($mission == MT_SPY) { |
|
| 391 | 391 | return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | // Is it MISSILE mission? |
| 395 | - if($mission == MT_MISSILE) { |
|
| 395 | + if ($mission == MT_MISSILE) { |
|
| 396 | 396 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
| 397 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 397 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
| 398 | 398 | return $result = FLIGHT_MISSION_MISSILE_NO_SILO; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 401 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
| 402 | 402 | return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
| 406 | 406 | $mip_range = flt_get_missile_range($user); |
| 407 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 407 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
| 408 | 408 | return $result = FLIGHT_MISSION_MISSILE_TOO_FAR; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 411 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
| 412 | 412 | return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE; |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 416 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
| 417 | 417 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
| 420 | + if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
| 421 | 421 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
| 422 | 422 | } |
| 423 | 423 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | $from = $from['planet']; |
| 445 | 445 | |
| 446 | 446 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
| 447 | - if($can_attack != FLIGHT_ALLOWED) { |
|
| 447 | + if ($can_attack != FLIGHT_ALLOWED) { |
|
| 448 | 448 | $internal_transaction ? sn_db_transaction_rollback() : false; |
| 449 | 449 | |
| 450 | 450 | return $can_attack; |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
| 456 | 456 | |
| 457 | 457 | $time_on_mission = 0; |
| 458 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 458 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
| 459 | 459 | // TODO - include some checks about maximum and minumum stay_duration |
| 460 | 460 | $time_on_mission = $options['stay_time'] * 3600; |
| 461 | 461 | } |
@@ -478,14 +478,14 @@ discard block |
||
| 478 | 478 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
| 479 | 479 | $db_changeset = array(); |
| 480 | 480 | $planet_row_changed_fields = array(); |
| 481 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
| 482 | - if(!$amount || !$unit_id) { |
|
| 481 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
| 482 | + if (!$amount || !$unit_id) { |
|
| 483 | 483 | continue; |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
| 486 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
| 487 | 487 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']); |
| 488 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
| 488 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
| 489 | 489 | $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
| 490 | 490 | } |
| 491 | 491 | } |
@@ -524,16 +524,16 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | $ship_data = array(); |
| 526 | 526 | $fleet_array = array(); |
| 527 | - foreach($ship_list as $transport_id => $cork) { |
|
| 527 | + foreach ($ship_list as $transport_id => $cork) { |
|
| 528 | 528 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
| 529 | 529 | } |
| 530 | 530 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
| 531 | 531 | |
| 532 | 532 | $fleet_capacity = 0; |
| 533 | 533 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
| 534 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
| 534 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
| 535 | 535 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
| 536 | - if($ship_loaded) { |
|
| 536 | + if ($ship_loaded) { |
|
| 537 | 537 | $fleet_array[$transport_id] = $ship_loaded; |
| 538 | 538 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
| 539 | 539 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |
@@ -6,26 +6,26 @@ discard block |
||
| 6 | 6 | $fleet_events = array(); |
| 7 | 7 | $fleet_number = 0; |
| 8 | 8 | |
| 9 | - if($objFleetList->count() <= 0) { |
|
| 9 | + if ($objFleetList->count() <= 0) { |
|
| 10 | 10 | return; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - foreach($objFleetList->_container as $objFleet) { |
|
| 13 | + foreach ($objFleetList->_container as $objFleet) { |
|
| 14 | 14 | $planet_start_type = $objFleet->fleet_start_type == PT_MOON ? PT_MOON : PT_PLANET; |
| 15 | 15 | $planet_start = db_planet_by_gspt($objFleet->fleet_start_galaxy, $objFleet->fleet_start_system, $objFleet->fleet_start_planet, $planet_start_type, false, 'name'); |
| 16 | 16 | $objFleet->fleet_start_name = $planet_start['name']; |
| 17 | 17 | |
| 18 | 18 | $planet_end_type = $objFleet->fleet_end_type == PT_MOON ? PT_MOON : PT_PLANET; |
| 19 | - if($objFleet->fleet_end_planet > Vector::$knownPlanets) { |
|
| 19 | + if ($objFleet->fleet_end_planet > Vector::$knownPlanets) { |
|
| 20 | 20 | $objFleet->fleet_end_name = classLocale::$lang['ov_fleet_exploration']; |
| 21 | - } elseif($objFleet->mission_type == MT_COLONIZE) { |
|
| 21 | + } elseif ($objFleet->mission_type == MT_COLONIZE) { |
|
| 22 | 22 | $objFleet->fleet_end_name = classLocale::$lang['ov_fleet_colonization']; |
| 23 | 23 | } else { |
| 24 | 24 | $planet_end = db_planet_by_gspt($objFleet->fleet_end_galaxy, $objFleet->fleet_end_system, $objFleet->fleet_end_planet, $planet_end_type, false, 'name'); |
| 25 | 25 | $objFleet->fleet_end_name = $planet_end['name']; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if($objFleet->time_arrive_to_target > SN_TIME_NOW && !$objFleet->isReturning() && $objFleet->mission_type != MT_MISSILE && |
|
| 28 | + if ($objFleet->time_arrive_to_target > SN_TIME_NOW && !$objFleet->isReturning() && $objFleet->mission_type != MT_MISSILE && |
|
| 29 | 29 | ($planet_scanned === false |
| 30 | 30 | || |
| 31 | 31 | ( |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | $fleet_events[] = flt_register_event_objFleet($objFleet, 0, $planet_end_type); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($objFleet->time_mission_job_complete > SN_TIME_NOW && !$objFleet->isReturning() && $planet_scanned === false && $objFleet->mission_type != MT_MISSILE) { |
|
| 42 | + if ($objFleet->time_mission_job_complete > SN_TIME_NOW && !$objFleet->isReturning() && $planet_scanned === false && $objFleet->mission_type != MT_MISSILE) { |
|
| 43 | 43 | $fleet_events[] = flt_register_event_objFleet($objFleet, 1, $planet_end_type); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if( |
|
| 46 | + if ( |
|
| 47 | 47 | $objFleet->time_return_to_source > SN_TIME_NOW && $objFleet->mission_type != MT_MISSILE && ($objFleet->isReturning() || ($objFleet->mission_type != MT_RELOCATE && $objFleet->mission_type != MT_COLONIZE)) && |
| 48 | 48 | ( |
| 49 | 49 | ($planet_scanned === false && $objFleet->playerOwnerId == $user['id']) |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $fleet_events[] = flt_register_event_objFleet($objFleet, 2, $planet_end_type); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($objFleet->mission_type == MT_MISSILE) { |
|
| 62 | + if ($objFleet->mission_type == MT_MISSILE) { |
|
| 63 | 63 | $fleet_events[] = flt_register_event_objFleet($objFleet, 3, $planet_end_type); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $is_this_planet = false; |
| 81 | 81 | |
| 82 | - switch($objFleet->ov_label = $ov_label) { |
|
| 82 | + switch ($objFleet->ov_label = $ov_label) { |
|
| 83 | 83 | case 0: |
| 84 | 84 | $objFleet->event_time = $objFleet->time_arrive_to_target; |
| 85 | 85 | $is_this_planet = ( |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $objFleet->ov_this_planet = $is_this_planet;// || $planet_scanned != false; |
|
| 113 | + $objFleet->ov_this_planet = $is_this_planet; // || $planet_scanned != false; |
|
| 114 | 114 | |
| 115 | - if($objFleet->playerOwnerId == $user['id']) { |
|
| 115 | + if ($objFleet->playerOwnerId == $user['id']) { |
|
| 116 | 116 | $user_data = $user; |
| 117 | 117 | } else { |
| 118 | 118 | $user_data = db_user_by_id($objFleet->playerOwnerId); |
@@ -1,42 +1,42 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once('includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
|
| 3 | +require_once('includes/init.'.substr(strrchr(__FILE__, '.'), 1)); |
|
| 4 | 4 | |
| 5 | 5 | $mode = sys_get_param_int('mode'); |
| 6 | 6 | $ajax = sys_get_param_int('ajax'); |
| 7 | 7 | |
| 8 | -$url = 'http://supernova.ws/version_check.php?mode=' . $mode |
|
| 9 | - . '&db=' . DB_VERSION |
|
| 10 | - . '&release=' . SN_RELEASE |
|
| 11 | - . '&version=' . SN_VERSION |
|
| 12 | - . '&key=' . urlencode(classSupernova::$config->server_updater_key) |
|
| 13 | - . '&id=' . urlencode(classSupernova::$config->server_updater_id); |
|
| 8 | +$url = 'http://supernova.ws/version_check.php?mode='.$mode |
|
| 9 | + . '&db='.DB_VERSION |
|
| 10 | + . '&release='.SN_RELEASE |
|
| 11 | + . '&version='.SN_VERSION |
|
| 12 | + . '&key='.urlencode(classSupernova::$config->server_updater_key) |
|
| 13 | + . '&id='.urlencode(classSupernova::$config->server_updater_id); |
|
| 14 | 14 | |
| 15 | -switch($mode) { |
|
| 15 | +switch ($mode) { |
|
| 16 | 16 | case SNC_MODE_REGISTER: |
| 17 | - if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
| 18 | - if($ajax) { |
|
| 17 | + if (classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) { |
|
| 18 | + if ($ajax) { |
|
| 19 | 19 | print(SNC_VER_REGISTER_ERROR_REGISTERED); |
| 20 | 20 | } |
| 21 | 21 | die(); |
| 22 | 22 | } |
| 23 | - $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL); |
|
| 23 | + $url .= "&name=".urlencode(classSupernova::$config->game_name)."&url=".urlencode(SN_ROOT_VIRTUAL); |
|
| 24 | 24 | break; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | $check_result = sn_get_url_contents($url); |
| 28 | -if(!$check_result) { |
|
| 28 | +if (!$check_result) { |
|
| 29 | 29 | $version_check = SNC_VER_ERROR_CONNECT; |
| 30 | -} elseif(($version_check = intval($check_result)) && $version_check == $check_result) { |
|
| 30 | +} elseif (($version_check = intval($check_result)) && $version_check == $check_result) { |
|
| 31 | 31 | $version_check = $check_result; |
| 32 | 32 | } else { |
| 33 | 33 | // JSON decode if string |
| 34 | 34 | $check_result = json_decode($check_result, true); |
| 35 | 35 | $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check']; |
| 36 | 36 | |
| 37 | - switch($mode) { |
|
| 37 | + switch ($mode) { |
|
| 38 | 38 | case SNC_MODE_REGISTER: |
| 39 | - if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
| 39 | + if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) { |
|
| 40 | 40 | classSupernova::$config->db_saveItem('server_updater_key', $check_result['site']['site_key']); |
| 41 | 41 | classSupernova::$config->db_saveItem('server_updater_id', $check_result['site']['site_id']); |
| 42 | 42 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | classSupernova::$config->db_saveItem('server_updater_check_last', SN_TIME_NOW); |
| 50 | 50 | classSupernova::$config->db_saveItem('server_updater_check_result', $version_check); |
| 51 | 51 | |
| 52 | -if($ajax) { |
|
| 52 | +if ($ajax) { |
|
| 53 | 53 | define('IN_AJAX', true); |
| 54 | 54 | print($version_check); |
| 55 | 55 | } |
@@ -4,9 +4,9 @@ discard block |
||
| 4 | 4 | // Может добавить спецстатус "Ответ системы платежа" и парсить дальше getMessage |
| 5 | 5 | // см constants.php |
| 6 | 6 | |
| 7 | -include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
| 7 | +include_once('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
| 8 | 8 | |
| 9 | -if(!sn_module_get_active_count('payment')) { |
|
| 9 | +if (!sn_module_get_active_count('payment')) { |
|
| 10 | 10 | sys_redirect('dark_matter.php'); |
| 11 | 11 | die(); |
| 12 | 12 | } |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | // Таблица скидок |
| 25 | 25 | $prev_discount = 0; |
| 26 | -if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
| 27 | - foreach(sn_module_payment::$bonus_table as $sum => $discount) { |
|
| 28 | - if($discount && $discount != $prev_discount) { |
|
| 26 | +if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) { |
|
| 27 | + foreach (sn_module_payment::$bonus_table as $sum => $discount) { |
|
| 28 | + if ($discount && $discount != $prev_discount) { |
|
| 29 | 29 | $template->assign_block_vars('discount', array( |
| 30 | 30 | 'SUM' => $sum, |
| 31 | 31 | 'DISCOUNT' => $discount * 100, |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Результат платежа |
| 41 | -if($payment_id = sys_get_param_id('payment_id')) { |
|
| 41 | +if ($payment_id = sys_get_param_id('payment_id')) { |
|
| 42 | 42 | $payment = db_payment_get($payment_id); |
| 43 | - if($payment && $payment['payment_user_id'] == $user['id']) { |
|
| 44 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 43 | + if ($payment && $payment['payment_user_id'] == $user['id']) { |
|
| 44 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 45 | 45 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained']))); |
| 46 | 46 | } |
| 47 | - if($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 47 | + if ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 48 | 48 | $template->assign_block_vars('result', array( |
| 49 | 49 | 'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']), |
| 50 | 50 | 'STATUS' => 1, |
| 51 | 51 | )); |
| 52 | 52 | } |
| 53 | - if($payment['payment_test']) { |
|
| 53 | + if ($payment['payment_test']) { |
|
| 54 | 54 | $template->assign_block_vars('result', array( |
| 55 | 55 | 'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_test']), |
| 56 | 56 | 'STATUS' => -1, |
@@ -65,28 +65,28 @@ discard block |
||
| 65 | 65 | 'metamatter' => sys_get_param_float('metamatter'), |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | -if(!$request['metamatter']) { |
|
| 68 | +if (!$request['metamatter']) { |
|
| 69 | 69 | unset($_POST); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
| 73 | -array_walk($payment_methods_available, function (&$value, $index) { |
|
| 73 | +array_walk($payment_methods_available, function(&$value, $index) { |
|
| 74 | 74 | $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value; |
| 75 | 75 | }); |
| 76 | 76 | |
| 77 | 77 | // pdump($payment_methods_available); |
| 78 | 78 | $payment_module_valid = false; |
| 79 | 79 | $payment_module = sys_get_param_str('payment_module'); |
| 80 | -foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) { |
|
| 81 | - if(!is_object($module) || !$module->manifest['active']) { |
|
| 80 | +foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) { |
|
| 81 | + if (!is_object($module) || !$module->manifest['active']) { |
|
| 82 | 82 | continue; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | lng_include($module_name, $module->manifest['root_relative']); |
| 86 | 86 | |
| 87 | - foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
| 88 | - foreach($available_methods as $payment_method => $payment_currency) { |
|
| 89 | - if(isset($module->manifest['payment_method'][$payment_method])) { |
|
| 87 | + foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) { |
|
| 88 | + foreach ($available_methods as $payment_method => $payment_currency) { |
|
| 89 | + if (isset($module->manifest['payment_method'][$payment_method])) { |
|
| 90 | 90 | $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method]; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | global $template_result; |
| 99 | 99 | // Доступные платежные методы |
| 100 | -foreach($payment_methods_available as $payment_type_id => $payment_methods) { |
|
| 101 | - if(empty($payment_methods)) { |
|
| 100 | +foreach ($payment_methods_available as $payment_type_id => $payment_methods) { |
|
| 101 | + if (empty($payment_methods)) { |
|
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | 'ID' => $payment_type_id, |
| 107 | 107 | 'NAME' => classLocale::$lang['pay_methods'][$payment_type_id], |
| 108 | 108 | ); |
| 109 | - foreach($payment_methods as $payment_method_id => $module_list) { |
|
| 110 | - if(empty($module_list)) { |
|
| 109 | + foreach ($payment_methods as $payment_method_id => $module_list) { |
|
| 110 | + if (empty($module_list)) { |
|
| 111 | 111 | continue; |
| 112 | 112 | } |
| 113 | 113 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array( |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | 'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']), |
| 119 | 119 | 'BUTTON' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']), |
| 120 | 120 | ); |
| 121 | - foreach($module_list as $payment_module_name => $payment_module_method_details) { |
|
| 121 | + foreach ($module_list as $payment_module_name => $payment_module_method_details) { |
|
| 122 | 122 | $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array( |
| 123 | 123 | 'MODULE' => $payment_module_name, |
| 124 | 124 | ); |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - if(empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
| 128 | + if (empty($template_result['.']['payment'][$payment_type_id]['.'])) { |
|
| 129 | 129 | unset($template_result['.']['payment'][$payment_type_id]); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -138,19 +138,19 @@ discard block |
||
| 138 | 138 | $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name])); |
| 139 | 139 | |
| 140 | 140 | // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it |
| 141 | -if($payment_module_valid) { |
|
| 141 | +if ($payment_module_valid) { |
|
| 142 | 142 | // $payment_module = $payment_module; // Really - do nothing |
| 143 | -} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
| 143 | +} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) { |
|
| 144 | 144 | reset($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
| 145 | 145 | $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]); |
| 146 | -} elseif(count(sn_module::$sn_module_list['payment']) == 1) { |
|
| 146 | +} elseif (count(sn_module::$sn_module_list['payment']) == 1) { |
|
| 147 | 147 | $payment_module = $module_name; |
| 148 | 148 | } else { |
| 149 | 149 | $payment_module = ''; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | -if($payment_type_selected && $payment_method_selected) { |
|
| 153 | - foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
| 152 | +if ($payment_type_selected && $payment_method_selected) { |
|
| 153 | + foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) { |
|
| 154 | 154 | $template->assign_block_vars('payment_module', array( |
| 155 | 155 | 'ID' => $module_name, |
| 156 | 156 | 'NAME' => classLocale::$lang["module_{$module_name}_name"], |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | -foreach(classLocale::$lang['pay_currency_list'] as $key => $value) { |
|
| 162 | +foreach (classLocale::$lang['pay_currency_list'] as $key => $value) { |
|
| 163 | 163 | $course = get_exchange_rate($key); |
| 164 | - if(!$course) { |
|
| 164 | + if (!$course) { |
|
| 165 | 165 | continue; |
| 166 | 166 | } |
| 167 | 167 | $template->assign_block_vars('exchange', array( |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | )); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | -if($request['metamatter'] && $payment_module) { |
|
| 179 | +if ($request['metamatter'] && $payment_module) { |
|
| 180 | 180 | try { |
| 181 | 181 | // Any possible errors about generating paylink should be raised in module! |
| 182 | 182 | $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request); |
| 183 | 183 | |
| 184 | 184 | // Поддержка дополнительной информации |
| 185 | - if(is_array($pay_link['RENDER'])) { |
|
| 186 | - foreach($pay_link['RENDER'] as $html_data) { |
|
| 185 | + if (is_array($pay_link['RENDER'])) { |
|
| 186 | + foreach ($pay_link['RENDER'] as $html_data) { |
|
| 187 | 187 | $template->assign_block_vars('render', $html_data); |
| 188 | - if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
| 189 | - foreach($html_data['VALUE'] as $value_id => $value_value) { |
|
| 188 | + if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) { |
|
| 189 | + foreach ($html_data['VALUE'] as $value_id => $value_value) { |
|
| 190 | 190 | $template->assign_block_vars('render.value', array( |
| 191 | 191 | 'FIELD' => $value_id, |
| 192 | 192 | 'VALUE' => $value_value, |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Поддержка передачи данных для многошаговых платежных систем |
| 200 | - if(is_array($pay_link['DATA'])) { |
|
| 201 | - foreach($pay_link['DATA'] as $key => $value) { |
|
| 200 | + if (is_array($pay_link['DATA'])) { |
|
| 201 | + foreach ($pay_link['DATA'] as $key => $value) { |
|
| 202 | 202 | $template->assign_block_vars('pay_link_data', array( |
| 203 | 203 | 'FIELD' => $key, |
| 204 | 204 | 'VALUE' => $value, |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
| 209 | + if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) { |
|
| 210 | 210 | // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте |
| 211 | 211 | $template->assign_vars(array( |
| 212 | 212 | 'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'], |
@@ -215,17 +215,17 @@ discard block |
||
| 215 | 215 | } else { |
| 216 | 216 | throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR); |
| 217 | 217 | } |
| 218 | - } catch(exception $e) { |
|
| 218 | + } catch (exception $e) { |
|
| 219 | 219 | $template->assign_block_vars('result', $response = array( |
| 220 | 220 | 'STATUS' => $e->getCode(), |
| 221 | 221 | 'MESSAGE' => $e->getMessage(), |
| 222 | 222 | )); |
| 223 | - classSupernova::$debug->warning('Результат операции: код ' . $e->getCode() . ' сообщение "' . $e->getMessage() . '"', 'Ошибка платежа', LOG_INFO_PAYMENT); |
|
| 223 | + classSupernova::$debug->warning('Результат операции: код '.$e->getCode().' сообщение "'.$e->getMessage().'"', 'Ошибка платежа', LOG_INFO_PAYMENT); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | // Прегенерированные пакеты |
| 228 | -foreach($unit_available_amount_list as $unit_amount => $discount) { |
|
| 228 | +foreach ($unit_available_amount_list as $unit_amount => $discount) { |
|
| 229 | 229 | $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency); |
| 230 | 230 | $template->assign_block_vars('mm_amount', array( |
| 231 | 231 | 'VALUE' => $unit_amount, |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | 'PLAYER_CURRENCY' => $player_currency, |
| 261 | 261 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
| 262 | 262 | |
| 263 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
| 263 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
| 264 | 264 | 'UNIT_AMOUNT_TEXT' => pretty_number($request['metamatter']), |
| 265 | 265 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
| 266 | 266 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |