@@ -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 = DBStaticPlanet::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'] == ATTACK_ALLOWED) { |
|
| 163 | + foreach ($planet_list as $planet_id => $planet_data) { |
|
| 164 | + if ($planet_data['RESULT'] == ATTACK_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'] = $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'] == ATTACK_ALLOWED) { |
|
| 172 | - foreach($planet_data['FLEET'] as $unit_id => $amount) { |
|
| 171 | + if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == ATTACK_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' => $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']) : $lang['flt_no_fuel']; |
| 187 | 187 | $template->assign_block_vars('colonies', $planet_data); |
| 188 | 188 | } |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
| 13 | 13 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) |
| 14 | 14 | { |
| 15 | - foreach($unit_group as $unit_id) |
|
| 15 | + foreach ($unit_group as $unit_id) |
|
| 16 | 16 | { |
| 17 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) |
|
| 17 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) |
|
| 18 | 18 | { |
| 19 | 19 | $compress_data[$unit_id] = $unit_count; |
| 20 | 20 | } |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | global $lang; |
| 35 | 35 | |
| 36 | 36 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
| 37 | - foreach(sn_get_groups($group_name) as $unit_id) |
|
| 37 | + foreach (sn_get_groups($group_name) as $unit_id) |
|
| 38 | 38 | { |
| 39 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) |
|
| 39 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) |
|
| 40 | 40 | { |
| 41 | 41 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
| 42 | 42 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $spying_user_row = &$mission_data['src_user']; |
| 64 | 64 | $spying_planet_row = &$mission_data['src_planet']; |
| 65 | 65 | |
| 66 | - if(!isset($target_user_row['id']) || !isset($target_planet_row['id']) || !isset($spying_user_row['id'])) |
|
| 66 | + if (!isset($target_user_row['id']) || !isset($target_planet_row['id']) || !isset($spying_user_row['id'])) |
|
| 67 | 67 | { |
| 68 | 68 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 69 | 69 | fleet_send_back($fleet_row); |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']); |
| 74 | - if($fleet_array[SHIP_SPY] > 0) |
|
| 74 | + if ($fleet_array[SHIP_SPY] > 0) |
|
| 75 | 75 | { |
| 76 | 76 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
| 77 | 77 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
| 78 | 78 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
| 79 | 79 | |
| 80 | 80 | $spy_probes = $fleet_array[SHIP_SPY]; |
| 81 | - $spy_diff = $spy_diff_empire + sqrt($spy_probes) - 1 ; |
|
| 81 | + $spy_diff = $spy_diff_empire + sqrt($spy_probes) - 1; |
|
| 82 | 82 | |
| 83 | 83 | $combat_pack[0] = array( |
| 84 | 84 | RES_METAL => $target_planet_row['metal'], |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $spy_message .= "<td width=220>{$lang['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>"; |
| 95 | 95 | $spy_message .= "<td width=220>{$lang['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>"; |
| 96 | 96 | $spy_message .= "</tr><tr>"; |
| 97 | - $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
|
| 97 | + $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
|
| 98 | 98 | $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
| 99 | 99 | $spy_message .= "</tr>"; |
| 100 | 100 | if ($spy_diff >= 2) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if($spy_diff_empire >= 0) |
|
| 114 | + if ($spy_diff_empire >= 0) |
|
| 115 | 115 | { |
| 116 | 116 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
| 117 | 117 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
@@ -121,14 +121,14 @@ discard block |
||
| 121 | 121 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
| 122 | 122 | |
| 123 | 123 | $target_unit_list = 0; |
| 124 | - foreach(sn_get_groups('fleet') as $unit_id) |
|
| 124 | + foreach (sn_get_groups('fleet') as $unit_id) |
|
| 125 | 125 | { |
| 126 | 126 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
| 130 | 130 | |
| 131 | - if(mt_rand(0, 99) > $spy_detected) |
|
| 131 | + if (mt_rand(0, 99) > $spy_detected) |
|
| 132 | 132 | { |
| 133 | 133 | $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected); |
| 134 | 134 | $spy_detected = false; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $target_user_id = $fleet_row['fleet_target_owner']; |
| 155 | 155 | |
| 156 | - if($spy_detected) |
|
| 156 | + if ($spy_detected) |
|
| 157 | 157 | { |
| 158 | 158 | // doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"); |
| 159 | 159 | db_fleet_delete($fleet_row['fleet_id']); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
| 164 | 164 | |
| 165 | 165 | DBStaticPlanet::db_planet_set_by_id($debris_planet_id, |
| 166 | - "`debris_metal` = `debris_metal` + ". floor($spy_probes * $spy_cost[RES_METAL] * 0.3) .", `debris_crystal` = `debris_crystal` + ". floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3)); |
|
| 166 | + "`debris_metal` = `debris_metal` + " . floor($spy_probes * $spy_cost[RES_METAL] * 0.3) . ", `debris_crystal` = `debris_crystal` + " . floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3)); |
|
| 167 | 167 | |
| 168 | 168 | $target_message .= "<br />{$lang['sys_mess_spy_destroyed_enemy']}"; |
| 169 | 169 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | msg_send_simple_message($target_user_id, '', $fleet_row['fleet_start_time'], MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if(!$spy_detected) |
|
| 179 | + if (!$spy_detected) |
|
| 180 | 180 | { |
| 181 | 181 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = '1' WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"); |
| 182 | 182 | fleet_send_back($fleet_row); |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | $fleet_row = &$mission_data['fleet']; |
| 13 | 13 | $destination_planet = &$mission_data['dst_planet']; |
| 14 | 14 | |
| 15 | - if(!$fleet_row) |
|
| 15 | + if (!$fleet_row) |
|
| 16 | 16 | { |
| 17 | 17 | return CACHE_NOTHING; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if(!isset($destination_planet['id'])) |
|
| 20 | + if (!isset($destination_planet['id'])) |
|
| 21 | 21 | { |
| 22 | 22 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 23 | 23 | fleet_send_back($mission_data['fleet']); |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | $RecyclerCapacity = 0; |
| 30 | 30 | $OtherFleetCapacity = 0; |
| 31 | 31 | $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']); |
| 32 | - foreach($fleet_array as $unit_id => $unit_count) |
|
| 32 | + foreach ($fleet_array as $unit_id => $unit_count) |
|
| 33 | 33 | { |
| 34 | - if(in_array($unit_id, sn_get_groups('fleet'))) |
|
| 34 | + if (in_array($unit_id, sn_get_groups('fleet'))) |
|
| 35 | 35 | { |
| 36 | 36 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count; |
| 37 | - if(in_array($unit_id, sn_get_groups('flt_recyclers'))) |
|
| 37 | + if (in_array($unit_id, sn_get_groups('flt_recyclers'))) |
|
| 38 | 38 | { |
| 39 | 39 | $RecyclerCapacity += $capacity; |
| 40 | 40 | } |
@@ -46,19 +46,19 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"]; |
| 49 | - if($IncomingFleetGoods > $OtherFleetCapacity) |
|
| 49 | + if ($IncomingFleetGoods > $OtherFleetCapacity) |
|
| 50 | 50 | { |
| 51 | 51 | $RecyclerCapacity -= ($IncomingFleetGoods - $OtherFleetCapacity); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) |
|
| 54 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) |
|
| 55 | 55 | { |
| 56 | 56 | $RecycledGoods["metal"] = $destination_planet["debris_metal"]; |
| 57 | 57 | $RecycledGoods["crystal"] = $destination_planet["debris_crystal"]; |
| 58 | 58 | } |
| 59 | 59 | else |
| 60 | 60 | { |
| 61 | - if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
| 61 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND |
|
| 62 | 62 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)) |
| 63 | 63 | { |
| 64 | 64 | $RecycledGoods["metal"] = $RecyclerCapacity / 2; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | - $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; |
|
| 95 | + $NewCargo['Metal'] = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"]; |
|
| 96 | 96 | $NewCargo['Crystal'] = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"]; |
| 97 | 97 | $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"]; |
| 98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | 103 | $Message = sprintf($lang['sys_recy_gotten'], pretty_number($RecycledGoods["metal"]), $lang['Metal'], pretty_number($RecycledGoods["crystal"]), $lang['Crystal']); |
| 104 | - msg_send_simple_message ( $fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); |
|
| 104 | + msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message); |
|
| 105 | 105 | |
| 106 | 106 | // $QryUpdateFleet = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' "; |
| 107 | 107 | // $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"; |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000; |
| 16 | 16 | $fleet_lost = array(); |
| 17 | - foreach($fleet as $unit_id => &$unit_amount) { |
|
| 17 | + foreach ($fleet as $unit_id => &$unit_amount) { |
|
| 18 | 18 | $ships_left = floor($unit_amount * $fleet_left); |
| 19 | 19 | $fleet_lost[$unit_id] = $unit_amount - $ships_left; |
| 20 | 20 | $unit_amount = $ships_left; |
| 21 | - if(!$unit_amount) { |
|
| 21 | + if (!$unit_amount) { |
|
| 22 | 22 | unset($fleet[$unit_id]); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | // $fleet = array(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));} |
|
| 34 | +function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); } |
|
| 35 | 35 | function sn_flt_mission_explore_addon(&$result) { |
| 36 | 36 | return $result; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | function flt_mission_explore(&$mission_data) { |
| 41 | - if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
| 41 | + if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
| 42 | 42 | return CACHE_NONE; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | $outcome_list = &$result['$outcome_list']; |
| 72 | 72 | $fleet_metal_points = &$result['$fleet_metal_points']; |
| 73 | 73 | |
| 74 | - if(!$ship_data) { |
|
| 75 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
| 74 | + if (!$ship_data) { |
|
| 75 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
| 76 | 76 | $unit_info = get_unit_param($unit_id); |
| 77 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 77 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $fleet = sys_unit_str2arr($fleet_row['fleet_array']); |
| 87 | 87 | $fleet_capacity = 0; |
| 88 | 88 | $fleet_metal_points = 0; |
| 89 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 89 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 90 | 90 | $unit_info = get_unit_param($ship_id); |
| 91 | 91 | $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY]; |
| 92 | 92 | $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1); |
| 97 | 97 | |
| 98 | 98 | $outcome_list = sn_get_groups('mission_explore_outcome_list'); |
| 99 | - $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7)); |
|
| 99 | + $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
|
| 100 | 100 | |
| 101 | 101 | $chance_max = 0; |
| 102 | - foreach($outcome_list as $key => &$value) { |
|
| 103 | - if(!$value['chance']) { |
|
| 102 | + foreach ($outcome_list as $key => &$value) { |
|
| 103 | + if (!$value['chance']) { |
|
| 104 | 104 | unset($outcome_list[$key]); |
| 105 | 105 | continue; |
| 106 | 106 | } |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | $outcome_value = mt_rand(0, $chance_max); |
| 110 | 110 | // $outcome_value = 409; |
| 111 | 111 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
| 112 | - foreach($outcome_list as $key => &$value) { |
|
| 113 | - if(!$value['chance']) { |
|
| 112 | + foreach ($outcome_list as $key => &$value) { |
|
| 113 | + if (!$value['chance']) { |
|
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | $mission_outcome = $key; |
| 117 | 117 | $outcome_description = $value; |
| 118 | - if($outcome_value <= $outcome_description['value']) { |
|
| 118 | + if ($outcome_value <= $outcome_description['value']) { |
|
| 119 | 119 | break; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $found_dark_matter = 0; |
| 132 | 132 | // $outcome_mission_sub = -1; |
| 133 | 133 | |
| 134 | - switch($mission_outcome) { |
|
| 134 | + switch ($mission_outcome) { |
|
| 135 | 135 | // switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG! |
| 136 | 136 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
| 137 | 137 | flt_mission_explore_outcome_lost_fleet($result); |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | // Рассчитываем стоимость самого дорого корабля в металле |
| 168 | 168 | $max_metal_cost = 0; |
| 169 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 169 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 170 | 170 | $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
| 174 | 174 | $can_be_found = array(); |
| 175 | - foreach($ship_data as $ship_id => $ship_info) { |
|
| 176 | - if($ship_info['metal_cost'] < $max_metal_cost) { |
|
| 175 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
| 176 | + if ($ship_info['metal_cost'] < $max_metal_cost) { |
|
| 177 | 177 | $can_be_found[$ship_id] = $ship_info['metal_cost']; |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | unset($can_be_found[SHIP_SPY]); |
| 183 | 183 | |
| 184 | 184 | $fleet_found = array(); |
| 185 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 185 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 186 | 186 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
| 187 | 187 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
| 188 | 188 | $found_ship_cost = reset($found_ship); |
| 189 | 189 | $found_ship_id = key($found_ship); |
| 190 | 190 | |
| 191 | - if($found_ship_cost > $found_in_metal) { |
|
| 191 | + if ($found_ship_cost > $found_in_metal) { |
|
| 192 | 192 | unset($can_be_found[$found_ship_id]); |
| 193 | 193 | } else { |
| 194 | 194 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if(empty($fleet_found)) { |
|
| 200 | + if (empty($fleet_found)) { |
|
| 201 | 201 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 202 | 202 | } else { |
| 203 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
| 203 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
| 204 | 204 | $fleet[$unit_id] += $unit_amount; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL]; |
| 227 | 227 | $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM]; |
| 228 | 228 | |
| 229 | - if(array_sum($resources_found) == 0) { |
|
| 229 | + if (array_sum($resources_found) == 0) { |
|
| 230 | 230 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 231 | 231 | } |
| 232 | 232 | break; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | // Рассчитываем количество найденной ТМ |
| 238 | 238 | $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
| 239 | 239 | |
| 240 | - if(!$found_dark_matter) { |
|
| 240 | + if (!$found_dark_matter) { |
|
| 241 | 241 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 242 | 242 | } |
| 243 | 243 | break; |
@@ -251,31 +251,31 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | flt_mission_explore_addon($result); |
| 253 | 253 | |
| 254 | - if($found_dark_matter) { |
|
| 254 | + if ($found_dark_matter) { |
|
| 255 | 255 | rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
| 256 | 256 | $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if(!empty($fleet_lost)) { |
|
| 259 | + if (!empty($fleet_lost)) { |
|
| 260 | 260 | $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet']; |
| 261 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
| 261 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
| 262 | 262 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $fleet_row['fleet_amount'] = array_sum($fleet); |
| 267 | - if(!empty($fleet) && $fleet_row['fleet_amount']) { |
|
| 268 | - if(!empty($fleet_found)) { |
|
| 267 | + if (!empty($fleet) && $fleet_row['fleet_amount']) { |
|
| 268 | + if (!empty($fleet_found)) { |
|
| 269 | 269 | $msg_text_addon = $lang['flt_mission_expedition']['found_fleet']; |
| 270 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
| 270 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
| 271 | 271 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $query_delta = array(); |
| 276 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 276 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 277 | 277 | $msg_text_addon = $lang['flt_mission_expedition']['found_resources']; |
| 278 | - foreach($resources_found as $ship_id => $ship_amount) { |
|
| 278 | + foreach ($resources_found as $ship_id => $ship_amount) { |
|
| 279 | 279 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $query_data = array(); |
| 291 | - if(!empty($fleet_lost) || !empty($fleet_found)) { |
|
| 291 | + if (!empty($fleet_lost) || !empty($fleet_found)) { |
|
| 292 | 292 | $fleet_row['fleet_array'] = sys_unit_arr2str($fleet); |
| 293 | 293 | |
| 294 | 294 | // $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}"; |
@@ -316,17 +316,16 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1"); |
| 318 | 318 | |
| 319 | - if(!$msg_text) { |
|
| 319 | + if (!$msg_text) { |
|
| 320 | 320 | $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
| 321 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 321 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 322 | 322 | $messages = &$messages[$outcome_mission_sub]; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $msg_text = is_string($messages) ? $messages : |
|
| 326 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 325 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 327 | 326 | } |
| 328 | 327 | $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) . |
| 329 | - ($msg_text_addon ? "\r\n" . $msg_text_addon: ''); |
|
| 328 | + ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
| 330 | 329 | |
| 331 | 330 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
| 332 | 331 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $fleet_row = &$mission_data['fleet']; |
| 14 | 14 | $destination_planet = &$mission_data['dst_planet']; |
| 15 | 15 | |
| 16 | - if(!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner']) |
|
| 16 | + if (!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner']) |
|
| 17 | 17 | { |
| 18 | 18 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 19 | 19 | fleet_send_back($mission_data['fleet']); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $mission_data['src_planet']['name'], uni_render_coordinates_href($fleet_row, 'fleet_start_', 3, ''), $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), |
| 27 | 27 | $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']) . |
| 28 | 28 | '<br />' . $lang['sys_relocate_mess_user']; |
| 29 | - foreach(sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) |
|
| 29 | + foreach (sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) |
|
| 30 | 30 | { |
| 31 | 31 | $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
| 32 | 32 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | function flt_mission_destroy($mission_data) { |
| 9 | 9 | $fleet_row = $mission_data['fleet']; |
| 10 | 10 | $destination_planet = $mission_data['dst_planet']; |
| 11 | - if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
| 11 | + if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
| 12 | 12 | fleet_send_back($fleet_row); |
| 13 | 13 | |
| 14 | 14 | return CACHE_FLEET; |
@@ -6,12 +6,12 @@ discard block |
||
| 6 | 6 | $uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']); |
| 7 | 7 | $uni_system = sys_get_param_int('system'); |
| 8 | 8 | |
| 9 | - if($uni_galaxy < 1 || $uni_galaxy > $config->game_maxGalaxy) |
|
| 9 | + if ($uni_galaxy < 1 || $uni_galaxy > $config->game_maxGalaxy) |
|
| 10 | 10 | { |
| 11 | 11 | throw new exception($lang['uni_msg_error_wrong_galaxy'], ERR_ERROR); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - if($uni_system < 0 || $uni_system > $config->game_maxSystem) |
|
| 14 | + if ($uni_system < 0 || $uni_system > $config->game_maxSystem) |
|
| 15 | 15 | { |
| 16 | 16 | throw new exception($lang['uni_msg_error_wrong_system'], ERR_ERROR); |
| 17 | 17 | } |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | $uni_row['universe_price'] += $uni_system ? $config->uni_price_system : $config->uni_price_galaxy; |
| 21 | 21 | $uni_row['universe_name'] = strip_tags($uni_row['universe_name'] ? $uni_row['universe_name'] : ($uni_system ? "{$lang['sys_system']} [{$uni_galaxy}:{$uni_system}]" : "{$lang['sys_galaxy']} {$uni_galaxy}")); |
| 22 | 22 | |
| 23 | - if(sys_get_param_str('uni_name_submit')) |
|
| 23 | + if (sys_get_param_str('uni_name_submit')) |
|
| 24 | 24 | { |
| 25 | 25 | $uni_row['universe_name'] = strip_tags(sys_get_param_str('uni_name')); |
| 26 | 26 | |
| 27 | 27 | $uni_price = sys_get_param_float('uni_price'); |
| 28 | - if($uni_price < $uni_row['universe_price']) |
|
| 28 | + if ($uni_price < $uni_row['universe_price']) |
|
| 29 | 29 | { |
| 30 | 30 | throw new exception($lang['uni_msg_error_low_price'], ERR_ERROR); |
| 31 | 31 | } |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | sn_db_transaction_start(); |
| 35 | 35 | $user = db_user_by_id($user['id'], true); |
| 36 | 36 | // if($user[get_unit_param(RES_DARK_MATTER, P_NAME)] < $uni_price) |
| 37 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
| 37 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price) |
|
| 38 | 38 | { |
| 39 | 39 | throw new exception($lang['uni_msg_error_no_dm'], ERR_ERROR); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if(!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) |
|
| 42 | + if (!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name'))) |
|
| 43 | 43 | { |
| 44 | 44 | throw new exception($lang['sys_msg_err_update_dm'], ERR_ERROR); |
| 45 | 45 | } |
@@ -7,16 +7,16 @@ discard block |
||
| 7 | 7 | global $config; |
| 8 | 8 | |
| 9 | 9 | $mercenary_info = get_unit_param($mercenary_id); |
| 10 | - if($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) |
|
| 10 | + if ($config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) |
|
| 11 | 11 | { |
| 12 | 12 | return true; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if(isset($mercenary_info[P_REQUIRE])) |
|
| 15 | + if (isset($mercenary_info[P_REQUIRE])) |
|
| 16 | 16 | { |
| 17 | - foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) |
|
| 17 | + foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) |
|
| 18 | 18 | { |
| 19 | - if(mrc_get_level($user, null, $unit_id) < $unit_level) |
|
| 19 | + if (mrc_get_level($user, null, $unit_id) < $unit_level) |
|
| 20 | 20 | { |
| 21 | 21 | return false; |
| 22 | 22 | } |
@@ -33,35 +33,35 @@ discard block |
||
| 33 | 33 | $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary; |
| 34 | 34 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1); |
| 35 | 35 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
| 36 | - if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
| 36 | + if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
| 37 | 37 | throw new Exception($lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if(!mrc_officer_accessible($user, $mercenary_id)) { |
|
| 40 | + if (!mrc_officer_accessible($user, $mercenary_id)) { |
|
| 41 | 41 | throw new Exception($lang['mrc_msg_error_requirements'], ERR_ERROR); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $mercenary_level = sys_get_param_int('mercenary_level'); |
| 45 | - if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
| 45 | + if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
| 46 | 46 | throw new Exception($lang['mrc_msg_error_wrong_level'], ERR_ERROR); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
| 49 | + if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
| 50 | 50 | throw new Exception($lang['mrc_msg_error_wrong_period'], ERR_ERROR); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | sn_db_transaction_start(); |
| 54 | 54 | |
| 55 | 55 | $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true); |
| 56 | - if($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
| 56 | + if ($config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
| 57 | 57 | throw new Exception($lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first |
| 58 | - } elseif($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
| 58 | + } elseif ($config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
| 59 | 59 | throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if($mercenary_level) { |
|
| 62 | + if ($mercenary_level) { |
|
| 63 | 63 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
| 64 | - if(!$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
| 64 | + if (!$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
| 65 | 65 | $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
| 66 | 66 | $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
| 67 | 67 | } |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | $darkmater_cost *= $cost_alliance_multiplyer; |
| 73 | 73 | |
| 74 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
| 74 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
| 75 | 75 | throw new Exception($lang['mrc_msg_error_no_resource'], ERR_ERROR); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if(($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
| 78 | + if (($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
| 79 | 79 | $unit_row = DBStaticUnit::db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id); |
| 80 | - if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
| 80 | + if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
| 81 | 81 | $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']); |
| 82 | 82 | $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 83 | 83 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | DBStaticUnit::db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($darkmater_cost && $mercenary_level) { |
|
| 98 | + if ($darkmater_cost && $mercenary_level) { |
|
| 99 | 99 | DBStaticUnit::db_unit_set_insert( |
| 100 | 100 | "unit_player_id = {$user['id']}, |
| 101 | 101 | unit_location_type = " . LOC_USER . ", |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES; |
| 131 | 131 | $is_permanent = $mode == UNIT_PLANS || !$config->empire_mercenary_temporary; |
| 132 | 132 | |
| 133 | - if($mercenary_id = sys_get_param_int('mercenary_id')) |
|
| 133 | + if ($mercenary_id = sys_get_param_int('mercenary_id')) |
|
| 134 | 134 | { |
| 135 | 135 | $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id); |
| 136 | 136 | } |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $template = gettemplate('mrc_mercenary_hire', true); |
| 141 | 141 | |
| 142 | - if(!empty($operation_result)) |
|
| 142 | + if (!empty($operation_result)) |
|
| 143 | 143 | { |
| 144 | 144 | $template->assign_block_vars('result', $operation_result); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) |
|
| 147 | + foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) |
|
| 148 | 148 | { |
| 149 | 149 | $template->assign_block_vars('period', array( |
| 150 | 150 | 'LENGTH' => $hire_period, |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | $user_dark_matter = mrc_get_level($user, '', RES_DARK_MATTER); |
| 158 | 158 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? $config->ali_bonus_members : 1); |
| 159 | 159 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
| 160 | - foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) |
|
| 160 | + foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) |
|
| 161 | 161 | { |
| 162 | 162 | { |
| 163 | 163 | $mercenary = get_unit_param($mercenary_id); |
| 164 | 164 | $mercenary_bonus = $mercenary['bonus']; |
| 165 | 165 | $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; |
| 166 | - switch($mercenary['bonus_type']) |
|
| 166 | + switch ($mercenary['bonus_type']) |
|
| 167 | 167 | { |
| 168 | 168 | case BONUS_PERCENT: |
| 169 | 169 | $mercenary_bonus = "{$mercenary_bonus}% "; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true); |
| 182 | 182 | $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level); |
| 183 | 183 | $total_cost_old = 0; |
| 184 | - if($is_permanent) |
|
| 184 | + if ($is_permanent) |
|
| 185 | 185 | { |
| 186 | 186 | $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level); |
| 187 | 187 | $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer; |
@@ -205,13 +205,13 @@ discard block |
||
| 205 | 205 | 'BONUS_TYPE' => $mercenary['bonus_type'], |
| 206 | 206 | 'HIRE_END' => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW ? date(FMT_DATE_TIME, $mercenary_time_finish) : '', |
| 207 | 207 | 'HIRE_LEFT_PERCENT' => $mercenary_time_finish && $mercenary_time_finish >= SN_TIME_NOW |
| 208 | - ? round(($mercenary_time_finish - SN_TIME_NOW)/($mercenary_time_finish - $mercenary_time_start) * 100, 1) |
|
| 208 | + ? round(($mercenary_time_finish - SN_TIME_NOW) / ($mercenary_time_finish - $mercenary_time_start) * 100, 1) |
|
| 209 | 209 | : 0, |
| 210 | 210 | 'CAN_BUY' => mrc_officer_accessible($user, $mercenary_id), |
| 211 | 211 | )); |
| 212 | 212 | |
| 213 | 213 | $upgrade_cost = 1; |
| 214 | - for($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) |
|
| 214 | + for ($i = $config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) |
|
| 215 | 215 | { |
| 216 | 216 | $total_cost = eco_get_total_cost($mercenary_id, $i); |
| 217 | 217 | $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | $source_planet = &$mission_data['src_planet']; |
| 15 | 15 | $destination_planet = &$mission_data['dst_planet']; |
| 16 | 16 | |
| 17 | - if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) |
|
| 17 | + if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) |
|
| 18 | 18 | { |
| 19 | 19 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
| 20 | 20 | fleet_send_back($fleet_row); |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), |
| 28 | 28 | $fleet_row['fleet_resource_metal'], $lang['Metal'], |
| 29 | 29 | $fleet_row['fleet_resource_crystal'], $lang['Crystal'], |
| 30 | - $fleet_row['fleet_resource_deuterium'], $lang['Deuterium'] ); |
|
| 30 | + $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']); |
|
| 31 | 31 | msg_send_simple_message($fleet_row['fleet_target_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
| 32 | 32 | |
| 33 | - if($fleet_row['fleet_target_owner'] <> $fleet_row['fleet_owner']) |
|
| 33 | + if ($fleet_row['fleet_target_owner'] <> $fleet_row['fleet_owner']) |
|
| 34 | 34 | { |
| 35 | 35 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
| 36 | 36 | } |