@@ -29,6 +29,9 @@ |
||
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | +/** |
|
33 | + * @param string $group_name |
|
34 | + */ |
|
32 | 35 | function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array()) |
33 | 36 | { |
34 | 37 | global $lang; |
@@ -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); |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | * @copyright 2008 |
11 | 11 | */ |
12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
13 | -function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) |
|
14 | -{ |
|
13 | +function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
|
15 | 14 | foreach($unit_group as $unit_id) |
16 | 15 | { |
17 | 16 | if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) |
@@ -29,8 +28,7 @@ discard block |
||
29 | 28 | } |
30 | 29 | } |
31 | 30 | |
32 | -function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array()) |
|
33 | -{ |
|
31 | +function flt_spy_scan($target_planet, $group_name, $section_title, $target_user = array()) { |
|
34 | 32 | global $lang; |
35 | 33 | |
36 | 34 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
@@ -53,8 +51,7 @@ discard block |
||
53 | 51 | return $result; |
54 | 52 | } |
55 | 53 | |
56 | -function flt_mission_spy(&$mission_data) |
|
57 | -{ |
|
54 | +function flt_mission_spy(&$mission_data) { |
|
58 | 55 | global $lang; |
59 | 56 | |
60 | 57 | $fleet_row = &$mission_data['fleet']; |
@@ -132,8 +129,7 @@ discard block |
||
132 | 129 | { |
133 | 130 | $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected); |
134 | 131 | $spy_detected = false; |
135 | - } |
|
136 | - else |
|
132 | + } else |
|
137 | 133 | { |
138 | 134 | $spy_outcome_str = $lang['sys_mess_spy_destroyed']; |
139 | 135 | $spy_detected = true; |
@@ -168,8 +164,7 @@ discard block |
||
168 | 164 | $target_message .= "<br />{$lang['sys_mess_spy_destroyed_enemy']}"; |
169 | 165 | |
170 | 166 | $result = CACHE_FLEET | CACHE_PLANET_DST; |
171 | - } |
|
172 | - else |
|
167 | + } else |
|
173 | 168 | { |
174 | 169 | $result = CACHE_FLEET; |
175 | 170 | } |
@@ -26,6 +26,10 @@ |
||
26 | 26 | return true; |
27 | 27 | } |
28 | 28 | |
29 | +/** |
|
30 | + * @param integer $mode |
|
31 | + * @param integer $mercenary_id |
|
32 | + */ |
|
29 | 33 | function mrc_mercenary_hire($mode, $user, $mercenary_id) { |
30 | 34 | global $config, $lang, $sn_powerup_buy_discounts; |
31 | 35 |
@@ -62,8 +62,8 @@ |
||
62 | 62 | if($mercenary_level) { |
63 | 63 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
64 | 64 | if(!$config->empire_mercenary_temporary && $mercenary_level_old) { |
65 | - $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
|
66 | - $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
|
65 | + $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
|
66 | + $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
|
67 | 67 | } |
68 | 68 | $darkmater_cost = ceil($darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] * $mercenary_period * $sn_powerup_buy_discounts[$mercenary_period] / $config->empire_mercenary_base_period); |
69 | 69 | } else { |
@@ -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; |
@@ -2,8 +2,7 @@ |
||
2 | 2 | |
3 | 3 | lng_include('mrc_mercenary'); |
4 | 4 | |
5 | -function mrc_officer_accessible(&$user, $mercenary_id) |
|
6 | -{ |
|
5 | +function mrc_officer_accessible(&$user, $mercenary_id) { |
|
7 | 6 | global $config; |
8 | 7 | |
9 | 8 | $mercenary_info = get_unit_param($mercenary_id); |
@@ -108,6 +108,9 @@ discard block |
||
108 | 108 | |
109 | 109 | // ------------------------------------------------------------------------------------------------ |
110 | 110 | // Заполняет данные по флоту |
111 | +/** |
|
112 | + * @param boolean $is_attacker |
|
113 | + */ |
|
111 | 114 | function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker){return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker));} |
112 | 115 | function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) |
113 | 116 | { |
@@ -331,6 +334,9 @@ discard block |
||
331 | 334 | |
332 | 335 | // ------------------------------------------------------------------------------------------------ |
333 | 336 | // Вычисление дополнительной информации для расчета раунда |
337 | +/** |
|
338 | + * @param integer $round |
|
339 | + */ |
|
334 | 340 | function sn_ube_combat_round_prepare(&$combat_data, $round) |
335 | 341 | { |
336 | 342 | global $ube_combat_bonus_list; |
@@ -393,6 +399,9 @@ discard block |
||
393 | 399 | |
394 | 400 | // ------------------------------------------------------------------------------------------------ |
395 | 401 | // Рассчитывает результат столкновения флотов ака раунд |
402 | +/** |
|
403 | + * @param integer $round |
|
404 | + */ |
|
396 | 405 | function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round) |
397 | 406 | { |
398 | 407 | if(BE_DEBUG === true) |
@@ -510,6 +519,9 @@ discard block |
||
510 | 519 | } |
511 | 520 | } |
512 | 521 | |
522 | +/** |
|
523 | + * @param double $amplified_damage |
|
524 | + */ |
|
513 | 525 | function sn_ube_combat_round_crossfire_unit_damage_current(&$defend_fleet_data, $defend_unit_id, &$amplified_damage, &$units_lost, &$units_boomed, &$combat_options) |
514 | 526 | { |
515 | 527 | $unit_is_lost = false; |
@@ -632,6 +644,9 @@ discard block |
||
632 | 644 | |
633 | 645 | // ------------------------------------------------------------------------------------------------ |
634 | 646 | // Анализирует результаты раунда и генерирует данные для следующего раунда |
647 | +/** |
|
648 | + * @param integer $round |
|
649 | + */ |
|
635 | 650 | function sn_ube_combat_round_analyze(&$combat_data, $round) |
636 | 651 | { |
637 | 652 | $round_data = &$combat_data[UBE_ROUNDS][$round]; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | */ |
53 | 53 | |
54 | -if(BE_DEBUG === true) |
|
54 | +if (BE_DEBUG === true) |
|
55 | 55 | { |
56 | 56 | require_once('ube_zi_helpers.php'); |
57 | 57 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | global $ube_convert_techs; |
85 | 85 | |
86 | - if(!isset($combat_data[UBE_PLAYERS][$player_id])) |
|
86 | + if (!isset($combat_data[UBE_PLAYERS][$player_id])) |
|
87 | 87 | { |
88 | 88 | $combat_data[UBE_PLAYERS][$player_id] = array(UBE_ATTACKER => $is_attacker); |
89 | 89 | $player_info = &$combat_data[UBE_PLAYERS][$player_id]; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $player_info[UBE_PLAYER_DATA] = $player_data; |
96 | 96 | |
97 | 97 | $admiral_bonus = mrc_get_level($player_data, false, MRC_ADMIRAL) * get_unit_param(MRC_ADMIRAL, P_BONUS_VALUE) / 100; |
98 | - foreach($ube_convert_techs as $unit_id => $ube_id) |
|
98 | + foreach ($ube_convert_techs as $unit_id => $ube_id) |
|
99 | 99 | { |
100 | 100 | $player_info[UBE_BONUSES][$ube_id] += mrc_get_level($player_data, false, $unit_id) * get_unit_param($unit_id, P_BONUS_VALUE) / 100 + $admiral_bonus; |
101 | 101 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | // ------------------------------------------------------------------------------------------------ |
110 | 110 | // Заполняет данные по флоту |
111 | -function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker){return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker));} |
|
111 | +function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) {return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker)); } |
|
112 | 112 | function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) |
113 | 113 | { |
114 | 114 | $fleet_owner_id = $fleet['fleet_owner']; |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | $combat_data[UBE_FLEETS][$fleet_id][UBE_OWNER] = $fleet_owner_id; |
122 | 122 | $fleet_info = &$combat_data[UBE_FLEETS][$fleet_id]; |
123 | 123 | $fleet_info[UBE_FLEET_GROUP] = $fleet['fleet_group']; |
124 | - foreach($fleet_data as $unit_id => $unit_count) |
|
124 | + foreach ($fleet_data as $unit_id => $unit_count) |
|
125 | 125 | { |
126 | - if(!$unit_count) |
|
126 | + if (!$unit_count) |
|
127 | 127 | { |
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
132 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) |
|
132 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) |
|
133 | 133 | { |
134 | 134 | $fleet_info[UBE_COUNT][$unit_id] = $unit_count; |
135 | 135 | } |
@@ -169,23 +169,23 @@ discard block |
||
169 | 169 | $combat_data[UBE_FLEETS][0] = array(UBE_OWNER => $player_id); |
170 | 170 | $fleet_info = &$combat_data[UBE_FLEETS][0]; |
171 | 171 | |
172 | - foreach(sn_get_groups('combat') as $unit_id) |
|
172 | + foreach (sn_get_groups('combat') as $unit_id) |
|
173 | 173 | { |
174 | - if($unit_count = mrc_get_level($player, $planet, $unit_id)) |
|
174 | + if ($unit_count = mrc_get_level($player, $planet, $unit_id)) |
|
175 | 175 | { |
176 | 176 | $fleet_info[UBE_COUNT][$unit_id] = $unit_count; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - foreach(sn_get_groups('resources_loot') as $resource_id) |
|
180 | + foreach (sn_get_groups('resources_loot') as $resource_id) |
|
181 | 181 | { |
182 | 182 | $fleet_info[UBE_RESOURCES][$resource_id] = floor(mrc_get_level($player, $planet, $resource_id)); |
183 | 183 | } |
184 | 184 | |
185 | - if($fortifier_level = mrc_get_level($player, $planet, MRC_FORTIFIER)) |
|
185 | + if ($fortifier_level = mrc_get_level($player, $planet, MRC_FORTIFIER)) |
|
186 | 186 | { |
187 | 187 | $fortifier_bonus = $fortifier_level * get_unit_param(MRC_FORTIFIER, P_BONUS_VALUE) / 100; |
188 | - foreach($ube_combat_bonus_list as $ube_id) |
|
188 | + foreach ($ube_combat_bonus_list as $ube_id) |
|
189 | 189 | { |
190 | 190 | $fleet_info[UBE_BONUSES][$ube_id] += $fortifier_bonus; |
191 | 191 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | PLANET_SIZE => $planet['diameter'], |
202 | 202 | ); |
203 | 203 | |
204 | - $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE] = $player['onlinetime'] >= $combat_data[UBE_TIME] - 60*60*24*7; |
|
204 | + $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE] = $player['onlinetime'] >= $combat_data[UBE_TIME] - 60 * 60 * 24 * 7; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | // ube_attack_prepare_fleet($combat_data, $fleet, false); |
242 | 242 | // } |
243 | 243 | $fleet_list_on_hold = fleet_list_on_hold($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $fleet_row['fleet_end_type'], $ube_time); |
244 | - foreach($fleet_list_on_hold as $fleet) { |
|
244 | + foreach ($fleet_list_on_hold as $fleet) { |
|
245 | 245 | ube_attack_prepare_fleet($combat_data, $fleet, false); |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Готовим инфу по атакующим |
249 | - if($fleet_row['fleet_group']) |
|
249 | + if ($fleet_row['fleet_group']) |
|
250 | 250 | { |
251 | 251 | // $fleets = doquery("SELECT * FROM {{fleets}} WHERE fleet_group = {$fleet_row['fleet_group']} FOR UPDATE"); |
252 | 252 | // while($fleet = db_fetch($fleets)) |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | // ube_attack_prepare_fleet($combat_data, $fleet, true); |
255 | 255 | // } |
256 | 256 | $acs_fleet_list = fleet_list_by_group($fleet_row['fleet_group']); |
257 | - foreach($acs_fleet_list as $fleet) { |
|
257 | + foreach ($acs_fleet_list as $fleet) { |
|
258 | 258 | ube_attack_prepare_fleet($combat_data, $fleet, true); |
259 | 259 | } |
260 | 260 | } |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | |
280 | 280 | // Готовим информацию для первого раунда - проводим все нужные вычисления из исходных данных |
281 | 281 | $first_round_data = array(); |
282 | - foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
282 | + foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
283 | 283 | { |
284 | 284 | $fleet_info[UBE_COUNT] = is_array($fleet_info[UBE_COUNT]) ? $fleet_info[UBE_COUNT] : array(); |
285 | 285 | $player_data = &$combat_data[UBE_PLAYERS][$fleet_info[UBE_OWNER]]; |
286 | 286 | $fleet_info[UBE_FLEET_TYPE] = $player_data[UBE_ATTACKER] ? UBE_ATTACKERS : UBE_DEFENDERS; |
287 | 287 | |
288 | - foreach($ube_combat_bonus_list as $bonus_id => $bonus_value) |
|
288 | + foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value) |
|
289 | 289 | { |
290 | 290 | // Вычисляем бонус игрока |
291 | 291 | $bonus_value = isset($player_data[UBE_BONUSES][$bonus_id]) ? $player_data[UBE_BONUSES][$bonus_id] : 0; |
@@ -294,16 +294,16 @@ discard block |
||
294 | 294 | } |
295 | 295 | |
296 | 296 | $first_round_data[$fleet_id][UBE_COUNT] = $fleet_info[UBE_PRICE] = array(); |
297 | - foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
297 | + foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
298 | 298 | { |
299 | - if($unit_count <= 0) |
|
299 | + if ($unit_count <= 0) |
|
300 | 300 | { |
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
304 | 304 | $unit_info = get_unit_param($unit_id); |
305 | 305 | // Заполняем информацию о кораблях в информации флота |
306 | - foreach($ube_combat_bonus_list as $bonus_id => $bonus_value) |
|
306 | + foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value) |
|
307 | 307 | { |
308 | 308 | $fleet_info[$bonus_id][$unit_id] = floor($unit_info[$ube_convert_to_techs[$bonus_id]] * (1 + $fleet_info[UBE_BONUSES][$bonus_id])); |
309 | 309 | } |
@@ -346,16 +346,16 @@ discard block |
||
346 | 346 | $is_simulator = $combat_data[UBE_OPTIONS][UBE_SIMULATOR]; |
347 | 347 | |
348 | 348 | $round_data = &$combat_data[UBE_ROUNDS][$round]; |
349 | - foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
349 | + foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
350 | 350 | { |
351 | 351 | // Кэшируем переменные для легкого доступа к подмассивам |
352 | 352 | $fleet_info = &$combat_data[UBE_FLEETS][$fleet_id]; |
353 | 353 | $fleet_data[UBE_FLEET_INFO] = &$fleet_info; |
354 | 354 | $fleet_type = $fleet_info[UBE_FLEET_TYPE]; |
355 | 355 | |
356 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
356 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
357 | 357 | { |
358 | - if($unit_count <= 0) |
|
358 | + if ($unit_count <= 0) |
|
359 | 359 | { |
360 | 360 | continue; |
361 | 361 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | // Для не-симулятора - рандомизируем каждый раунд значения атаки и щитов |
366 | 366 | $fleet_data[UBE_ATTACK_BASE][$unit_id] = floor($fleet_info[UBE_ATTACK][$unit_id] * ($is_simulator ? 1 : mt_rand(80, 120) / 100)); |
367 | 367 | $fleet_data[UBE_SHIELD_BASE][$unit_id] = floor($fleet_info[UBE_SHIELD][$unit_id] * ($is_simulator ? 1 : mt_rand(80, 120) / 100)); |
368 | - $fleet_data[UBE_ARMOR_BASE][$unit_id] = floor($fleet_info[UBE_ARMOR][$unit_id]);// * ($is_simulator ? 1 : mt_rand(80, 120) / 100)); |
|
368 | + $fleet_data[UBE_ARMOR_BASE][$unit_id] = floor($fleet_info[UBE_ARMOR][$unit_id]); // * ($is_simulator ? 1 : mt_rand(80, 120) / 100)); |
|
369 | 369 | |
370 | 370 | $fleet_data[UBE_ATTACK][$unit_id] = $fleet_data[UBE_ATTACK_BASE][$unit_id] * $unit_count; |
371 | 371 | $fleet_data[UBE_SHIELD][$unit_id] = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $unit_count; |
@@ -375,24 +375,24 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | // Суммируем данные по флоту |
378 | - foreach($ube_combat_bonus_list as $bonus_id) |
|
378 | + foreach ($ube_combat_bonus_list as $bonus_id) |
|
379 | 379 | { |
380 | 380 | $round_data[$fleet_type][$bonus_id][$fleet_id] += is_array($fleet_data[$bonus_id]) ? array_sum($fleet_data[$bonus_id]) : 0; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | 384 | // Суммируем данные по атакующим и защитникам |
385 | - foreach($ube_combat_bonus_list as $bonus_id) |
|
385 | + foreach ($ube_combat_bonus_list as $bonus_id) |
|
386 | 386 | { |
387 | 387 | $round_data[UBE_TOTAL][UBE_DEFENDERS][$bonus_id] = array_sum($round_data[UBE_DEFENDERS][$bonus_id]); |
388 | 388 | $round_data[UBE_TOTAL][UBE_ATTACKERS][$bonus_id] = array_sum($round_data[UBE_ATTACKERS][$bonus_id]); |
389 | 389 | } |
390 | 390 | |
391 | 391 | // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще |
392 | - foreach($round_data[UBE_FLEETS] as &$fleet_data) |
|
392 | + foreach ($round_data[UBE_FLEETS] as &$fleet_data) |
|
393 | 393 | { |
394 | 394 | $fleet_type = $fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE]; |
395 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
395 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
396 | 396 | { |
397 | 397 | $fleet_data[UBE_DAMAGE_PERCENT][$unit_id] = $fleet_data[UBE_ARMOR][$unit_id] / $round_data[UBE_TOTAL][$fleet_type][UBE_ARMOR]; |
398 | 398 | } |
@@ -403,24 +403,24 @@ discard block |
||
403 | 403 | // Рассчитывает результат столкновения флотов ака раунд |
404 | 404 | function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round) |
405 | 405 | { |
406 | - if(BE_DEBUG === true) |
|
406 | + if (BE_DEBUG === true) |
|
407 | 407 | { |
408 | 408 | // sn_ube_combat_helper_round_header($round); |
409 | 409 | } |
410 | 410 | |
411 | 411 | $round_data = &$combat_data[UBE_ROUNDS][$round]; |
412 | 412 | // Проводим бой. Сталкиваем каждый корабль атакующего с каждым кораблем атакуемого |
413 | - foreach($round_data[UBE_ATTACKERS][UBE_ATTACK] as $attack_fleet_id => $temp) |
|
413 | + foreach ($round_data[UBE_ATTACKERS][UBE_ATTACK] as $attack_fleet_id => $temp) |
|
414 | 414 | { |
415 | 415 | $attack_fleet_data = &$round_data[UBE_FLEETS][$attack_fleet_id]; |
416 | - foreach($round_data[UBE_DEFENDERS][UBE_ATTACK] as $defend_fleet_id => $temp2) |
|
416 | + foreach ($round_data[UBE_DEFENDERS][UBE_ATTACK] as $defend_fleet_id => $temp2) |
|
417 | 417 | { |
418 | 418 | $defend_fleet_data = &$round_data[UBE_FLEETS][$defend_fleet_id]; |
419 | 419 | |
420 | - foreach($attack_fleet_data[UBE_COUNT] as $attack_unit_id => $attack_unit_count) |
|
420 | + foreach ($attack_fleet_data[UBE_COUNT] as $attack_unit_id => $attack_unit_count) |
|
421 | 421 | { |
422 | 422 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
423 | - foreach($defend_fleet_data[UBE_COUNT] as $defend_unit_id => $defend_unit_count) |
|
423 | + foreach ($defend_fleet_data[UBE_COUNT] as $defend_unit_id => $defend_unit_count) |
|
424 | 424 | { |
425 | 425 | sn_ube_combat_round_crossfire_unit2($attack_fleet_data, $defend_fleet_data, $attack_unit_id, $defend_unit_id, $combat_data[UBE_OPTIONS]); |
426 | 426 | sn_ube_combat_round_crossfire_unit2($defend_fleet_data, $attack_fleet_data, $defend_unit_id, $attack_unit_id, $combat_data[UBE_OPTIONS]); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - if(BE_DEBUG === true) |
|
432 | + if (BE_DEBUG === true) |
|
433 | 433 | { |
434 | 434 | // sn_ube_combat_helper_round_footer(); |
435 | 435 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $boom = 0; |
478 | 478 | $boom_limit = 75; |
479 | 479 | $random = $combat_options[UBE_SIMULATOR] ? $boom_limit / 2 : mt_rand(0, 100); |
480 | - if($armor_damage && $units_left > 0 && $last_unit_percent <= $boom_limit && $last_unit_percent <= $random) |
|
480 | + if ($armor_damage && $units_left > 0 && $last_unit_percent <= $boom_limit && $last_unit_percent <= $random) |
|
481 | 481 | { |
482 | 482 | $boom = 1; |
483 | 483 | $units_left--; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | |
488 | 488 | $defend_fleet_data[UBE_COUNT][$defend_unit_id] = $units_left; |
489 | 489 | |
490 | - if(BE_DEBUG === true) |
|
490 | + if (BE_DEBUG === true) |
|
491 | 491 | { |
492 | 492 | $debug_unit_crossfire_result = array( |
493 | 493 | 'attack_unit_id' => $attack_unit_id, |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | $units_lost = $units_lost ? $units_lost : 0; |
527 | 527 | |
528 | 528 | $boom_limit = 75; // Взрываемся на 75% прочности |
529 | - if($defend_fleet_data[UBE_COUNT][$defend_unit_id] > 0 && $amplified_damage) |
|
529 | + if ($defend_fleet_data[UBE_COUNT][$defend_unit_id] > 0 && $amplified_damage) |
|
530 | 530 | { |
531 | 531 | // $defend_fleet_info = &$defend_fleet_data[UBE_FLEET_INFO]; |
532 | 532 | |
@@ -539,18 +539,18 @@ discard block |
||
539 | 539 | $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] -= $damage_to_armor; |
540 | 540 | |
541 | 541 | // Если брони не осталось - юнит потерян |
542 | - if($defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] <= 0) |
|
542 | + if ($defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] <= 0) |
|
543 | 543 | { |
544 | 544 | $unit_is_lost = true; |
545 | 545 | } |
546 | 546 | // Если броня осталось, но не осталось щитов - прошел дамадж по броне и надо проверить - не взорвался ли корабль |
547 | - elseif($defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] <= 0) |
|
547 | + elseif ($defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] <= 0) |
|
548 | 548 | { |
549 | 549 | $last_unit_hp = $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id]; |
550 | 550 | $last_unit_percent = $last_unit_hp / $defend_fleet_data[UBE_ARMOR_BASE][$defend_unit_id] * 100; |
551 | 551 | |
552 | 552 | $random = $combat_options[UBE_SIMULATOR] ? $boom_limit / 2 : mt_rand(0, 100); |
553 | - if($last_unit_percent <= $boom_limit && $last_unit_percent <= $random) |
|
553 | + if ($last_unit_percent <= $boom_limit && $last_unit_percent <= $random) |
|
554 | 554 | { |
555 | 555 | $unit_is_lost = true; |
556 | 556 | $units_boomed++; |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | $defend_fleet_data[UBE_ARMOR][$defend_unit_id] -= $damage_to_armor; |
564 | 564 | $defend_fleet_data[UBE_SHIELD][$defend_unit_id] -= $damage_to_shield; |
565 | 565 | |
566 | - if($unit_is_lost) |
|
566 | + if ($unit_is_lost) |
|
567 | 567 | { |
568 | 568 | $units_lost++; |
569 | 569 | $defend_fleet_data[UBE_COUNT][$defend_unit_id]--; |
570 | - if($defend_fleet_data[UBE_COUNT][$defend_unit_id]) |
|
570 | + if ($defend_fleet_data[UBE_COUNT][$defend_unit_id]) |
|
571 | 571 | { |
572 | 572 | $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] = $defend_fleet_data[UBE_ARMOR_BASE][$defend_unit_id]; |
573 | 573 | $defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] = $defend_fleet_data[UBE_SHIELD_BASE][$defend_unit_id]; |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | // Рассчитывает результат столкновения двух юнитов ака ход |
583 | 583 | function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) |
584 | 584 | { |
585 | - if($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0) |
|
585 | + if ($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0) |
|
586 | 586 | { |
587 | 587 | return; |
588 | 588 | } |
@@ -625,16 +625,16 @@ discard block |
||
625 | 625 | |
626 | 626 | $outcome = array(); |
627 | 627 | $next_round_fleet = array(); |
628 | - foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
628 | + foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
629 | 629 | { |
630 | - if(array_sum($fleet_data[UBE_COUNT]) <= 0) |
|
630 | + if (array_sum($fleet_data[UBE_COUNT]) <= 0) |
|
631 | 631 | { |
632 | 632 | continue; |
633 | 633 | } |
634 | 634 | |
635 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
635 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
636 | 636 | { |
637 | - if($unit_count <= 0) |
|
637 | + if ($unit_count <= 0) |
|
638 | 638 | { |
639 | 639 | continue; |
640 | 640 | } |
@@ -646,17 +646,17 @@ discard block |
||
646 | 646 | } |
647 | 647 | |
648 | 648 | // Проверяем - если кого-то не осталось или не осталось обоих - заканчиваем цикл |
649 | - if(count($outcome) == 0 || $round == 10) |
|
649 | + if (count($outcome) == 0 || $round == 10) |
|
650 | 650 | { |
651 | 651 | $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW_END; |
652 | 652 | } |
653 | - elseif(count($outcome) == 1) |
|
653 | + elseif (count($outcome) == 1) |
|
654 | 654 | { |
655 | 655 | $round_data[UBE_OUTCOME] = isset($outcome[UBE_ATTACKERS]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS; |
656 | 656 | } |
657 | - elseif(count($outcome) == 2) |
|
657 | + elseif (count($outcome) == 2) |
|
658 | 658 | { |
659 | - if($round < 10) |
|
659 | + if ($round < 10) |
|
660 | 660 | { |
661 | 661 | $combat_data[UBE_ROUNDS][$round + 1][UBE_FLEETS] = $next_round_fleet; |
662 | 662 | } |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | $start = microtime(true); |
675 | 675 | sn_ube_combat_prepare_first_round($combat_data); |
676 | 676 | |
677 | - for($round = 1; $round <= 10; $round++) |
|
677 | + for ($round = 1; $round <= 10; $round++) |
|
678 | 678 | { |
679 | 679 | // Готовим данные для раунда |
680 | 680 | sn_ube_combat_round_prepare($combat_data, $round); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | sn_ube_combat_round_crossfire_fleet($combat_data, $round); |
684 | 684 | |
685 | 685 | // Анализируем итоги текущего раунда и готовим данные для следующего |
686 | - if(sn_ube_combat_round_analyze($combat_data, $round) != UBE_COMBAT_RESULT_DRAW) |
|
686 | + if (sn_ube_combat_round_analyze($combat_data, $round) != UBE_COMBAT_RESULT_DRAW) |
|
687 | 687 | { |
688 | 688 | break; |
689 | 689 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | $combat_data[UBE_OPTIONS][UBE_EXCHANGE] = array(RES_METAL => $config->rpg_exchange_metal); |
705 | 705 | |
706 | 706 | $exchange = &$combat_data[UBE_OPTIONS][UBE_EXCHANGE]; |
707 | - foreach(array(RES_CRYSTAL => 'rpg_exchange_crystal', RES_DEUTERIUM => 'rpg_exchange_deuterium', RES_DARK_MATTER => 'rpg_exchange_darkMatter') as $resource_id => $resource_name) |
|
707 | + foreach (array(RES_CRYSTAL => 'rpg_exchange_crystal', RES_DEUTERIUM => 'rpg_exchange_deuterium', RES_DARK_MATTER => 'rpg_exchange_darkMatter') as $resource_id => $resource_name) |
|
708 | 708 | { |
709 | 709 | $exchange[$resource_id] = $config->$resource_name * $exchange[RES_METAL]; |
710 | 710 | } |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $outcome[UBE_DEBRIS] = array(); |
719 | 719 | |
720 | 720 | // Генерируем результат боя |
721 | - foreach($fleets_info as $fleet_id => &$fleet_info) |
|
721 | + foreach ($fleets_info as $fleet_id => &$fleet_info) |
|
722 | 722 | { |
723 | 723 | $fleet_type = $fleet_info[UBE_FLEET_TYPE]; |
724 | 724 | // Инициализируем массив результатов для флота |
@@ -729,32 +729,32 @@ discard block |
||
729 | 729 | $fleet_outcome = &$outcome[UBE_FLEETS][$fleet_id]; |
730 | 730 | $fleet_data = &$last_round_data[UBE_FLEETS][$fleet_id]; |
731 | 731 | |
732 | - foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
732 | + foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
733 | 733 | { |
734 | 734 | // Вычисляем сколько юнитов осталось и сколько потеряно |
735 | 735 | $units_left = $fleet_data[UBE_COUNT][$unit_id]; |
736 | 736 | |
737 | 737 | // Восстановление обороны - 75% от уничтоженной |
738 | - if($fleet_info[UBE_TYPE][$unit_id] == UNIT_DEFENCE) |
|
738 | + if ($fleet_info[UBE_TYPE][$unit_id] == UNIT_DEFENCE) |
|
739 | 739 | { |
740 | 740 | $giveback_chance = 75; // TODO Configure |
741 | 741 | $units_lost = $unit_count - $units_left; |
742 | - if($combat_data[UBE_OPTIONS][UBE_SIMULATOR]) |
|
742 | + if ($combat_data[UBE_OPTIONS][UBE_SIMULATOR]) |
|
743 | 743 | { // for simulation just return 75% of loss |
744 | 744 | $units_giveback = round($units_lost * $giveback_chance / 100); |
745 | 745 | } |
746 | 746 | else |
747 | 747 | { |
748 | - if($unit_count > 10) |
|
748 | + if ($unit_count > 10) |
|
749 | 749 | { // if there were more then 10 defense elements - mass-calculating giveback |
750 | 750 | $units_giveback = round($units_lost * mt_rand($giveback_chance * 0.8, $giveback_chance * 1.2) / 100); |
751 | 751 | } |
752 | 752 | else |
753 | 753 | { //if there were less then 10 defense elements - calculating giveback per element |
754 | 754 | $units_giveback = 0; |
755 | - for($i = 1; $i <= $units_lost; $i++) |
|
755 | + for ($i = 1; $i <= $units_lost; $i++) |
|
756 | 756 | { |
757 | - if(mt_rand(1,100) <= $giveback_chance) |
|
757 | + if (mt_rand(1, 100) <= $giveback_chance) |
|
758 | 758 | { |
759 | 759 | $units_giveback++; |
760 | 760 | } |
@@ -773,13 +773,13 @@ discard block |
||
773 | 773 | $outcome[$fleet_type][UBE_CAPACITY][$fleet_id] += $fleet_info[UBE_CAPACITY][$unit_id] * $units_left; |
774 | 774 | |
775 | 775 | // Вычисляем потери в ресурсах |
776 | - if($units_lost) |
|
776 | + if ($units_lost) |
|
777 | 777 | { |
778 | 778 | $fleet_outcome[UBE_UNITS_LOST][$unit_id] = $units_lost; |
779 | 779 | |
780 | - foreach($fleet_info[UBE_PRICE] as $resource_id => $unit_prices) |
|
780 | + foreach ($fleet_info[UBE_PRICE] as $resource_id => $unit_prices) |
|
781 | 781 | { |
782 | - if(!$unit_prices[$unit_id]) |
|
782 | + if (!$unit_prices[$unit_id]) |
|
783 | 783 | { |
784 | 784 | continue; |
785 | 785 | } |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | $fleet_outcome[UBE_RESOURCES_LOST][$resource_id] += $resources_lost; |
790 | 790 | |
791 | 791 | // Если это корабль - прибавляем потери к обломкам на орбите |
792 | - if($fleet_info[UBE_TYPE][$unit_id] == UNIT_SHIPS) |
|
792 | + if ($fleet_info[UBE_TYPE][$unit_id] == UNIT_SHIPS) |
|
793 | 793 | { |
794 | 794 | $outcome[UBE_DEBRIS][$resource_id] += floor($resources_lost * ($combat_data[UBE_OPTIONS][UBE_SIMULATOR] ? 30 : mt_rand(20, 40)) / 100); // TODO: Configurize |
795 | 795 | } |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | } |
803 | 803 | |
804 | 804 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
805 | - if($fleet_id == 0) |
|
805 | + if ($fleet_id == 0) |
|
806 | 806 | { |
807 | 807 | continue; |
808 | 808 | } |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | // Количество ресурсов флота |
811 | 811 | $fleet_total_resources = empty($fleet_info[UBE_RESOURCES]) ? 0 : array_sum($fleet_info[UBE_RESOURCES]); |
812 | 812 | // Если на борту нет ресурсов - зачем нам все это? |
813 | - if($fleet_total_resources == 0) |
|
813 | + if ($fleet_total_resources == 0) |
|
814 | 814 | { |
815 | 815 | continue; |
816 | 816 | } |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | // Емкость трюмов флота |
819 | 819 | $fleet_capacity = $outcome[$fleet_type][UBE_CAPACITY][$fleet_id]; |
820 | 820 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
821 | - if($fleet_capacity < $fleet_total_resources) |
|
821 | + if ($fleet_capacity < $fleet_total_resources) |
|
822 | 822 | { |
823 | 823 | $left_percent = $fleet_capacity / $fleet_total_resources; // Сколько ресурсов будет оставлено |
824 | - foreach($fleet_info[UBE_RESOURCES] as $resource_id => $resource_amount) |
|
824 | + foreach ($fleet_info[UBE_RESOURCES] as $resource_id => $resource_amount) |
|
825 | 825 | { |
826 | 826 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
827 | - if(!$resource_amount) |
|
827 | + if (!$resource_amount) |
|
828 | 828 | { |
829 | 829 | continue; |
830 | 830 | } |
@@ -847,9 +847,9 @@ discard block |
||
847 | 847 | // SFR - Small Fleet Reconnaissance ака РМФ |
848 | 848 | $outcome[UBE_SFR] = count($combat_data[UBE_ROUNDS]) == 2 && $outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_LOSS; |
849 | 849 | |
850 | - if(!$combat_data[UBE_OPTIONS][UBE_LOADED]) |
|
850 | + if (!$combat_data[UBE_OPTIONS][UBE_LOADED]) |
|
851 | 851 | { |
852 | - if($combat_data[UBE_OPTIONS][UBE_MOON_WAS]) |
|
852 | + if ($combat_data[UBE_OPTIONS][UBE_MOON_WAS]) |
|
853 | 853 | { |
854 | 854 | $outcome[UBE_MOON] = UBE_MOON_WAS; |
855 | 855 | } |
@@ -859,10 +859,10 @@ discard block |
||
859 | 859 | } |
860 | 860 | |
861 | 861 | // Лутаем ресурсы - если аттакер выиграл |
862 | - if($outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN) |
|
862 | + if ($outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN) |
|
863 | 863 | { |
864 | 864 | sn_ube_combat_analyze_loot($combat_data); |
865 | - if($combat_data[UBE_OPTIONS][UBE_MOON_WAS] && $combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY) |
|
865 | + if ($combat_data[UBE_OPTIONS][UBE_MOON_WAS] && $combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY) |
|
866 | 866 | { |
867 | 867 | sn_ube_combat_analyze_moon_destroy($combat_data); |
868 | 868 | } |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | $planet_looted_in_metal = 0; |
882 | 882 | $planet_resource_looted = array(); |
883 | 883 | $planet_resource_total = is_array($planet_resource_list) ? array_sum($planet_resource_list) : 0; |
884 | - if($planet_resource_total && ($total_capacity = array_sum($outcome[UBE_ATTACKERS][UBE_CAPACITY]))) |
|
884 | + if ($planet_resource_total && ($total_capacity = array_sum($outcome[UBE_ATTACKERS][UBE_CAPACITY]))) |
|
885 | 885 | { |
886 | 886 | // Можно вывести только половину ресурсов, но не больше, чем общая вместимость флотов атакующих |
887 | 887 | $planet_lootable = min($planet_resource_total / 2, $total_capacity); |
@@ -892,11 +892,11 @@ discard block |
||
892 | 892 | $total_lootable = min($planet_lootable, $total_capacity); |
893 | 893 | |
894 | 894 | // Вычисляем сколько ресурсов вывезено |
895 | - foreach($outcome[UBE_ATTACKERS][UBE_CAPACITY] as $fleet_id => $fleet_capacity) |
|
895 | + foreach ($outcome[UBE_ATTACKERS][UBE_CAPACITY] as $fleet_id => $fleet_capacity) |
|
896 | 896 | { |
897 | 897 | $looted_in_metal = 0; |
898 | 898 | $fleet_loot_data = array(); |
899 | - foreach($planet_resource_list as $resource_id => $resource_amount) |
|
899 | + foreach ($planet_resource_list as $resource_id => $resource_amount) |
|
900 | 900 | { |
901 | 901 | // TODO Восстанавливаем ошибку округления - придумать нормальный алгоритм - вроде round() должно быть достаточно. Проверить |
902 | 902 | $fleet_lootable_percent = $fleet_capacity / $total_capacity; |
@@ -919,25 +919,25 @@ discard block |
||
919 | 919 | function sn_ube_combat_analyze_moon(&$outcome, $is_simulator) |
920 | 920 | { |
921 | 921 | $outcome[UBE_DEBRIS_TOTAL] = 0; |
922 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array |
|
922 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array |
|
923 | 923 | { |
924 | 924 | $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id]; |
925 | 925 | } |
926 | 926 | |
927 | - if($outcome[UBE_DEBRIS_TOTAL]) |
|
927 | + if ($outcome[UBE_DEBRIS_TOTAL]) |
|
928 | 928 | { |
929 | 929 | // TODO uni_calculate_moon_chance |
930 | 930 | $moon_chance = min($outcome[UBE_DEBRIS_TOTAL] / 1000000, 30); // TODO Configure |
931 | 931 | $moon_chance = $moon_chance >= 1 ? $moon_chance : 0; |
932 | 932 | $outcome[UBE_MOON_CHANCE] = $moon_chance; |
933 | - if($moon_chance) |
|
933 | + if ($moon_chance) |
|
934 | 934 | { |
935 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) |
|
935 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) |
|
936 | 936 | { |
937 | 937 | $outcome[UBE_MOON_SIZE] = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
938 | 938 | $outcome[UBE_MOON] = UBE_MOON_CREATE_SUCCESS; |
939 | 939 | |
940 | - if($outcome[UBE_DEBRIS_TOTAL] <= 30000000) |
|
940 | + if ($outcome[UBE_DEBRIS_TOTAL] <= 30000000) |
|
941 | 941 | { |
942 | 942 | $outcome[UBE_DEBRIS_TOTAL] = 0; |
943 | 943 | $outcome[UBE_DEBRIS] = array(); |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | $moon_debris_left_percent = ($outcome[UBE_DEBRIS_TOTAL] - $moon_debris_spent) / $outcome[UBE_DEBRIS_TOTAL]; |
949 | 949 | |
950 | 950 | $outcome[UBE_DEBRIS_TOTAL] = 0; |
951 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array |
|
951 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array |
|
952 | 952 | { |
953 | 953 | $outcome[UBE_DEBRIS][$resource_id] = floor($outcome[UBE_DEBRIS][$resource_id] * $moon_debris_left_percent); |
954 | 954 | $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id]; |
@@ -972,11 +972,11 @@ discard block |
||
972 | 972 | { |
973 | 973 | // TODO: $is_simulator |
974 | 974 | $reapers = 0; |
975 | - foreach($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS])-1][UBE_FLEETS] as $fleet_data) |
|
975 | + foreach ($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS]) - 1][UBE_FLEETS] as $fleet_data) |
|
976 | 976 | { |
977 | - if($fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE] == UBE_ATTACKERS) |
|
977 | + if ($fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE] == UBE_ATTACKERS) |
|
978 | 978 | { |
979 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
979 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
980 | 980 | { |
981 | 981 | // TODO: Работа по группам - группа "Уничтожители лун" |
982 | 982 | $reapers += ($unit_id == SHIP_HUGE_DEATH_STAR) ? $unit_count : 0; |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | } |
986 | 986 | |
987 | 987 | $moon_size = $combat_data[UBE_OUTCOME][UBE_PLANET][PLANET_SIZE]; |
988 | - if($reapers) |
|
988 | + if ($reapers) |
|
989 | 989 | { |
990 | 990 | $random = mt_rand(1, 100); |
991 | 991 | $combat_data[UBE_OUTCOME][UBE_MOON_DESTROY_CHANCE] = max(1, min(99, round((100 - sqrt($moon_size)) * sqrt($reapers)))); |
@@ -1019,38 +1019,37 @@ discard block |
||
1019 | 1019 | $planet_info[PLANET_SYSTEM], |
1020 | 1020 | $planet_info[PLANET_PLANET], |
1021 | 1021 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
1022 | - $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
1023 | - ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss') |
|
1022 | + $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss') |
|
1024 | 1023 | ] |
1025 | 1024 | ); |
1026 | 1025 | |
1027 | 1026 | $text_defender = ''; |
1028 | - foreach($outcome[UBE_DEBRIS] as $resource_id => $resource_amount) |
|
1027 | + foreach ($outcome[UBE_DEBRIS] as $resource_id => $resource_amount) |
|
1029 | 1028 | { |
1030 | - if($resource_id == RES_DEUTERIUM) |
|
1029 | + if ($resource_id == RES_DEUTERIUM) |
|
1031 | 1030 | { |
1032 | 1031 | continue; |
1033 | 1032 | } |
1034 | 1033 | |
1035 | 1034 | $text_defender .= "{$lang['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />'; |
1036 | 1035 | } |
1037 | - if($text_defender) |
|
1036 | + if ($text_defender) |
|
1038 | 1037 | { |
1039 | 1038 | $text_defender = "{$lang['ube_report_msg_body_debris']}{$text_defender}<br />"; |
1040 | 1039 | } |
1041 | 1040 | |
1042 | - if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS) |
|
1041 | + if ($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS) |
|
1043 | 1042 | { |
1044 | 1043 | $text_defender .= "{$lang['ube_report_moon_created']} {$outcome[UBE_MOON_SIZE]} {$lang['sys_kilometers_short']}<br /><br />"; |
1045 | 1044 | } |
1046 | - elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED) |
|
1045 | + elseif ($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED) |
|
1047 | 1046 | { |
1048 | 1047 | $text_defender .= "{$lang['ube_report_moon_chance']} {$outcome[UBE_MOON_CHANCE]}%<br /><br />"; |
1049 | 1048 | } |
1050 | 1049 | |
1051 | - if($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY) |
|
1050 | + if ($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY) |
|
1052 | 1051 | { |
1053 | - if($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE) |
|
1052 | + if ($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE) |
|
1054 | 1053 | { |
1055 | 1054 | $text_defender .= $lang['ube_report_moon_reapers_none']; |
1056 | 1055 | } |
@@ -1068,7 +1067,7 @@ discard block |
||
1068 | 1067 | $text_defender .= "{$lang['ube_report_info_link']}: <a href=\"index.php?page=battle_report&cypher={$combat_data[UBE_REPORT_CYPHER]}\">{$combat_data[UBE_REPORT_CYPHER]}</a>"; |
1069 | 1068 | |
1070 | 1069 | // TODO: Оптимизировать отсылку сообщений - отсылать пакетами |
1071 | - foreach($combat_data[UBE_PLAYERS] as $player_id => $player_info) |
|
1070 | + foreach ($combat_data[UBE_PLAYERS] as $player_id => $player_info) |
|
1072 | 1071 | { |
1073 | 1072 | $message = $text_common . ($outcome[UBE_SFR] && $player_info[UBE_ATTACKER] ? $lang['ube_report_msg_body_sfr'] : $text_defender); |
1074 | 1073 | msg_send_simple_message($player_id, '', $combat_data[UBE_TIME], MSG_TYPE_COMBAT, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $message); |
@@ -1080,7 +1079,7 @@ discard block |
||
1080 | 1079 | // ------------------------------------------------------------------------------------------------ |
1081 | 1080 | // Записывает результат боя в БД |
1082 | 1081 | /** @noinspection SpellCheckingInspection */ |
1083 | -function ube_combat_result_apply(&$combat_data){return sn_function_call('ube_combat_result_apply', array(&$combat_data));} |
|
1082 | +function ube_combat_result_apply(&$combat_data) {return sn_function_call('ube_combat_result_apply', array(&$combat_data)); } |
|
1084 | 1083 | function sn_ube_combat_result_apply(&$combat_data) |
1085 | 1084 | { |
1086 | 1085 | // TODO: Поменять все отладки на запросы |
@@ -1090,7 +1089,7 @@ discard block |
||
1090 | 1089 | $planet_info = &$outcome[UBE_PLANET]; |
1091 | 1090 | $planet_id = $planet_info[PLANET_ID]; |
1092 | 1091 | // Обновляем поле обломков на планете |
1093 | - if(!$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] && !empty($outcome[UBE_DEBRIS])) |
|
1092 | + if (!$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] && !empty($outcome[UBE_DEBRIS])) |
|
1094 | 1093 | { |
1095 | 1094 | DBStaticPlanet::db_planet_set_by_gspt($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], PT_PLANET, |
1096 | 1095 | "`debris_metal` = `debris_metal` + " . floor($outcome[UBE_DEBRIS][RES_METAL]) . ", `debris_crystal` = `debris_crystal` + " . floor($outcome[UBE_DEBRIS][RES_CRYSTAL]) |
@@ -1102,9 +1101,9 @@ discard block |
||
1102 | 1101 | ); |
1103 | 1102 | |
1104 | 1103 | $fleets_outcome = &$outcome[UBE_FLEETS]; |
1105 | - foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
1104 | + foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
1106 | 1105 | { |
1107 | - if($fleet_info[UBE_FLEET_GROUP]) |
|
1106 | + if ($fleet_info[UBE_FLEET_GROUP]) |
|
1108 | 1107 | { |
1109 | 1108 | $db_save[UBE_FLEET_GROUP][$fleet_info[UBE_FLEET_GROUP]] = $fleet_info[UBE_FLEET_GROUP]; |
1110 | 1109 | } |
@@ -1117,28 +1116,28 @@ discard block |
||
1117 | 1116 | $old_fleet_count = array_sum($fleet_info[UBE_COUNT]); |
1118 | 1117 | $new_fleet_count = $old_fleet_count - array_sum($fleets_outcome[$fleet_id][UBE_UNITS_LOST]); |
1119 | 1118 | // Перебираем юниты если во время боя количество юнитов изменилось и при этом во флоту остались юниты или это планета |
1120 | - if($new_fleet_count != $old_fleet_count && (!$fleet_id || $new_fleet_count)) |
|
1119 | + if ($new_fleet_count != $old_fleet_count && (!$fleet_id || $new_fleet_count)) |
|
1121 | 1120 | { |
1122 | 1121 | // Просматриваем результаты изменения флотов |
1123 | - foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
1122 | + foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
1124 | 1123 | { |
1125 | 1124 | // Перебираем аутком на случай восстановления юнитов |
1126 | - $units_lost = (float)$fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id]; |
|
1125 | + $units_lost = (float) $fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id]; |
|
1127 | 1126 | |
1128 | 1127 | $units_left = $unit_count - $units_lost; |
1129 | - if($fleet_id) |
|
1128 | + if ($fleet_id) |
|
1130 | 1129 | { |
1131 | 1130 | // Не планета - всегда сразу записываем строку итогов флота |
1132 | 1131 | $fleet_query[$unit_id] = "{$unit_id},{$units_left}"; |
1133 | 1132 | } |
1134 | - elseif($units_lost) |
|
1133 | + elseif ($units_lost) |
|
1135 | 1134 | { |
1136 | 1135 | // Планета - записываем в ИД юнита его потери только если есть потери |
1137 | 1136 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$units_lost, $combat_data[UBE_PLAYERS][$destination_user_id][UBE_PLAYER_DATA], $planet_id); |
1138 | 1137 | } |
1139 | 1138 | } |
1140 | 1139 | |
1141 | - if($fleet_id) |
|
1140 | + if ($fleet_id) |
|
1142 | 1141 | { |
1143 | 1142 | // Для флотов перегенерируем массив как одно вхождение в SET SQL-запроса |
1144 | 1143 | $fleet_query = array( |
@@ -1149,12 +1148,12 @@ discard block |
||
1149 | 1148 | |
1150 | 1149 | $fleet_delta = array(); |
1151 | 1150 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
1152 | - if($new_fleet_count || !$fleet_id) |
|
1151 | + if ($new_fleet_count || !$fleet_id) |
|
1153 | 1152 | { |
1154 | - foreach(sn_get_groups('resources_loot') as $resource_id) |
|
1153 | + foreach (sn_get_groups('resources_loot') as $resource_id) |
|
1155 | 1154 | { |
1156 | - $resource_change = (float)$fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float)$fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id]; |
|
1157 | - if($resource_change) |
|
1155 | + $resource_change = (float) $fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float) $fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id]; |
|
1156 | + if ($resource_change) |
|
1158 | 1157 | { |
1159 | 1158 | $resource_db_name = ($fleet_id ? 'fleet_resource_' : '') . pname_resource_name($resource_id); |
1160 | 1159 | // $fleet_query[] = "`{$resource_db_name}` = `{$resource_db_name}` - ({$resource_change})"; |
@@ -1168,10 +1167,10 @@ discard block |
||
1168 | 1167 | continue; |
1169 | 1168 | } |
1170 | 1169 | */ |
1171 | - if($fleet_id && $new_fleet_count) |
|
1170 | + if ($fleet_id && $new_fleet_count) |
|
1172 | 1171 | { |
1173 | 1172 | // Если защитник и не РМФ - отправляем флот назад |
1174 | - if(($fleet_info[UBE_FLEET_TYPE] == UBE_DEFENDERS && !$outcome[UBE_SFR]) || $fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS) |
|
1173 | + if (($fleet_info[UBE_FLEET_TYPE] == UBE_DEFENDERS && !$outcome[UBE_SFR]) || $fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS) |
|
1175 | 1174 | { |
1176 | 1175 | // $fleet_query[] = '`fleet_mess` = 1'; |
1177 | 1176 | $fleet_query['fleet_mess'] = 1; |
@@ -1186,16 +1185,16 @@ discard block |
||
1186 | 1185 | |
1187 | 1186 | //global $debug; |
1188 | 1187 | // $fleet_query = implode(',', $fleet_query); |
1189 | - if($fleet_id) // Не планета |
|
1188 | + if ($fleet_id) // Не планета |
|
1190 | 1189 | { |
1191 | - if($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED) |
|
1190 | + if ($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED) |
|
1192 | 1191 | { |
1193 | 1192 | $new_fleet_count = 0; |
1194 | 1193 | } |
1195 | 1194 | |
1196 | - if($new_fleet_count) |
|
1195 | + if ($new_fleet_count) |
|
1197 | 1196 | { |
1198 | - if(!empty($fleet_query) || !empty($fleet_delta)) |
|
1197 | + if (!empty($fleet_query) || !empty($fleet_delta)) |
|
1199 | 1198 | { |
1200 | 1199 | // doquery("UPDATE {{fleets}} SET {$fleet_query}, `fleet_amount` = '{$new_fleet_count}' WHERE `fleet_id` = {$fleet_id} LIMIT 1"); |
1201 | 1200 | // db_fleet_update_set_safe_string($fleet_id, "{$fleet_query}, `fleet_amount` = '{$new_fleet_count}'"); |
@@ -1214,15 +1213,15 @@ discard block |
||
1214 | 1213 | else // Планета |
1215 | 1214 | { |
1216 | 1215 | // Сохраняем изменения ресурсов - если они есть |
1217 | - if(!empty($fleet_delta)) |
|
1216 | + if (!empty($fleet_delta)) |
|
1218 | 1217 | { |
1219 | 1218 | $temp = array(); |
1220 | - foreach($fleet_delta as $resource_db_name => $resource_amount) { |
|
1219 | + foreach ($fleet_delta as $resource_db_name => $resource_amount) { |
|
1221 | 1220 | $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})"; |
1222 | 1221 | } |
1223 | 1222 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp)); |
1224 | 1223 | } |
1225 | - if(!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть |
|
1224 | + if (!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть |
|
1226 | 1225 | { |
1227 | 1226 | OldDbChangeSet::db_changeset_apply($db_changeset); |
1228 | 1227 | } |
@@ -1231,34 +1230,34 @@ discard block |
||
1231 | 1230 | |
1232 | 1231 | // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL |
1233 | 1232 | // $db_save[UBE_FLEET_GROUP][$fleet_info[UBE_FLEET_GROUP]] = $fleet_info[UBE_FLEET_GROUP]; |
1234 | - if(!empty($db_save[UBE_FLEET_GROUP])) |
|
1233 | + if (!empty($db_save[UBE_FLEET_GROUP])) |
|
1235 | 1234 | { |
1236 | 1235 | $db_save[UBE_FLEET_GROUP] = implode(',', $db_save[UBE_FLEET_GROUP]); |
1237 | 1236 | doquery("DELETE FROM {{aks}} WHERE `id` IN ({$db_save[UBE_FLEET_GROUP]})"); |
1238 | 1237 | } |
1239 | 1238 | |
1240 | - if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS) |
|
1239 | + if ($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS) |
|
1241 | 1240 | { |
1242 | 1241 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $outcome[UBE_MOON_SIZE], '', false); |
1243 | 1242 | $outcome[UBE_MOON_NAME] = $moon_row['name']; |
1244 | 1243 | unset($moon_row); |
1245 | 1244 | } |
1246 | - elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS) |
|
1245 | + elseif ($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS) |
|
1247 | 1246 | { |
1248 | 1247 | DBStaticPlanet::db_planet_delete_by_id($planet_id); |
1249 | 1248 | } |
1250 | 1249 | |
1251 | 1250 | { |
1252 | 1251 | $bashing_list = array(); |
1253 | - foreach($combat_data[UBE_PLAYERS] as $player_id => $player_info) |
|
1252 | + foreach ($combat_data[UBE_PLAYERS] as $player_id => $player_info) |
|
1254 | 1253 | { |
1255 | - if($player_info[UBE_ATTACKER]) |
|
1254 | + if ($player_info[UBE_ATTACKER]) |
|
1256 | 1255 | { |
1257 | - if($outcome[UBE_MOON] != UBE_MOON_DESTROY_SUCCESS) |
|
1256 | + if ($outcome[UBE_MOON] != UBE_MOON_DESTROY_SUCCESS) |
|
1258 | 1257 | { |
1259 | 1258 | $bashing_list[] = "({$player_id}, {$planet_id}, {$combat_data[UBE_TIME]})"; |
1260 | 1259 | } |
1261 | - if($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_ATTACK && $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE]) |
|
1260 | + if ($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_ATTACK && $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE]) |
|
1262 | 1261 | { |
1263 | 1262 | $str_loose_or_win = $outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose'; |
1264 | 1263 | db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1"); |
@@ -1266,7 +1265,7 @@ discard block |
||
1266 | 1265 | } |
1267 | 1266 | } |
1268 | 1267 | $bashing_list = implode(',', $bashing_list); |
1269 | - if($bashing_list) |
|
1268 | + if ($bashing_list) |
|
1270 | 1269 | { |
1271 | 1270 | doquery("INSERT INTO {{bashing}} (bashing_user_id, bashing_planet_id, bashing_time) VALUES {$bashing_list};"); |
1272 | 1271 | } |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | // ------------------------------------------------------------------------------------------------ |
81 | 81 | // Заполняет данные по игроку |
82 | -function ube_attack_prepare_player(&$combat_data, $player_id, $is_attacker) |
|
83 | -{ |
|
82 | +function ube_attack_prepare_player(&$combat_data, $player_id, $is_attacker) { |
|
84 | 83 | global $ube_convert_techs; |
85 | 84 | |
86 | 85 | if(!isset($combat_data[UBE_PLAYERS][$player_id])) |
@@ -99,8 +98,7 @@ discard block |
||
99 | 98 | { |
100 | 99 | $player_info[UBE_BONUSES][$ube_id] += mrc_get_level($player_data, false, $unit_id) * get_unit_param($unit_id, P_BONUS_VALUE) / 100 + $admiral_bonus; |
101 | 100 | } |
102 | - } |
|
103 | - else |
|
101 | + } else |
|
104 | 102 | { |
105 | 103 | $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] = $combat_data[UBE_PLAYERS][$player_id][UBE_ATTACKER] || $is_attacker; |
106 | 104 | } |
@@ -109,8 +107,7 @@ discard block |
||
109 | 107 | // ------------------------------------------------------------------------------------------------ |
110 | 108 | // Заполняет данные по флоту |
111 | 109 | function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker){return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker));} |
112 | -function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) |
|
113 | -{ |
|
110 | +function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) { |
|
114 | 111 | $fleet_owner_id = $fleet['fleet_owner']; |
115 | 112 | $fleet_id = $fleet['fleet_id']; |
116 | 113 | |
@@ -257,8 +254,7 @@ discard block |
||
257 | 254 | foreach($acs_fleet_list as $fleet) { |
258 | 255 | ube_attack_prepare_fleet($combat_data, $fleet, true); |
259 | 256 | } |
260 | - } |
|
261 | - else |
|
257 | + } else |
|
262 | 258 | { |
263 | 259 | ube_attack_prepare_fleet($combat_data, $fleet_row, true); |
264 | 260 | } |
@@ -273,8 +269,7 @@ discard block |
||
273 | 269 | } |
274 | 270 | |
275 | 271 | // ------------------------------------------------------------------------------------------------ |
276 | -function sn_ube_combat_prepare_first_round(&$combat_data) |
|
277 | -{ |
|
272 | +function sn_ube_combat_prepare_first_round(&$combat_data) { |
|
278 | 273 | global $ube_combat_bonus_list, $ube_convert_to_techs; |
279 | 274 | |
280 | 275 | // Готовим информацию для первого раунда - проводим все нужные вычисления из исходных данных |
@@ -339,8 +334,7 @@ discard block |
||
339 | 334 | |
340 | 335 | // ------------------------------------------------------------------------------------------------ |
341 | 336 | // Вычисление дополнительной информации для расчета раунда |
342 | -function sn_ube_combat_round_prepare(&$combat_data, $round) |
|
343 | -{ |
|
337 | +function sn_ube_combat_round_prepare(&$combat_data, $round) { |
|
344 | 338 | global $ube_combat_bonus_list; |
345 | 339 | |
346 | 340 | $is_simulator = $combat_data[UBE_OPTIONS][UBE_SIMULATOR]; |
@@ -401,8 +395,7 @@ discard block |
||
401 | 395 | |
402 | 396 | // ------------------------------------------------------------------------------------------------ |
403 | 397 | // Рассчитывает результат столкновения флотов ака раунд |
404 | -function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round) |
|
405 | -{ |
|
398 | +function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round) { |
|
406 | 399 | if(BE_DEBUG === true) |
407 | 400 | { |
408 | 401 | // sn_ube_combat_helper_round_header($round); |
@@ -437,8 +430,7 @@ discard block |
||
437 | 430 | |
438 | 431 | // ------------------------------------------------------------------------------------------------ |
439 | 432 | // Рассчитывает результат столкновения двух юнитов ака ход |
440 | -function sn_ube_combat_round_crossfire_unit(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) |
|
441 | -{ |
|
433 | +function sn_ube_combat_round_crossfire_unit(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) { |
|
442 | 434 | $attack_fleet_info = &$attack_fleet_data[UBE_FLEET_INFO]; |
443 | 435 | $defend_fleet_info = &$defend_fleet_data[UBE_FLEET_INFO]; |
444 | 436 | $defend_unit_armor = $defend_fleet_info[UBE_ARMOR][$defend_unit_id]; |
@@ -518,8 +510,7 @@ discard block |
||
518 | 510 | } |
519 | 511 | } |
520 | 512 | |
521 | -function sn_ube_combat_round_crossfire_unit_damage_current(&$defend_fleet_data, $defend_unit_id, &$amplified_damage, &$units_lost, &$units_boomed, &$combat_options) |
|
522 | -{ |
|
513 | +function sn_ube_combat_round_crossfire_unit_damage_current(&$defend_fleet_data, $defend_unit_id, &$amplified_damage, &$units_lost, &$units_boomed, &$combat_options) { |
|
523 | 514 | $unit_is_lost = false; |
524 | 515 | |
525 | 516 | $units_boomed = $units_boomed ? $units_boomed : 0; |
@@ -580,8 +571,7 @@ discard block |
||
580 | 571 | |
581 | 572 | // ------------------------------------------------------------------------------------------------ |
582 | 573 | // Рассчитывает результат столкновения двух юнитов ака ход |
583 | -function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) |
|
584 | -{ |
|
574 | +function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options) { |
|
585 | 575 | if($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0) |
586 | 576 | { |
587 | 577 | return; |
@@ -618,8 +608,7 @@ discard block |
||
618 | 608 | |
619 | 609 | // ------------------------------------------------------------------------------------------------ |
620 | 610 | // Анализирует результаты раунда и генерирует данные для следующего раунда |
621 | -function sn_ube_combat_round_analyze(&$combat_data, $round) |
|
622 | -{ |
|
611 | +function sn_ube_combat_round_analyze(&$combat_data, $round) { |
|
623 | 612 | $round_data = &$combat_data[UBE_ROUNDS][$round]; |
624 | 613 | $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW; |
625 | 614 | |
@@ -649,12 +638,10 @@ discard block |
||
649 | 638 | if(count($outcome) == 0 || $round == 10) |
650 | 639 | { |
651 | 640 | $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW_END; |
652 | - } |
|
653 | - elseif(count($outcome) == 1) |
|
641 | + } elseif(count($outcome) == 1) |
|
654 | 642 | { |
655 | 643 | $round_data[UBE_OUTCOME] = isset($outcome[UBE_ATTACKERS]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS; |
656 | - } |
|
657 | - elseif(count($outcome) == 2) |
|
644 | + } elseif(count($outcome) == 2) |
|
658 | 645 | { |
659 | 646 | if($round < 10) |
660 | 647 | { |
@@ -667,8 +654,7 @@ discard block |
||
667 | 654 | |
668 | 655 | // ------------------------------------------------------------------------------------------------ |
669 | 656 | // Общий алгоритм расчета боя |
670 | -function sn_ube_combat(&$combat_data) |
|
671 | -{ |
|
657 | +function sn_ube_combat(&$combat_data) { |
|
672 | 658 | // TODO: Сделать атаку по типам, когда они будут |
673 | 659 | |
674 | 660 | $start = microtime(true); |
@@ -696,8 +682,7 @@ discard block |
||
696 | 682 | |
697 | 683 | // ------------------------------------------------------------------------------------------------ |
698 | 684 | // Разбирает данные боя для генерации отчета |
699 | -function sn_ube_combat_analyze(&$combat_data) |
|
700 | -{ |
|
685 | +function sn_ube_combat_analyze(&$combat_data) { |
|
701 | 686 | global $config; |
702 | 687 | |
703 | 688 | // $combat_data[UBE_OUTCOME] = array(); |
@@ -742,14 +727,12 @@ discard block |
||
742 | 727 | if($combat_data[UBE_OPTIONS][UBE_SIMULATOR]) |
743 | 728 | { // for simulation just return 75% of loss |
744 | 729 | $units_giveback = round($units_lost * $giveback_chance / 100); |
745 | - } |
|
746 | - else |
|
730 | + } else |
|
747 | 731 | { |
748 | 732 | if($unit_count > 10) |
749 | 733 | { // if there were more then 10 defense elements - mass-calculating giveback |
750 | 734 | $units_giveback = round($units_lost * mt_rand($giveback_chance * 0.8, $giveback_chance * 1.2) / 100); |
751 | - } |
|
752 | - else |
|
735 | + } else |
|
753 | 736 | { //if there were less then 10 defense elements - calculating giveback per element |
754 | 737 | $units_giveback = 0; |
755 | 738 | for($i = 1; $i <= $units_lost; $i++) |
@@ -852,8 +835,7 @@ discard block |
||
852 | 835 | if($combat_data[UBE_OPTIONS][UBE_MOON_WAS]) |
853 | 836 | { |
854 | 837 | $outcome[UBE_MOON] = UBE_MOON_WAS; |
855 | - } |
|
856 | - else |
|
838 | + } else |
|
857 | 839 | { |
858 | 840 | sn_ube_combat_analyze_moon($outcome, $combat_data[UBE_OPTIONS][UBE_SIMULATOR]); |
859 | 841 | } |
@@ -872,8 +854,7 @@ discard block |
||
872 | 854 | } |
873 | 855 | |
874 | 856 | // ------------------------------------------------------------------------------------------------ |
875 | -function sn_ube_combat_analyze_loot(&$combat_data) |
|
876 | -{ |
|
857 | +function sn_ube_combat_analyze_loot(&$combat_data) { |
|
877 | 858 | $exchange = &$combat_data[UBE_OPTIONS][UBE_EXCHANGE]; |
878 | 859 | $planet_resource_list = &$combat_data[UBE_FLEETS][0][UBE_RESOURCES]; |
879 | 860 | $outcome = &$combat_data[UBE_OUTCOME]; |
@@ -916,13 +897,14 @@ discard block |
||
916 | 897 | } |
917 | 898 | |
918 | 899 | // ------------------------------------------------------------------------------------------------ |
919 | -function sn_ube_combat_analyze_moon(&$outcome, $is_simulator) |
|
920 | -{ |
|
900 | +function sn_ube_combat_analyze_moon(&$outcome, $is_simulator) { |
|
921 | 901 | $outcome[UBE_DEBRIS_TOTAL] = 0; |
922 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array |
|
902 | + foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
903 | + // TODO via array |
|
923 | 904 | { |
924 | 905 | $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id]; |
925 | 906 | } |
907 | + } |
|
926 | 908 | |
927 | 909 | if($outcome[UBE_DEBRIS_TOTAL]) |
928 | 910 | { |
@@ -941,35 +923,33 @@ discard block |
||
941 | 923 | { |
942 | 924 | $outcome[UBE_DEBRIS_TOTAL] = 0; |
943 | 925 | $outcome[UBE_DEBRIS] = array(); |
944 | - } |
|
945 | - else |
|
926 | + } else |
|
946 | 927 | { |
947 | 928 | $moon_debris_spent = 30000000; |
948 | 929 | $moon_debris_left_percent = ($outcome[UBE_DEBRIS_TOTAL] - $moon_debris_spent) / $outcome[UBE_DEBRIS_TOTAL]; |
949 | 930 | |
950 | 931 | $outcome[UBE_DEBRIS_TOTAL] = 0; |
951 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array |
|
932 | + foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
933 | + // TODO via array |
|
952 | 934 | { |
953 | 935 | $outcome[UBE_DEBRIS][$resource_id] = floor($outcome[UBE_DEBRIS][$resource_id] * $moon_debris_left_percent); |
936 | + } |
|
954 | 937 | $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id]; |
955 | 938 | } |
956 | 939 | } |
957 | - } |
|
958 | - else |
|
940 | + } else |
|
959 | 941 | { |
960 | 942 | $outcome[UBE_MOON] = UBE_MOON_CREATE_FAILED; |
961 | 943 | } |
962 | 944 | } |
963 | - } |
|
964 | - else |
|
945 | + } else |
|
965 | 946 | { |
966 | 947 | $outcome[UBE_MOON] = UBE_MOON_NONE; |
967 | 948 | } |
968 | 949 | } |
969 | 950 | |
970 | 951 | // ------------------------------------------------------------------------------------------------ |
971 | -function sn_ube_combat_analyze_moon_destroy(&$combat_data) |
|
972 | -{ |
|
952 | +function sn_ube_combat_analyze_moon_destroy(&$combat_data) { |
|
973 | 953 | // TODO: $is_simulator |
974 | 954 | $reapers = 0; |
975 | 955 | foreach($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS])-1][UBE_FLEETS] as $fleet_data) |
@@ -993,8 +973,7 @@ discard block |
||
993 | 973 | $combat_data[UBE_OUTCOME][UBE_MOON] = $random <= $combat_data[UBE_OUTCOME][UBE_MOON_DESTROY_CHANCE] ? UBE_MOON_DESTROY_SUCCESS : UBE_MOON_DESTROY_FAILED; |
994 | 974 | $random = mt_rand(1, 100); |
995 | 975 | $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = $random <= $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS_DIE_CHANCE] ? UBE_MOON_REAPERS_DIED : UBE_MOON_REAPERS_RETURNED; |
996 | - } |
|
997 | - else |
|
976 | + } else |
|
998 | 977 | { |
999 | 978 | $combat_data[UBE_OUTCOME][UBE_MOON_REAPERS] = UBE_MOON_REAPERS_NONE; |
1000 | 979 | } |
@@ -1002,8 +981,7 @@ discard block |
||
1002 | 981 | |
1003 | 982 | // ------------------------------------------------------------------------------------------------ |
1004 | 983 | // Рассылает письма всем участникам боя |
1005 | -function sn_ube_message_send(&$combat_data) |
|
1006 | -{ |
|
984 | +function sn_ube_message_send(&$combat_data) { |
|
1007 | 985 | global $lang; |
1008 | 986 | |
1009 | 987 | // TODO: Отсылать каждому игроку сообщение на его языке! |
@@ -1042,8 +1020,7 @@ discard block |
||
1042 | 1020 | if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS) |
1043 | 1021 | { |
1044 | 1022 | $text_defender .= "{$lang['ube_report_moon_created']} {$outcome[UBE_MOON_SIZE]} {$lang['sys_kilometers_short']}<br /><br />"; |
1045 | - } |
|
1046 | - elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED) |
|
1023 | + } elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED) |
|
1047 | 1024 | { |
1048 | 1025 | $text_defender .= "{$lang['ube_report_moon_chance']} {$outcome[UBE_MOON_CHANCE]}%<br /><br />"; |
1049 | 1026 | } |
@@ -1053,8 +1030,7 @@ discard block |
||
1053 | 1030 | if($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE) |
1054 | 1031 | { |
1055 | 1032 | $text_defender .= $lang['ube_report_moon_reapers_none']; |
1056 | - } |
|
1057 | - else |
|
1033 | + } else |
|
1058 | 1034 | { |
1059 | 1035 | $text_defender .= "{$lang['ube_report_moon_reapers_wave']}. {$lang['ube_report_moon_reapers_chance']} {$outcome[UBE_MOON_DESTROY_CHANCE]}%. "; |
1060 | 1036 | $text_defender .= $lang[$outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
@@ -1081,8 +1057,7 @@ discard block |
||
1081 | 1057 | // Записывает результат боя в БД |
1082 | 1058 | /** @noinspection SpellCheckingInspection */ |
1083 | 1059 | function ube_combat_result_apply(&$combat_data){return sn_function_call('ube_combat_result_apply', array(&$combat_data));} |
1084 | -function sn_ube_combat_result_apply(&$combat_data) |
|
1085 | -{ |
|
1060 | +function sn_ube_combat_result_apply(&$combat_data) { |
|
1086 | 1061 | // TODO: Поменять все отладки на запросы |
1087 | 1062 | $destination_user_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
1088 | 1063 | |
@@ -1130,8 +1105,7 @@ discard block |
||
1130 | 1105 | { |
1131 | 1106 | // Не планета - всегда сразу записываем строку итогов флота |
1132 | 1107 | $fleet_query[$unit_id] = "{$unit_id},{$units_left}"; |
1133 | - } |
|
1134 | - elseif($units_lost) |
|
1108 | + } elseif($units_lost) |
|
1135 | 1109 | { |
1136 | 1110 | // Планета - записываем в ИД юнита его потери только если есть потери |
1137 | 1111 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$units_lost, $combat_data[UBE_PLAYERS][$destination_user_id][UBE_PLAYER_DATA], $planet_id); |
@@ -1186,11 +1160,13 @@ discard block |
||
1186 | 1160 | |
1187 | 1161 | //global $debug; |
1188 | 1162 | // $fleet_query = implode(',', $fleet_query); |
1189 | - if($fleet_id) // Не планета |
|
1163 | + if($fleet_id) { |
|
1164 | + // Не планета |
|
1190 | 1165 | { |
1191 | 1166 | if($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED) |
1192 | 1167 | { |
1193 | 1168 | $new_fleet_count = 0; |
1169 | + } |
|
1194 | 1170 | } |
1195 | 1171 | |
1196 | 1172 | if($new_fleet_count) |
@@ -1202,16 +1178,14 @@ discard block |
||
1202 | 1178 | $fleet_query['fleet_amount'] = $new_fleet_count; |
1203 | 1179 | fleet_update_set($fleet_id, $fleet_query, $fleet_delta); |
1204 | 1180 | } |
1205 | - } |
|
1206 | - else |
|
1181 | + } else |
|
1207 | 1182 | { |
1208 | 1183 | // Удаляем пустые флоты |
1209 | 1184 | // doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = {$fleet_id} LIMIT 1"); |
1210 | 1185 | db_fleet_delete($fleet_id); |
1211 | 1186 | DBStaticUnit::db_unit_list_delete(0, LOC_FLEET, $fleet_id, 0); |
1212 | 1187 | } |
1213 | - } |
|
1214 | - else // Планета |
|
1188 | + } else // Планета |
|
1215 | 1189 | { |
1216 | 1190 | // Сохраняем изменения ресурсов - если они есть |
1217 | 1191 | if(!empty($fleet_delta)) |
@@ -1222,10 +1196,12 @@ discard block |
||
1222 | 1196 | } |
1223 | 1197 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp)); |
1224 | 1198 | } |
1225 | - if(!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть |
|
1199 | + if(!empty($db_changeset)) { |
|
1200 | + // Сохраняем изменения юнитов на планете - если они есть |
|
1226 | 1201 | { |
1227 | 1202 | OldDbChangeSet::db_changeset_apply($db_changeset); |
1228 | 1203 | } |
1204 | + } |
|
1229 | 1205 | } |
1230 | 1206 | } |
1231 | 1207 | |
@@ -1242,8 +1218,7 @@ discard block |
||
1242 | 1218 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $outcome[UBE_MOON_SIZE], '', false); |
1243 | 1219 | $outcome[UBE_MOON_NAME] = $moon_row['name']; |
1244 | 1220 | unset($moon_row); |
1245 | - } |
|
1246 | - elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS) |
|
1221 | + } elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS) |
|
1247 | 1222 | { |
1248 | 1223 | DBStaticPlanet::db_planet_delete_by_id($planet_id); |
1249 | 1224 | } |
@@ -281,6 +281,9 @@ discard block |
||
281 | 281 | |
282 | 282 | // ------------------------------------------------------------------------------------------------ |
283 | 283 | // Читает боевой отчет из БД |
284 | +/** |
|
285 | + * @param string $report_cypher |
|
286 | + */ |
|
284 | 287 | function sn_ube_report_load($report_cypher) |
285 | 288 | { |
286 | 289 | $report_cypher = db_escape($report_cypher); |
@@ -480,6 +483,9 @@ discard block |
||
480 | 483 | |
481 | 484 | // ------------------------------------------------------------------------------------------------ |
482 | 485 | // Парсит инфу о раунде для темплейта |
486 | +/** |
|
487 | + * @param integer $round |
|
488 | + */ |
|
483 | 489 | function sn_ube_report_round_fleet(&$combat_data, $round) |
484 | 490 | { |
485 | 491 | global $lang; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | global $config; |
8 | 8 | |
9 | 9 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
10 | - if($combat_data[UBE_REPORT_CYPHER]) |
|
10 | + if ($combat_data[UBE_REPORT_CYPHER]) |
|
11 | 11 | { |
12 | 12 | return false; |
13 | 13 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | $combat_data[UBE_REPORT_CYPHER] = sys_random_string(32); |
19 | 19 | } |
20 | - while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true)); |
|
20 | + while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true)); |
|
21 | 21 | |
22 | 22 | // Инициализация таблицы для пакетной вставки информации |
23 | 23 | $sql_perform = array( |
@@ -113,55 +113,55 @@ discard block |
||
113 | 113 | `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $combat_data[UBE_TIME]) . "', |
114 | 114 | `ube_report_time_spent` = {$combat_data[UBE_TIME_SPENT]}, |
115 | 115 | |
116 | - `ube_report_combat_admin` = " . (int)$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ", |
|
116 | + `ube_report_combat_admin` = " . (int) $combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ", |
|
117 | 117 | `ube_report_mission_type` = {$combat_data[UBE_OPTIONS][UBE_MISSION_TYPE]}, |
118 | 118 | |
119 | 119 | `ube_report_combat_result` = {$outcome[UBE_COMBAT_RESULT]}, |
120 | - `ube_report_combat_sfr` = " . (int)$outcome[UBE_SFR] .", |
|
120 | + `ube_report_combat_sfr` = " . (int) $outcome[UBE_SFR] . ", |
|
121 | 121 | |
122 | - `ube_report_debris_metal` = " . (float)$outcome[UBE_DEBRIS][RES_METAL] . ", |
|
123 | - `ube_report_debris_crystal` = " . (float)$outcome[UBE_DEBRIS][RES_CRYSTAL] . ", |
|
122 | + `ube_report_debris_metal` = " . (float) $outcome[UBE_DEBRIS][RES_METAL] . ", |
|
123 | + `ube_report_debris_crystal` = " . (float) $outcome[UBE_DEBRIS][RES_CRYSTAL] . ", |
|
124 | 124 | `ube_report_debris_total_in_metal` = " . $ube_report_debris_total_in_metal . ", |
125 | 125 | |
126 | - `ube_report_planet_id` = " . (int)$outcome[UBE_PLANET][PLANET_ID] . ", |
|
126 | + `ube_report_planet_id` = " . (int) $outcome[UBE_PLANET][PLANET_ID] . ", |
|
127 | 127 | `ube_report_planet_name` = '" . db_escape($outcome[UBE_PLANET][PLANET_NAME]) . "', |
128 | - `ube_report_planet_size` = " . (int)$outcome[UBE_PLANET][PLANET_SIZE] . ", |
|
129 | - `ube_report_planet_galaxy` = " . (int)$outcome[UBE_PLANET][PLANET_GALAXY] . ", |
|
130 | - `ube_report_planet_system` = " . (int)$outcome[UBE_PLANET][PLANET_SYSTEM] . ", |
|
131 | - `ube_report_planet_planet` = " . (int)$outcome[UBE_PLANET][PLANET_PLANET] . ", |
|
132 | - `ube_report_planet_planet_type` = " . (int)$outcome[UBE_PLANET][PLANET_TYPE] . ", |
|
128 | + `ube_report_planet_size` = " . (int) $outcome[UBE_PLANET][PLANET_SIZE] . ", |
|
129 | + `ube_report_planet_galaxy` = " . (int) $outcome[UBE_PLANET][PLANET_GALAXY] . ", |
|
130 | + `ube_report_planet_system` = " . (int) $outcome[UBE_PLANET][PLANET_SYSTEM] . ", |
|
131 | + `ube_report_planet_planet` = " . (int) $outcome[UBE_PLANET][PLANET_PLANET] . ", |
|
132 | + `ube_report_planet_planet_type` = " . (int) $outcome[UBE_PLANET][PLANET_TYPE] . ", |
|
133 | 133 | |
134 | - `ube_report_moon` = " . (int)$outcome[UBE_MOON] .", |
|
135 | - `ube_report_moon_chance` = " . (int)$outcome[UBE_MOON_CHANCE] . ", |
|
136 | - `ube_report_moon_size` = " . (float)$outcome[UBE_MOON_SIZE] . ", |
|
134 | + `ube_report_moon` = " . (int) $outcome[UBE_MOON] . ", |
|
135 | + `ube_report_moon_chance` = " . (int) $outcome[UBE_MOON_CHANCE] . ", |
|
136 | + `ube_report_moon_size` = " . (float) $outcome[UBE_MOON_SIZE] . ", |
|
137 | 137 | |
138 | - `ube_report_moon_reapers` = " . (int)$outcome[UBE_MOON_REAPERS] . ", |
|
139 | - `ube_report_moon_destroy_chance` = " . (int)$outcome[UBE_MOON_DESTROY_CHANCE] . ", |
|
140 | - `ube_report_moon_reapers_die_chance` = " . (int)$outcome[UBE_MOON_REAPERS_DIE_CHANCE] . ", |
|
138 | + `ube_report_moon_reapers` = " . (int) $outcome[UBE_MOON_REAPERS] . ", |
|
139 | + `ube_report_moon_destroy_chance` = " . (int) $outcome[UBE_MOON_DESTROY_CHANCE] . ", |
|
140 | + `ube_report_moon_reapers_die_chance` = " . (int) $outcome[UBE_MOON_REAPERS_DIE_CHANCE] . ", |
|
141 | 141 | |
142 | - `ube_report_capture_result` = " . (int)$outcome[UBE_CAPTURE_RESULT] . " |
|
142 | + `ube_report_capture_result` = " . (int) $outcome[UBE_CAPTURE_RESULT] . " |
|
143 | 143 | "); |
144 | 144 | $ube_report_id = $combat_data[UBE_REPORT_ID] = db_insert_id(); |
145 | 145 | |
146 | 146 | // Сохраняем общую информацию по игрокам |
147 | - foreach($combat_data[UBE_PLAYERS] as $player_id => &$player_info) |
|
147 | + foreach ($combat_data[UBE_PLAYERS] as $player_id => &$player_info) |
|
148 | 148 | { |
149 | 149 | $sql_perform['ube_report_player'][] = array( |
150 | 150 | $ube_report_id, |
151 | 151 | $player_id, |
152 | 152 | |
153 | 153 | "'" . db_escape($player_info[UBE_NAME]) . "'", |
154 | - (int)$player_info[UBE_ATTACKER], |
|
154 | + (int) $player_info[UBE_ATTACKER], |
|
155 | 155 | |
156 | - (float)$player_info[UBE_BONUSES][UBE_ATTACK], |
|
157 | - (float)$player_info[UBE_BONUSES][UBE_SHIELD], |
|
158 | - (float)$player_info[UBE_BONUSES][UBE_ARMOR], |
|
156 | + (float) $player_info[UBE_BONUSES][UBE_ATTACK], |
|
157 | + (float) $player_info[UBE_BONUSES][UBE_SHIELD], |
|
158 | + (float) $player_info[UBE_BONUSES][UBE_ARMOR], |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | 162 | // Всякая информация по флотам |
163 | 163 | $unit_sort_order = 0; |
164 | - foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
164 | + foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) |
|
165 | 165 | { |
166 | 166 | // Сохраняем общую информацию по флотам |
167 | 167 | $sql_perform['ube_report_fleet'][] = array( |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | $fleet_info[UBE_OWNER], |
170 | 170 | $fleet_id, |
171 | 171 | |
172 | - (float)$fleet_info[UBE_PLANET][PLANET_ID], |
|
172 | + (float) $fleet_info[UBE_PLANET][PLANET_ID], |
|
173 | 173 | "'" . db_escape($fleet_info[UBE_PLANET][PLANET_NAME]) . "'", |
174 | - (int)$fleet_info[UBE_PLANET][PLANET_GALAXY], |
|
175 | - (int)$fleet_info[UBE_PLANET][PLANET_SYSTEM], |
|
176 | - (int)$fleet_info[UBE_PLANET][PLANET_PLANET], |
|
177 | - (int)$fleet_info[UBE_PLANET][PLANET_TYPE], |
|
178 | - |
|
179 | - (float)$fleet_info[UBE_RESOURCES][RES_METAL], |
|
180 | - (float)$fleet_info[UBE_RESOURCES][RES_CRYSTAL], |
|
181 | - (float)$fleet_info[UBE_RESOURCES][RES_DEUTERIUM], |
|
182 | - |
|
183 | - (float)$fleet_info[UBE_BONUSES][UBE_ATTACK], |
|
184 | - (float)$fleet_info[UBE_BONUSES][UBE_SHIELD], |
|
185 | - (float)$fleet_info[UBE_BONUSES][UBE_ARMOR], |
|
174 | + (int) $fleet_info[UBE_PLANET][PLANET_GALAXY], |
|
175 | + (int) $fleet_info[UBE_PLANET][PLANET_SYSTEM], |
|
176 | + (int) $fleet_info[UBE_PLANET][PLANET_PLANET], |
|
177 | + (int) $fleet_info[UBE_PLANET][PLANET_TYPE], |
|
178 | + |
|
179 | + (float) $fleet_info[UBE_RESOURCES][RES_METAL], |
|
180 | + (float) $fleet_info[UBE_RESOURCES][RES_CRYSTAL], |
|
181 | + (float) $fleet_info[UBE_RESOURCES][RES_DEUTERIUM], |
|
182 | + |
|
183 | + (float) $fleet_info[UBE_BONUSES][UBE_ATTACK], |
|
184 | + (float) $fleet_info[UBE_BONUSES][UBE_SHIELD], |
|
185 | + (float) $fleet_info[UBE_BONUSES][UBE_ARMOR], |
|
186 | 186 | ); |
187 | 187 | |
188 | 188 | // Сохраняем итоговую информацию по ресурсам флота - потеряно, выброшено, увезено |
@@ -191,25 +191,25 @@ discard block |
||
191 | 191 | $ube_report_id, |
192 | 192 | $fleet_id, |
193 | 193 | |
194 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL], |
|
195 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL], |
|
196 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM], |
|
194 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL], |
|
195 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL], |
|
196 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM], |
|
197 | 197 | |
198 | - (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL], |
|
199 | - (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL], |
|
200 | - (float)$fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM], |
|
198 | + (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL], |
|
199 | + (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL], |
|
200 | + (float) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM], |
|
201 | 201 | |
202 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL], |
|
203 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL], |
|
204 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM], |
|
202 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL], |
|
203 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL], |
|
204 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM], |
|
205 | 205 | |
206 | - (float)$fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL], |
|
206 | + (float) $fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL], |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | // Сохраняем результаты по юнитам - потеряно и восстановлено |
210 | - foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
210 | + foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) |
|
211 | 211 | { |
212 | - if($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id]) |
|
212 | + if ($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id]) |
|
213 | 213 | { |
214 | 214 | $unit_sort_order++; |
215 | 215 | $sql_perform['ube_report_outcome_unit'][] = array( |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | $fleet_id, |
218 | 218 | |
219 | 219 | $unit_id, |
220 | - (float)$fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id], |
|
221 | - (float)$fleet_outcome_data[UBE_UNITS_LOST][$unit_id], |
|
220 | + (float) $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id], |
|
221 | + (float) $fleet_outcome_data[UBE_UNITS_LOST][$unit_id], |
|
222 | 222 | |
223 | 223 | $unit_sort_order, |
224 | 224 | ); |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | |
229 | 229 | // Сохраняем информацию о раундах |
230 | 230 | $unit_sort_order = 0; |
231 | - foreach($combat_data[UBE_ROUNDS] as $round => &$round_data) |
|
231 | + foreach ($combat_data[UBE_ROUNDS] as $round => &$round_data) |
|
232 | 232 | { |
233 | - foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
233 | + foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) |
|
234 | 234 | { |
235 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
235 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
236 | 236 | { |
237 | 237 | $unit_sort_order++; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $unit_id, |
246 | 246 | $unit_count, |
247 | - (int)$fleet_data[UBE_UNITS_BOOM][$unit_id], |
|
247 | + (int) $fleet_data[UBE_UNITS_BOOM][$unit_id], |
|
248 | 248 | |
249 | 249 | $fleet_data[UBE_ATTACK][$unit_id], |
250 | 250 | $fleet_data[UBE_SHIELD][$unit_id], |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | // Пакетная вставка данных |
264 | - foreach($sql_perform as $table_name => $table_data) |
|
264 | + foreach ($sql_perform as $table_name => $table_data) |
|
265 | 265 | { |
266 | - if(count($table_data) < 2) |
|
266 | + if (count($table_data) < 2) |
|
267 | 267 | { |
268 | 268 | continue; |
269 | 269 | } |
270 | - foreach($table_data as &$record_data) |
|
270 | + foreach ($table_data as &$record_data) |
|
271 | 271 | { |
272 | 272 | $record_data = '(' . implode(',', $record_data) . ')'; |
273 | 273 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $report_cypher = db_escape($report_cypher); |
287 | 287 | |
288 | 288 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
289 | - if(!$report_row) |
|
289 | + if (!$report_row) |
|
290 | 290 | { |
291 | 291 | return UBE_REPORT_NOT_FOUND; |
292 | 292 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $outcome = &$combat_data[UBE_OUTCOME]; |
341 | 341 | |
342 | 342 | $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
343 | - while($player_row = db_fetch($query)) |
|
343 | + while ($player_row = db_fetch($query)) |
|
344 | 344 | { |
345 | 345 | $combat_data[UBE_PLAYERS][$player_row['ube_report_player_player_id']] = array( |
346 | 346 | UBE_NAME => $player_row['ube_report_player_name'], |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
358 | - while($fleet_row = db_fetch($query)) |
|
358 | + while ($fleet_row = db_fetch($query)) |
|
359 | 359 | { |
360 | 360 | $combat_data[UBE_FLEETS][$fleet_row['ube_report_fleet_fleet_id']] = array( |
361 | 361 | UBE_OWNER => $fleet_row['ube_report_fleet_player_id'], |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $rounds_data = &$combat_data[UBE_ROUNDS]; |
390 | 390 | |
391 | 391 | $query = doquery("SELECT * FROM {{ube_report_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_unit_sort_order`"); |
392 | - while($round_row = db_fetch($query)) |
|
392 | + while ($round_row = db_fetch($query)) |
|
393 | 393 | { |
394 | 394 | $round = $round_row['ube_report_unit_round']; |
395 | 395 | $fleet_id = $round_row['ube_report_unit_fleet_id']; |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | $side = $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE]; |
398 | 398 | $rounds_data[$round][$side][UBE_ATTACK][$fleet_id] = 0; |
399 | 399 | |
400 | - if(!isset($rounds_data[$round][UBE_FLEETS][$fleet_id])) |
|
400 | + if (!isset($rounds_data[$round][UBE_FLEETS][$fleet_id])) |
|
401 | 401 | { |
402 | 402 | $rounds_data[$round][UBE_FLEETS][$fleet_id] = array(); |
403 | 403 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | |
419 | 419 | |
420 | 420 | $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
421 | - while($row = db_fetch($query)) |
|
421 | + while ($row = db_fetch($query)) |
|
422 | 422 | { |
423 | 423 | $fleet_id = $row['ube_report_outcome_fleet_fleet_id']; |
424 | 424 | |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`"); |
455 | - while($row = db_fetch($query)) |
|
455 | + while ($row = db_fetch($query)) |
|
456 | 456 | { |
457 | 457 | $fleet_id = $row['ube_report_outcome_unit_fleet_id']; |
458 | - $side= $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE]; |
|
458 | + $side = $combat_data[UBE_FLEETS][$fleet_id][UBE_FLEET_TYPE]; |
|
459 | 459 | $outcome[$side][UBE_FLEETS][$fleet_id][UBE_UNITS_LOST][$row['ube_report_outcome_unit_unit_id']] = $row['ube_report_outcome_unit_lost']; |
460 | 460 | $outcome[$side][UBE_FLEETS][$fleet_id][UBE_DEFENCE_RESTORE][$row['ube_report_outcome_unit_unit_id']] = $row['ube_report_outcome_unit_restored']; |
461 | 461 | } |
@@ -487,10 +487,10 @@ discard block |
||
487 | 487 | $fleets_info = &$combat_data[UBE_FLEETS]; |
488 | 488 | $round_template = array(); |
489 | 489 | $round_data = &$combat_data[UBE_ROUNDS][$round]; |
490 | - foreach(array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
490 | + foreach (array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
491 | 491 | { |
492 | 492 | $round_data[$side][UBE_ATTACK] = $round_data[$side][UBE_ATTACK] ? $round_data[$side][UBE_ATTACK] : array(); |
493 | - foreach($round_data[$side][UBE_ATTACK] as $fleet_id => $temp) |
|
493 | + foreach ($round_data[$side][UBE_ATTACK] as $fleet_id => $temp) |
|
494 | 494 | { |
495 | 495 | $fleet_data = &$round_data[UBE_FLEETS][$fleet_id]; |
496 | 496 | $fleet_data_prev = &$combat_data[UBE_ROUNDS][$round - 1][UBE_FLEETS][$fleet_id]; |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | 'PLAYER_NAME' => htmlentities($combat_data[UBE_PLAYERS][$fleets_info[$fleet_id][UBE_OWNER]][UBE_NAME], ENT_COMPAT, 'UTF-8'), |
501 | 501 | ); |
502 | 502 | |
503 | - if(is_array($combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET])) |
|
503 | + if (is_array($combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET])) |
|
504 | 504 | { |
505 | 505 | $fleet_template += $combat_data[UBE_FLEETS][$fleet_id][UBE_PLANET]; |
506 | 506 | $fleet_template[PLANET_NAME] = $fleet_template[PLANET_NAME] ? htmlentities($fleet_template[PLANET_NAME], ENT_COMPAT, 'UTF-8') : ''; |
507 | 507 | $fleet_template['PLANET_TYPE_TEXT'] = $lang['sys_planet_type_sh'][$fleet_template['PLANET_TYPE']]; |
508 | 508 | } |
509 | 509 | |
510 | - foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
510 | + foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) |
|
511 | 511 | { |
512 | 512 | $shields_original = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $fleet_data_prev[UBE_COUNT][$unit_id]; |
513 | 513 | $ship_template = array( |
@@ -540,11 +540,11 @@ discard block |
||
540 | 540 | global $lang; |
541 | 541 | |
542 | 542 | $result = array(); |
543 | - if(!empty($array)) |
|
543 | + if (!empty($array)) |
|
544 | 544 | { |
545 | - foreach($array as $unit_id => $unit_count) |
|
545 | + foreach ($array as $unit_id => $unit_count) |
|
546 | 546 | { |
547 | - if($unit_count) |
|
547 | + if ($unit_count) |
|
548 | 548 | { |
549 | 549 | $result[] = array( |
550 | 550 | 'NAME' => $lang['tech'][$unit_id], |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | ); |
553 | 553 | } |
554 | 554 | } |
555 | - if($header && count($result)) |
|
555 | + if ($header && count($result)) |
|
556 | 556 | { |
557 | 557 | array_unshift($result, array('NAME' => $header)); |
558 | 558 | } |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | // Генерирует данные для отчета из разобранных данных боя |
566 | 566 | function sn_ube_report_generate(&$combat_data, &$template_result) |
567 | 567 | { |
568 | - if(!is_array($combat_data)) |
|
568 | + if (!is_array($combat_data)) |
|
569 | 569 | { |
570 | 570 | return; |
571 | 571 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $fleets_info = &$combat_data[UBE_FLEETS]; |
578 | 578 | $outcome = &$combat_data[UBE_OUTCOME]; |
579 | 579 | // Генерируем отчет по флотам |
580 | - for($round = 1; $round <= count($combat_data[UBE_ROUNDS]) - 1; $round++) |
|
580 | + for ($round = 1; $round <= count($combat_data[UBE_ROUNDS]) - 1; $round++) |
|
581 | 581 | { |
582 | 582 | $round_template = array( |
583 | 583 | 'NUMBER' => $round, |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | } |
590 | 590 | |
591 | 591 | // Боевые потери флотов |
592 | - foreach(array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
592 | + foreach (array(UBE_ATTACKERS, UBE_DEFENDERS) as $side) |
|
593 | 593 | { |
594 | - if(!is_array($outcome[$side][UBE_FLEETS])) |
|
594 | + if (!is_array($outcome[$side][UBE_FLEETS])) |
|
595 | 595 | { |
596 | 596 | continue; |
597 | 597 | } |
598 | - foreach($outcome[$side][UBE_FLEETS] as $fleet_id => $temp) |
|
598 | + foreach ($outcome[$side][UBE_FLEETS] as $fleet_id => $temp) |
|
599 | 599 | { |
600 | 600 | $player_info = &$players_info[$fleets_info[$fleet_id][UBE_OWNER]]; |
601 | 601 | $fleet_outcome = &$outcome[UBE_FLEETS][$fleet_id]; |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | |
621 | 621 | // Обломки |
622 | 622 | $debris = array(); |
623 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) |
|
623 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) |
|
624 | 624 | { |
625 | - if($resource_amount = $outcome[UBE_DEBRIS][$resource_id]) |
|
625 | + if ($resource_amount = $outcome[UBE_DEBRIS][$resource_id]) |
|
626 | 626 | { |
627 | 627 | $debris[] = array( |
628 | 628 | 'NAME' => $lang['tech'][$resource_id], |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | |
636 | 636 | // Координаты, тип и название планеты - если есть |
637 | 637 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
638 | - if(isset($combat_data[UBE_OUTCOME][UBE_PLANET])) |
|
638 | + if (isset($combat_data[UBE_OUTCOME][UBE_PLANET])) |
|
639 | 639 | { |
640 | 640 | $template_result += $combat_data[UBE_OUTCOME][UBE_PLANET]; |
641 | 641 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | // ------------------------------------------------------------------------------------------------ |
4 | 4 | // Записывает боевой отчет в БД |
5 | -function sn_ube_report_save(&$combat_data) |
|
6 | -{ |
|
5 | +function sn_ube_report_save(&$combat_data) { |
|
7 | 6 | global $config; |
8 | 7 | |
9 | 8 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
@@ -281,8 +280,7 @@ discard block |
||
281 | 280 | |
282 | 281 | // ------------------------------------------------------------------------------------------------ |
283 | 282 | // Читает боевой отчет из БД |
284 | -function sn_ube_report_load($report_cypher) |
|
285 | -{ |
|
283 | +function sn_ube_report_load($report_cypher) { |
|
286 | 284 | $report_cypher = db_escape($report_cypher); |
287 | 285 | |
288 | 286 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
@@ -480,8 +478,7 @@ discard block |
||
480 | 478 | |
481 | 479 | // ------------------------------------------------------------------------------------------------ |
482 | 480 | // Парсит инфу о раунде для темплейта |
483 | -function sn_ube_report_round_fleet(&$combat_data, $round) |
|
484 | -{ |
|
481 | +function sn_ube_report_round_fleet(&$combat_data, $round) { |
|
485 | 482 | global $lang; |
486 | 483 | |
487 | 484 | $fleets_info = &$combat_data[UBE_FLEETS]; |
@@ -535,8 +532,7 @@ discard block |
||
535 | 532 | |
536 | 533 | // ------------------------------------------------------------------------------------------------ |
537 | 534 | // Рендерит таблицу общего результата боя |
538 | -function sn_ube_report_table_render(&$array, $header) |
|
539 | -{ |
|
535 | +function sn_ube_report_table_render(&$array, $header) { |
|
540 | 536 | global $lang; |
541 | 537 | |
542 | 538 | $result = array(); |
@@ -563,8 +559,7 @@ discard block |
||
563 | 559 | |
564 | 560 | // ------------------------------------------------------------------------------------------------ |
565 | 561 | // Генерирует данные для отчета из разобранных данных боя |
566 | -function sn_ube_report_generate(&$combat_data, &$template_result) |
|
567 | -{ |
|
562 | +function sn_ube_report_generate(&$combat_data, &$template_result) { |
|
568 | 563 | if(!is_array($combat_data)) |
569 | 564 | { |
570 | 565 | return; |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | |
93 | 93 | for ($Option = 10; $Option >= 0; $Option--) |
94 | 94 | { |
95 | - $template->assign_block_vars('option', array( |
|
96 | - 'VALUE' => $Option * 10, |
|
97 | - )); |
|
95 | + $template->assign_block_vars('option', array( |
|
96 | + 'VALUE' => $Option * 10, |
|
97 | + )); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $caps_real = eco_get_planet_caps($user, $planetrow, 3600); |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | int_calc_storage_bar(RES_DEUTERIUM); |
164 | 164 | |
165 | 165 | $template->assign_vars(array( |
166 | - 'PLANET_NAME' => $planetrow['name'], |
|
167 | - 'PLANET_TYPE' => $planetrow['planet_type'], |
|
168 | - 'PLANET_DENSITY_INDEX' => $planet_density_index, |
|
169 | - 'PLANET_CORE_TEXT' => $lang['uni_planet_density_types'][$planet_density_index], |
|
166 | + 'PLANET_NAME' => $planetrow['name'], |
|
167 | + 'PLANET_TYPE' => $planetrow['planet_type'], |
|
168 | + 'PLANET_DENSITY_INDEX' => $planet_density_index, |
|
169 | + 'PLANET_CORE_TEXT' => $lang['uni_planet_density_types'][$planet_density_index], |
|
170 | 170 | |
171 | - 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
|
171 | + 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
|
172 | 172 | |
173 | - 'PAGE_HINT' => $lang['res_hint'], |
|
173 | + 'PAGE_HINT' => $lang['res_hint'], |
|
174 | 174 | )); |
175 | 175 | |
176 | 176 | display($template, $lang['res_planet_production']); |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | )); |
47 | 47 | }; |
48 | 48 | |
49 | -$ValidList['percent'] = array ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); |
|
49 | +$ValidList['percent'] = array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100); |
|
50 | 50 | $template = gettemplate('resources', true); |
51 | 51 | |
52 | 52 | $transmutation_result = sn_sys_planet_core_transmute($user, $planetrow); |
53 | -if(!empty($transmutation_result)) |
|
53 | +if (!empty($transmutation_result)) |
|
54 | 54 | { |
55 | 55 | $template->assign_block_vars('result', $transmutation_result); // array('STATUS' => $transmutation_result['STATUS'], 'MESSAGE' => $transmutation_result['MESSAGE'])); |
56 | 56 | } |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | $production = $_POST['production']; |
60 | 60 | //$SubQry = ''; |
61 | 61 | $SubQry = array(); |
62 | -if(is_array($production)) { |
|
63 | - foreach($production as $prod_id => $percent) { |
|
64 | - if($percent > 100 || $percent < 0) { |
|
62 | +if (is_array($production)) { |
|
63 | + foreach ($production as $prod_id => $percent) { |
|
64 | + if ($percent > 100 || $percent < 0) { |
|
65 | 65 | $debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true)); |
66 | 66 | die(); |
67 | 67 | } |
68 | 68 | |
69 | 69 | $prod_id = intval($prod_id); |
70 | - if(in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
|
70 | + if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
|
71 | 71 | $field_name = pname_factory_production_field_name($prod_id); |
72 | 72 | $percent = floor($percent / 10); |
73 | 73 | $planetrow[$field_name] = $percent; |
74 | 74 | //$SubQry .= "`{$field_name}` = '{$percent}',"; |
75 | - $SubQry[] = "`{$field_name}` = '{$percent}'"; |
|
75 | + $SubQry[] = "`{$field_name}` = '{$percent}'"; |
|
76 | 76 | } else { |
77 | 77 | $debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301); |
78 | 78 | continue; |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | 'ENERGY_TYPE' => pretty_number($caps_real['production'][RES_ENERGY][0], true, true), |
109 | 109 | )); |
110 | 110 | |
111 | -foreach($sn_group_factories as $unit_id) |
|
111 | +foreach ($sn_group_factories as $unit_id) |
|
112 | 112 | { |
113 | - if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
|
113 | + if (mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
|
114 | 114 | { |
115 | 115 | $level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true); |
116 | 116 | $template->assign_block_vars('production', array( |
@@ -24,8 +24,7 @@ |
||
24 | 24 | |
25 | 25 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
26 | 26 | |
27 | -function int_calc_storage_bar($resource_id) |
|
28 | -{ |
|
27 | +function int_calc_storage_bar($resource_id) { |
|
29 | 28 | global $lang, $template, $caps_real, $planetrow, $user; |
30 | 29 | |
31 | 30 | $totalProduction = $caps_real['total'][$resource_id]; |
@@ -39,8 +39,8 @@ |
||
39 | 39 | 0 => $row['visit_time'], // start |
40 | 40 | 1 => $row['visit_time'], // end |
41 | 41 | ) |
42 | - //: false |
|
43 | - ; |
|
42 | + //: false |
|
43 | + ; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $session_list = array(); |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | // define('SESSION_INTERRUPT', 15*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
20 | 20 | // define('SUSPICIOUS_LONG', 2 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
21 | 21 | |
22 | -define('SESSION_INTERRUPT', 1 * 60*60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
|
23 | -define('SUSPICIOUS_LONG', 16 * 60*60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
|
22 | +define('SESSION_INTERRUPT', 1 * 60 * 60); // Можно увеличить до 4 часов - никито не может сидеть 2 суток с перерывом менее 4 часов |
|
23 | +define('SUSPICIOUS_LONG', 16 * 60 * 60); // Тогда это увеличиваем до, скажем суток - и там смотрим |
|
24 | 24 | |
25 | 25 | |
26 | 26 | function check_suspicious(&$session, &$session_list_last_id, &$row) { |
27 | 27 | $session[2] = $session[1] - $session[0]; |
28 | - if($session[2] > SUSPICIOUS_LONG) |
|
28 | + if ($session[2] > SUSPICIOUS_LONG) |
|
29 | 29 | { |
30 | 30 | $session[2] = pretty_time($session[2]); |
31 | 31 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | $session_list = array(); |
47 | 47 | $query = doquery("SELECT `visit_time`, user_id FROM {{counter}} where user_id <> 0 and visit_time > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) order by user_id, visit_time;"); |
48 | 48 | $session = array(); |
49 | -if($row = db_fetch($query)) { |
|
49 | +if ($row = db_fetch($query)) { |
|
50 | 50 | $session = array( |
51 | 51 | 0 => strtotime($row['visit_time']), // start |
52 | 52 | 1 => strtotime($row['visit_time']), // end |
53 | 53 | ); |
54 | 54 | $last_id = $row['user_id']; |
55 | 55 | } |
56 | -while($row = db_fetch($query)) { |
|
56 | +while ($row = db_fetch($query)) { |
|
57 | 57 | $row['visit_time'] = strtotime($row['visit_time']); |
58 | - if($last_id == $row['user_id']) { |
|
58 | + if ($last_id == $row['user_id']) { |
|
59 | 59 | // Тот же юзер |
60 | - if($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия |
|
60 | + if ($row['visit_time'] - $session[1] <= SESSION_INTERRUPT) { // Та же сессия |
|
61 | 61 | $session[1] = $row['visit_time']; |
62 | 62 | } else { |
63 | 63 | // Новая сессия |
64 | 64 | // check_suspicious($session, $session_list[$last_id], $row); |
65 | 65 | $session[2] = $session[1] - $session[0]; |
66 | - if($session[2] > SUSPICIOUS_LONG) |
|
66 | + if ($session[2] > SUSPICIOUS_LONG) |
|
67 | 67 | { |
68 | 68 | $session[2] = pretty_time($session[2]); |
69 | 69 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } else { |
79 | 79 | // check_suspicious($session, $session_list[$last_id], $row); |
80 | 80 | $session[2] = $session[1] - $session[0]; |
81 | - if($session[2] > SUSPICIOUS_LONG) |
|
81 | + if ($session[2] > SUSPICIOUS_LONG) |
|
82 | 82 | { |
83 | 83 | $session[2] = pretty_time($session[2]); |
84 | 84 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if($last_id) { |
|
96 | +if ($last_id) { |
|
97 | 97 | // check_suspicious($session, $session_list[$last_id], $row = array('time' => 0)); |
98 | 98 | $session[2] = $session[1] - $session[0]; |
99 | 99 | |
100 | - if($session[2] > SUSPICIOUS_LONG) |
|
100 | + if ($session[2] > SUSPICIOUS_LONG) |
|
101 | 101 | { |
102 | 102 | $session[2] = pretty_time($session[2]); |
103 | 103 | $session[0] = date(FMT_DATE_TIME_SQL, $session[0]); |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | print("<td>ID</td><td>Username</td><td>Start</td><td>End</td><td>Length</td>"); |
112 | 112 | print("<td>Last online</td>"); |
113 | 113 | print("</tr>"); |
114 | -foreach($session_list as $user_id => $value) { |
|
114 | +foreach ($session_list as $user_id => $value) { |
|
115 | 115 | $user_record = doquery("SELECT `username`, onlinetime FROM {{users}} WHERE id = {$user_id};", true); |
116 | - foreach($value as $interval_data) { |
|
116 | + foreach ($value as $interval_data) { |
|
117 | 117 | print("<tr>"); |
118 | 118 | print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>"); |
119 | 119 | print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
@@ -22,12 +22,10 @@ discard block |
||
22 | 22 | if($delete = sys_get_param_id('delete')) |
23 | 23 | { |
24 | 24 | doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;"); |
25 | -} |
|
26 | -elseif(sys_get_param_str('delete_update_info')) |
|
25 | +} elseif(sys_get_param_str('delete_update_info')) |
|
27 | 26 | { |
28 | 27 | doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);"); |
29 | -} |
|
30 | -elseif(sys_get_param_str('deleteall') == 'yes') |
|
28 | +} elseif(sys_get_param_str('deleteall') == 'yes') |
|
31 | 29 | { |
32 | 30 | // doquery("TRUNCATE TABLE `{{logs}}`"); |
33 | 31 | } |
@@ -51,8 +49,7 @@ discard block |
||
51 | 49 | } |
52 | 50 | } |
53 | 51 | $template->assign_vars($errorInfo); |
54 | -} |
|
55 | -else |
|
52 | +} else |
|
56 | 53 | { |
57 | 54 | $template = gettemplate('admin/adm_log_main', true); |
58 | 55 |
@@ -18,26 +18,26 @@ discard block |
||
18 | 18 | |
19 | 19 | messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
20 | 20 | |
21 | -if($delete = sys_get_param_id('delete')) |
|
21 | +if ($delete = sys_get_param_id('delete')) |
|
22 | 22 | { |
23 | 23 | doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;"); |
24 | 24 | } |
25 | -elseif(sys_get_param_str('delete_update_info')) |
|
25 | +elseif (sys_get_param_str('delete_update_info')) |
|
26 | 26 | { |
27 | 27 | doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);"); |
28 | 28 | } |
29 | -elseif(sys_get_param_str('deleteall') == 'yes') |
|
29 | +elseif (sys_get_param_str('deleteall') == 'yes') |
|
30 | 30 | { |
31 | 31 | // doquery("TRUNCATE TABLE `{{logs}}`"); |
32 | 32 | } |
33 | 33 | |
34 | -if($detail = sys_get_param_id('detail')) |
|
34 | +if ($detail = sys_get_param_id('detail')) |
|
35 | 35 | { |
36 | 36 | $template = gettemplate('admin/adm_log_main_detail', true); |
37 | 37 | |
38 | 38 | $errorInfo = doquery("SELECT * FROM `{{logs}}` WHERE `log_id` = {$detail} LIMIT 1;", true); |
39 | 39 | $error_dump = unserialize($errorInfo['log_dump']); |
40 | - if(is_array($error_dump)) |
|
40 | + if (is_array($error_dump)) |
|
41 | 41 | { |
42 | 42 | foreach ($error_dump as $key => $value) |
43 | 43 | { |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | |
58 | 58 | $i = 0; |
59 | 59 | $query = doquery("SELECT * FROM `{{logs}}` ORDER BY log_id DESC LIMIT 100;"); |
60 | - while($u = db_fetch($query)) |
|
60 | + while ($u = db_fetch($query)) |
|
61 | 61 | { |
62 | 62 | $i++; |
63 | 63 | $v = array(); |
64 | - foreach($u as $key => $value) |
|
64 | + foreach ($u as $key => $value) |
|
65 | 65 | { |
66 | 66 | $v[strtoupper($key)] = $value; |
67 | 67 | } |
@@ -72,8 +72,7 @@ |
||
72 | 72 | if(sys_get_param('page_prev') && $int_page_current > 1) |
73 | 73 | { |
74 | 74 | $int_page_current--; |
75 | -} |
|
76 | -elseif(sys_get_param('page_next') && $int_page_current < $page_max) |
|
75 | +} elseif(sys_get_param('page_next') && $int_page_current < $page_max) |
|
77 | 76 | { |
78 | 77 | $int_page_current++; |
79 | 78 | } |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -define('INSIDE' , true); |
|
12 | -define('INSTALL' , false); |
|
11 | +define('INSIDE', true); |
|
12 | +define('INSTALL', false); |
|
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | |
15 | 15 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | $template->assign_block_vars('int_type_selected', $allowed_types[-1]); |
31 | -foreach($sn_message_class_list as $key => $value) |
|
31 | +foreach ($sn_message_class_list as $key => $value) |
|
32 | 32 | { |
33 | - if($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) |
|
33 | + if ($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) |
|
34 | 34 | { |
35 | 35 | continue; |
36 | 36 | } |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | |
44 | 44 | |
45 | 45 | $message_delete = sys_get_param_id('msg_del'); |
46 | -if(sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) |
|
46 | +if (sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) |
|
47 | 47 | { |
48 | 48 | $message_delete = implode(', ', $message_delete); |
49 | 49 | } |
50 | 50 | |
51 | -if($message_delete) |
|
51 | +if ($message_delete) |
|
52 | 52 | { |
53 | 53 | doquery("DELETE FROM {{messages}} WHERE `message_id` in ({$message_delete});"); |
54 | 54 | $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['mlst_messages_deleted'], $message_delete))); |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | -if(sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) |
|
58 | +if (sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) |
|
59 | 59 | { |
60 | 60 | $delete_date = "{$year}-{$month}-{$day}"; |
61 | 61 | doquery("DELETE FROM {{messages}} WHERE message_time <= UNIX_TIMESTAMP('{$delete_date}')" . ($int_type_selected >= 0 ? " AND `message_type` = {$int_type_selected}" : '')); |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | |
69 | 69 | $int_page_current = min(sys_get_param_id('int_page_current', 1), $page_max); |
70 | 70 | |
71 | -if(sys_get_param('page_prev') && $int_page_current > 1) |
|
71 | +if (sys_get_param('page_prev') && $int_page_current > 1) |
|
72 | 72 | { |
73 | 73 | $int_page_current--; |
74 | 74 | } |
75 | -elseif(sys_get_param('page_next') && $int_page_current < $page_max) |
|
75 | +elseif (sys_get_param('page_next') && $int_page_current < $page_max) |
|
76 | 76 | { |
77 | 77 | $int_page_current++; |
78 | 78 | } |
79 | 79 | |
80 | -for($i = 1; $i <= $page_max; $i++) |
|
80 | +for ($i = 1; $i <= $page_max; $i++) |
|
81 | 81 | { |
82 | 82 | $template->assign_block_vars('page', array('NUMBER' => $i)); |
83 | 83 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $StartRec = ($int_page_current - 1) * 25; |
86 | 86 | |
87 | 87 | $Messages = db_message_list_admin_by_type($int_type_selected, $StartRec); |
88 | -while($row = db_fetch($Messages)) |
|
88 | +while ($row = db_fetch($Messages)) |
|
89 | 89 | { |
90 | 90 | $row['FROM'] = htmlentities($row['FROM'], ENT_COMPAT, 'UTF-8'); |
91 | 91 | $row['OWNER_NAME'] = htmlentities($row['OWNER_NAME'], ENT_COMPAT, 'UTF-8'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
|
3 | +function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list)); } |
|
4 | 4 | function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
5 | 5 | { |
6 | 6 | global $lang; |
@@ -19,19 +19,19 @@ discard block |
||
19 | 19 | return $mode; |
20 | 20 | } |
21 | 21 | |
22 | -function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));} |
|
22 | +function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode)); } |
|
23 | 23 | function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) |
24 | 24 | { |
25 | 25 | global $lang; |
26 | 26 | |
27 | 27 | $unit_list = sn_get_groups($mode); |
28 | - if(empty($unit_list)) |
|
28 | + if (empty($unit_list)) |
|
29 | 29 | { |
30 | 30 | return; |
31 | 31 | } |
32 | 32 | $name_list = $lang['tech']; |
33 | 33 | |
34 | - foreach($unit_list as $unit_id) |
|
34 | + foreach ($unit_list as $unit_id) |
|
35 | 35 | { |
36 | 36 | $template->assign_block_vars('unit', array( |
37 | 37 | 'ID' => $unit_id, |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | -function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
|
45 | +function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode)); } |
|
46 | 46 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
47 | 47 | { |
48 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
48 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
|
49 | 49 | { |
50 | 50 | $unit_amount = round($unit_amount); |
51 | 51 | $unit_name = get_unit_param($unit_id, P_NAME); |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));} |
4 | -function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) |
|
5 | -{ |
|
4 | +function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) { |
|
6 | 5 | global $lang; |
7 | 6 | |
8 | 7 | $admin_planet_edit_mode_list = array_merge(isset($admin_planet_edit_mode_list) ? $admin_planet_edit_mode_list : array(), array( |
@@ -20,8 +19,7 @@ discard block |
||
20 | 19 | } |
21 | 20 | |
22 | 21 | function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));} |
23 | -function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) |
|
24 | -{ |
|
22 | +function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
|
25 | 23 | global $lang; |
26 | 24 | |
27 | 25 | $unit_list = sn_get_groups($mode); |
@@ -43,15 +41,13 @@ discard block |
||
43 | 41 | } |
44 | 42 | |
45 | 43 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));} |
46 | -function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) |
|
47 | -{ |
|
44 | +function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
|
48 | 45 | if($unit_amount && in_array($unit_id, sn_get_groups($mode))) |
49 | 46 | { |
50 | 47 | $unit_amount = round($unit_amount); |
51 | 48 | $unit_name = get_unit_param($unit_id, P_NAME); |
52 | 49 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
53 | - } |
|
54 | - else |
|
50 | + } else |
|
55 | 51 | { |
56 | 52 | $result = ''; |
57 | 53 | } |