@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | $destination_planet = &$mission_data->dst_planet; |
22 | 22 | |
23 | - if(empty($destination_planet['id'])) { |
|
23 | + if (empty($destination_planet['id'])) { |
|
24 | 24 | $objFleet->mark_fleet_as_returned(); |
25 | 25 | $objFleet->flush_changes_to_db(); |
26 | 26 | |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $OtherFleetCapacity = 0; |
32 | 32 | |
33 | 33 | $fleet_array = $objFleet->get_unit_list(); |
34 | - foreach($fleet_array as $unit_id => $unit_count) { |
|
35 | - if(in_array($unit_id, sn_get_groups('fleet'))) { |
|
34 | + foreach ($fleet_array as $unit_id => $unit_count) { |
|
35 | + if (in_array($unit_id, sn_get_groups('fleet'))) { |
|
36 | 36 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count; |
37 | - if(in_array($unit_id, sn_get_groups('flt_recyclers'))) { |
|
37 | + if (in_array($unit_id, sn_get_groups('flt_recyclers'))) { |
|
38 | 38 | $RecyclerCapacity += $capacity; |
39 | 39 | } else { |
40 | 40 | $OtherFleetCapacity += $capacity; |
@@ -43,33 +43,33 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | $fleet_resources_amount = $objFleet->get_resources_amount(); |
46 | - if($fleet_resources_amount > $OtherFleetCapacity) { |
|
46 | + if ($fleet_resources_amount > $OtherFleetCapacity) { |
|
47 | 47 | // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков |
48 | 48 | // Уменьшаем ёмкость переработчиков на указанную величину |
49 | 49 | $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity); |
50 | 50 | } |
51 | 51 | |
52 | 52 | $resources_recycled = array(); |
53 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
53 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
54 | 54 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
55 | 55 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
56 | 56 | } else { |
57 | - if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
57 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
58 | 58 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2) |
59 | 59 | ) { |
60 | 60 | $resources_recycled[RES_METAL] = $RecyclerCapacity / 2; |
61 | 61 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2; |
62 | 62 | } else { |
63 | - if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
63 | + if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
64 | 64 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
65 | - if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
65 | + if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
66 | 66 | $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL]; |
67 | 67 | } else { |
68 | 68 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
69 | 69 | } |
70 | 70 | } else { |
71 | 71 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
72 | - if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
72 | + if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
73 | 73 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL]; |
74 | 74 | } else { |
75 | 75 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function flt_fleet_speed($user, $fleet) { |
4 | - if(!is_array($fleet)) { |
|
4 | + if (!is_array($fleet)) { |
|
5 | 5 | $fleet = array($fleet => 1); |
6 | 6 | } |
7 | 7 | |
8 | 8 | $speeds = array(); |
9 | - if(!empty($fleet)) { |
|
10 | - foreach($fleet as $ship_id => $amount) { |
|
11 | - if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
9 | + if (!empty($fleet)) { |
|
10 | + foreach ($fleet as $ship_id => $amount) { |
|
11 | + if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
12 | 12 | $single_ship_data = get_ship_data($ship_id, $user); |
13 | 13 | $speeds[] = $single_ship_data['speed']; |
14 | 14 | } |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | function flt_travel_distance($from, $to) { |
22 | 22 | global $config; |
23 | 23 | |
24 | - if($from['galaxy'] != $to['galaxy']) { |
|
24 | + if ($from['galaxy'] != $to['galaxy']) { |
|
25 | 25 | $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance; |
26 | - } elseif($from['system'] != $to['system']) { |
|
26 | + } elseif ($from['system'] != $to['system']) { |
|
27 | 27 | $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700; |
28 | - } elseif($from['planet'] != $to['planet']) { |
|
28 | + } elseif ($from['planet'] != $to['planet']) { |
|
29 | 29 | $distance = abs($from['planet'] - $to['planet']) * 5 + 1000; |
30 | 30 | } else { |
31 | 31 | $distance = 5; |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | |
53 | 53 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
54 | 54 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
55 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
55 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
56 | 56 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
57 | 57 | $real_speed = $speed_percent * sqrt($fleet_speed); |
58 | 58 | |
59 | 59 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
60 | 60 | |
61 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
62 | - if(!$ship_id || !$ship_count) { |
|
61 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
62 | + if (!$ship_id || !$ship_count) { |
|
63 | 63 | continue; |
64 | 64 | } |
65 | 65 | |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | |
90 | 90 | $config_bashing_attacks = $config->fleet_bashing_attacks; |
91 | 91 | $config_bashing_interval = $config->fleet_bashing_interval; |
92 | - if(!$config_bashing_attacks) { |
|
92 | + if (!$config_bashing_attacks) { |
|
93 | 93 | // Bashing allowed - protection disabled |
94 | 94 | return ATTACK_ALLOWED; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $bashing_result = ATTACK_BASHING; |
98 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
98 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
99 | 99 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
100 | - if(!empty($relations)) { |
|
100 | + if (!empty($relations)) { |
|
101 | 101 | $relations = $relations[$enemy['ally_id']]; |
102 | - switch($relations['alliance_diplomacy_relation']) { |
|
102 | + switch ($relations['alliance_diplomacy_relation']) { |
|
103 | 103 | case ALLY_DIPLOMACY_WAR: |
104 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
104 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
105 | 105 | $bashing_result = ATTACK_BASHING_WAR_DELAY; |
106 | 106 | } else { |
107 | 107 | return ATTACK_ALLOWED; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | |
124 | 124 | // Retrieving flying fleets |
125 | 125 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
126 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
126 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
127 | 127 | // Checking for ACS - each ACS count only once |
128 | - if($fleetBashing->group_id) { |
|
128 | + if ($fleetBashing->group_id) { |
|
129 | 129 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
130 | 130 | } else { |
131 | 131 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
136 | - if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
136 | + if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
137 | 137 | return ATTACK_ALLOWED; |
138 | 138 | } |
139 | 139 | |
140 | 140 | $query = db_bashing_list_get($user, $planet_dst, $time_limit); |
141 | - while($bashing_row = db_fetch($query)) { |
|
141 | + while ($bashing_row = db_fetch($query)) { |
|
142 | 142 | $bashing_list[] = $bashing_row['bashing_time']; |
143 | 143 | } |
144 | 144 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | $last_attack = 0; |
148 | 148 | $wave = 0; |
149 | 149 | $attack = 1; |
150 | - foreach($bashing_list as &$bash_time) { |
|
150 | + foreach ($bashing_list as &$bash_time) { |
|
151 | 151 | $attack++; |
152 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
152 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
153 | 153 | $attack = 1; |
154 | 154 | $wave++; |
155 | 155 | } |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | //TODO: try..catch |
167 | 167 | global $config, $user; |
168 | 168 | |
169 | - if($user['vacation']) { |
|
169 | + if ($user['vacation']) { |
|
170 | 170 | return $result = ATTACK_OWN_VACATION; |
171 | 171 | } |
172 | 172 | |
173 | - if(empty($fleet) || !is_array($fleet)) { |
|
173 | + if (empty($fleet) || !is_array($fleet)) { |
|
174 | 174 | return $result = ATTACK_NO_FLEET; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $sn_groups_mission = sn_get_groups('missions'); |
178 | - if(!isset($sn_groups_mission[$mission])) { |
|
178 | + if (!isset($sn_groups_mission[$mission])) { |
|
179 | 179 | return $result = ATTACK_MISSION_ABSENT; |
180 | 180 | } |
181 | 181 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -194,32 +194,32 @@ discard block |
||
194 | 194 | $resources = 0; |
195 | 195 | $ship_ids = sn_get_groups('fleet'); |
196 | 196 | $resource_ids = sn_get_groups('resources_loot'); |
197 | - foreach($fleet as $ship_id => $ship_count) { |
|
197 | + foreach ($fleet as $ship_id => $ship_count) { |
|
198 | 198 | $is_ship = in_array($ship_id, $ship_ids); |
199 | 199 | $is_resource = in_array($ship_id, $resource_ids); |
200 | - if(!$is_ship && !$is_resource) { |
|
200 | + if (!$is_ship && !$is_resource) { |
|
201 | 201 | // TODO Спецобработчик для Капитана и модулей |
202 | 202 | // return ATTACK_WRONG_UNIT; |
203 | 203 | } |
204 | 204 | |
205 | - if($ship_count < 0) { |
|
205 | + if ($ship_count < 0) { |
|
206 | 206 | return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG; |
207 | 207 | } |
208 | 208 | |
209 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
209 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
210 | 210 | // TODO ATTACK_NO_MISSILE |
211 | 211 | return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES; |
212 | 212 | } |
213 | 213 | |
214 | - if($is_ship) { |
|
214 | + if ($is_ship) { |
|
215 | 215 | $single_ship_data = get_ship_data($ship_id, $user); |
216 | - if($single_ship_data[P_SPEED] <= 0) { |
|
216 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
217 | 217 | return $result = ATTACK_ZERO_SPEED; |
218 | 218 | } |
219 | 219 | $ships += $ship_count; |
220 | 220 | $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; |
221 | 221 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
222 | - } elseif($is_resource) { |
|
222 | + } elseif ($is_resource) { |
|
223 | 223 | $resources += $ship_count; |
224 | 224 | } |
225 | 225 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | */ |
232 | 232 | |
233 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
233 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
234 | 234 | return $result = ATTACK_RESOURCE_FORBIDDEN; |
235 | 235 | } |
236 | 236 | |
@@ -242,78 +242,78 @@ discard block |
||
242 | 242 | */ |
243 | 243 | |
244 | 244 | $speed = $options['fleet_speed_percent']; |
245 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
245 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
246 | 246 | return $result = ATTACK_WRONG_SPEED; |
247 | 247 | } |
248 | 248 | |
249 | 249 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
250 | 250 | |
251 | 251 | |
252 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
252 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
253 | 253 | return $result = ATTACK_NO_FUEL; |
254 | 254 | } |
255 | 255 | |
256 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
256 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
257 | 257 | return $result = ATTACK_TOO_FAR; |
258 | 258 | } |
259 | 259 | |
260 | - if($travel_data['hold'] < $resources) { |
|
260 | + if ($travel_data['hold'] < $resources) { |
|
261 | 261 | return $result = ATTACK_OVERLOADED; |
262 | 262 | } |
263 | 263 | |
264 | 264 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
265 | 265 | |
266 | 266 | $fleet_group = $options['fleet_group']; |
267 | - if($fleet_group) { |
|
268 | - if($mission != MT_AKS) { |
|
267 | + if ($fleet_group) { |
|
268 | + if ($mission != MT_AKS) { |
|
269 | 269 | return $result = ATTACK_WRONG_MISSION; |
270 | 270 | }; |
271 | 271 | |
272 | 272 | $acs = db_acs_get_by_group_id($fleet_group); |
273 | - if(!$acs['id']) { |
|
273 | + if (!$acs['id']) { |
|
274 | 274 | return $result = ATTACK_NO_ACS; |
275 | 275 | } |
276 | 276 | |
277 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
277 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
278 | 278 | return $result = ATTACK_ACS_WRONG_TARGET; |
279 | 279 | } |
280 | 280 | |
281 | - if($fleet_start_time > $acs['ankunft']) { |
|
281 | + if ($fleet_start_time > $acs['ankunft']) { |
|
282 | 282 | return $result = ATTACK_ACS_TOO_LATE; |
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | 286 | $flying_fleets = $options['flying_fleets']; |
287 | - if(!$flying_fleets) { |
|
287 | + if (!$flying_fleets) { |
|
288 | 288 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
289 | 289 | } |
290 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
290 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
291 | 291 | return $result = ATTACK_NO_SLOTS; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
295 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
295 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
296 | 296 | return $result = ATTACK_SPIES_LONLY; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Checking for no planet |
300 | - if(!$planet_dst['id_owner']) { |
|
301 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
300 | + if (!$planet_dst['id_owner']) { |
|
301 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
302 | 302 | return $result = ATTACK_NO_COLONIZER; |
303 | 303 | } |
304 | 304 | |
305 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
305 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
306 | 306 | return $result = ATTACK_ALLOWED; |
307 | 307 | } |
308 | 308 | |
309 | 309 | return $result = ATTACK_NO_TARGET; |
310 | 310 | } |
311 | 311 | |
312 | - if($mission == MT_RECYCLE) { |
|
313 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
312 | + if ($mission == MT_RECYCLE) { |
|
313 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
314 | 314 | return $result = ATTACK_NO_DEBRIS; |
315 | 315 | } |
316 | - if($recyclers <= 0) { |
|
316 | + if ($recyclers <= 0) { |
|
317 | 317 | return $result = ATTACK_NO_RECYCLERS; |
318 | 318 | } |
319 | 319 | |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | // Got planet. Checking if it is ours |
324 | - if($planet_dst['id_owner'] == $user['id']) { |
|
325 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
324 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
325 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
326 | 326 | return $result = ATTACK_ALLOWED; |
327 | 327 | } |
328 | 328 | |
@@ -330,19 +330,19 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
333 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
333 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
334 | 334 | return $result = ATTACK_WRONG_MISSION; |
335 | 335 | } |
336 | 336 | |
337 | 337 | $enemy = db_user_by_id($planet_dst['id_owner']); |
338 | 338 | // We cannot attack or send resource to users in VACATION mode |
339 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
339 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
340 | 340 | return $result = ATTACK_VACATION; |
341 | 341 | } |
342 | 342 | |
343 | 343 | // Multi IP protection |
344 | 344 | // TODO: Here we need a procedure to check proxies |
345 | - if(sys_is_multiaccount($user, $enemy)) { |
|
345 | + if (sys_is_multiaccount($user, $enemy)) { |
|
346 | 346 | return $result = ATTACK_SAME_IP; |
347 | 347 | } |
348 | 348 | |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | $enemy_points = $enemy['total_points']; |
351 | 351 | |
352 | 352 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
353 | - if($mission == MT_TRANSPORT) { |
|
354 | - if($user_points >= $enemy_points || $config->allow_buffing) { |
|
353 | + if ($mission == MT_TRANSPORT) { |
|
354 | + if ($user_points >= $enemy_points || $config->allow_buffing) { |
|
355 | 355 | return $result = ATTACK_ALLOWED; |
356 | 356 | } else { |
357 | 357 | return $result = ATTACK_BUFFING; |
@@ -361,66 +361,66 @@ discard block |
||
361 | 361 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
362 | 362 | |
363 | 363 | // Is it admin with planet protection? |
364 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
364 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
365 | 365 | return $result = ATTACK_ADMIN; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // Okay. Now skipping protection checks for inactive longer then 1 week |
369 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
370 | - if( |
|
369 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
370 | + if ( |
|
371 | 371 | ($enemy_points <= $config->game_noob_points && $user_points > $config->game_noob_points) |
372 | 372 | || |
373 | 373 | ($config->game_noob_factor && $user_points > $enemy_points * $config->game_noob_factor) |
374 | 374 | ) { |
375 | - if($mission != MT_HOLD) { |
|
375 | + if ($mission != MT_HOLD) { |
|
376 | 376 | return $result = ATTACK_NOOB; |
377 | 377 | } |
378 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
378 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
379 | 379 | return $result = ATTACK_NOOB; |
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | 384 | // Is it HOLD mission? If yes - there should be ally deposit |
385 | - if($mission == MT_HOLD) { |
|
386 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
385 | + if ($mission == MT_HOLD) { |
|
386 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
387 | 387 | return $result = ATTACK_ALLOWED; |
388 | 388 | } |
389 | 389 | |
390 | 390 | return $result = ATTACK_NO_ALLY_DEPOSIT; |
391 | 391 | } |
392 | 392 | |
393 | - if($mission == MT_SPY) { |
|
393 | + if ($mission == MT_SPY) { |
|
394 | 394 | return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES; |
395 | 395 | } |
396 | 396 | |
397 | 397 | // Is it MISSILE mission? |
398 | - if($mission == MT_MISSILE) { |
|
398 | + if ($mission == MT_MISSILE) { |
|
399 | 399 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
400 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
400 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
401 | 401 | return $result = ATTACK_NO_SILO; |
402 | 402 | } |
403 | 403 | |
404 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
404 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
405 | 405 | return $result = ATTACK_NO_MISSILE; |
406 | 406 | } |
407 | 407 | |
408 | 408 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
409 | 409 | $mip_range = flt_get_missile_range($user); |
410 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
410 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
411 | 411 | return $result = ATTACK_MISSILE_TOO_FAR; |
412 | 412 | } |
413 | 413 | |
414 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
414 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
415 | 415 | return $result = ATTACK_WRONG_STRUCTURE; |
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
419 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
420 | 420 | return $result = ATTACK_WRONG_MISSION; |
421 | 421 | } |
422 | 422 | |
423 | - if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
423 | + if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
424 | 424 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
425 | 425 | } |
426 | 426 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $from = $from['planet']; |
448 | 448 | |
449 | 449 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
450 | - if($can_attack != ATTACK_ALLOWED) { |
|
450 | + if ($can_attack != ATTACK_ALLOWED) { |
|
451 | 451 | $internal_transaction ? sn_db_transaction_rollback() : false; |
452 | 452 | |
453 | 453 | return $can_attack; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
459 | 459 | |
460 | 460 | $time_on_mission = 0; |
461 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
461 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
462 | 462 | // TODO - include some checks about maximum and minumum stay_duration |
463 | 463 | $time_on_mission = $options['stay_time'] * 3600; |
464 | 464 | } |
@@ -481,14 +481,14 @@ discard block |
||
481 | 481 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
482 | 482 | $db_changeset = array(); |
483 | 483 | $planet_row_changed_fields = array(); |
484 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
485 | - if(!$amount || !$unit_id) { |
|
484 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
485 | + if (!$amount || !$unit_id) { |
|
486 | 486 | continue; |
487 | 487 | } |
488 | 488 | |
489 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
489 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
490 | 490 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']); |
491 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
491 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
492 | 492 | $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
493 | 493 | } |
494 | 494 | } |
@@ -527,16 +527,16 @@ discard block |
||
527 | 527 | |
528 | 528 | $ship_data = array(); |
529 | 529 | $fleet_array = array(); |
530 | - foreach($ship_list as $transport_id => $cork) { |
|
530 | + foreach ($ship_list as $transport_id => $cork) { |
|
531 | 531 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
532 | 532 | } |
533 | 533 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
534 | 534 | |
535 | 535 | $fleet_capacity = 0; |
536 | 536 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
537 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
537 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
538 | 538 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
539 | - if($ship_loaded) { |
|
539 | + if ($ship_loaded) { |
|
540 | 540 | $fleet_array[$transport_id] = $ship_loaded; |
541 | 541 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
542 | 542 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | |
40 | 40 | $sta_update_msg = db_escape($sta_update_msg); |
41 | 41 | |
42 | - if($next_step) { |
|
42 | + if ($next_step) { |
|
43 | 43 | $sta_update_step++; |
44 | 44 | } |
45 | 45 | $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}."; |
46 | 46 | |
47 | 47 | $config->db_saveItem('var_stat_update_msg', $sta_update_msg); |
48 | - if($next_step) { |
|
48 | + if ($next_step) { |
|
49 | 49 | $debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | function sys_stat_calculate_flush(&$data, $force = false) { |
54 | - if(count($data) < 25 && !$force) { |
|
54 | + if (count($data) < 25 && !$force) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if(!empty($data)) { |
|
58 | + if (!empty($data)) { |
|
59 | 59 | doquery('REPLACE INTO {{statpoints}} |
60 | 60 | (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`, |
61 | 61 | `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`, |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id'); |
96 | 96 | $row_num = count($user_list); |
97 | 97 | // while($player = db_fetch($query)) |
98 | - foreach($user_list as $player) { |
|
99 | - if($i++ % 100 == 0) { |
|
98 | + foreach ($user_list as $player) { |
|
99 | + if ($i++ % 100 == 0) { |
|
100 | 100 | sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false); |
101 | 101 | } |
102 | - if(array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
102 | + if (array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | // $points[$user_id][UNIT_RESOURCES] += $resources; |
110 | 110 | |
111 | 111 | // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что |
112 | - if(!isset($user_skip_list[$user_id])) { |
|
112 | + if (!isset($user_skip_list[$user_id])) { |
|
113 | 113 | $user_allies[$user_id] = $player['ally_id']; |
114 | 114 | } |
115 | 115 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | $i = 0; |
124 | 124 | $query = db_planet_list_resources_by_owner(); |
125 | 125 | $row_num = db_num_rows($query); |
126 | - while($planet = db_fetch($query)) { |
|
127 | - if($i++ % 100 == 0) { |
|
126 | + while ($planet = db_fetch($query)) { |
|
127 | + if ($i++ % 100 == 0) { |
|
128 | 128 | sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false); |
129 | 129 | } |
130 | - if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
130 | + if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | $i = 0; |
143 | 143 | $query = FleetList::dbQueryAllId(); |
144 | 144 | $row_num = db_num_rows($query); |
145 | - while($fleet_row = db_fetch($query)) { |
|
146 | - if($i++ % 100 == 0) { |
|
145 | + while ($fleet_row = db_fetch($query)) { |
|
146 | + if ($i++ % 100 == 0) { |
|
147 | 147 | sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false); |
148 | 148 | } |
149 | 149 | $objFleet = new Fleet(); |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными |
152 | 152 | // $objFleet->_reset(); |
153 | 153 | $objFleet->dbRowParse($fleet_row); |
154 | - if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
154 | + if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $fleet = $objFleet->get_unit_list(); |
159 | - foreach($fleet as $unit_id => $unit_amount) { |
|
159 | + foreach ($fleet as $unit_id => $unit_amount) { |
|
160 | 160 | $counts[$user_id][UNIT_SHIPS] += $unit_amount; |
161 | 161 | |
162 | - if(!isset($unit_cost_cache[$unit_id][0])) { |
|
162 | + if (!isset($unit_cost_cache[$unit_id][0])) { |
|
163 | 163 | $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST); |
164 | 164 | } |
165 | 165 | $unit_cost_data = &$unit_cost_cache[$unit_id][0]; |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | $i = 0; |
180 | 180 | $query = db_unit_list_stat_calculate(); |
181 | 181 | $row_num = db_num_rows($query); |
182 | - while($unit = db_fetch($query)) { |
|
183 | - if($i++ % 100 == 0) { |
|
182 | + while ($unit = db_fetch($query)) { |
|
183 | + if ($i++ % 100 == 0) { |
|
184 | 184 | sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false); |
185 | 185 | } |
186 | - if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
186 | + if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | $i = 0; |
198 | 198 | $query = db_que_list_stat(); |
199 | 199 | $row_num = db_num_rows($query); |
200 | - while($que_item = db_fetch($query)) { |
|
201 | - if($i++ % 100 == 0) { |
|
200 | + while ($que_item = db_fetch($query)) { |
|
201 | + if ($i++ % 100 == 0) { |
|
202 | 202 | sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false); |
203 | 203 | } |
204 | - if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
204 | + if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | $que_unit_amount = $que_item['que_unit_amount']; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | sta_set_time_limit('posting new user stats to DB'); |
221 | 221 | $data = array(); |
222 | - foreach($user_allies as $user_id => $ally_id) { |
|
222 | + foreach ($user_allies as $user_id => $ally_id) { |
|
223 | 223 | // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000 |
224 | 224 | $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000; |
225 | 225 | $points[$user_id] = array_map('floor', $points[$user_id]); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | // Updating player's ranks |
277 | 277 | sta_set_time_limit("updating ranks for players"); |
278 | - foreach($rankNames as $rankName) { |
|
278 | + foreach ($rankNames as $rankName) { |
|
279 | 279 | sta_set_time_limit("updating player rank '{$rankName}'", false); |
280 | 280 | doquery($qryResetRowNum); |
281 | 281 | doquery(sprintf($qryFormat, $rankName, 1)); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | sta_set_time_limit("updating ranks for Alliances"); |
285 | 285 | // --- Updating Allie's ranks |
286 | - foreach($rankNames as $rankName) { |
|
286 | + foreach ($rankNames as $rankName) { |
|
287 | 287 | sta_set_time_limit("updating Alliances rank '{$rankName}'", false); |
288 | 288 | doquery($qryResetRowNum); |
289 | 289 | doquery(sprintf($qryFormat, $rankName, 2)); |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | global $config; |
16 | 16 | |
17 | 17 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
18 | - if($ube->get_cypher()) { |
|
18 | + if ($ube->get_cypher()) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | 22 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
23 | 23 | do { |
24 | 24 | $ube->report_cypher = sys_random_string(32); |
25 | - } while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
25 | + } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
26 | 26 | |
27 | 27 | // Инициализация таблицы для пакетной вставки информации |
28 | 28 | $sql_perform = array( |
@@ -113,21 +113,21 @@ discard block |
||
113 | 113 | `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "', |
114 | 114 | `ube_report_time_spent` = {$ube->time_spent}, |
115 | 115 | |
116 | - `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ", |
|
116 | + `ube_report_combat_admin` = " . (int) $ube->is_admin_in_combat . ", |
|
117 | 117 | `ube_report_mission_type` = {$ube->mission_type_id}, |
118 | 118 | |
119 | 119 | `ube_report_combat_result` = {$ube->combat_result}, |
120 | - `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ", |
|
120 | + `ube_report_combat_sfr` = " . (int) $ube->is_small_fleet_recce . ", |
|
121 | 121 | |
122 | - `ube_report_planet_id` = " . (int)$ube->ube_planet_info[PLANET_ID] . ", |
|
122 | + `ube_report_planet_id` = " . (int) $ube->ube_planet_info[PLANET_ID] . ", |
|
123 | 123 | `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "', |
124 | - `ube_report_planet_size` = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ", |
|
125 | - `ube_report_planet_galaxy` = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ", |
|
126 | - `ube_report_planet_system` = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
127 | - `ube_report_planet_planet` = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ", |
|
128 | - `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ", |
|
124 | + `ube_report_planet_size` = " . (int) $ube->ube_planet_info[PLANET_SIZE] . ", |
|
125 | + `ube_report_planet_galaxy` = " . (int) $ube->ube_planet_info[PLANET_GALAXY] . ", |
|
126 | + `ube_report_planet_system` = " . (int) $ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
127 | + `ube_report_planet_planet` = " . (int) $ube->ube_planet_info[PLANET_PLANET] . ", |
|
128 | + `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE] . ", |
|
129 | 129 | |
130 | - `ube_report_capture_result` = " . (int)$ube->capture_result . ", " |
|
130 | + `ube_report_capture_result` = " . (int) $ube->capture_result . ", " |
|
131 | 131 | . $ube->debris->report_generate_sql($config) |
132 | 132 | . $ube->moon_calculator->report_generate_sql(); |
133 | 133 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | // Сохраняем общую информацию по игрокам |
138 | 138 | $player_sides = $ube->players->get_player_sides(); |
139 | - foreach($player_sides as $player_id => $player_side) { |
|
139 | + foreach ($player_sides as $player_id => $player_side) { |
|
140 | 140 | $sql_perform['ube_report_player'][] = array( |
141 | 141 | $ube_report_id, |
142 | 142 | $player_id, |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | "'" . db_escape($ube->players[$player_id]->name) . "'", |
145 | 145 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
146 | 146 | |
147 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
148 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
149 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
147 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
148 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
149 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
153 | 153 | // Всякая информация по флотам |
154 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
154 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
155 | 155 | // Сохраняем общую информацию по флотам |
156 | 156 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
157 | 157 | |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
168 | 168 | |
169 | 169 | // Пакетная вставка данных |
170 | - foreach($sql_perform as $table_name => $table_data) { |
|
171 | - if(count($table_data) < 2) { |
|
170 | + foreach ($sql_perform as $table_name => $table_data) { |
|
171 | + if (count($table_data) < 2) { |
|
172 | 172 | continue; |
173 | 173 | } |
174 | - foreach($table_data as &$record_data) { |
|
174 | + foreach ($table_data as &$record_data) { |
|
175 | 175 | $record_data = '(' . implode(',', $record_data) . ')'; |
176 | 176 | } |
177 | 177 | $fields = $table_data[0]; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $report_cypher = db_escape($report_cypher); |
195 | 195 | |
196 | 196 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
197 | - if(!$report_row) { |
|
197 | + if (!$report_row) { |
|
198 | 198 | return UBE_REPORT_NOT_FOUND; |
199 | 199 | } |
200 | 200 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param $template_result |
211 | 211 | */ |
212 | 212 | function sn_ube_report_generate(UBE $ube, &$template_result) { |
213 | - if(!is_object($ube)) { |
|
213 | + if (!is_object($ube)) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
@@ -227,15 +227,15 @@ discard block |
||
227 | 227 | |
228 | 228 | // Координаты, тип и название планеты - если есть |
229 | 229 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
230 | - if(isset($ube->ube_planet_info)) { |
|
230 | + if (isset($ube->ube_planet_info)) { |
|
231 | 231 | $template_result += $ube->ube_planet_info; |
232 | 232 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
233 | 233 | } |
234 | 234 | |
235 | 235 | // Обломки |
236 | 236 | $debris = array(); |
237 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
238 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
237 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
238 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
239 | 239 | $debris[] = array( |
240 | 240 | 'NAME' => $lang['tech'][$resource_id], |
241 | 241 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | parent::setUnitId($unitId); |
51 | 51 | |
52 | 52 | // Reset combat stats?? |
53 | - if($this->_unitId) { |
|
53 | + if ($this->_unitId) { |
|
54 | 54 | $this->amplify = $this->info[P_AMPLIFY]; |
55 | 55 | $this->capacity = $this->info[P_CAPACITY]; |
56 | 56 | $this->price[RES_METAL] = $this->info[P_COST][RES_METAL]; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $this->bonus_attack = $this->info[P_ATTACK]; |
73 | 73 | $this->bonus_shield = $this->info[P_SHIELD]; |
74 | 74 | $this->bonus_armor = $this->info[P_ARMOR]; |
75 | - if(is_object($this->unit_bonus)) { |
|
75 | + if (is_object($this->unit_bonus)) { |
|
76 | 76 | $this->bonus_attack = floor($this->bonus_attack * $this->unit_bonus->calcBonus(P_ATTACK)); |
77 | 77 | $this->bonus_shield = floor($this->bonus_shield * $this->unit_bonus->calcBonus(P_SHIELD)); |
78 | 78 | $this->bonus_armor = floor($this->bonus_armor * $this->unit_bonus->calcBonus(P_ARMOR)); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->randomized_attack = $this->bonus_attack; |
81 | 81 | $this->randomized_shield = $this->bonus_shield; |
82 | 82 | $this->randomized_armor = $this->bonus_armor; |
83 | - if(!$is_simulator) { |
|
83 | + if (!$is_simulator) { |
|
84 | 84 | // TODO - randomize attack if is not simulator |
85 | 85 | $this->randomized_attack = floor($this->bonus_attack * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100)); |
86 | 86 | $this->randomized_shield = floor($this->bonus_shield * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100)); |
@@ -159,22 +159,22 @@ discard block |
||
159 | 159 | * @version 2016-02-25 23:42:45 41a4.68 |
160 | 160 | */ |
161 | 161 | public function restore_unit($is_simulator) { |
162 | - if($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) { |
|
162 | + if ($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - if($is_simulator) { |
|
166 | + if ($is_simulator) { |
|
167 | 167 | $units_giveback = round($this->units_lost * UBE_DEFENCE_RESTORATION_CHANCE_AVG / 100); // for simulation just return 75% of loss |
168 | 168 | } else { |
169 | 169 | // Checking - should we trigger mass-restore |
170 | - if($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) { |
|
170 | + if ($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) { |
|
171 | 171 | // For large amount - mass-restoring defence |
172 | 172 | $units_giveback = round($this->units_lost * mt_rand(UBE_DEFENCE_RESTORATION_CHANCE_MIN, UBE_DEFENCE_RESTORATION_CHANCE_MAX) / 100); |
173 | 173 | } else { |
174 | 174 | // For small amount - restoring defence per single unit |
175 | 175 | $units_giveback = 0; |
176 | - for($i = 1; $i <= $this->units_lost; $i++) { |
|
177 | - if(mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) { |
|
176 | + for ($i = 1; $i <= $this->units_lost; $i++) { |
|
177 | + if (mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) { |
|
178 | 178 | $units_giveback++; |
179 | 179 | } |
180 | 180 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function receive_damage($is_simulator) { |
195 | 195 | // TODO - Добавить взрывы от полуповрежденных юнитов - т.е. заранее вычислить из убитых юнитов еще количество убитых умножить на вероятность от структуры |
196 | - if($this->_count <= 0) { |
|
196 | + if ($this->_count <= 0) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $this->adjustCount(-$units_lost); |
217 | 217 | |
218 | 218 | // Проверяем - не взорвался ли текущий юнит |
219 | - while($this->_count > 0 && $this->attack_income > 0) { |
|
219 | + while ($this->_count > 0 && $this->attack_income > 0) { |
|
220 | 220 | $this->attack_damaged_unit($is_simulator); |
221 | 221 | } |
222 | 222 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $armor_left = $this->pool_armor % $this->randomized_armor; |
242 | 242 | // Проверка - не атакуем ли мы целый корабль |
243 | 243 | // Такое может быть, если на прошлой итерации поврежденный корабль был взорван и еще осталась входящяя атака |
244 | - if($shield_left == 0 && $armor_left == 0) { |
|
244 | + if ($shield_left == 0 && $armor_left == 0) { |
|
245 | 245 | $shield_left = $this->randomized_shield; |
246 | 246 | $armor_left = $this->randomized_armor; |
247 | 247 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | // Вычитаем этот дамадж из щитов пула |
256 | 256 | $this->pool_shield -= $damage_to_shield; |
257 | 257 | // Если весь дамадж был поглощён щитами - выходим |
258 | - if($this->attack_income <= 0) { |
|
258 | + if ($this->attack_income <= 0) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $armor_left -= $damage_to_armor; |
273 | 273 | |
274 | 274 | // Проверяем - осталась ли броня на текущем корабле и вааще |
275 | - if($this->pool_armor <= 0 || $armor_left <= 0) { |
|
275 | + if ($this->pool_armor <= 0 || $armor_left <= 0) { |
|
276 | 276 | // Не осталось - корабль уничтожен |
277 | 277 | $this->adjustCount(-1); |
278 | 278 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | $armor_left_percent = $armor_left / $this->randomized_armor * 100; |
284 | 284 | // Проверяем % здоровья |
285 | 285 | // TODO - сделать динамический процент для каждого вида юнитов |
286 | - if($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) { |
|
286 | + if ($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) { |
|
287 | 287 | // Дамадж пошёл по структуре. Чем более поврежден юнит - тем больше шансов у него взорваться |
288 | 288 | $random = $is_simulator ? UBE_CRITICAL_DAMAGE_THRESHOLD / 2 : mt_rand(0, 100); |
289 | - if($random >= $armor_left_percent) { |
|
289 | + if ($random >= $armor_left_percent) { |
|
290 | 290 | $this->adjustCount(-1); |
291 | 291 | $this->unit_count_boom++; |
292 | 292 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | UBE_PLAYER_IS_DEFENDER => array(), |
56 | 56 | ); |
57 | 57 | |
58 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
58 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
59 | 59 | $result[$UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER][$player_id] = $UBEPlayer->getDbRow(); |
60 | 60 | } |
61 | 61 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function get_first_player_on_side($side) { |
72 | 72 | $result = null; |
73 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
74 | - if($UBEPlayer->getSide() == $side) { |
|
73 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
74 | + if ($UBEPlayer->getSide() == $side) { |
|
75 | 75 | $result = $UBEPlayer; |
76 | 76 | break; |
77 | 77 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function get_player_sides() { |
90 | 90 | $result = array(); |
91 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
91 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
92 | 92 | $result[$player_id] = $UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER; |
93 | 93 | } |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | public function ubeLoadPlayersAndSetSideFromFleetIdList(array $added_fleets, UBEFleetList $fleetList, $side = UBE_PLAYER_IS_DEFENDER) { |
99 | - foreach($added_fleets as $fleet_id) { |
|
99 | + foreach ($added_fleets as $fleet_id) { |
|
100 | 100 | $this->db_load_player_by_id($fleetList[$fleet_id]->owner_id, $side); |
101 | 101 | } |
102 | 102 | } |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function ube_db_load_fleets_outcome($report_row) { |
84 | 84 | $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
85 | - while($row = db_fetch($query)) { |
|
85 | + while ($row = db_fetch($query)) { |
|
86 | 86 | $fleet_id = $row['ube_report_outcome_fleet_fleet_id']; |
87 | 87 | $this[$fleet_id]->load_outcome_from_report_row($row); |
88 | 88 | } |
89 | 89 | |
90 | 90 | $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`"); |
91 | - while($row = db_fetch($query)) { |
|
91 | + while ($row = db_fetch($query)) { |
|
92 | 92 | $fleet_id = $row['ube_report_outcome_unit_fleet_id']; |
93 | 93 | $this[$fleet_id]->load_unit_outcome_from_row($row); |
94 | 94 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | UBE_PLAYER_IS_DEFENDER => array(), |
109 | 109 | ); |
110 | 110 | |
111 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
111 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
112 | 112 | $result[$UBEFleet->is_attacker][] = array( |
113 | 113 | 'ID' => $fleet_id, |
114 | 114 | 'NAME' => $ube->players[$UBEFleet->owner_id]->name, |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function ube_analyze_fleets($is_simulator, UBEDebris $debris, array $resource_exchange_rates) { |
133 | 133 | // Генерируем результат боя |
134 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
134 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
135 | 135 | // Инициализируем массив результатов для флота |
136 | 136 | // $this->init_fleet_outcome_and_link_to_side($UBEFleet); |
137 | 137 | |
138 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
138 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
139 | 139 | $UBEUnit->ube_analyze_unit($is_simulator); |
140 | 140 | } |
141 | 141 | |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | $this->resources_lost_in_metal = array( |
153 | 153 | RES_METAL => 0, |
154 | 154 | ); |
155 | - foreach($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) { |
|
155 | + foreach ($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) { |
|
156 | 156 | $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id]; |
157 | 157 | } |
158 | - foreach($UBEFleet->cargo_dropped as $resource_id => $resource_amount) { |
|
158 | + foreach ($UBEFleet->cargo_dropped as $resource_id => $resource_amount) { |
|
159 | 159 | $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id]; |
160 | 160 | } |
161 | 161 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function ube_get_groups() { |
168 | 168 | $result = array(); |
169 | - foreach($this->_container as $UBEFleet) { |
|
170 | - if($UBEFleet->group_id) { |
|
169 | + foreach ($this->_container as $UBEFleet) { |
|
170 | + if ($UBEFleet->group_id) { |
|
171 | 171 | $result[$UBEFleet->group_id] = $UBEFleet->group_id; |
172 | 172 | } |
173 | 173 | } |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function ube_get_capacity_attackers() { |
182 | 182 | $result = 0; |
183 | - foreach($this->_container as $UBEFleet) { |
|
184 | - if($UBEFleet->is_attacker) { |
|
183 | + foreach ($this->_container as $UBEFleet) { |
|
184 | + if ($UBEFleet->is_attacker) { |
|
185 | 185 | $result += $UBEFleet->fleet_capacity; |
186 | 186 | } |
187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function ube_db_load_from_report_row(array $report_row, UBE $ube) { |
197 | 197 | $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
198 | - while($fleet_row = db_fetch($query)) { |
|
198 | + while ($fleet_row = db_fetch($query)) { |
|
199 | 199 | $objFleet = new UBEFleet(); |
200 | 200 | $objFleet->load_from_report($fleet_row, $ube); |
201 | 201 | $this[$objFleet->db_id] = $objFleet; |
@@ -209,20 +209,20 @@ discard block |
||
209 | 209 | * @version 2016-02-25 23:42:45 41a4.68 |
210 | 210 | */ |
211 | 211 | public function ube_prepare_for_next_round($is_simulator) { |
212 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
212 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
213 | 213 | $UBEFleet->prepare_for_next_round($is_simulator); |
214 | 214 | } |
215 | 215 | |
216 | 216 | // Суммируем данные по атакующим и защитникам |
217 | 217 | $this->ube_total[UBE_PLAYER_IS_ATTACKER]->_reset(); |
218 | 218 | $this->ube_total[UBE_PLAYER_IS_DEFENDER]->_reset(); |
219 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
219 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
220 | 220 | $this->ube_total[$UBEFleet->is_attacker]->add_unit_stats_array($UBEFleet->total_stats); |
221 | 221 | } |
222 | 222 | //pvar_dump($this->ube_total); |
223 | 223 | |
224 | 224 | // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще |
225 | - foreach($this->_container as $fleet_id => $UBEFleet) { |
|
225 | + foreach ($this->_container as $fleet_id => $UBEFleet) { |
|
226 | 226 | $UBEFleet->calculate_unit_partial_data($this->ube_total[$UBEFleet->is_attacker]); |
227 | 227 | } |
228 | 228 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function ube_calculate_attack_results(UBE $ube) { |
238 | 238 | // Каждый флот атакует все |
239 | - foreach($this->_container as $attack_fleet_data) { |
|
239 | + foreach ($this->_container as $attack_fleet_data) { |
|
240 | 240 | defined('DEBUG_UBE') ? print("Fleet {$attack_fleet_data->db_id} attacks<br /><div style='margin-left: 30px;'>") : false; |
241 | 241 | |
242 | 242 | $attack_fleet_data->attack_fleets($this, $ube->is_simulator); |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @version 2016-02-25 23:42:45 41a4.68 |
252 | 252 | */ |
253 | 253 | public function ube_actualize_sides() { |
254 | - foreach($this->_container as $UBEFleet) { |
|
255 | - if($UBEFleet->get_unit_count() > 0) { |
|
254 | + foreach ($this->_container as $UBEFleet) { |
|
255 | + if ($UBEFleet->get_unit_count() > 0) { |
|
256 | 256 | $this->ube_side_present_at_round_start[$UBEFleet->is_attacker] = 1; |
257 | 257 | } |
258 | 258 | } |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function ube_calculate_attack_reapers() { |
267 | 267 | $reapers = 0; |
268 | - foreach($this->_container as $fleet_id => $UBERoundFleetCombat) { |
|
269 | - if($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) { |
|
268 | + foreach ($this->_container as $fleet_id => $UBERoundFleetCombat) { |
|
269 | + if ($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) { |
|
270 | 270 | $reapers += $UBERoundFleetCombat->unit_list->unitCountReapers(); |
271 | 271 | } |
272 | 272 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | |
284 | 284 | $result = UBE_COMBAT_RESULT_DRAW; |
285 | 285 | // Проверяем результат боя |
286 | - if($this->ube_get_sides_count() == 0 || $round >= 10) { |
|
286 | + if ($this->ube_get_sides_count() == 0 || $round >= 10) { |
|
287 | 287 | // Если кого-то не осталось или не осталось обоих - заканчиваем цикл |
288 | 288 | $result = UBE_COMBAT_RESULT_DRAW_END; |
289 | - } elseif($this->ube_get_sides_count() == 1) { |
|
289 | + } elseif ($this->ube_get_sides_count() == 1) { |
|
290 | 290 | // Если осталась одна сторона - она и выиграла |
291 | 291 | $result = isset($this->ube_side_present_at_round_start[UBE_PLAYER_IS_ATTACKER]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS; |
292 | 292 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @version 41a6.16 |
304 | 304 | */ |
305 | 305 | public function ubeInitGetAttackers(Fleet $objFleet, UBEPlayerList $players) { |
306 | - if($objFleet->group_id) { |
|
306 | + if ($objFleet->group_id) { |
|
307 | 307 | $fleets_added = $this->dbLoadWhere("`fleet_group` = {$objFleet->group_id}"); |
308 | 308 | } else { |
309 | 309 | $this->ube_insert_from_Fleet($objFleet); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $debris_for_moon = $debris->debris_total(); |
72 | 72 | |
73 | - if(!$debris_for_moon) { |
|
73 | + if (!$debris_for_moon) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
80 | 80 | $this->create_chance = $moon_chance; |
81 | - if($moon_chance) { |
|
82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
81 | + if ($moon_chance) { |
|
82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
85 | 85 | |
86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
87 | 87 | $debris->_reset(); |
88 | 88 | } else { |
89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function moon_destroy_try($reapers) { |
104 | 104 | // TODO: $is_simulator |
105 | - if($reapers <= 0) { |
|
105 | + if ($reapers <= 0) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
121 | 121 | */ |
122 | 122 | public function calculate_moon(UBE $ube) { |
123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
126 | 126 | $this->moon_destroy_try($reapers); |
127 | 127 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | public function report_generate_sql() { |
134 | - return "`ube_report_moon` = " . (int)$this->status . ", |
|
135 | - `ube_report_moon_chance` = " . (int)$this->create_chance . ", |
|
136 | - `ube_report_moon_size` = " . (float)$this->moon_diameter . ", |
|
137 | - `ube_report_moon_reapers` = " . (int)$this->reapers_status . ", |
|
138 | - `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ", |
|
139 | - `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance; |
|
134 | + return "`ube_report_moon` = " . (int) $this->status . ", |
|
135 | + `ube_report_moon_chance` = " . (int) $this->create_chance . ", |
|
136 | + `ube_report_moon_size` = " . (float) $this->moon_diameter . ", |
|
137 | + `ube_report_moon_reapers` = " . (int) $this->reapers_status . ", |
|
138 | + `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance . ", |
|
139 | + `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function report_render_moon() { |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | * @param $planet_id |
167 | 167 | */ |
168 | 168 | public function db_apply_result($planet_info, $destination_user_id) { |
169 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
169 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
170 | 170 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
171 | 171 | $this->moon_name = $moon_row['name']; |
172 | 172 | unset($moon_row); |
173 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
173 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
174 | 174 | db_planet_delete_by_id($planet_info[PLANET_ID]); |
175 | 175 | } |
176 | 176 | } |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | global $lang; |
180 | 180 | |
181 | 181 | $text_defender = ''; |
182 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
182 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
183 | 183 | $text_defender .= "{$lang['ube_report_moon_created']} {$this->moon_diameter} {$lang['sys_kilometers_short']}<br /><br />"; |
184 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
184 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
185 | 185 | $text_defender .= "{$lang['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
186 | 186 | } |
187 | 187 | |
188 | - if($ube->mission_type_id == MT_DESTROY) { |
|
189 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
188 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
189 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
190 | 190 | $text_defender .= $lang['ube_report_moon_reapers_none']; |
191 | 191 | } else { |
192 | 192 | $text_defender .= "{$lang['ube_report_moon_reapers_wave']}. {$lang['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @version 2016-02-25 23:42:45 41a4.68 |
216 | 216 | */ |
217 | 217 | public function ubeInitLoadStatis($destination_planet) { |
218 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
218 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
219 | 219 | $this->status = UBE_MOON_EXISTS; |
220 | 220 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
221 | 221 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function report_render_rounds(&$template_result, UBE $ube) { |
27 | 27 | $round_count = $this->count(); |
28 | - for($round = 1; $round <= $round_count - 1; $round++) { |
|
28 | + for ($round = 1; $round <= $round_count - 1; $round++) { |
|
29 | 29 | $template_result['.']['round'][] = array( |
30 | 30 | 'NUMBER' => $round, |
31 | 31 | '.' => array( |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function sql_generate_unit_array(array &$sql_perform_ube_report_unit, $ube_report_id, UBEFleetList $UBEFleetList) { |
50 | 50 | $unit_sort_order = 1; |
51 | - foreach($this->_container as $round_number => $UBERound) { |
|
51 | + foreach ($this->_container as $round_number => $UBERound) { |
|
52 | 52 | $outer_prefix = array( |
53 | 53 | $ube_report_id, |
54 | 54 | $round_number, |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function db_load_round_list_from_report_row($report_row, UBE $ube) { |
68 | 68 | $query = doquery("SELECT * FROM {{ube_report_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_unit_id`"); |
69 | - while($report_unit_row = db_fetch($query)) { |
|
69 | + while ($report_unit_row = db_fetch($query)) { |
|
70 | 70 | $round_number = $report_unit_row['ube_report_unit_round']; |
71 | - if(!isset($this[$round_number])) { |
|
71 | + if (!isset($this[$round_number])) { |
|
72 | 72 | $this[$round_number] = new UBERound(); |
73 | 73 | $this[$round_number]->init_round_from_report_unit_row($report_unit_row); |
74 | 74 | } |