@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | * @param string $group_name |
155 | 155 | */ |
156 | 156 | public static function _init($group_name = '') { |
157 | - if(static::$_is_static_init) { |
|
157 | + if (static::$_is_static_init) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - if($group_name) { |
|
161 | + if ($group_name) { |
|
162 | 162 | static::$_sn_group_name = $group_name; |
163 | 163 | } |
164 | 164 | |
165 | - if(static::$_sn_group_name) { |
|
165 | + if (static::$_sn_group_name) { |
|
166 | 166 | static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name); |
167 | 167 | empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false; |
168 | 168 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // TODO - Reset combat stats?? |
188 | 188 | $this->_unitId = $unitId; |
189 | 189 | |
190 | - if($this->_unitId) { |
|
190 | + if ($this->_unitId) { |
|
191 | 191 | $this->info = get_unit_param($this->_unitId); |
192 | 192 | $this->_type = $this->info[P_UNIT_TYPE]; |
193 | 193 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | protected function setCount($value) { |
200 | 200 | // TODO - Reset combat stats?? |
201 | - if($value < 0) { |
|
201 | + if ($value < 0) { |
|
202 | 202 | classSupernova::$debug->error('Can not set Unit::$count to negative value'); |
203 | 203 | } |
204 | 204 | $this->_count = $value; |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $TargetAddress = sprintf($lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']); |
21 | 21 | |
22 | 22 | $TheMessage = $lang['sys_colo_no_colonizer']; |
23 | - if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
23 | + if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
24 | 24 | $TheMessage = $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 = $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 = $lang['sys_colo_badpos']; |
33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'], |
36 | 36 | $objFleet->playerOwnerId, "{$lang['sys_colo_defaultname']} {$iPlanetCount}", false, |
37 | 37 | array('user_row' => $src_user_row)); |
38 | - if($NewOwnerPlanet) { |
|
38 | + if ($NewOwnerPlanet) { |
|
39 | 39 | $TheMessage = $lang['sys_colo_arrival'] . $TargetAddress . $lang['sys_colo_allisok']; |
40 | 40 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); |
41 | 41 |
@@ -17,14 +17,14 @@ |
||
17 | 17 | function flt_mission_attack($objMission) { |
18 | 18 | $objFleet = $objMission->fleet; |
19 | 19 | |
20 | - if($objFleet->shipsGetTotal() <= 0) { |
|
20 | + if ($objFleet->shipsGetTotal() <= 0) { |
|
21 | 21 | return null; |
22 | 22 | } |
23 | 23 | |
24 | 24 | $destination_user = $objMission->dst_user; |
25 | 25 | $destination_planet = $objMission->dst_planet; |
26 | 26 | |
27 | - if( |
|
27 | + if ( |
|
28 | 28 | // Нет данных о планете назначения или её владельце |
29 | 29 | empty($destination_user) || empty($destination_planet) || !is_array($destination_user) || !is_array($destination_planet) |
30 | 30 | || |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | global $lang, $config; |
22 | 22 | static $ship_data, $rates; |
23 | 23 | |
24 | - if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
24 | + if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
25 | 25 | return CACHE_NONE; |
26 | 26 | } |
27 | 27 | |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | $outcome_value = &$result['$outcome_value']; |
47 | 47 | $outcome_list = &$result['$outcome_list']; |
48 | 48 | |
49 | - if(!$ship_data) { |
|
50 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
49 | + if (!$ship_data) { |
|
50 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
51 | 51 | $unit_info = get_unit_param($unit_id); |
52 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
52 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
53 | 53 | continue; |
54 | 54 | } |
55 | 55 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | $max_metal_cost = 0; |
61 | 61 | $fleet_real_array = $objFleet->shipsGetArray(); |
62 | - foreach($fleet_real_array as $ship_id => $ship_amount) { |
|
62 | + foreach ($fleet_real_array as $ship_id => $ship_amount) { |
|
63 | 63 | $ship_cost_in_metal = $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
64 | 64 | $result['$fleet_metal_points'] += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
65 | 65 | // Рассчитываем стоимость самого дорого корабля в металле |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
74 | 74 | |
75 | 75 | $chance_max = 0; |
76 | - foreach($outcome_list as $key => &$value) { |
|
77 | - if(!$value['chance']) { |
|
76 | + foreach ($outcome_list as $key => &$value) { |
|
77 | + if (!$value['chance']) { |
|
78 | 78 | unset($outcome_list[$key]); |
79 | 79 | continue; |
80 | 80 | } |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | } |
83 | 83 | $outcome_value = mt_rand(0, $chance_max); |
84 | 84 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
85 | - foreach($outcome_list as $key => &$value) { |
|
86 | - if(!$value['chance']) { |
|
85 | + foreach ($outcome_list as $key => &$value) { |
|
86 | + if (!$value['chance']) { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | $mission_outcome = $key; |
90 | 90 | $outcome_description = $value; |
91 | - if($outcome_value <= $outcome_description['value']) { |
|
91 | + if ($outcome_value <= $outcome_description['value']) { |
|
92 | 92 | break; |
93 | 93 | } |
94 | 94 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | // $outcome_mission_sub = -1; |
106 | 106 | |
107 | 107 | $fleet_found = array(); |
108 | - switch($mission_outcome) { |
|
108 | + switch ($mission_outcome) { |
|
109 | 109 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
110 | 110 | $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000); |
111 | 111 | break; |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | |
127 | 127 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
128 | 128 | $can_be_found = array(); |
129 | - foreach($ship_data as $ship_id => $ship_info) { |
|
130 | - if($ship_info['metal_cost'] < $max_metal_cost) { |
|
129 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
130 | + if ($ship_info['metal_cost'] < $max_metal_cost) { |
|
131 | 131 | $can_be_found[$ship_id] = $ship_info['metal_cost']; |
132 | 132 | } |
133 | 133 | } |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | unset($can_be_found[SHIP_COLONIZER]); |
136 | 136 | unset($can_be_found[SHIP_SPY]); |
137 | 137 | |
138 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
138 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
139 | 139 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
140 | 140 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
141 | 141 | $found_ship_cost = reset($found_ship); |
142 | 142 | $found_ship_id = key($found_ship); |
143 | 143 | |
144 | - if($found_ship_cost > $found_in_metal) { |
|
144 | + if ($found_ship_cost > $found_in_metal) { |
|
145 | 145 | unset($can_be_found[$found_ship_id]); |
146 | 146 | } else { |
147 | 147 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - if(empty($fleet_found)) { |
|
153 | + if (empty($fleet_found)) { |
|
154 | 154 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
155 | 155 | } else { |
156 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
156 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
157 | 157 | $objFleet->shipAdjustCount($unit_id, $unit_amount); |
158 | 158 | } |
159 | 159 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $objFleet->resourcesAdjust($resources_found); |
179 | 179 | |
180 | - if(array_sum($resources_found) == 0) { |
|
180 | + if (array_sum($resources_found) == 0) { |
|
181 | 181 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
182 | 182 | } |
183 | 183 | break; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // Рассчитываем количество найденной ТМ |
189 | 189 | $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
190 | 190 | |
191 | - if(!$found_dark_matter) { |
|
191 | + if (!$found_dark_matter) { |
|
192 | 192 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
193 | 193 | } |
194 | 194 | break; |
@@ -202,40 +202,39 @@ discard block |
||
202 | 202 | |
203 | 203 | mission_expedition_result_adjust($result, $objFleet); |
204 | 204 | |
205 | - if($found_dark_matter) { |
|
205 | + if ($found_dark_matter) { |
|
206 | 206 | rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
207 | 207 | $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
208 | 208 | } |
209 | 209 | |
210 | - if(!empty($fleet_lost)) { |
|
210 | + if (!empty($fleet_lost)) { |
|
211 | 211 | $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet']; |
212 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
212 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
213 | 213 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if(!empty($fleet_found)) { |
|
217 | + if (!empty($fleet_found)) { |
|
218 | 218 | $msg_text_addon = $lang['flt_mission_expedition']['found_fleet']; |
219 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
219 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
220 | 220 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
224 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
225 | 225 | $msg_text_addon = $lang['flt_mission_expedition']['found_resources']; |
226 | - foreach($resources_found as $resource_id => $resource_amount) { |
|
226 | + foreach ($resources_found as $resource_id => $resource_amount) { |
|
227 | 227 | $msg_text_addon .= $lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n"; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - if(!$msg_text) { |
|
231 | + if (!$msg_text) { |
|
232 | 232 | $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
233 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
233 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
234 | 234 | $messages = &$messages[$outcome_mission_sub]; |
235 | 235 | } |
236 | 236 | |
237 | - $msg_text = is_string($messages) ? $messages : |
|
238 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
237 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
239 | 238 | } |
240 | 239 | |
241 | 240 | $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type(); |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | $this->owner_id, |
163 | 163 | $this->db_id, |
164 | 164 | |
165 | - (float)$this->UBE_PLANET[PLANET_ID], |
|
165 | + (float) $this->UBE_PLANET[PLANET_ID], |
|
166 | 166 | "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'", |
167 | - (int)$this->UBE_PLANET[PLANET_GALAXY], |
|
168 | - (int)$this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | - (int)$this->UBE_PLANET[PLANET_PLANET], |
|
170 | - (int)$this->UBE_PLANET[PLANET_TYPE], |
|
171 | - |
|
172 | - (float)$this->resource_list[RES_METAL], |
|
173 | - (float)$this->resource_list[RES_CRYSTAL], |
|
174 | - (float)$this->resource_list[RES_DEUTERIUM], |
|
175 | - |
|
176 | - (float)$this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | - (float)$this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | - (float)$this->fleet_bonus->calcBonus(P_ARMOR), |
|
167 | + (int) $this->UBE_PLANET[PLANET_GALAXY], |
|
168 | + (int) $this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | + (int) $this->UBE_PLANET[PLANET_PLANET], |
|
170 | + (int) $this->UBE_PLANET[PLANET_TYPE], |
|
171 | + |
|
172 | + (float) $this->resource_list[RES_METAL], |
|
173 | + (float) $this->resource_list[RES_CRYSTAL], |
|
174 | + (float) $this->resource_list[RES_DEUTERIUM], |
|
175 | + |
|
176 | + (float) $this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | + (float) $this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | + (float) $this->fleet_bonus->calcBonus(P_ARMOR), |
|
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | $this->group_id = $objFleet->group_id; |
191 | 191 | |
192 | 192 | $fleet_unit_list = $objFleet->shipsGetArray(); |
193 | - foreach($fleet_unit_list as $unit_id => $unit_count) { |
|
194 | - if(!$unit_count) { |
|
193 | + foreach ($fleet_unit_list as $unit_id => $unit_count) { |
|
194 | + if (!$unit_count) { |
|
195 | 195 | continue; |
196 | 196 | } |
197 | 197 | |
198 | 198 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
199 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
199 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
200 | 200 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
201 | 201 | } |
202 | 202 | } |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | // } |
233 | 233 | // } |
234 | 234 | |
235 | - foreach($sn_group_combat as $unit_id) { |
|
236 | - if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
235 | + foreach ($sn_group_combat as $unit_id) { |
|
236 | + if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
237 | 237 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
241 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
242 | 242 | $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id)); |
243 | 243 | } |
244 | 244 | |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | $ube_report_id, |
298 | 298 | $this->db_id, |
299 | 299 | |
300 | - (float)$this->resources_lost_on_units[RES_METAL], |
|
301 | - (float)$this->resources_lost_on_units[RES_CRYSTAL], |
|
302 | - (float)$this->resources_lost_on_units[RES_DEUTERIUM], |
|
303 | - (float)$this->cargo_dropped[RES_METAL], |
|
304 | - (float)$this->cargo_dropped[RES_CRYSTAL], |
|
305 | - (float)$this->cargo_dropped[RES_DEUTERIUM], |
|
306 | - (float)$this->resources_looted[RES_METAL], |
|
307 | - (float)$this->resources_looted[RES_CRYSTAL], |
|
308 | - (float)$this->resources_looted[RES_DEUTERIUM], |
|
309 | - (float)$this->resources_lost_in_metal[RES_METAL], |
|
300 | + (float) $this->resources_lost_on_units[RES_METAL], |
|
301 | + (float) $this->resources_lost_on_units[RES_CRYSTAL], |
|
302 | + (float) $this->resources_lost_on_units[RES_DEUTERIUM], |
|
303 | + (float) $this->cargo_dropped[RES_METAL], |
|
304 | + (float) $this->cargo_dropped[RES_CRYSTAL], |
|
305 | + (float) $this->cargo_dropped[RES_DEUTERIUM], |
|
306 | + (float) $this->resources_looted[RES_METAL], |
|
307 | + (float) $this->resources_looted[RES_CRYSTAL], |
|
308 | + (float) $this->resources_looted[RES_DEUTERIUM], |
|
309 | + (float) $this->resources_lost_in_metal[RES_METAL], |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | |
313 | 313 | public function report_render_outcome_side_fleet() { |
314 | 314 | $UBE_DEFENCE_RESTORE = array(); |
315 | 315 | $UBE_UNITS_LOST = array(); |
316 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
317 | - if($UBEUnit->units_restored) { |
|
316 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
317 | + if ($UBEUnit->units_restored) { |
|
318 | 318 | $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored; |
319 | 319 | } |
320 | - if($UBEUnit->units_lost) { |
|
320 | + if ($UBEUnit->units_lost) { |
|
321 | 321 | $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost; |
322 | 322 | } |
323 | 323 | } |
@@ -344,16 +344,16 @@ discard block |
||
344 | 344 | global $lang; |
345 | 345 | |
346 | 346 | $result = array(); |
347 | - if(!empty($array)) { |
|
348 | - foreach($array as $unit_id => $unit_count) { |
|
349 | - if($unit_count) { |
|
347 | + if (!empty($array)) { |
|
348 | + foreach ($array as $unit_id => $unit_count) { |
|
349 | + if ($unit_count) { |
|
350 | 350 | $result[] = array( |
351 | 351 | 'NAME' => $lang['tech'][$unit_id], |
352 | 352 | 'LOSS' => pretty_number($unit_count), |
353 | 353 | ); |
354 | 354 | } |
355 | 355 | } |
356 | - if($lang_header_index && count($result)) { |
|
356 | + if ($lang_header_index && count($result)) { |
|
357 | 357 | array_unshift($result, array('NAME' => $lang[$lang_header_index])); |
358 | 358 | } |
359 | 359 | } |
@@ -366,16 +366,16 @@ discard block |
||
366 | 366 | $fleet_id = $this->db_id; |
367 | 367 | |
368 | 368 | $unit_sort_order = 0; |
369 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
370 | - if($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
369 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
370 | + if ($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
371 | 371 | $unit_sort_order++; |
372 | 372 | $sql_perform_report_unit[] = array( |
373 | 373 | $ube_report_id, |
374 | 374 | $fleet_id, |
375 | 375 | |
376 | 376 | $UBEUnit->unitId, |
377 | - (float)$UBEUnit->units_restored, |
|
378 | - (float)$UBEUnit->units_lost, |
|
377 | + (float) $UBEUnit->units_restored, |
|
378 | + (float) $UBEUnit->units_lost, |
|
379 | 379 | |
380 | 380 | $unit_sort_order, |
381 | 381 | ); |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | function ube_combat_result_calculate_resources() { |
392 | 392 | $resource_delta_fleet = array(); |
393 | 393 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
394 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
395 | - $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id]; |
|
396 | - if($resource_change) { |
|
394 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
395 | + $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id]; |
|
396 | + if ($resource_change) { |
|
397 | 397 | $resource_delta_fleet[$resource_id] = -($resource_change); |
398 | 398 | } |
399 | 399 | } |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | ); |
427 | 427 | |
428 | 428 | $this->fleet_capacity = 0; |
429 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
429 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
430 | 430 | $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount(); |
431 | 431 | |
432 | - if($UBEUnit->units_lost) { |
|
433 | - foreach($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
434 | - if(!$unit_resource_price) { |
|
432 | + if ($UBEUnit->units_lost) { |
|
433 | + foreach ($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
434 | + if (!$unit_resource_price) { |
|
435 | 435 | continue; |
436 | 436 | } |
437 | 437 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $this->resources_lost_on_units[$resource_id] += $resources_lost; |
440 | 440 | // Если это корабль - прибавляем потери к обломкам на орбите |
441 | 441 | // TODO - опция выбрасывания обороны в обломки |
442 | - if($UBEUnit->getType() == UNIT_SHIPS) { |
|
442 | + if ($UBEUnit->getType() == UNIT_SHIPS) { |
|
443 | 443 | $this->resources_lost_on_ships[$resource_id] += $resources_lost; |
444 | 444 | } |
445 | 445 | } |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | |
452 | 452 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
453 | 453 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
454 | - if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
454 | + if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
455 | 455 | $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена |
456 | - foreach($this->resource_list as $resource_id => &$resource_amount) { |
|
456 | + foreach ($this->resource_list as $resource_id => &$resource_amount) { |
|
457 | 457 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
458 | - if(!$resource_amount) { |
|
458 | + if (!$resource_amount) { |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | |
@@ -476,19 +476,19 @@ discard block |
||
476 | 476 | $objFleet2->setDbId($this->db_id); |
477 | 477 | |
478 | 478 | // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли |
479 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
479 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
480 | 480 | $objFleet2->dbDelete(); |
481 | - } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
481 | + } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
482 | 482 | $objFleet2->dbDelete(); |
483 | 483 | } else { |
484 | - if($ship_count_lost) { |
|
484 | + if ($ship_count_lost) { |
|
485 | 485 | // Просматриваем результаты изменения флотов |
486 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
486 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
487 | 487 | // Перебираем аутком на случай восстановления юнитов |
488 | 488 | // if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) { |
489 | 489 | // $fleet_real_array[$UBEUnit->unitId] = $units_left; |
490 | 490 | // }; |
491 | - if(floatval($UBEUnit->units_lost) != 0) { |
|
491 | + if (floatval($UBEUnit->units_lost) != 0) { |
|
492 | 492 | $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost)); |
493 | 493 | }; |
494 | 494 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $objFleet2->resourcesAdjust($resource_delta_fleet); |
499 | 499 | |
500 | 500 | // Если защитник и не РМФ - отправляем флот назад |
501 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
501 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
502 | 502 | $objFleet2->markReturned(); |
503 | 503 | } |
504 | 504 | $objFleet2->dbSave(); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | public function calculate_unit_partial_data(UBEASA $side_ASA) { |
529 | 529 | $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor(); |
530 | 530 | |
531 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
531 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
532 | 532 | $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor(); |
533 | 533 | } |
534 | 534 | } |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | * @version 2016-02-25 23:42:45 41a4.68 |
541 | 541 | */ |
542 | 542 | public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) { |
543 | - foreach($fleet_list->_container as $defending_fleet) { |
|
543 | + foreach ($fleet_list->_container as $defending_fleet) { |
|
544 | 544 | // Не атакуются флоты на своей стороне |
545 | - if($this->is_attacker == $defending_fleet->is_attacker) { |
|
545 | + if ($this->is_attacker == $defending_fleet->is_attacker) { |
|
546 | 546 | continue; |
547 | 547 | } |
548 | 548 | $this->attack_fleet($defending_fleet, $is_simulator); |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) { |
559 | 559 | UBEDebug::unit_dump_header(); |
560 | 560 | |
561 | - foreach($this->unit_list->_container as $attacking_unit_pool) { |
|
561 | + foreach ($this->unit_list->_container as $attacking_unit_pool) { |
|
562 | 562 | UBEDebug::unit_dump($attacking_unit_pool, 'attacker'); |
563 | 563 | |
564 | 564 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
565 | - foreach($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
566 | - if($defending_unit_pool->isEmpty()) { |
|
565 | + foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
566 | + if ($defending_unit_pool->isEmpty()) { |
|
567 | 567 | continue; |
568 | 568 | } |
569 | 569 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | function db_change_units_perform($query, $tablename, $object_id) { |
13 | 13 | $query = implode(',', $query); |
14 | - if($query && $object_id) { |
|
14 | + if ($query && $object_id) { |
|
15 | 15 | return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
16 | 16 | // return doquery("UPDATE {{{$tablename}}} SET {$query} WHERE `id` = '{$object_id}' LIMIT 1;"); |
17 | 17 | } |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | |
29 | 29 | $group = sn_get_groups('resources_loot'); |
30 | 30 | |
31 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
32 | - if(!in_array($unit_id, $group)) { |
|
31 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
32 | + if (!in_array($unit_id, $group)) { |
|
33 | 33 | // TODO - remove later |
34 | 34 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
35 | 35 | pdump(debug_backtrace()); |
36 | 36 | die('db_change_units() вызван для не-ресурсов!'); |
37 | 37 | } |
38 | 38 | |
39 | - if(!$unit_amount) { |
|
39 | + if (!$unit_amount) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
46 | 46 | |
47 | 47 | // Changing value in object |
48 | - switch($unit_location) { |
|
48 | + switch ($unit_location) { |
|
49 | 49 | case LOC_USER: |
50 | 50 | $user[$unit_db_name] += $unit_amount; |
51 | 51 | break; |
@@ -67,23 +67,23 @@ discard block |
||
67 | 67 | $field_set = ''; |
68 | 68 | $value_set = ''; |
69 | 69 | |
70 | - switch($type) { |
|
70 | + switch ($type) { |
|
71 | 71 | case 'delete': |
72 | 72 | $query = 'DELETE FROM'; |
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'insert': |
76 | 76 | $query = 'INSERT INTO'; |
77 | - if(isset($options['__multi'])) { |
|
77 | + if (isset($options['__multi'])) { |
|
78 | 78 | // Here we generate mass-insert set |
79 | 79 | break; |
80 | 80 | } |
81 | 81 | case 'update': |
82 | - if(!$query) { |
|
82 | + if (!$query) { |
|
83 | 83 | $query = 'UPDATE'; |
84 | 84 | } |
85 | 85 | |
86 | - foreach($values as $field => &$value) { |
|
86 | + foreach ($values as $field => &$value) { |
|
87 | 87 | $value_type = gettype($value); |
88 | 88 | if ($value_type == 'string') { |
89 | 89 | $value = "'" . db_escape($value) . "'"; |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | $field_set['__IS_SAFE'] = true; |
112 | 112 | } |
113 | 113 | function sn_db_field_set_make_safe($field_set, $serialize = false) { |
114 | - if(!is_array($field_set)) { |
|
114 | + if (!is_array($field_set)) { |
|
115 | 115 | die('$field_set is not an array!'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $result = array(); |
119 | - foreach($field_set as $field => $value) { |
|
119 | + foreach ($field_set as $field => $value) { |
|
120 | 120 | $field = db_escape(trim($field)); |
121 | 121 | switch (true) { |
122 | 122 | case is_int($value): |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'shield' => 10, |
36 | 36 | 'armor' => 400, |
37 | 37 | 'attack' => 5, |
38 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
38 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
39 | 39 | ), |
40 | 40 | SHIP_CARGO_BIG => array( |
41 | 41 | 'name' => 'big_ship_cargo', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'shield' => 25, |
56 | 56 | 'armor' => 1200, |
57 | 57 | 'attack' => 5, |
58 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
58 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
59 | 59 | 'engine' => array( |
60 | 60 | array( |
61 | 61 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'shield' => 50, |
84 | 84 | 'armor' => 3000, |
85 | 85 | 'attack' => 10, |
86 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
86 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
87 | 87 | 'engine' => array( |
88 | 88 | array( |
89 | 89 | 'tech' => TECH_ENGINE_ION, |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'shield' => 200, |
112 | 112 | 'armor' => 70000, |
113 | 113 | 'attack' => 50, |
114 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
114 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
115 | 115 | 'engine' => array( |
116 | 116 | array( |
117 | 117 | 'tech' => TECH_ENGINE_HYPER, |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'shield' => 100, |
141 | 141 | 'armor' => 3000, |
142 | 142 | 'attack' => 50, |
143 | - 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
143 | + 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
144 | 144 | 'engine' => array( |
145 | 145 | array( |
146 | 146 | 'tech' => TECH_ENGINE_ION, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | 'shield' => 10, |
169 | 169 | 'armor' => 1600, |
170 | 170 | 'attack' => 1, |
171 | - 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050, ), |
|
171 | + 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050,), |
|
172 | 172 | 'engine' => array( |
173 | 173 | array( |
174 | 174 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'shield' => 0.01, |
197 | 197 | 'armor' => 100, |
198 | 198 | 'attack' => 0.01, |
199 | - 'amplify' => array( SHIP_SPY => 1,), |
|
199 | + 'amplify' => array(SHIP_SPY => 1,), |
|
200 | 200 | 'engine' => array( |
201 | 201 | array( |
202 | 202 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'factor' => 1, |
221 | 221 | ), |
222 | 222 | P_UNIT_PRODUCTION => array( |
223 | - RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor);}, |
|
223 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
224 | 224 | ), |
225 | 225 | P_MINING_IS_MANAGED => true, |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'shield' => 10, |
230 | 230 | 'armor' => 200, |
231 | 231 | 'attack' => 1, |
232 | - 'amplify' => array(SHIP_SPY => 1, ), |
|
232 | + 'amplify' => array(SHIP_SPY => 1,), |
|
233 | 233 | 'engine' => array( |
234 | 234 | array( |
235 | 235 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'shield' => 10, |
262 | 262 | 'armor' => 400, |
263 | 263 | 'attack' => 50, |
264 | - 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
264 | + 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
265 | 265 | 'engine' => array( |
266 | 266 | array( |
267 | 267 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'shield' => 25, |
291 | 291 | 'armor' => 1000, |
292 | 292 | 'attack' => 150, |
293 | - 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7, ), |
|
293 | + 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7,), |
|
294 | 294 | 'engine' => array( |
295 | 295 | array( |
296 | 296 | 'tech' => TECH_ENGINE_ION, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | 'shield' => 50, |
350 | 350 | 'armor' => 2700, |
351 | 351 | 'attack' => 400, |
352 | - 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5, ), |
|
352 | + 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5,), |
|
353 | 353 | 'engine' => array( |
354 | 354 | array( |
355 | 355 | 'tech' => TECH_ENGINE_ION, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'shield' => 200, |
409 | 409 | 'armor' => 6000, |
410 | 410 | 'attack' => 1000, |
411 | - 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76, ), |
|
411 | + 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76,), |
|
412 | 412 | 'engine' => array( |
413 | 413 | array( |
414 | 414 | 'tech' => TECH_ENGINE_HYPER, |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'shield' => 500, |
505 | 505 | 'armor' => 11000, |
506 | 506 | 'attack' => 2000, |
507 | - 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125, ), |
|
507 | + 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125,), |
|
508 | 508 | 'engine' => array( |
509 | 509 | array( |
510 | 510 | 'tech' => TECH_ENGINE_HYPER, |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | 'shield' => 20, |
609 | 609 | 'armor' => 200, |
610 | 610 | 'attack' => 80, |
611 | - 'amplify' => array(SHIP_SPY => 7, ), |
|
611 | + 'amplify' => array(SHIP_SPY => 7,), |
|
612 | 612 | ), |
613 | 613 | UNIT_DEF_TURRET_LASER_SMALL => array( |
614 | 614 | 'name' => 'small_laser', |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | 'shield' => 25, |
627 | 627 | 'armor' => 200, |
628 | 628 | 'attack' => 100, |
629 | - 'amplify' => array(SHIP_SPY => 5, ), |
|
629 | + 'amplify' => array(SHIP_SPY => 5,), |
|
630 | 630 | ), |
631 | 631 | UNIT_DEF_TURRET_LASER_BIG => array( |
632 | 632 | 'name' => 'big_laser', |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | 'shield' => 100, |
645 | 645 | 'armor' => 800, |
646 | 646 | 'attack' => 250, |
647 | - 'amplify' => array(SHIP_SPY => 2, ), |
|
647 | + 'amplify' => array(SHIP_SPY => 2,), |
|
648 | 648 | ), |
649 | 649 | UNIT_DEF_TURRET_GAUSS => array( |
650 | 650 | 'name' => 'gauss_canyon', |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | 'armor' => 3500, |
663 | 663 | 'shield' => 200, |
664 | 664 | 'attack' => 1100, |
665 | - 'amplify' => array(SHIP_SPY => 0.5, ), |
|
665 | + 'amplify' => array(SHIP_SPY => 0.5,), |
|
666 | 666 | ), |
667 | 667 | UNIT_DEF_TURRET_ION => array( |
668 | 668 | 'name' => 'ionic_canyon', |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | 'shield' => 500, |
681 | 681 | 'armor' => 800, |
682 | 682 | 'attack' => 150, |
683 | - 'amplify' => array(SHIP_SPY => 3.3, ), |
|
683 | + 'amplify' => array(SHIP_SPY => 3.3,), |
|
684 | 684 | ), |
685 | 685 | UNIT_DEF_TURRET_PLASMA => array( |
686 | 686 | 'name' => 'buster_canyon', |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'shield' => 300, |
699 | 699 | 'armor' => 10000, |
700 | 700 | 'attack' => 3000, |
701 | - 'amplify' => array(SHIP_SPY => 0.17, ), |
|
701 | + 'amplify' => array(SHIP_SPY => 0.17,), |
|
702 | 702 | ), |
703 | 703 | |
704 | 704 | UNIT_DEF_SHIELD_SMALL => array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | 'shield' => 2000, |
719 | 719 | 'armor' => 2000, |
720 | 720 | 'attack' => 1, |
721 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
721 | + 'amplify' => array(SHIP_SPY => 500,), |
|
722 | 722 | ), |
723 | 723 | UNIT_DEF_SHIELD_BIG => array( |
724 | 724 | 'name' => 'big_protection_shield', |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | 'shield' => 2000, |
738 | 738 | 'armor' => 10000, |
739 | 739 | 'attack' => 1, |
740 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
740 | + 'amplify' => array(SHIP_SPY => 500,), |
|
741 | 741 | ), |
742 | 742 | UNIT_DEF_SHIELD_PLANET => array( |
743 | 743 | 'name' => 'planet_protector', |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | require SN_ROOT_PHYSICAL . 'config.php'; |
77 | 77 | |
78 | 78 | $module_config_array = get_class($this) . '_config'; |
79 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
79 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
80 | 80 | $this->config = $$module_config_array; |
81 | 81 | |
82 | 82 | return true; |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | |
95 | 95 | // TODO: Load configuration from DB. Manifest setting |
96 | 96 | // Trying to load configuration from file |
97 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
97 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
98 | 98 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
99 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
99 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
100 | 100 | $config_exists = true; |
101 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
101 | + } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
102 | 102 | $config_exists = true; |
103 | 103 | } |
104 | 104 | |
105 | - if($config_exists) { |
|
105 | + if ($config_exists) { |
|
106 | 106 | include($config_filename); |
107 | 107 | $module_config_array = $class_module_name . '_config'; |
108 | 108 | $this->config = $$module_config_array; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // Checking module status - is it installed and active |
121 | 121 | $this->check_status(); |
122 | - if(!$this->manifest['active']) { |
|
122 | + if (!$this->manifest['active']) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | |
140 | 140 | protected function setSystemConstants() { |
141 | 141 | // Setting constants - if any |
142 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
142 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
146 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
146 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
147 | 147 | defined($constant_name) || define($constant_name, $constant_value); |
148 | 148 | } |
149 | 149 | } |
@@ -155,48 +155,48 @@ discard block |
||
155 | 155 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
156 | 156 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
157 | 157 | $this->manifest['vars'] = $this->__assign_vars(); |
158 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
158 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $vars_assigned = array(); |
163 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
163 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
164 | 164 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
165 | 165 | $var_name = $sub_vars[0]; |
166 | 166 | |
167 | - if(!isset($vars_assigned[$var_name])) { |
|
167 | + if (!isset($vars_assigned[$var_name])) { |
|
168 | 168 | $vars_assigned[$var_name] = true; |
169 | 169 | global $$var_name; |
170 | 170 | } |
171 | 171 | |
172 | 172 | $pointer = &$$var_name; |
173 | - if(($n = count($sub_vars)) > 1) { |
|
174 | - for($i = 1; $i < $n; $i++) { |
|
175 | - if(defined($sub_vars[$i])) { |
|
173 | + if (($n = count($sub_vars)) > 1) { |
|
174 | + for ($i = 1; $i < $n; $i++) { |
|
175 | + if (defined($sub_vars[$i])) { |
|
176 | 176 | $sub_vars[$i] = constant($sub_vars[$i]); |
177 | 177 | } |
178 | 178 | |
179 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
179 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
180 | 180 | $pointer[$sub_vars[$i]] = array(); |
181 | 181 | } |
182 | 182 | $pointer = &$pointer[$sub_vars[$i]]; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - if(!isset($pointer) || !is_array($pointer)) { |
|
186 | + if (!isset($pointer) || !is_array($pointer)) { |
|
187 | 187 | $pointer = $var_value; |
188 | - } elseif(is_array($$var_name)) { |
|
188 | + } elseif (is_array($$var_name)) { |
|
189 | 189 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
195 | - if(!is_array($menu_patch)) { |
|
195 | + if (!is_array($menu_patch)) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
199 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
200 | 200 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
201 | 201 | } |
202 | 202 | } |
@@ -205,34 +205,34 @@ discard block |
||
205 | 205 | // Overriding function if any |
206 | 206 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
207 | 207 | |
208 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
208 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
209 | 209 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | 213 | protected function mergeNavbarButton() { |
214 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
214 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
218 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
219 | 219 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | 223 | protected function mergeI18N() { |
224 | 224 | $arrayName = 'i18n'; |
225 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
225 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
230 | - foreach($contentList as &$i18n_file_data) { |
|
231 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
229 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
230 | + foreach ($contentList as &$i18n_file_data) { |
|
231 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
232 | 232 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
233 | 233 | } |
234 | 234 | } |
235 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
235 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
236 | 236 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
237 | 237 | } |
238 | 238 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | protected function mergeArraySpecial($arrayName) { |
243 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
243 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
247 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
248 | 248 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
249 | - foreach($contentList as $contentName => &$content) { |
|
249 | + foreach ($contentList as $contentName => &$content) { |
|
250 | 250 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
251 | 251 | } |
252 | 252 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Защита от двойного инита |
4 | -if(defined('INIT')) { |
|
4 | +if (defined('INIT')) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | version_compare(PHP_VERSION, '5.3.2') < 0 ? die('FATAL ERROR: SuperNova REQUIRE PHP version > 5.3.2') : false; |
21 | 21 | |
22 | 22 | // Бенчмарк |
23 | -register_shutdown_function(function () { |
|
24 | - if(defined('IN_AJAX')) { |
|
23 | +register_shutdown_function(function() { |
|
24 | + if (defined('IN_AJAX')) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') . |
32 | 32 | (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') . |
33 | 33 | '</div>'); |
34 | - if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
34 | + if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
35 | 35 | echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>'; |
36 | 36 | } |
37 | 37 | |
38 | - if(!empty($locale_cache_statistic['misses'])) { |
|
38 | + if (!empty($locale_cache_statistic['misses'])) { |
|
39 | 39 | print('<!--'); |
40 | 40 | pdump($locale_cache_statistic); |
41 | 41 | print('-->'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW)); |
57 | 57 | |
58 | -if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
58 | +if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
59 | 59 | define('SN_GOOGLE', true); |
60 | 60 | } |
61 | 61 | |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $debug = new debug(); |
106 | 106 | classSupernova::debug_set_handler($debug); |
107 | 107 | |
108 | -spl_autoload_register(function ($class) { |
|
109 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
108 | +spl_autoload_register(function($class) { |
|
109 | + if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php')) { |
|
110 | 110 | require_once SN_ROOT_PHYSICAL . 'includes/classes/' . $class . '.php'; |
111 | 111 | } |
112 | 112 | }); |
113 | 113 | |
114 | -spl_autoload_register(function ($class) { |
|
115 | - if(file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
114 | +spl_autoload_register(function($class) { |
|
115 | + if (file_exists(SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php')) { |
|
116 | 116 | require_once SN_ROOT_PHYSICAL . 'includes/classes/UBE/' . $class . '.php'; |
117 | 117 | } |
118 | 118 | }); |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | |
178 | 178 | sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX); |
179 | 179 | |
180 | -spl_autoload_register(function ($class) { |
|
181 | - if(file_exists('includes/classes/' . $class . '.php')) { |
|
180 | +spl_autoload_register(function($class) { |
|
181 | + if (file_exists('includes/classes/' . $class . '.php')) { |
|
182 | 182 | require_once 'includes/classes/' . $class . '.php'; |
183 | - } elseif(file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
183 | + } elseif (file_exists('includes/classes/UBE/' . $class . '.php')) { |
|
184 | 184 | require_once 'includes/classes/UBE/' . $class . '.php'; |
185 | 185 | } else { |
186 | 186 | // die("Can't find {$class} class"); |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | // Но нужно, пока у нас есть не MVC-страницы |
215 | 215 | $sn_page_data = $sn_data['pages'][$sn_page_name]; |
216 | 216 | $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
217 | -if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
217 | +if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
218 | 218 | require_once($sn_page_name_file); |
219 | - if(is_array($sn_page_data['options'])) { |
|
219 | + if (is_array($sn_page_data['options'])) { |
|
220 | 220 | $supernova->options = array_merge($supernova->options, $sn_page_data['options']); |
221 | 221 | } |
222 | 222 | } |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | $load_order = array(); |
232 | 232 | $sn_req = array(); |
233 | 233 | |
234 | -foreach(sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
234 | +foreach (sn_module::$sn_module as $loaded_module_name => $module_data) { |
|
235 | 235 | $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000; |
236 | - if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
237 | - foreach($module_data->manifest['require'] as $require_name) { |
|
236 | + if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) { |
|
237 | + foreach ($module_data->manifest['require'] as $require_name) { |
|
238 | 238 | $sn_req[$loaded_module_name][$require_name] = 0; |
239 | 239 | } |
240 | 240 | } |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | do { |
248 | 248 | $prev_order = $load_order; |
249 | 249 | |
250 | - foreach($sn_req as $loaded_module_name => &$req_data) { |
|
250 | + foreach ($sn_req as $loaded_module_name => &$req_data) { |
|
251 | 251 | $level = 1; |
252 | - foreach($req_data as $req_name => &$req_level) { |
|
253 | - if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
252 | + foreach ($req_data as $req_name => &$req_level) { |
|
253 | + if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) { |
|
254 | 254 | $level = $req_level = -1; |
255 | 255 | break; |
256 | 256 | } else { |
@@ -258,20 +258,20 @@ discard block |
||
258 | 258 | } |
259 | 259 | $req_level = $load_order[$req_name]; |
260 | 260 | } |
261 | - if($level > $load_order[$loaded_module_name] || $level == -1) { |
|
261 | + if ($level > $load_order[$loaded_module_name] || $level == -1) { |
|
262 | 262 | $load_order[$loaded_module_name] = $level; |
263 | 263 | } |
264 | 264 | } |
265 | -} while($prev_order != $load_order); |
|
265 | +} while ($prev_order != $load_order); |
|
266 | 266 | |
267 | 267 | asort($load_order); |
268 | 268 | |
269 | 269 | // Инициализируем модули |
270 | 270 | // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти |
271 | -foreach($load_order as $loaded_module_name => $load_order_order) { |
|
272 | - if($load_order_order >= 0) { |
|
271 | +foreach ($load_order as $loaded_module_name => $load_order_order) { |
|
272 | + if ($load_order_order >= 0) { |
|
273 | 273 | sn_module::$sn_module[$loaded_module_name]->check_status(); |
274 | - if(!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
274 | + if (!sn_module::$sn_module[$loaded_module_name]->manifest['active']) { |
|
275 | 275 | unset(sn_module::$sn_module[$loaded_module_name]); |
276 | 276 | continue; |
277 | 277 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | unset($sn_req); |
289 | 289 | |
290 | 290 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
291 | -if(!isset($sn_data['pages'][$sn_page_name])) { |
|
291 | +if (!isset($sn_data['pages'][$sn_page_name])) { |
|
292 | 292 | $sn_page_name = ''; |
293 | 293 | } |
294 | 294 | |
@@ -296,6 +296,6 @@ discard block |
||
296 | 296 | $lang = new classLocale($config->server_locale_log_usage); |
297 | 297 | $lang->lng_switch(sys_get_param_str('lang')); |
298 | 298 | |
299 | -if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
299 | +if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
300 | 300 | require_once "init_secondary.php"; |
301 | 301 | } |