@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | function pname_factory_production_field_name($factory_unit_id) |
6 | 6 | { |
7 | - return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
|
7 | + return get_unit_param($factory_unit_id, P_NAME).'_porcent'; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | function flt_mission_explore(&$mission_data) { |
21 | 21 | static $ship_data, $rates; |
22 | 22 | |
23 | - if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
23 | + if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
24 | 24 | return CACHE_NONE; |
25 | 25 | } |
26 | 26 | |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $outcome_value = &$result['$outcome_value']; |
46 | 46 | $outcome_list = &$result['$outcome_list']; |
47 | 47 | |
48 | - if(!$ship_data) { |
|
49 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
48 | + if (!$ship_data) { |
|
49 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
50 | 50 | $unit_info = get_unit_param($unit_id); |
51 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
51 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
52 | 52 | continue; |
53 | 53 | } |
54 | 54 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $max_metal_cost = 0; |
60 | 60 | $fleet_real_array = $objFleet->shipsGetArray(); |
61 | - foreach($fleet_real_array as $ship_id => $ship_amount) { |
|
61 | + foreach ($fleet_real_array as $ship_id => $ship_amount) { |
|
62 | 62 | $ship_cost_in_metal = $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
63 | 63 | $result['$fleet_metal_points'] += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
64 | 64 | // Рассчитываем стоимость самого дорого корабля в металле |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
73 | 73 | |
74 | 74 | $chance_max = 0; |
75 | - foreach($outcome_list as $key => &$value) { |
|
76 | - if(!$value['chance']) { |
|
75 | + foreach ($outcome_list as $key => &$value) { |
|
76 | + if (!$value['chance']) { |
|
77 | 77 | unset($outcome_list[$key]); |
78 | 78 | continue; |
79 | 79 | } |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | } |
82 | 82 | $outcome_value = mt_rand(0, $chance_max); |
83 | 83 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
84 | - foreach($outcome_list as $key => &$value) { |
|
85 | - if(!$value['chance']) { |
|
84 | + foreach ($outcome_list as $key => &$value) { |
|
85 | + if (!$value['chance']) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | $mission_outcome = $key; |
89 | 89 | $outcome_description = $value; |
90 | - if($outcome_value <= $outcome_description['value']) { |
|
90 | + if ($outcome_value <= $outcome_description['value']) { |
|
91 | 91 | break; |
92 | 92 | } |
93 | 93 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // $outcome_mission_sub = -1; |
105 | 105 | |
106 | 106 | $fleet_found = array(); |
107 | - switch($mission_outcome) { |
|
107 | + switch ($mission_outcome) { |
|
108 | 108 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
109 | 109 | $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000); |
110 | 110 | break; |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | |
126 | 126 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
127 | 127 | $can_be_found = array(); |
128 | - foreach($ship_data as $ship_id => $ship_info) { |
|
129 | - if($ship_info['metal_cost'] < $max_metal_cost) { |
|
128 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
129 | + if ($ship_info['metal_cost'] < $max_metal_cost) { |
|
130 | 130 | $can_be_found[$ship_id] = $ship_info['metal_cost']; |
131 | 131 | } |
132 | 132 | } |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | unset($can_be_found[SHIP_COLONIZER]); |
135 | 135 | unset($can_be_found[SHIP_SPY]); |
136 | 136 | |
137 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
137 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
138 | 138 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
139 | 139 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
140 | 140 | $found_ship_cost = reset($found_ship); |
141 | 141 | $found_ship_id = key($found_ship); |
142 | 142 | |
143 | - if($found_ship_cost > $found_in_metal) { |
|
143 | + if ($found_ship_cost > $found_in_metal) { |
|
144 | 144 | unset($can_be_found[$found_ship_id]); |
145 | 145 | } else { |
146 | 146 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if(empty($fleet_found)) { |
|
152 | + if (empty($fleet_found)) { |
|
153 | 153 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
154 | 154 | } else { |
155 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
155 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
156 | 156 | $objFleet->shipAdjustCount($unit_id, $unit_amount); |
157 | 157 | } |
158 | 158 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $objFleet->resourcesAdjust($resources_found); |
178 | 178 | |
179 | - if(array_sum($resources_found) == 0) { |
|
179 | + if (array_sum($resources_found) == 0) { |
|
180 | 180 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
181 | 181 | } |
182 | 182 | break; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // Рассчитываем количество найденной ТМ |
188 | 188 | $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
189 | 189 | |
190 | - if(!$found_dark_matter) { |
|
190 | + if (!$found_dark_matter) { |
|
191 | 191 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
192 | 192 | } |
193 | 193 | break; |
@@ -201,46 +201,45 @@ discard block |
||
201 | 201 | |
202 | 202 | mission_expedition_result_adjust($result, $objFleet); |
203 | 203 | |
204 | - if($found_dark_matter) { |
|
204 | + if ($found_dark_matter) { |
|
205 | 205 | rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
206 | 206 | $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
207 | 207 | } |
208 | 208 | |
209 | - if(!empty($fleet_lost)) { |
|
209 | + if (!empty($fleet_lost)) { |
|
210 | 210 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet']; |
211 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
212 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
211 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
212 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if(!empty($fleet_found)) { |
|
216 | + if (!empty($fleet_found)) { |
|
217 | 217 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet']; |
218 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
219 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
218 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
219 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
223 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
224 | 224 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources']; |
225 | - foreach($resources_found as $resource_id => $resource_amount) { |
|
226 | - $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n"; |
|
225 | + foreach ($resources_found as $resource_id => $resource_amount) { |
|
226 | + $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n"; |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - if(!$msg_text) { |
|
230 | + if (!$msg_text) { |
|
231 | 231 | $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
232 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
232 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
233 | 233 | $messages = &$messages[$outcome_mission_sub]; |
234 | 234 | } |
235 | 235 | |
236 | - $msg_text = is_string($messages) ? $messages : |
|
237 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
236 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
238 | 237 | } |
239 | 238 | |
240 | 239 | $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type(); |
241 | 240 | |
242 | - $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) . |
|
243 | - ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
241 | + $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)). |
|
242 | + ($msg_text_addon ? "\r\n".$msg_text_addon : ''); |
|
244 | 243 | |
245 | 244 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
246 | 245 |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | */ |
12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
13 | 13 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
14 | - foreach($unit_group as $unit_id) { |
|
15 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
14 | + foreach ($unit_group as $unit_id) { |
|
15 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
16 | 16 | $compress_data[$unit_id] = $unit_count; |
17 | 17 | } |
18 | 18 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | $classLocale = classLocale::$lang; |
23 | 23 | |
24 | 24 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
25 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
26 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
25 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
26 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
27 | 27 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
28 | 28 | } |
29 | 29 | |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | |
56 | 56 | $objFleet = $mission_data->fleet; |
57 | 57 | |
58 | - if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
58 | + if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
59 | 59 | $objFleet->markReturnedAndSave(); |
60 | 60 | |
61 | 61 | return $result; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY); |
65 | - if($spy_probes > 0) { |
|
65 | + if ($spy_probes > 0) { |
|
66 | 66 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
67 | 67 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
68 | 68 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -80,26 +80,26 @@ discard block |
||
80 | 80 | $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} "; |
81 | 81 | $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target); |
82 | 82 | $spy_message .= "</td></tr><tr>"; |
83 | - $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>"; |
|
84 | - $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>"; |
|
83 | + $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>"; |
|
84 | + $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>"; |
|
85 | 85 | $spy_message .= "</tr><tr>"; |
86 | - $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
|
87 | - $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
|
86 | + $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>"; |
|
87 | + $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>"; |
|
88 | 88 | $spy_message .= "</tr>"; |
89 | - if($spy_diff >= 2) { |
|
90 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
|
89 | + if ($spy_diff >= 2) { |
|
90 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>"; |
|
91 | 91 | coe_compress_add_units(sn_get_groups('fleet'), $target_planet_row, $combat_pack[0]); |
92 | 92 | } |
93 | - if($spy_diff >= 3) { |
|
94 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
|
93 | + if ($spy_diff >= 3) { |
|
94 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>"; |
|
95 | 95 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
96 | 96 | } |
97 | - if($spy_diff >= 5) { |
|
98 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
|
97 | + if ($spy_diff >= 5) { |
|
98 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>"; |
|
99 | 99 | } |
100 | 100 | |
101 | - if($spy_diff_empire >= 0) { |
|
102 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
|
101 | + if ($spy_diff_empire >= 0) { |
|
102 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>"; |
|
103 | 103 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
104 | 104 | } |
105 | 105 | // TODO: Наемники, губернаторы, артефакты и прочее имперское |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
108 | 108 | |
109 | 109 | $target_unit_list = 0; |
110 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
110 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
111 | 111 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
115 | 115 | |
116 | - if(mt_rand(0, 99) > $spy_detected) { |
|
116 | + if (mt_rand(0, 99) > $spy_detected) { |
|
117 | 117 | $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected); |
118 | 118 | $spy_detected = false; |
119 | 119 | } else { |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | |
131 | 131 | msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message); |
132 | 132 | |
133 | - $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
|
134 | - $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
|
133 | + $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3); |
|
134 | + $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row); |
|
135 | 135 | |
136 | - if($spy_detected) { |
|
136 | + if ($spy_detected) { |
|
137 | 137 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
138 | 138 | |
139 | 139 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
140 | 140 | |
141 | 141 | db_planet_set_by_id($debris_planet_id, |
142 | - "`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)); |
|
142 | + "`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)); |
|
143 | 143 | |
144 | 144 | $target_message .= "<br />{$classLocale['sys_mess_spy_destroyed_enemy']}"; |
145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message); |
151 | 151 | } |
152 | 152 | |
153 | - if($spy_detected) { |
|
153 | + if ($spy_detected) { |
|
154 | 154 | $objFleet->dbDelete(); |
155 | 155 | } else { |
156 | 156 | $objFleet->markReturnedAndSave(); |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | global $template_result; |
20 | 20 | $classLocale = classLocale::$lang; |
21 | 21 | |
22 | - if($ally_id = sys_get_param_id('ally_id')) { |
|
22 | + if ($ally_id = sys_get_param_id('ally_id')) { |
|
23 | 23 | define('SN_IN_ALLY', true); |
24 | 24 | $ranks = ally_get_ranks($auser['ally']); |
25 | - if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
25 | + if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
26 | 26 | $user = &$auser['ally']['player']; |
27 | 27 | $planet = array( |
28 | 28 | 'metal' => $user['metal'], |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - if(!$user) { |
|
35 | + if (!$user) { |
|
36 | 36 | $user = &$auser; |
37 | 37 | } |
38 | 38 | |
39 | - switch($action = sys_get_param_escaped('action')) { |
|
39 | + switch ($action = sys_get_param_escaped('action')) { |
|
40 | 40 | case 'create': // Add unit to que for build |
41 | 41 | case 'create_autoconvert': // Add unit to que for build |
42 | 42 | case 'destroy': // Add unit to que for remove |
@@ -53,28 +53,28 @@ discard block |
||
53 | 53 | |
54 | 54 | $group_missile = sn_get_groups('missile'); |
55 | 55 | $silo_capacity_free = 0; |
56 | - if($que_type == QUE_STRUCTURES) { |
|
56 | + if ($que_type == QUE_STRUCTURES) { |
|
57 | 57 | $build_unit_list = sn_get_groups('build_allow'); |
58 | 58 | $build_unit_list = $build_unit_list[$planet['planet_type']]; |
59 | 59 | $artifact_id = ART_NANO_BUILDER; |
60 | 60 | $page_header = classLocale::$lang['tech'][UNIT_STRUCTURES]; |
61 | - } elseif($que_type == QUE_RESEARCH) { |
|
62 | - if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
61 | + } elseif ($que_type == QUE_RESEARCH) { |
|
62 | + if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
63 | 63 | message(classLocale::$lang['no_laboratory'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
64 | 64 | } |
65 | 65 | |
66 | - if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
66 | + if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
67 | 67 | message(classLocale::$lang['eco_bld_msg_err_laboratory_upgrading'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
68 | 68 | } |
69 | 69 | $build_unit_list = sn_get_groups('tech'); |
70 | 70 | $artifact_id = ART_HEURISTIC_CHIP; |
71 | - $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
72 | - } elseif($que_type == QUE_MERCENARY) { |
|
71 | + $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES].($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
72 | + } elseif ($que_type == QUE_MERCENARY) { |
|
73 | 73 | $build_unit_list = sn_get_groups('mercenaries'); |
74 | 74 | $artifact_id = 0; |
75 | - $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
75 | + $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES].($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
76 | 76 | } else { |
77 | - if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
77 | + if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
78 | 78 | message(classLocale::$lang['need_hangar'], classLocale::$lang['tech'][STRUC_FACTORY_HANGAR]); |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $artifact_id = 0; |
84 | 84 | |
85 | 85 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY); |
86 | - foreach($group_missile as $unit_id) { |
|
86 | + foreach ($group_missile as $unit_id) { |
|
87 | 87 | $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE); |
88 | 88 | } |
89 | 89 | $silo_capacity_free = max(0, $silo_capacity_free); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
95 | 95 | |
96 | 96 | $template = gettemplate('buildings_builds', true); |
97 | - if(!empty($operation_result)) { |
|
97 | + if (!empty($operation_result)) { |
|
98 | 98 | $template_result['.']['result'][] = $operation_result; |
99 | 99 | } |
100 | 100 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $record_index = 0; |
126 | 126 | |
127 | - foreach($build_unit_list as $unit_id) { |
|
127 | + foreach ($build_unit_list as $unit_id) { |
|
128 | 128 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true); |
129 | 129 | $level_effective = mrc_get_level($user, $planet, $unit_id); |
130 | 130 | $level_in_que = $in_que[$unit_id]; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE]; |
148 | 148 | // Restricting $can_build by free silo capacity |
149 | 149 | $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build; |
150 | - if(!$can_build) { |
|
151 | - if(!$build_data['CAN'][BUILD_CREATE]) { |
|
150 | + if (!$can_build) { |
|
151 | + if (!$build_data['CAN'][BUILD_CREATE]) { |
|
152 | 152 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES; |
153 | - } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
153 | + } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
154 | 154 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL; |
155 | - } elseif($unit_info[P_MAX_STACK]) { |
|
155 | + } elseif ($unit_info[P_MAX_STACK]) { |
|
156 | 156 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED; |
157 | 157 | } |
158 | 158 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]), |
220 | 220 | ); |
221 | 221 | |
222 | - if($unit_stackable) { |
|
222 | + if ($unit_stackable) { |
|
223 | 223 | $level_production_base = array( |
224 | 224 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), |
225 | 225 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), |
226 | 226 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])), |
227 | 227 | ); |
228 | 228 | |
229 | - if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
229 | + if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
230 | 230 | $ship_data = get_ship_data($unit_id, $user); |
231 | 231 | |
232 | 232 | $level_production_base += array( |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | ); |
237 | 237 | } |
238 | 238 | |
239 | - if($unit_info[P_UNIT_PRODUCTION]) { |
|
240 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
241 | - if($resource_income = |
|
239 | + if ($unit_info[P_UNIT_PRODUCTION]) { |
|
240 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
241 | + if ($resource_income = |
|
242 | 242 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) |
243 | 243 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
244 | 244 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
245 | 245 | ) { |
246 | - $level_production_base['R' . $resource_id] = $resource_income; |
|
246 | + $level_production_base['R'.$resource_id] = $resource_income; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | $production['.']['resource'][] = $level_production_base; |
251 | - } elseif($unit_info[P_UNIT_PRODUCTION]) { |
|
251 | + } elseif ($unit_info[P_UNIT_PRODUCTION]) { |
|
252 | 252 | $level_production_base = array(); |
253 | 253 | $element_level_start = $level_effective + $in_que[$unit_id]; |
254 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
255 | - if($resource_income = |
|
254 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
255 | + if ($resource_income = |
|
256 | 256 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) |
257 | 257 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
258 | 258 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -262,21 +262,21 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
265 | - for($i = 0; $i < 6; $i++) { |
|
265 | + for ($i = 0; $i < 6; $i++) { |
|
266 | 266 | $level_production = array('LEVEL' => $level_start + $i); |
267 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | - if( |
|
267 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | + if ( |
|
269 | 269 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) |
270 | 270 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
271 | 271 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
272 | 272 | ) { |
273 | - $level_production['R' . $resource_id] = $resource_income; |
|
274 | - $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id]; |
|
273 | + $level_production['R'.$resource_id] = $resource_income; |
|
274 | + $level_production['D'.$resource_id] = $resource_income - $level_production_base[$resource_id]; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | $production['.']['resource'][] = $level_production; |
278 | 278 | } |
279 | - } elseif($unit_id == TECH_ASTROTECH) { |
|
279 | + } elseif ($unit_id == TECH_ASTROTECH) { |
|
280 | 280 | $element_level_start = $level_effective + $in_que[$unit_id]; |
281 | 281 | $level_production_base = array( |
282 | 282 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | ); |
285 | 285 | |
286 | 286 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
287 | - for($i = 0; $i < 6; $i++) { |
|
287 | + for ($i = 0; $i < 6; $i++) { |
|
288 | 288 | $level_production = array('LEVEL' => $level_start + $i); |
289 | - $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
|
290 | - $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
|
291 | - $level_production['R' . UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i); |
|
292 | - $level_production['D' . UNIT_PLAYER_COLONIES_MAX] = $level_production['R' . UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX]; |
|
289 | + $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
|
290 | + $level_production['D'.UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
|
291 | + $level_production['R'.UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i); |
|
292 | + $level_production['D'.UNIT_PLAYER_COLONIES_MAX] = $level_production['R'.UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX]; |
|
293 | 293 | $production['.']['resource'][] = $level_production; |
294 | 294 | |
295 | 295 | $level_production_base = array( |
296 | - UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX], |
|
297 | - UNIT_PLAYER_COLONIES_MAX => $level_production['R' . UNIT_PLAYER_COLONIES_MAX], |
|
296 | + UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX], |
|
297 | + UNIT_PLAYER_COLONIES_MAX => $level_production['R'.UNIT_PLAYER_COLONIES_MAX], |
|
298 | 298 | ); |
299 | 299 | } |
300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $template_result['.']['production'][] = $production; |
306 | 306 | } |
307 | 307 | |
308 | - foreach(classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
308 | + foreach (classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
309 | 309 | $template->assign_block_vars('sort_values', array( |
310 | 310 | 'VALUE' => $sort_id, |
311 | 311 | 'TEXT' => $sort_text, |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | function art_use(&$user, &$planetrow, $unit_id) { |
4 | 4 | $classLocale = classLocale::$lang; |
5 | 5 | |
6 | - if(!in_array($unit_id, sn_get_groups('artifacts'))) { |
|
6 | + if (!in_array($unit_id, sn_get_groups('artifacts'))) { |
|
7 | 7 | return; |
8 | 8 | } |
9 | 9 | |
@@ -11,21 +11,21 @@ discard block |
||
11 | 11 | $user = db_user_by_id($user['id'], true); |
12 | 12 | |
13 | 13 | $unit_level = $artifact_level_old = mrc_get_level($user, null, $unit_id, true); |
14 | - if($unit_level > 0) { |
|
14 | + if ($unit_level > 0) { |
|
15 | 15 | $db_changeset = array(); |
16 | - switch($unit_id) { |
|
16 | + switch ($unit_id) { |
|
17 | 17 | case ART_LHC: |
18 | 18 | case ART_HOOK_SMALL: |
19 | 19 | case ART_HOOK_MEDIUM: |
20 | 20 | case ART_HOOK_LARGE: |
21 | 21 | $has_moon = db_planet_by_parent($planetrow['id'], true, '`id`'); |
22 | - if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) { |
|
22 | + if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) { |
|
23 | 23 | $unit_level--; |
24 | 24 | $moon_chance = $unit_id == ART_LHC ? uni_calculate_moon_chance($planetrow['debris_metal'] + $planetrow['debris_crystal']) : ( |
25 | 25 | $unit_id == ART_HOOK_MEDIUM ? mt_rand(1100, 8999) : ($unit_id == ART_HOOK_SMALL ? 1100 : 8999) |
26 | 26 | ); |
27 | 27 | $random = $unit_id == ART_LHC ? mt_rand(1, 100) : $moon_chance; |
28 | - if($random <= $moon_chance) { |
|
28 | + if ($random <= $moon_chance) { |
|
29 | 29 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance); |
30 | 30 | $message = sprintf(classLocale::$lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), pretty_number($moon_chance)); |
31 | 31 | } else { |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | case ART_RCD_MEDIUM: |
42 | 42 | case ART_RCD_LARGE: |
43 | 43 | $planetrow = db_planet_by_id($planetrow['id'], true); |
44 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
44 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
45 | 45 | $message = classLocale::$lang['art_rcd_err_moon']; |
46 | 46 | break; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false); |
50 | - if(!empty($que['items'])) { |
|
50 | + if (!empty($que['items'])) { |
|
51 | 51 | $message = classLocale::$lang['art_rcd_err_que']; |
52 | 52 | break; |
53 | 53 | } |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | // $deployment_str = ''; |
58 | 58 | $sectors_used = 0; |
59 | - foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) { |
|
60 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
59 | + foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level) { |
|
60 | + if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | $sectors_used += $levels_deployed; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | //$deployment_str .= ",`{$deploy_unit_name}` = GREATEST(`{$deploy_unit_name}`, {$deploy_unit_level})"; |
67 | 67 | } |
68 | 68 | |
69 | - if($sectors_used == 0) { |
|
69 | + if ($sectors_used == 0) { |
|
70 | 70 | $message = classLocale::$lang['art_rcd_err_no_sense']; |
71 | 71 | break; |
72 | 72 | } |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | $que_item = null; |
81 | 81 | $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true); |
82 | 82 | $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0]; |
83 | - if(!empty($current_que)) { |
|
83 | + if (!empty($current_que)) { |
|
84 | 84 | reset($current_que); |
85 | 85 | $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)]; |
86 | 86 | } |
87 | 87 | |
88 | - if(!empty($que_item) && $que_item['que_time_left'] > 60) { |
|
88 | + if (!empty($que_item) && $que_item['que_time_left'] > 60) { |
|
89 | 89 | $unit_level--; |
90 | 90 | $old_time = $que_item['que_time_left']; |
91 | 91 | $que_item['que_time_left'] = $que_item['que_time_left'] > PERIOD_HOUR ? ceil($que_item['que_time_left'] / 2) : 0; |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true); |
104 | 104 | $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']]; |
105 | 105 | // $que_item = &$que['que'][QUE_STRUCTURES][0]; |
106 | - if(!empty($current_que)) { |
|
106 | + if (!empty($current_que)) { |
|
107 | 107 | reset($current_que); |
108 | 108 | $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)]; |
109 | 109 | } |
110 | 110 | |
111 | - if(isset($que_item) && $que_item['que_time_left'] > 60) { |
|
111 | + if (isset($que_item) && $que_item['que_time_left'] > 60) { |
|
112 | 112 | $unit_level--; |
113 | 113 | $old_time = $que_item['que_time_left']; |
114 | 114 | $que_item['que_time_left'] = $que_item['que_time_left'] > PERIOD_HOUR ? ceil($que_item['que_time_left'] / 2) : 0; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | break; |
124 | 124 | |
125 | 125 | } |
126 | - if($unit_level != $artifact_level_old) { |
|
126 | + if ($unit_level != $artifact_level_old) { |
|
127 | 127 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_level - $artifact_level_old, $user); |
128 | 128 | db_changeset_apply($db_changeset); |
129 | 129 | } |
@@ -133,6 +133,6 @@ discard block |
||
133 | 133 | |
134 | 134 | sn_db_transaction_commit(); |
135 | 135 | message($message, "{$classLocale['tech'][UNIT_ARTIFACTS]} - {$classLocale['tech'][$unit_id]}", |
136 | - ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts' . DOT_PHP_EX . '#' . $unit_id), |
|
136 | + ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts'.DOT_PHP_EX.'#'.$unit_id), |
|
137 | 137 | 5); |
138 | 138 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | print($round); |
28 | 28 | print('<table border=1>'); |
29 | 29 | print('<tr align="left">'); |
30 | - foreach($header as $key => $value) |
|
30 | + foreach ($header as $key => $value) |
|
31 | 31 | { |
32 | - if(is_array($value)) |
|
32 | + if (is_array($value)) |
|
33 | 33 | { |
34 | 34 | continue; |
35 | 35 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | ); |
62 | 62 | |
63 | 63 | print('<tr align="right">'); |
64 | - foreach($unit_crossfire_result as $key => $value) |
|
64 | + foreach ($unit_crossfire_result as $key => $value) |
|
65 | 65 | { |
66 | - if(is_array($value)) |
|
66 | + if (is_array($value)) |
|
67 | 67 | { |
68 | 68 | continue; |
69 | 69 | } |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -41,11 +37,11 @@ discard block |
||
41 | 37 | function log_file($msg) { |
42 | 38 | static $handler; |
43 | 39 | |
44 | - if(!$handler) { |
|
40 | + if (!$handler) { |
|
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
49 | 45 | } |
50 | 46 | |
51 | 47 | // ------------------------------------------------------------------ |
@@ -80,12 +76,12 @@ discard block |
||
80 | 76 | |
81 | 77 | */ |
82 | 78 | |
83 | - if(classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
79 | + if (classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
84 | 80 | return; |
85 | 81 | } |
86 | 82 | |
87 | 83 | sn_db_transaction_start(); |
88 | - if(classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
84 | + if (classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
89 | 85 | sn_db_transaction_rollback(); |
90 | 86 | |
91 | 87 | return; |
@@ -93,14 +89,14 @@ discard block |
||
93 | 89 | |
94 | 90 | |
95 | 91 | // Watchdog timer |
96 | - if(classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
97 | - if(defined('DEBUG_FLYING_FLEETS')) { |
|
92 | + if (classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
93 | + if (defined('DEBUG_FLYING_FLEETS')) { |
|
98 | 94 | $random = 0; |
99 | 95 | } else { |
100 | 96 | $random = mt_rand(240, 300); |
101 | 97 | } |
102 | 98 | |
103 | - if(SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
99 | + if (SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
104 | 100 | sn_db_transaction_rollback(); |
105 | 101 | |
106 | 102 | return; |
@@ -124,11 +120,11 @@ discard block |
||
124 | 120 | $missions_used = array(); |
125 | 121 | |
126 | 122 | $objFleetList = FleetList::dbGetFleetListCurrentTick(); |
127 | - foreach($objFleetList->_container as $objFleet) { |
|
123 | + foreach ($objFleetList->_container as $objFleet) { |
|
128 | 124 | set_time_limit(15); |
129 | 125 | // TODO - Унифицировать код с темплейтным разбором эвентов на планете! |
130 | 126 | $missions_used[$objFleet->mission_type] = 1; |
131 | - if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
127 | + if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
132 | 128 | $fleet_event_list[] = array( |
133 | 129 | 'object' => $objFleet, |
134 | 130 | 'fleet_time' => $objFleet->time_arrive_to_target, |
@@ -136,7 +132,7 @@ discard block |
||
136 | 132 | ); |
137 | 133 | } |
138 | 134 | |
139 | - if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
135 | + if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
140 | 136 | $fleet_event_list[] = array( |
141 | 137 | 'object' => $objFleet, |
142 | 138 | 'fleet_time' => $objFleet->time_mission_job_complete, |
@@ -144,7 +140,7 @@ discard block |
||
144 | 140 | ); |
145 | 141 | } |
146 | 142 | |
147 | - if($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
143 | + if ($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
148 | 144 | $fleet_event_list[] = array( |
149 | 145 | 'object' => $objFleet, |
150 | 146 | 'fleet_time' => $objFleet->time_return_to_source, |
@@ -170,17 +166,17 @@ discard block |
||
170 | 166 | // MT_MISSILE => 'flt_mission_missile.php', |
171 | 167 | MT_EXPLORE => 'flt_mission_explore', |
172 | 168 | ); |
173 | - foreach($missions_used as $mission_id => $cork) { |
|
174 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
169 | + foreach ($missions_used as $mission_id => $cork) { |
|
170 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
175 | 171 | } |
176 | 172 | |
177 | 173 | //log_file('Обработка миссий'); |
178 | 174 | $sn_groups_mission = sn_get_groups('missions'); |
179 | - foreach($fleet_event_list as $fleet_event) { |
|
175 | + foreach ($fleet_event_list as $fleet_event) { |
|
180 | 176 | // TODO: Указатель тут потом сделать |
181 | 177 | // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?! |
182 | 178 | $fleet_row = $fleet_event['fleet_row']; |
183 | - if(empty($fleet_event['object'])) { |
|
179 | + if (empty($fleet_event['object'])) { |
|
184 | 180 | // Fleet was destroyed in course of previous actions |
185 | 181 | continue; |
186 | 182 | } |
@@ -205,20 +201,20 @@ discard block |
||
205 | 201 | |
206 | 202 | $objFleet->dbLoad($objFleet->dbId); |
207 | 203 | |
208 | - if(!$objFleet->dbId) { |
|
204 | + if (!$objFleet->dbId) { |
|
209 | 205 | // Fleet was destroyed in course of previous actions |
210 | 206 | sn_db_transaction_commit(); |
211 | 207 | continue; |
212 | 208 | } |
213 | 209 | |
214 | - if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
210 | + if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
215 | 211 | // Fleet returns to planet |
216 | 212 | $objFleet->shipsLand(true); |
217 | 213 | sn_db_transaction_commit(); |
218 | 214 | continue; |
219 | 215 | } |
220 | 216 | |
221 | - if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
217 | + if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
222 | 218 | // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0 |
223 | 219 | // В противном случае это означает, что флот уже был обработан ранее - например, при САБе |
224 | 220 | sn_db_transaction_commit(); |
@@ -238,13 +234,13 @@ discard block |
||
238 | 234 | $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null; |
239 | 235 | $objMission->fleet_event = $fleet_event['fleet_event']; |
240 | 236 | |
241 | - if($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
237 | + if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
242 | 238 | $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target); |
243 | 239 | $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null; |
244 | 240 | $objMission->dst_planet = $update_result['planet']; |
245 | 241 | } |
246 | 242 | |
247 | - switch($objFleet->mission_type) { |
|
243 | + switch ($objFleet->mission_type) { |
|
248 | 244 | // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий! |
249 | 245 | case MT_ACS: |
250 | 246 | case MT_ATTACK: |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $TargetAddress = sprintf(classLocale::$lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']); |
21 | 21 | |
22 | 22 | $TheMessage = classLocale::$lang['sys_colo_no_colonizer']; |
23 | - if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
23 | + if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
24 | 24 | $TheMessage = classLocale::$lang['sys_colo_notfree']; |
25 | - if(empty($mission_data->dst_planet)) { |
|
25 | + if (empty($mission_data->dst_planet)) { |
|
26 | 26 | $iPlanetCount = get_player_current_colonies($src_user_row); |
27 | 27 | |
28 | 28 | // Can we colonize more planets? |
29 | 29 | $TheMessage = classLocale::$lang['sys_colo_maxcolo']; |
30 | - if($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
30 | + if ($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
31 | 31 | // Yes, we can colonize |
32 | 32 | $TheMessage = classLocale::$lang['sys_colo_badpos']; |
33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'], |
36 | 36 | $objFleet->playerOwnerId, "{$classLocale['sys_colo_defaultname']} {$iPlanetCount}", false, |
37 | 37 | array('user_row' => $src_user_row)); |
38 | - if($NewOwnerPlanet) { |
|
39 | - $TheMessage = classLocale::$lang['sys_colo_arrival'] . $TargetAddress . classLocale::$lang['sys_colo_allisok']; |
|
38 | + if ($NewOwnerPlanet) { |
|
39 | + $TheMessage = classLocale::$lang['sys_colo_arrival'].$TargetAddress.classLocale::$lang['sys_colo_allisok']; |
|
40 | 40 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_colo_mess_from'], classLocale::$lang['sys_colo_mess_report'], $TheMessage); |
41 | 41 | |
42 | 42 | $objFleet->shipAdjustCount(SHIP_COLONIZER, -1); |
@@ -2,28 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(SN_IN_FLEET !== true) { |
|
5 | +if (SN_IN_FLEET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $fleetid = sys_get_param_id('fleetid'); |
10 | 10 | |
11 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
11 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
12 | 12 | header("Location: fleet.php"); |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $objFleet = new Fleet(); |
17 | 17 | $objFleet->dbLoad($fleetid); |
18 | -if(!$objFleet->dbId) { |
|
18 | +if (!$objFleet->dbId) { |
|
19 | 19 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
20 | 20 | } |
21 | 21 | |
22 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
22 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
23 | 23 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
24 | 24 | } |
25 | 25 | |
26 | -if($objFleet->playerOwnerId != $user['id']) { |
|
26 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
27 | 27 | classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
28 | 28 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
29 | 29 | } |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | |
35 | 35 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
36 | 36 | |
37 | -if($userToAdd_unsafe) { |
|
37 | +if ($userToAdd_unsafe) { |
|
38 | 38 | $userToAdd = db_escape($userToAdd_unsafe); |
39 | 39 | $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
40 | 40 | $userToAddID = $userToAddID['id']; |
41 | 41 | |
42 | - if($objFleet->target_owner_id == $userToAddID) { |
|
42 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
43 | 43 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
44 | 44 | } |
45 | 45 | |
46 | - if($userToAddID) { |
|
47 | - if(!$aks) { |
|
46 | + if ($userToAddID) { |
|
47 | + if (!$aks) { |
|
48 | 48 | // No AСS exists - making one |
49 | - if(!$objFleet->group_id) { |
|
49 | + if (!$objFleet->group_id) { |
|
50 | 50 | db_acs_insert($fleetid, $user, $objFleet); |
51 | 51 | |
52 | 52 | $aks = db_acs_get_by_fleet($fleetid); |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $isUserExists = false; |
63 | 63 | $invited_ar = explode(",", $aks['eingeladen']); |
64 | - foreach($invited_ar as $inv) { |
|
65 | - if($userToAddID == $inv) { |
|
64 | + foreach ($invited_ar as $inv) { |
|
65 | + if ($userToAddID == $inv) { |
|
66 | 66 | $isUserExists = true; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - if(count($invited_ar) >= 5) { |
|
70 | + if (count($invited_ar) >= 5) { |
|
71 | 71 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
72 | 72 | } |
73 | 73 | |
74 | - if($isUserExists) { |
|
74 | + if ($isUserExists) { |
|
75 | 75 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
76 | 76 | } else { |
77 | 77 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
78 | 78 | !(db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], db_error())) : false; |
79 | - $aks['eingeladen'] .= ',' . $userToAddID; |
|
79 | + $aks['eingeladen'] .= ','.$userToAddID; |
|
80 | 80 | } |
81 | 81 | msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
82 | 82 | classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS], |
94 | 94 | )); |
95 | 95 | |
96 | -if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | - foreach($members as $row) { |
|
96 | +if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | + foreach ($members as $row) { |
|
98 | 98 | $template->assign_block_vars('invited', array( |
99 | 99 | 'NAME' => $row['username'], |
100 | 100 | )); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
120 | 120 | |
121 | 121 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
122 | -foreach($fleet_data['ships'] as $ship_data) { |
|
122 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
123 | 123 | $template->assign_block_vars('fleets.ships', $ship_data); |
124 | 124 | } |
125 | 125 |