@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | */ |
12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
13 | 13 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
14 | - foreach($unit_group as $unit_id) { |
|
15 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
14 | + foreach ($unit_group as $unit_id) { |
|
15 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
16 | 16 | $compress_data[$unit_id] = $unit_count; |
17 | 17 | } |
18 | 18 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | global $lang; |
23 | 23 | |
24 | 24 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
25 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
26 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
25 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
26 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
27 | 27 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
28 | 28 | } |
29 | 29 | |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | |
55 | 55 | $objFleet = $mission_data->fleet; |
56 | 56 | |
57 | - if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
57 | + if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
58 | 58 | $objFleet->mark_fleet_as_returned_and_save(); |
59 | 59 | |
60 | 60 | return $result; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $spy_probes = $objFleet->shipCountById(SHIP_SPY); |
64 | - if($spy_probes > 0) { |
|
64 | + if ($spy_probes > 0) { |
|
65 | 65 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
66 | 66 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
67 | 67 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
86 | 86 | $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
87 | 87 | $spy_message .= "</tr>"; |
88 | - if($spy_diff >= 2) { |
|
88 | + if ($spy_diff >= 2) { |
|
89 | 89 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', $lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
90 | 90 | coe_compress_add_units(sn_get_groups('fleet'), $target_planet_row, $combat_pack[0]); |
91 | 91 | } |
92 | - if($spy_diff >= 3) { |
|
92 | + if ($spy_diff >= 3) { |
|
93 | 93 | $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', $lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
94 | 94 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
95 | 95 | } |
96 | - if($spy_diff >= 5) { |
|
96 | + if ($spy_diff >= 5) { |
|
97 | 97 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
98 | 98 | } |
99 | 99 | |
100 | - if($spy_diff_empire >= 0) { |
|
100 | + if ($spy_diff_empire >= 0) { |
|
101 | 101 | $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
102 | 102 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
103 | 103 | } |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
107 | 107 | |
108 | 108 | $target_unit_list = 0; |
109 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
109 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
110 | 110 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
114 | 114 | |
115 | - if(mt_rand(0, 99) > $spy_detected) { |
|
115 | + if (mt_rand(0, 99) > $spy_detected) { |
|
116 | 116 | $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected); |
117 | 117 | $spy_detected = false; |
118 | 118 | } else { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $target_message = "{$lang['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
133 | 133 | $target_message .= " {$lang['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
134 | 134 | |
135 | - if($spy_detected) { |
|
135 | + if ($spy_detected) { |
|
136 | 136 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
137 | 137 | |
138 | 138 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message); |
150 | 150 | } |
151 | 151 | |
152 | - if($spy_detected) { |
|
152 | + if ($spy_detected) { |
|
153 | 153 | $objFleet->db_delete_this_fleet(); |
154 | 154 | } else { |
155 | 155 | $objFleet->mark_fleet_as_returned_and_save(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | $destination_planet = &$mission_data->dst_planet; |
18 | 18 | |
19 | - if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
19 | + if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
20 | 20 | $objFleet->mark_fleet_as_returned_and_save(); |
21 | 21 | |
22 | 22 | return CACHE_FLEET; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $fleet_resources[RES_DEUTERIUM], $lang['Deuterium'] |
32 | 32 | ) . '<br />' . $lang['sys_relocate_mess_user']; |
33 | 33 | $fleet_real_array = $objFleet->get_unit_list(); |
34 | - foreach($fleet_real_array as $ship_id => $ship_count) { |
|
34 | + foreach ($fleet_real_array as $ship_id => $ship_count) { |
|
35 | 35 | $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
36 | 36 | } |
37 | 37 | msg_send_simple_message( |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $source_planet = &$mission_data->src_planet; |
17 | 17 | $destination_planet = &$mission_data->dst_planet; |
18 | 18 | |
19 | - if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) { |
|
19 | + if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) { |
|
20 | 20 | $objFleet->mark_fleet_as_returned_and_save(); |
21 | 21 | |
22 | 22 | return CACHE_FLEET; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']); |
32 | 32 | msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
33 | 33 | |
34 | - if($objFleet->target_owner_id <> $objFleet->playerOwnerId) { |
|
34 | + if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) { |
|
35 | 35 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message); |
36 | 36 | } |
37 | 37 |
@@ -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"]; |
@@ -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); |