@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
15 | 15 | $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100)); |
16 | - foreach($structures as $key => $structure) |
|
16 | + foreach ($structures as $key => $structure) |
|
17 | 17 | { |
18 | 18 | $unit_info = get_unit_param($key); |
19 | 19 | $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | { |
32 | 32 | //attacking only selected structure |
33 | 33 | $damageDone = $structures[$targetedStructure][$damageTo]; |
34 | - $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
|
34 | + $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]); |
|
35 | 35 | $structures[$targetedStructure][0] -= $structsDestroyed; |
36 | - $MIPDamage -= $structsDestroyed*$damageDone; |
|
36 | + $MIPDamage -= $structsDestroyed * $damageDone; |
|
37 | 37 | } |
38 | 38 | else |
39 | 39 | { |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | do |
45 | 45 | { |
46 | 46 | // finding is there any structure that can be damaged with leftovers of $MIPDamage |
47 | - foreach($can_be_damaged as $key => $unit_id) |
|
47 | + foreach ($can_be_damaged as $key => $unit_id) |
|
48 | 48 | { |
49 | 49 | //debug($structures[$unit_id][0]); |
50 | 50 | //debug($structures[$unit_id][$damageTo], $MIPDamage); |
51 | - if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage) |
|
51 | + if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage) |
|
52 | 52 | { |
53 | 53 | unset($can_be_damaged[$key]); |
54 | 54 | } |
55 | 55 | } |
56 | - if(empty($can_be_damaged)) |
|
56 | + if (empty($can_be_damaged)) |
|
57 | 57 | { |
58 | 58 | break; |
59 | 59 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | //debug($destroyed, 'Actually destroyed'); |
73 | 73 | |
74 | 74 | //print('<hr>'); |
75 | - } while($MIPDamage > 0 && !empty($can_be_damaged)); |
|
75 | + } while ($MIPDamage > 0 && !empty($can_be_damaged)); |
|
76 | 76 | //debug($MIPDamage, 'MIPDamage left'); |
77 | 77 | } |
78 | 78 | //debug($structures);//die(); |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4; |
88 | 88 | } |
89 | 89 | |
90 | - $return['structures'] = $structures; // Structures left after attack |
|
91 | - $return['metal'] = floor($metal); // Metal scraps |
|
90 | + $return['structures'] = $structures; // Structures left after attack |
|
91 | + $return['metal'] = floor($metal); // Metal scraps |
|
92 | 92 | $return['crystal'] = floor($crystal); // Crystal scraps |
93 | 93 | |
94 | 94 | return $return; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | $iraks = db_missile_list_by_arrival(); |
114 | 114 | |
115 | - while($fleetRow = db_fetch($iraks)) { |
|
115 | + while ($fleetRow = db_fetch($iraks)) { |
|
116 | 116 | set_time_limit(15); |
117 | 117 | $db_changeset = array(); |
118 | 118 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true); |
130 | 130 | |
131 | - if($target_planet_row['id']) { |
|
131 | + if ($target_planet_row['id']) { |
|
132 | 132 | $planetDefense = array(); |
133 | - foreach(sn_get_groups('defense_active') as $unit_id) { |
|
133 | + foreach (sn_get_groups('defense_active') as $unit_id) { |
|
134 | 134 | $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true)); |
135 | 135 | } |
136 | 136 | |
@@ -141,24 +141,24 @@ discard block |
||
141 | 141 | $message = classLocale::$lang['mip_all_destroyed']; |
142 | 142 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']); |
143 | 143 | } else { |
144 | - if($interceptors) { |
|
144 | + if ($interceptors) { |
|
145 | 145 | $message = sprintf(classLocale::$lang['mip_destroyed'], $interceptors); |
146 | 146 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']); |
150 | 150 | |
151 | - foreach($attackResult['structures'] as $key => $structure) { |
|
151 | + foreach ($attackResult['structures'] as $key => $structure) { |
|
152 | 152 | $destroyed = $planetDefense[$key][0] - $structure[0]; |
153 | - if($destroyed) { |
|
153 | + if ($destroyed) { |
|
154 | 154 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']); |
155 | 155 | |
156 | 156 | $message .= " {$classLocale['tech'][$key]} - {$destroyed} {$classLocale['quantity']}<br>"; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - if(!empty($message)) { |
|
161 | - $message = classLocale::$lang['mip_defense_destroyed'] . $message . "{$classLocale['mip_recycled']}{$classLocale['Metal']}: {$attackResult['metal']}, {$classLocale['Crystal']}: {$attackResult['crystal']}<br>"; |
|
160 | + if (!empty($message)) { |
|
161 | + $message = classLocale::$lang['mip_defense_destroyed'].$message."{$classLocale['mip_recycled']}{$classLocale['Metal']}: {$attackResult['metal']}, {$classLocale['Crystal']}: {$attackResult['crystal']}<br>"; |
|
162 | 162 | |
163 | 163 | db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}"); |
164 | 164 | } |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | |
176 | 176 | empty($message) ? $message = classLocale::$lang['mip_no_defense'] : false; |
177 | 177 | |
178 | - msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message ); |
|
179 | - msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message ); |
|
178 | + msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage.$message); |
|
179 | + msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage.$message); |
|
180 | 180 | } |
181 | 181 | db_missile_delete($fleetRow); |
182 | 182 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | // Compare function to sort fleet in time order |
4 | 4 | function tpl_assign_fleet_compare($a, $b) { |
5 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
5 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
7 | 7 | return 0; |
8 | 8 | } |
9 | 9 | |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | * @param string $js_name |
20 | 20 | */ |
21 | 21 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
22 | - if(!$fleets) { |
|
22 | + if (!$fleets) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | 26 | usort($fleets, 'tpl_assign_fleet_compare'); |
27 | 27 | |
28 | - foreach($fleets as $fleet_data) { |
|
28 | + foreach ($fleets as $fleet_data) { |
|
29 | 29 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
30 | 30 | |
31 | - if($fleet_data['ships']) { |
|
32 | - foreach($fleet_data['ships'] as $ship_data) { |
|
31 | + if ($fleet_data['ships']) { |
|
32 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
33 | 33 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
34 | 34 | } |
35 | 35 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
51 | 51 | ); |
52 | 52 | |
53 | - foreach($fleet as $ship_id => $ship_amount) { |
|
54 | - if(in_array($ship_id, sn_get_groups('fleet'))) { |
|
53 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
54 | + if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
55 | 55 | $single_ship_data = get_ship_data($ship_id, $user_data); |
56 | 56 | $return['ships'][$ship_id] = array( |
57 | 57 | 'ID' => $ship_id, |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | $result = array(); |
92 | 92 | |
93 | - if(!$user_data) { |
|
93 | + if (!$user_data) { |
|
94 | 94 | $user_data = $user; |
95 | 95 | } |
96 | 96 | |
97 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
97 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
98 | 98 | $aks = db_acs_get_by_group_id($objFleet->group_id); |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'MISSION' => $objFleet->mission_type, |
114 | 114 | 'MISSION_NAME' => classLocale::$lang['type_mission'][$objFleet->mission_type], |
115 | 115 | 'ACS' => !empty($aks['name']) ? $aks['name'] : (!empty($objFleet->group_id) ? $objFleet->group_id : ''), |
116 | - 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()) . (array_sum($fleet_resources) ? '+' : '')) : '?', |
|
116 | + 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()).(array_sum($fleet_resources) ? '+' : '')) : '?', |
|
117 | 117 | |
118 | 118 | 'METAL' => $spy_level >= 8 ? $fleet_resources[RES_METAL] : 0, |
119 | 119 | 'CRYSTAL' => $spy_level >= 8 ? $fleet_resources[RES_CRYSTAL] : 0, |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
136 | 136 | ); |
137 | 137 | |
138 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
138 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
139 | 139 | $result['START_NAME'] = $objFleet->fleet_start_name; |
140 | 140 | } |
141 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
141 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
142 | 142 | $result['END_NAME'] = $objFleet->fleet_end_name; |
143 | 143 | } |
144 | 144 | |
145 | - if(property_exists($objFleet, 'event_time')) { |
|
145 | + if (property_exists($objFleet, 'event_time')) { |
|
146 | 146 | $result['fleet'] = array_merge($result['fleet'], array( |
147 | 147 | 'OV_LABEL' => $objFleet->ov_label, |
148 | 148 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | $ship_id = 0; |
157 | 157 | $result['ships'] = array(); |
158 | - if($spy_level >= 6) { |
|
159 | - foreach($ship_list_fully_parsed as $ship_sn_id => $ship_amount) { |
|
160 | - if($spy_level >= 10) { |
|
158 | + if ($spy_level >= 6) { |
|
159 | + foreach ($ship_list_fully_parsed as $ship_sn_id => $ship_amount) { |
|
160 | + if ($spy_level >= 10) { |
|
161 | 161 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
162 | 162 | $result['ships'][$ship_sn_id] = array( |
163 | 163 | 'ID' => $ship_sn_id, |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | function tpl_parse_planet_que($que, $planet, $que_id) { |
191 | 191 | $hangar_que = array(); |
192 | 192 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
193 | - if(!empty($que_hangar)) { |
|
194 | - foreach($que_hangar as $que_item) { |
|
193 | + if (!empty($que_hangar)) { |
|
194 | + foreach ($que_hangar as $que_item) { |
|
195 | 195 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
196 | 196 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
197 | 197 | } |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
252 | 252 | ); |
253 | 253 | |
254 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
254 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
255 | 255 | $result['building_que'] = array(); |
256 | 256 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
257 | - foreach($building_que as $que_element) { |
|
257 | + foreach ($building_que as $que_element) { |
|
258 | 258 | $result['building_que'][] = que_tpl_parse_element($que_element); |
259 | 259 | } |
260 | 260 | } |
@@ -270,19 +270,19 @@ discard block |
||
270 | 270 | function flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet) { |
271 | 271 | global $user; |
272 | 272 | |
273 | - if(empty($array_of_Fleet)) { |
|
273 | + if (empty($array_of_Fleet)) { |
|
274 | 274 | return false; |
275 | 275 | } |
276 | 276 | |
277 | 277 | $fleet_list = array(); |
278 | - foreach($array_of_Fleet as $fleet) { |
|
279 | - if($fleet->playerOwnerId == $user['id']) { |
|
280 | - if($fleet->mission_type == MT_MISSILE) { |
|
278 | + foreach ($array_of_Fleet as $fleet) { |
|
279 | + if ($fleet->playerOwnerId == $user['id']) { |
|
280 | + if ($fleet->mission_type == MT_MISSILE) { |
|
281 | 281 | continue; |
282 | 282 | } |
283 | 283 | $fleet_ownage = 'own'; |
284 | 284 | } else { |
285 | - switch($fleet->mission_type) { |
|
285 | + switch ($fleet->mission_type) { |
|
286 | 286 | case MT_ATTACK: |
287 | 287 | case MT_ACS: |
288 | 288 | case MT_DESTROY: |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | |
300 | 300 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
301 | 301 | |
302 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
302 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
303 | 303 | $fleet_sn = $fleet->shipsGetArray(); |
304 | - foreach($fleet_sn as $ship_id => $ship_amount) { |
|
305 | - if(in_array($ship_id, sn_get_groups('fleet'))) { |
|
304 | + foreach ($fleet_sn as $ship_id => $ship_amount) { |
|
305 | + if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
306 | 306 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount; |
307 | 307 | } |
308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | return $fleet_list; |
320 | 320 | } |
321 | 321 | |
322 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
322 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
323 | 323 | $template->assign_vars(array( |
324 | 324 | 'RESOURCE_ROUNDING' => $round, |
325 | 325 |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update')); |
10 | 10 | $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update); |
11 | 11 | |
12 | - if(sys_get_param_int('admin_update')) { |
|
12 | + if (sys_get_param_int('admin_update')) { |
|
13 | 13 | define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1); |
14 | - if(USER_LEVEL > 0) { |
|
14 | + if (USER_LEVEL > 0) { |
|
15 | 15 | $is_admin_request = true; |
16 | 16 | $ts_scheduled_update = SN_TIME_NOW; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - if($ts_scheduled_update > $ts_var_stat_update) { |
|
20 | + if ($ts_scheduled_update > $ts_var_stat_update) { |
|
21 | 21 | lng_include('admin'); |
22 | 22 | sn_db_transaction_start(); |
23 | 23 | $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')); |
24 | - if(SN_TIME_NOW > $ts_var_stat_update_end) { |
|
24 | + if (SN_TIME_NOW > $ts_var_stat_update_end) { |
|
25 | 25 | $old_server_status = classSupernova::$config->db_loadItem('game_disable'); |
26 | 26 | classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT); |
27 | 27 | |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | |
32 | 32 | $msg = $is_admin_request ? 'admin request' : 'scheduler'; |
33 | 33 | $next_run = date(FMT_DATE_TIME_SQL, sys_schedule_get_prev_run(classSupernova::$config->stats_schedule, classSupernova::$config->var_stat_update, true)); |
34 | - $msg = "Running stat updates: {$msg}. Config->var_stat_update = " . classSupernova::$config->var_stat_update . |
|
35 | - ', $ts_scheduled_update = ' . date(FMT_DATE_TIME_SQL, $ts_scheduled_update) . |
|
36 | - ', next_stat_update = ' . $next_run; |
|
34 | + $msg = "Running stat updates: {$msg}. Config->var_stat_update = ".classSupernova::$config->var_stat_update. |
|
35 | + ', $ts_scheduled_update = '.date(FMT_DATE_TIME_SQL, $ts_scheduled_update). |
|
36 | + ', next_stat_update = '.$next_run; |
|
37 | 37 | classSupernova::$debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
38 | 38 | $total_time = microtime(true); |
39 | 39 | |
40 | 40 | // require_once('../includes/sys_stat.php'); |
41 | - require_once(SN_ROOT_PHYSICAL . 'includes/includes/sys_stat.php'); |
|
41 | + require_once(SN_ROOT_PHYSICAL.'includes/includes/sys_stat.php'); |
|
42 | 42 | sys_stat_calculate(); |
43 | 43 | |
44 | 44 | $total_time = microtime(true) - $total_time; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL); |
58 | 58 | |
59 | 59 | classSupernova::$config->db_saveItem('game_disable', $old_server_status); |
60 | - } elseif($ts_scheduled_update > $ts_var_stat_update) { |
|
60 | + } elseif ($ts_scheduled_update > $ts_var_stat_update) { |
|
61 | 61 | $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW; |
62 | 62 | $msg = classSupernova::$config->db_loadItem('var_stat_update_msg'); |
63 | 63 | $msg = "{$msg} ETA {$timeout} seconds. Please wait..."; |
64 | 64 | } |
65 | 65 | sn_db_transaction_rollback(); |
66 | - } elseif($is_admin_request) { |
|
66 | + } elseif ($is_admin_request) { |
|
67 | 67 | $msg = 'Stat is up to date'; |
68 | 68 | } |
69 | 69 |
@@ -11,38 +11,38 @@ discard block |
||
11 | 11 | |
12 | 12 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
13 | 13 | |
14 | - if($in_admin) { |
|
14 | + if ($in_admin) { |
|
15 | 15 | $quest_id = sys_get_param_id('id'); |
16 | 16 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
17 | - if(!empty($quest_name)) { |
|
17 | + if (!empty($quest_name)) { |
|
18 | 18 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
19 | 19 | try { |
20 | 20 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
21 | 21 | $quest_rewards = array(); |
22 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
22 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
24 | 24 | throw new Exception(classLocale::$lang['qst_adm_err_reward_type']); |
25 | 25 | } |
26 | 26 | |
27 | - if($quest_rewards_amount < 0) { |
|
27 | + if ($quest_rewards_amount < 0) { |
|
28 | 28 | throw new Exception(classLocale::$lang['qst_adm_err_reward_amount']); |
29 | - } elseif($quest_rewards_amount > 0) { |
|
29 | + } elseif ($quest_rewards_amount > 0) { |
|
30 | 30 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
31 | 31 | } |
32 | 32 | } |
33 | - if(empty($quest_rewards)) { |
|
33 | + if (empty($quest_rewards)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['qst_adm_err_reward_empty']); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $quest_rewards = implode(';', $quest_rewards); |
38 | 38 | |
39 | 39 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
40 | - if(!in_array($quest_unit_id, $quest_units_allowed)) { |
|
40 | + if (!in_array($quest_unit_id, $quest_units_allowed)) { |
|
41 | 41 | throw new Exception(classLocale::$lang['qst_adm_err_unit_id']); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
45 | - if($quest_unit_amount <= 0) { |
|
45 | + if ($quest_unit_amount <= 0) { |
|
46 | 46 | throw new Exception(classLocale::$lang['qst_adm_err_unit_amount']); |
47 | 47 | } |
48 | 48 | $quest_conditions = "{$quest_unit_id},{$quest_unit_amount}"; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // TODO: Change quest type |
51 | 51 | $quest_type = 0; |
52 | 52 | |
53 | - if($mode == 'edit') { |
|
53 | + if ($mode == 'edit') { |
|
54 | 54 | $quest_name = db_escape($quest_name); |
55 | 55 | $quest_description = db_escape($quest_description); |
56 | 56 | db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | // TODO: Add mass mail for new quests |
68 | - } catch(Exception $e) { |
|
68 | + } catch (Exception $e) { |
|
69 | 69 | message($e->getMessage(), classLocale::$lang['sys_error']); |
70 | 70 | } |
71 | 71 | |
72 | 72 | $mode = ''; |
73 | 73 | }; |
74 | 74 | |
75 | - switch($mode) { |
|
75 | + switch ($mode) { |
|
76 | 76 | case 'del': |
77 | 77 | db_quest_delete($quest_id); |
78 | 78 | $mode = ''; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | $query = db_quest_count(); |
89 | 89 | classSupernova::$config->db_saveItem('quest_total', $query['count']); |
90 | - } elseif(!$user_id) { |
|
90 | + } elseif (!$user_id) { |
|
91 | 91 | $user_id = $user['id']; |
92 | 92 | } |
93 | 93 | |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | 'IN_ADMIN' => $in_admin, |
101 | 101 | )); |
102 | 102 | |
103 | - if($quest) { |
|
103 | + if ($quest) { |
|
104 | 104 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
105 | 105 | } else { |
106 | 106 | $quest_templatized['quest_rewards_list'] = array(); |
107 | 107 | } |
108 | 108 | |
109 | - foreach($quest_reward_allowed as $unit_id) { |
|
109 | + foreach ($quest_reward_allowed as $unit_id) { |
|
110 | 110 | $found = false; |
111 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | - if($quest_templatized_reward['ID'] == $unit_id) { |
|
111 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | + if ($quest_templatized_reward['ID'] == $unit_id) { |
|
113 | 113 | $found = true; |
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if(!$found) { |
|
118 | + if (!$found) { |
|
119 | 119 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
120 | 120 | 'ID' => $unit_id, |
121 | 121 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | qst_assign_to_template($template, $quest_templatized); |
128 | 128 | |
129 | - foreach($quest_list as $quest_data) { |
|
129 | + foreach ($quest_list as $quest_data) { |
|
130 | 130 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($quest_units_allowed as $unit_id) { |
|
133 | + foreach ($quest_units_allowed as $unit_id) { |
|
134 | 134 | $template->assign_block_vars('allowed_unit', array( |
135 | 135 | 'ID' => $unit_id, |
136 | 136 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | function qst_get_quests($user_id = false, $status = false) { |
142 | 142 | $quest_list = array(); |
143 | 143 | |
144 | - if($user_id) { |
|
145 | - if($status !== false) { |
|
144 | + if ($user_id) { |
|
145 | + if ($status !== false) { |
|
146 | 146 | $query_add_where = "AND qs.quest_status_status "; |
147 | - if($status == null) { |
|
147 | + if ($status == null) { |
|
148 | 148 | $query_add_where .= "IS NULL"; |
149 | 149 | } else { |
150 | 150 | $query_add_where .= "= {$status}"; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $query = db_quest_list_get($query_add_select, $query_add_from, $query_add_where); |
158 | 158 | |
159 | - while($quest = db_fetch($query)) { |
|
159 | + while ($quest = db_fetch($query)) { |
|
160 | 160 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
161 | 161 | } |
162 | 162 | |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) { |
167 | - if($block_name) { |
|
167 | + if ($block_name) { |
|
168 | 168 | $template->assign_block_vars($block_name, $quest_templatized); |
169 | 169 | } else { |
170 | 170 | $template->assign_vars($quest_templatized); |
171 | - if(!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
173 | - $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
|
171 | + if (!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
173 | + $template->assign_block_vars(($block_name ? $block_name.'.' : '').'quest_rewards_list', $quest_reward); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | function qst_templatize($quest, $for_display = true) { |
188 | 188 | $tmp = array(); |
189 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
189 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
190 | 190 | $tmp[] = array( |
191 | 191 | 'ID' => $quest_reward_id, |
192 | 192 | 'NAME' => $for_display ? str_replace(' ', ' ', classLocale::$lang['tech'][$quest_reward_id]) : classLocale::$lang['tech'][$quest_reward_id], |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | |
212 | 212 | function qst_active_triggers($quest_list) { |
213 | 213 | $quest_triggers = array(); |
214 | - foreach($quest_list as $quest_id => $quest) { |
|
215 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
214 | + foreach ($quest_list as $quest_id => $quest) { |
|
215 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
216 | 216 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
217 | 217 | $quest_triggers[$quest_id] = $quest_unit_id; |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | function qst_reward(&$user, &$rewards, &$quest_list) { |
225 | - if(empty($rewards)) { |
|
225 | + if (empty($rewards)) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | $total_rewards = array(); |
233 | 233 | $comment_dm = ''; |
234 | 234 | |
235 | - foreach($rewards as $quest_id => $user_data) { |
|
236 | - foreach($user_data as $user_id => $planet_data) { |
|
237 | - foreach($planet_data as $planet_id => $reward_list) { |
|
235 | + foreach ($rewards as $quest_id => $user_data) { |
|
236 | + foreach ($user_data as $user_id => $planet_data) { |
|
237 | + foreach ($planet_data as $planet_id => $reward_list) { |
|
238 | 238 | $comment = sprintf(classLocale::$lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
239 | 239 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
240 | 240 | |
241 | 241 | $comment_reward = array(); |
242 | - foreach($reward_list as $unit_id => $unit_amount) { |
|
243 | - $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
|
242 | + foreach ($reward_list as $unit_id => $unit_amount) { |
|
243 | + $comment_reward[] = $unit_amount.' '.classLocale::$lang['tech'][$unit_id]; |
|
244 | 244 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
245 | 245 | } |
246 | - $comment .= " {$classLocale['qst_msg_your_reward']} " . implode(',', $comment_reward); |
|
246 | + $comment .= " {$classLocale['qst_msg_your_reward']} ".implode(',', $comment_reward); |
|
247 | 247 | |
248 | 248 | msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['msg_from_admin'], classLocale::$lang['qst_msg_complete_subject'], $comment); |
249 | 249 | |
@@ -258,19 +258,19 @@ discard block |
||
258 | 258 | |
259 | 259 | $group_resources = sn_get_groups('resources_loot'); |
260 | 260 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
261 | - if(!empty($total_rewards)) { |
|
262 | - foreach($total_rewards as $user_id => $planet_data) { |
|
261 | + if (!empty($total_rewards)) { |
|
262 | + foreach ($total_rewards as $user_id => $planet_data) { |
|
263 | 263 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
264 | - foreach($planet_data as $planet_id => $unit_data) { |
|
264 | + foreach ($planet_data as $planet_id => $unit_data) { |
|
265 | 265 | $local_changeset = array(); |
266 | - foreach($unit_data as $unit_id => $unit_amount) { |
|
267 | - if(!isset($quest_rewards_allowed[$unit_id])) { |
|
266 | + foreach ($unit_data as $unit_id => $unit_amount) { |
|
267 | + if (!isset($quest_rewards_allowed[$unit_id])) { |
|
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | |
271 | - if($unit_id == RES_DARK_MATTER) { |
|
271 | + if ($unit_id == RES_DARK_MATTER) { |
|
272 | 272 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
273 | - } elseif(isset($group_resources[$unit_id])) { |
|
273 | + } elseif (isset($group_resources[$unit_id])) { |
|
274 | 274 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
275 | 275 | } else // Проверим на юниты |
276 | 276 | { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // unit |
280 | 280 | } |
281 | 281 | |
282 | - if(!empty($local_changeset)) { |
|
282 | + if (!empty($local_changeset)) { |
|
283 | 283 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
284 | 284 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
285 | 285 | 'action' => SQL_OP_UPDATE, |
@@ -29,32 +29,32 @@ discard block |
||
29 | 29 | function rpg_points_change($user_id, $change_type, $dark_matter, $comment = '', $already_changed = false) { |
30 | 30 | global $dm_change_legit, $user; |
31 | 31 | |
32 | - if(!$user_id) { |
|
32 | + if (!$user_id) { |
|
33 | 33 | return false; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $dm_change_legit = true; |
37 | 37 | $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER); |
38 | 38 | |
39 | - if($already_changed) { |
|
39 | + if ($already_changed) { |
|
40 | 40 | $rows_affected = 1; |
41 | 41 | } else { |
42 | 42 | $changeset = array(); |
43 | 43 | $a_user = db_user_by_id($user_id, true); |
44 | - if($dark_matter < 0) { |
|
44 | + if ($dark_matter < 0) { |
|
45 | 45 | $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true); |
46 | 46 | $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false; |
47 | 47 | $metamatter_to_reduce = -$dark_matter - $dark_matter_exists; |
48 | - if($metamatter_to_reduce > 0) { |
|
48 | + if ($metamatter_to_reduce > 0) { |
|
49 | 49 | $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER); |
50 | - if($metamatter_exists < $metamatter_to_reduce) { |
|
50 | + if ($metamatter_exists < $metamatter_to_reduce) { |
|
51 | 51 | classSupernova::$debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER); |
52 | 52 | } |
53 | - if(is_array($comment)) { |
|
53 | + if (is_array($comment)) { |
|
54 | 54 | $comment = call_user_func_array('sprintf', $comment); |
55 | 55 | } |
56 | 56 | // mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment); |
57 | - classSupernova::$auth->account->metamatter_change($change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment); |
|
57 | + classSupernova::$auth->account->metamatter_change($change_type, -$metamatter_to_reduce, 'ММ в ТМ: '.(-$dark_matter).' ТМ = '.$dark_matter_exists.' ТМ + '.$metamatter_to_reduce.' ММ. '.$comment); |
|
58 | 58 | $dark_matter = -$dark_matter_exists; |
59 | 59 | } |
60 | 60 | } else { |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $rows_affected = classSupernova::$db->db_affected_rows(); |
66 | 66 | } |
67 | 67 | |
68 | - if($rows_affected || !$dark_matter) { |
|
68 | + if ($rows_affected || !$dark_matter) { |
|
69 | 69 | $page_url = db_escape($_SERVER['SCRIPT_NAME']); |
70 | - if(is_array($comment)) { |
|
70 | + if (is_array($comment)) { |
|
71 | 71 | $comment = call_user_func_array('sprintf', $comment); |
72 | 72 | } |
73 | 73 | $comment = db_escape($comment); |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | $row['username'] = db_escape($row['username']); |
76 | 76 | db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url); |
77 | 77 | |
78 | - if($user['id'] == $user_id) { |
|
78 | + if ($user['id'] == $user_id) { |
|
79 | 79 | $user['dark_matter'] += $dark_matter; |
80 | 80 | } |
81 | 81 | |
82 | - if($dark_matter > 0) { |
|
82 | + if ($dark_matter > 0) { |
|
83 | 83 | $old_referral = db_referral_get_by_id($user_id); |
84 | - if($old_referral['id']) { |
|
84 | + if ($old_referral['id']) { |
|
85 | 85 | db_referral_update_dm($user_id, $dark_matter); |
86 | 86 | $new_referral = db_referral_get_by_id($user_id); |
87 | 87 | |
88 | 88 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
89 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
89 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
90 | 90 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}"); |
91 | 91 | } |
92 | 92 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | function rpg_level_up(&$user, $type, $xp_to_add = 0) { |
104 | 104 | $q = 1.03; |
105 | 105 | |
106 | - switch($type) { |
|
106 | + switch ($type) { |
|
107 | 107 | case RPG_STRUCTURE: |
108 | 108 | $field_level = 'lvl_minier'; |
109 | 109 | $field_xp = 'xpminier'; |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | |
141 | 141 | $xp = &$user[$field_xp]; |
142 | 142 | |
143 | - if($xp_to_add) { |
|
143 | + if ($xp_to_add) { |
|
144 | 144 | $xp += $xp_to_add; |
145 | 145 | db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'"); |
146 | 146 | } |
147 | 147 | |
148 | 148 | $level = $user[$field_level]; |
149 | - while($xp > rpg_xp_for_level($level + 1, $b1, $q)) { |
|
149 | + while ($xp > rpg_xp_for_level($level + 1, $b1, $q)) { |
|
150 | 150 | $level++; |
151 | 151 | } |
152 | 152 | $level -= $user[$field_level]; |
153 | - if($level > 0) { |
|
153 | + if ($level > 0) { |
|
154 | 154 | db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'"); |
155 | 155 | rpg_points_change($user['id'], $type, $level * 1000, $comment); |
156 | 156 | $user[$field_level] += $level; |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | function que_get_unit_que($unit_id) { |
4 | 4 | $que_type = false; |
5 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
6 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
5 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
6 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
7 | 7 | $que_type = $que_id; |
8 | 8 | break; |
9 | 9 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | |
15 | 15 | |
16 | 16 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
17 | - if(empty($que_data)) { |
|
17 | + if (empty($que_data)) { |
|
18 | 18 | $que_data = sn_get_groups('ques'); |
19 | 19 | $que_data = $que_data[$que_id]; |
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | $que_length = 1; |
24 | - switch($que_id) { |
|
24 | + switch ($que_id) { |
|
25 | 25 | case QUE_RESEARCH: |
26 | 26 | $que_length = classSupernova::$config->server_que_length_research + mrc_get_level($user, null, UNIT_PREMIUM); // TODO - вынести в модуль |
27 | 27 | break; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | function eco_que_str2arr($que_str) { |
37 | 37 | $que_arr = explode(';', $que_str); |
38 | - foreach($que_arr as $que_index => &$que_item) { |
|
39 | - if($que_item) { |
|
38 | + foreach ($que_arr as $que_index => &$que_item) { |
|
39 | + if ($que_item) { |
|
40 | 40 | $que_item = explode(',', $que_item); |
41 | 41 | } else { |
42 | 42 | unset($que_arr[$que_index]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | function eco_que_arr2str($que_arr) { |
50 | - foreach($que_arr as &$que_item) { |
|
50 | + foreach ($que_arr as &$que_item) { |
|
51 | 51 | $que_item = implode(',', $que_item); |
52 | 52 | } |
53 | 53 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | $classLocale = classLocale::$lang; |
60 | 60 | |
61 | 61 | $is_autoconvert = false; |
62 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
62 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
63 | 63 | $build_mode = BUILD_CREATE; |
64 | 64 | $is_autoconvert = true; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $unit_amount_qued = 0; |
68 | 68 | try { |
69 | - if(!$user['id']) { |
|
69 | + if (!$user['id']) { |
|
70 | 70 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
71 | 71 | } |
72 | 72 | |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; |
78 | 78 | } |
79 | 79 | */ |
80 | - if(!$unit_id) { |
|
80 | + if (!$unit_id) { |
|
81 | 81 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
82 | 82 | } |
83 | 83 | |
84 | 84 | $que_id = que_get_unit_que($unit_id); |
85 | - if(!$que_id) { |
|
85 | + if (!$que_id) { |
|
86 | 86 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
87 | 87 | } |
88 | 88 | |
89 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
89 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
90 | 90 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
91 | 91 | } |
92 | 92 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | $que_data = $que_data[$que_id]; |
95 | 95 | |
96 | 96 | // TODO Переделать под подочереди |
97 | - if($que_id == QUE_STRUCTURES) { |
|
97 | + if ($que_id == QUE_STRUCTURES) { |
|
98 | 98 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
99 | 99 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
100 | 100 | |
101 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
102 | - throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
101 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
102 | + throw new exception('{Это здание нельзя строить на '.($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | /* |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
120 | 120 | $user = db_user_by_id($user['id']); |
121 | 121 | // Это нужно, что бы заблокировать планету от списания ресурсов |
122 | - if(isset($planet['id']) && $planet['id']) { |
|
122 | + if (isset($planet['id']) && $planet['id']) { |
|
123 | 123 | $planet = db_planet_by_id($planet['id'], true); |
124 | 124 | } else { |
125 | 125 | $planet['id'] = 0; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
132 | 132 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
133 | 133 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
134 | - if(count($in_que) >= $que_max_length) { |
|
134 | + if (count($in_que) >= $que_max_length) { |
|
135 | 135 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
136 | 136 | } |
137 | 137 | |
138 | 138 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
139 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
139 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
140 | 140 | case BUILD_ALLOWED: |
141 | 141 | break; |
142 | 142 | case BUILD_UNIT_BUSY: |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
145 | 145 | // case BUILD_REQUIRE_NOT_MEET: |
146 | 146 | default: |
147 | - if($build_mode == BUILD_CREATE) { |
|
147 | + if ($build_mode == BUILD_CREATE) { |
|
148 | 148 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
149 | 149 | } |
150 | 150 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | $unit_amount_qued = $unit_amount; |
155 | 155 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
156 | 156 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
157 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
158 | - if($unit_level >= $unit_max) { |
|
157 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
158 | + if ($unit_level >= $unit_max) { |
|
159 | 159 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
160 | 160 | } |
161 | 161 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
162 | 162 | } |
163 | 163 | |
164 | - if($unit_amount < 1) { |
|
164 | + if ($unit_amount < 1) { |
|
165 | 165 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
166 | 166 | } |
167 | 167 | |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | // { |
171 | 171 | // die('Unit busy'); // TODO EXCEPTION |
172 | 172 | // } |
173 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
173 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
174 | 174 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
175 | - if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
175 | + if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
176 | 176 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
177 | 177 | $used_silo = 0; |
178 | - foreach($group_missile as $missile_id) { |
|
178 | + foreach ($group_missile as $missile_id) { |
|
179 | 179 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
180 | 180 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
181 | 181 | } |
182 | 182 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
183 | - if($free_silo <= 0) { |
|
183 | + if ($free_silo <= 0) { |
|
184 | 184 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
185 | 185 | } |
186 | 186 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
187 | - if($free_silo < $unit_size) { |
|
187 | + if ($free_silo < $unit_size) { |
|
188 | 188 | throw new exception("{В ракетной шахте нет места для {$classLocale['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
189 | 189 | } |
190 | 190 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | $unit_level = $new_unit_level = 0; |
193 | 193 | } else { |
194 | 194 | $unit_amount = 1; |
195 | - if($que_id == QUE_STRUCTURES) { |
|
195 | + if ($que_id == QUE_STRUCTURES) { |
|
196 | 196 | // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) |
197 | 197 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
198 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
198 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
199 | 199 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
200 | 200 | } |
201 | 201 | // И что это я такое написал? Зачем? |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | |
213 | 213 | $exchange = array(); |
214 | 214 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
215 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
215 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
216 | 216 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
217 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
218 | - throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
217 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
218 | + throw new exception("{Нет хватает ".($market_get_autoconvert_cost - $dark_matter)."ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | !get_unit_param($unit_id, P_STACKABLE) ? $unit_amount = 1 : false; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $resource_exchange_rates = array(); |
225 | 225 | $resource_diff = array(); |
226 | 226 | $all_positive = true; |
227 | - foreach($resources_loot as $resource_id) { |
|
227 | + foreach ($resources_loot as $resource_id) { |
|
228 | 228 | $resource_db_name = pname_resource_name($resource_id); |
229 | 229 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
230 | 230 | $resource_exchange_rates[$resource_id] = classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
233 | 233 | } |
234 | 234 | // Нужна автоконвертация |
235 | - if($all_positive) { |
|
235 | + if ($all_positive) { |
|
236 | 236 | $is_autoconvert = false; |
237 | 237 | } else { |
238 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
239 | - if($resource_diff_amount >= 0) { |
|
238 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
239 | + if ($resource_diff_amount >= 0) { |
|
240 | 240 | continue; |
241 | 241 | } |
242 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
243 | - if($resource_got_amount <= 0) { |
|
242 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
243 | + if ($resource_got_amount <= 0) { |
|
244 | 244 | continue; |
245 | 245 | } |
246 | 246 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | $is_autoconvert_ok = true; |
259 | - foreach($resource_diff as $resource_diff_amount2) { |
|
260 | - if($resource_diff_amount2 < 0) { |
|
259 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
260 | + if ($resource_diff_amount2 < 0) { |
|
261 | 261 | $is_autoconvert_ok = false; |
262 | 262 | break; |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - if($is_autoconvert_ok) { |
|
266 | + if ($is_autoconvert_ok) { |
|
267 | 267 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
268 | 268 | $build_data['CAN'][$build_mode] = $unit_amount; |
269 | 269 | } else { |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | } |
273 | 273 | } |
274 | 274 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
275 | - if($unit_amount <= 0) { |
|
275 | + if ($unit_amount <= 0) { |
|
276 | 276 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
277 | 277 | } |
278 | 278 | |
279 | - if($new_unit_level < 0) { |
|
279 | + if ($new_unit_level < 0) { |
|
280 | 280 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
281 | 281 | } |
282 | 282 | |
283 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
283 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
284 | 284 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
285 | 285 | } |
286 | 286 | |
287 | - if($is_autoconvert) { |
|
287 | + if ($is_autoconvert) { |
|
288 | 288 | ksort($exchange); |
289 | 289 | ksort($resource_got); |
290 | 290 | db_change_units($user, $planet, array( |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | $unit_amount_qued = 0; |
302 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
302 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
303 | 303 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
304 | 304 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
305 | 305 | $unit_amount -= $place; |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | |
310 | 310 | sn_db_transaction_commit(); |
311 | 311 | |
312 | - if($redirect) { |
|
313 | - sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
|
312 | + if ($redirect) { |
|
313 | + sys_redirect("{$_SERVER['PHP_SELF']}?mode=".sys_get_param_str('mode')."&ally_id=".sys_get_param_id('ally_id')); |
|
314 | 314 | die(); |
315 | 315 | } |
316 | 316 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | 'STATUS' => ERR_NONE, |
319 | 319 | 'MESSAGE' => '{Строительство начато}', |
320 | 320 | ); |
321 | - } catch(exception $e) { |
|
321 | + } catch (exception $e) { |
|
322 | 322 | sn_db_transaction_rollback(); |
323 | 323 | $operation_result = array( |
324 | 324 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | ); |
327 | 327 | } |
328 | 328 | |
329 | - if(!empty($operation_result['MESSAGE'])) { |
|
330 | - $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . classLocale::$lang['tech'][$unit_id] . ']'; |
|
329 | + if (!empty($operation_result['MESSAGE'])) { |
|
330 | + $operation_result['MESSAGE'] .= ' '.($unit_amount_qued ? $unit_amount_qued : $unit_amount).'x['.classLocale::$lang['tech'][$unit_id].']'; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | return $operation_result; |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | function que_recalculate($old_que) { |
338 | 338 | $new_que = array(); |
339 | 339 | |
340 | - if(!is_array($old_que['items'])) { |
|
340 | + if (!is_array($old_que['items'])) { |
|
341 | 341 | return $new_que; |
342 | 342 | } |
343 | - foreach($old_que['items'] as $row) { |
|
344 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
343 | + foreach ($old_que['items'] as $row) { |
|
344 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
345 | 345 | continue; |
346 | 346 | } |
347 | 347 | |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | |
353 | 353 | $last_id = count($new_que['items']) - 1; |
354 | 354 | |
355 | - if($row['que_planet_id']) { |
|
355 | + if ($row['que_planet_id']) { |
|
356 | 356 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
357 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
357 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
358 | 358 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
359 | 359 | } |
360 | 360 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | $que_type = que_get_unit_que($unit_id); |
390 | 390 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
391 | 391 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
392 | - if(is_numeric($planet_id)) { |
|
392 | + if (is_numeric($planet_id)) { |
|
393 | 393 | db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
394 | - } elseif(is_numeric($user['id'])) { |
|
394 | + } elseif (is_numeric($user['id'])) { |
|
395 | 395 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
396 | 396 | } |
397 | 397 | |
@@ -421,17 +421,17 @@ discard block |
||
421 | 421 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
422 | 422 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
423 | 423 | |
424 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
424 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
425 | 425 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
426 | 426 | |
427 | - foreach($que as $que_item) { |
|
427 | + foreach ($que as $que_item) { |
|
428 | 428 | db_que_delete_by_id($que_item['que_id']); |
429 | 429 | |
430 | - if($que_item['que_planet_id_origin']) { |
|
430 | + if ($que_item['que_planet_id_origin']) { |
|
431 | 431 | $planet['id'] = $que_item['que_planet_id_origin']; |
432 | 432 | } |
433 | 433 | |
434 | - if(!isset($planets_locked[$planet['id']])) { |
|
434 | + if (!isset($planets_locked[$planet['id']])) { |
|
435 | 435 | $planets_locked[$planet['id']] = $planet['id'] ? db_planet_by_id($planet['id'], true) : $planet; |
436 | 436 | } |
437 | 437 | |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'], |
444 | 444 | )); |
445 | 445 | |
446 | - if(!$clear) { |
|
446 | + if (!$clear) { |
|
447 | 447 | break; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if(is_numeric($planet['id'])) { |
|
451 | + if (is_numeric($planet['id'])) { |
|
452 | 452 | db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
453 | - } elseif(is_numeric($user['id'])) { |
|
453 | + } elseif (is_numeric($user['id'])) { |
|
454 | 454 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
455 | 455 | } |
456 | 456 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | sn_db_transaction_rollback(); |
460 | 460 | } |
461 | 461 | //die(); |
462 | - header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}" . "&ally_id=" . sys_get_param_id('ally_id')); |
|
462 | + header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}"."&ally_id=".sys_get_param_id('ally_id')); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -498,21 +498,21 @@ discard block |
||
498 | 498 | // TODO: Переделать для $que_type === false |
499 | 499 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
500 | 500 | |
501 | - if(!is_array($que)) { |
|
501 | + if (!is_array($que)) { |
|
502 | 502 | $que = que_get($user['id'], $planet['id'], $que_type); |
503 | 503 | } |
504 | 504 | |
505 | - if(is_array($que) && isset($que['items'])) { |
|
505 | + if (is_array($que) && isset($que['items'])) { |
|
506 | 506 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
507 | 507 | } |
508 | 508 | |
509 | - if($que) { |
|
510 | - foreach($que as $que_element) { |
|
509 | + if ($que) { |
|
510 | + foreach ($que as $que_element) { |
|
511 | 511 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | - if($que_type == QUE_RESEARCH) { |
|
515 | + if ($que_type == QUE_RESEARCH) { |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $user = db_user_by_id($user['id'], true); |
539 | 539 | |
540 | 540 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
541 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
541 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
542 | 542 | // TODO |
543 | 543 | return $que; |
544 | 544 | } |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
548 | 548 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
549 | 549 | $que = que_get($user['id'], $planet, $que_type_id, true); |
550 | - if(empty($que['items'])) { |
|
550 | + if (empty($que['items'])) { |
|
551 | 551 | return $que; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $planet_list = array(); |
555 | - if($planet !== null) { |
|
555 | + if ($planet !== null) { |
|
556 | 556 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
557 | 557 | // TODO - от них не надо ничего, кроме ID и que_processed |
558 | 558 | $planet_row = db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -561,21 +561,21 @@ discard block |
||
561 | 561 | } |
562 | 562 | |
563 | 563 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
564 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
564 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
565 | 565 | return $que; |
566 | 566 | } |
567 | 567 | |
568 | 568 | $db_changeset = array(); |
569 | 569 | $unit_changes = array(); |
570 | - foreach($que['items'] as &$que_item) { |
|
570 | + foreach ($que['items'] as &$que_item) { |
|
571 | 571 | $que_player_id = &$que_item['que_player_id']; |
572 | 572 | $que_planet_id = intval($que_item['que_planet_id']); |
573 | 573 | |
574 | 574 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
575 | - if(!isset($que_time_left)) { |
|
575 | + if (!isset($que_time_left)) { |
|
576 | 576 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
577 | 577 | } |
578 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
578 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
579 | 579 | continue; |
580 | 580 | } |
581 | 581 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
589 | 589 | |
590 | 590 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
591 | - if($que_time_left >= $que_item['que_time_left']) { |
|
591 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
592 | 592 | // Увеличиваем количество отстроенных юнитов |
593 | 593 | $unit_processed++; |
594 | 594 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -601,12 +601,12 @@ discard block |
||
601 | 601 | $que_item['que_unit_amount'] -= $unit_processed; |
602 | 602 | |
603 | 603 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
604 | - if($que_item['que_unit_amount'] > 0) { |
|
604 | + if ($que_item['que_unit_amount'] > 0) { |
|
605 | 605 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
606 | 606 | $que_time_left = 0; |
607 | 607 | } |
608 | 608 | |
609 | - if($que_item['que_unit_amount'] <= 0) { |
|
609 | + if ($que_item['que_unit_amount'] <= 0) { |
|
610 | 610 | $db_changeset['que'][] = array( |
611 | 611 | 'action' => SQL_OP_DELETE, |
612 | 612 | P_VERSION => 1, |
@@ -632,14 +632,14 @@ discard block |
||
632 | 632 | ); |
633 | 633 | } |
634 | 634 | |
635 | - if($unit_processed) { |
|
635 | + if ($unit_processed) { |
|
636 | 636 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
637 | 637 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
641 | - foreach($time_left as $player_id => $planet_data) { |
|
642 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
641 | + foreach ($time_left as $player_id => $planet_data) { |
|
642 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
643 | 643 | $table = $planet_id ? 'planets' : 'users'; |
644 | 644 | $id = $planet_id ? $planet_id : $player_id; |
645 | 645 | $db_changeset[$table][] = array( |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | ), |
656 | 656 | ); |
657 | 657 | |
658 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
659 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
658 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
659 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
660 | 660 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
661 | 661 | } |
662 | 662 | } |
@@ -666,38 +666,38 @@ discard block |
||
666 | 666 | $que = que_recalculate($que); |
667 | 667 | |
668 | 668 | // TODO: Re-enable quests for Alliances |
669 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
669 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
670 | 670 | $quest_list = qst_get_quests($user['id']); |
671 | 671 | $quest_triggers = qst_active_triggers($quest_list); |
672 | 672 | $quest_rewards = array(); |
673 | 673 | |
674 | 674 | |
675 | 675 | $xp_incoming = array(); |
676 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
677 | - foreach($planet_changes as $planet_id => $changes) { |
|
676 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
677 | + foreach ($planet_changes as $planet_id => $changes) { |
|
678 | 678 | $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
679 | - foreach($changes as $unit_id => $unit_value) { |
|
679 | + foreach ($changes as $unit_id => $unit_value) { |
|
680 | 680 | $que_id = que_get_unit_que($unit_id); |
681 | 681 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
682 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
682 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
683 | 683 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
684 | 684 | $build_data = $build_data[BUILD_CREATE]; |
685 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
685 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
686 | 686 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | - if(is_array($quest_triggers)) { |
|
690 | + if (is_array($quest_triggers)) { |
|
691 | 691 | // TODO: Check mutiply condition quests |
692 | 692 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
693 | - if(is_array($quest_trigger_list)) { |
|
694 | - foreach($quest_trigger_list as $quest_id) { |
|
693 | + if (is_array($quest_trigger_list)) { |
|
694 | + foreach ($quest_trigger_list as $quest_id) { |
|
695 | 695 | $quest_unit_level = $unit_level_new; |
696 | - if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
696 | + if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
697 | 697 | $quest_unit_level = db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id); |
698 | 698 | $quest_unit_level = $quest_unit_level[$unit_id]['qty']; |
699 | 699 | } |
700 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
700 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
701 | 701 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
702 | 702 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
703 | 703 | } |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
711 | 711 | qst_reward($user, $quest_rewards, $quest_list); |
712 | 712 | |
713 | - foreach($xp_incoming as $que_id => $xp) { |
|
713 | + foreach ($xp_incoming as $que_id => $xp) { |
|
714 | 714 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
715 | 715 | } |
716 | 716 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $args = func_get_args(); |
62 | 62 | |
63 | - switch(func_num_args()) |
|
63 | + switch (func_num_args()) |
|
64 | 64 | { |
65 | 65 | case 0: |
66 | 66 | // trigger_error('median() requires at least one parameter',E_USER_WARNING); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // fallthrough |
73 | 73 | |
74 | 74 | default: |
75 | - if(!is_array($args)) |
|
75 | + if (!is_array($args)) |
|
76 | 76 | { |
77 | 77 | // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE); |
78 | 78 | return false; |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | $n = count($args); |
84 | 84 | $h = intval($n / 2); |
85 | 85 | |
86 | - if($n % 2 == 0) |
|
86 | + if ($n % 2 == 0) |
|
87 | 87 | { |
88 | - $median = ($args[$h] + $args[$h-1]) / 2; |
|
88 | + $median = ($args[$h] + $args[$h - 1]) / 2; |
|
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
@@ -103,49 +103,49 @@ discard block |
||
103 | 103 | } |
104 | 104 | function linear_calc(&$linear, $from = 0, $logProcess = false) |
105 | 105 | { |
106 | - for($i = $from; $i < count($linear); $i++) |
|
106 | + for ($i = $from; $i < count($linear); $i++) |
|
107 | 107 | { |
108 | 108 | $eq = &$linear[$i]; |
109 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
109 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | 110 | { |
111 | 111 | $eq[$j] /= $eq[$from]; |
112 | 112 | } |
113 | 113 | } |
114 | - if($logProcess) pdump($linear, 'Нормализовано по х' . $from); |
|
114 | + if ($logProcess) pdump($linear, 'Нормализовано по х'.$from); |
|
115 | 115 | |
116 | - for($i = $from + 1; $i < count($linear); $i++) |
|
116 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
117 | 117 | { |
118 | 118 | $eq = &$linear[$i]; |
119 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
119 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | 120 | { |
121 | 121 | $eq[$j] -= $linear[$from][$j]; |
122 | 122 | } |
123 | 123 | } |
124 | - if($logProcess) pdump($linear, 'Подставили х' . $from); |
|
124 | + if ($logProcess) pdump($linear, 'Подставили х'.$from); |
|
125 | 125 | |
126 | - if($from < count($linear) - 1) |
|
126 | + if ($from < count($linear) - 1) |
|
127 | 127 | { |
128 | 128 | linear_calc($linear, $from + 1, $logProcess); |
129 | 129 | } |
130 | 130 | |
131 | - if($from) |
|
131 | + if ($from) |
|
132 | 132 | { |
133 | - for($i = 0; $i < $from; $i++) |
|
133 | + for ($i = 0; $i < $from; $i++) |
|
134 | 134 | { |
135 | 135 | $eq = &$linear[$i]; |
136 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
136 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | 137 | { |
138 | 138 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
139 | 139 | } |
140 | 140 | } |
141 | - if($logProcess) pdump($linear, 'Подставили обратно х' . $from); |
|
141 | + if ($logProcess) pdump($linear, 'Подставили обратно х'.$from); |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - if($logProcess) pdump($linear, 'Результат' . $from); |
|
146 | - foreach($linear as $index => &$eq) |
|
145 | + if ($logProcess) pdump($linear, 'Результат'.$from); |
|
146 | + foreach ($linear as $index => &$eq) |
|
147 | 147 | { |
148 | - pdump($eq[count($linear)], 'x' . $index); |
|
148 | + pdump($eq[count($linear)], 'x'.$index); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | public $type = PT_NONE; |
14 | 14 | |
15 | 15 | public static function _staticInit() { |
16 | - if(static::$_isStaticInit) { |
|
16 | + if (static::$_isStaticInit) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | static::$knownGalaxies = intval(classSupernova::$config->game_maxGalaxy); |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | public function __construct($galaxy = 0, $system = 0, $planet = 0, $type = PT_NONE) { |
34 | 34 | // static::_staticInit(); |
35 | 35 | |
36 | - if(is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) { |
|
36 | + if (is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) { |
|
37 | 37 | $this->readFromVector($system); |
38 | - } elseif(is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) { |
|
38 | + } elseif (is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) { |
|
39 | 39 | $this->readFromParamFleets($system); |
40 | 40 | } else { |
41 | 41 | $this->galaxy = intval($galaxy); |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | * @param Vector $vector |
75 | 75 | */ |
76 | 76 | public function distance($vector) { |
77 | - if($this->galaxy != $vector->galaxy) { |
|
77 | + if ($this->galaxy != $vector->galaxy) { |
|
78 | 78 | $distance = abs($this->galaxy - $vector->galaxy) * classSupernova::$config->uni_galaxy_distance; |
79 | - } elseif($this->system != $vector->system) { |
|
79 | + } elseif ($this->system != $vector->system) { |
|
80 | 80 | $distance = abs($this->system - $vector->system) * 5 * 19 + 2700; |
81 | - } elseif($this->planet != $vector->planet) { |
|
81 | + } elseif ($this->planet != $vector->planet) { |
|
82 | 82 | $distance = abs($this->planet - $vector->planet) * 5 + 1000; |
83 | 83 | // TODO - uncomment |
84 | 84 | // } elseif($this->type != PT_NONE && $vector->type != PT_NONE && $this->type == $vector->type) { |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * @param array $coordinates |
102 | 102 | */ |
103 | 103 | public static function convertToVector($coordinates, $prefix = '') { |
104 | - $galaxy = !empty($coordinates[$prefix . 'galaxy']) ? intval($coordinates[$prefix . 'galaxy']) : 0; |
|
105 | - $system = !empty($coordinates[$prefix . 'system']) ? intval($coordinates[$prefix . 'system']) : 0; |
|
106 | - $planet = !empty($coordinates[$prefix . 'planet']) ? intval($coordinates[$prefix . 'planet']) : 0; |
|
107 | - $type = !empty($coordinates[$prefix . 'type']) |
|
108 | - ? intval($coordinates[$prefix . 'type']) |
|
109 | - : (!empty($coordinates[$prefix . 'planet_type']) ? intval($coordinates[$prefix . 'planet_type']) : 0); |
|
104 | + $galaxy = !empty($coordinates[$prefix.'galaxy']) ? intval($coordinates[$prefix.'galaxy']) : 0; |
|
105 | + $system = !empty($coordinates[$prefix.'system']) ? intval($coordinates[$prefix.'system']) : 0; |
|
106 | + $planet = !empty($coordinates[$prefix.'planet']) ? intval($coordinates[$prefix.'planet']) : 0; |
|
107 | + $type = !empty($coordinates[$prefix.'type']) |
|
108 | + ? intval($coordinates[$prefix.'type']) |
|
109 | + : (!empty($coordinates[$prefix.'planet_type']) ? intval($coordinates[$prefix.'planet_type']) : 0); |
|
110 | 110 | |
111 | 111 | return new static($galaxy, $system, $planet, $type); |
112 | 112 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function sn_ube_report_save($ube) { |
15 | 15 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
16 | - if($ube->get_cypher()) { |
|
16 | + if ($ube->get_cypher()) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
20 | 20 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
21 | 21 | do { |
22 | 22 | $ube->report_cypher = sys_random_string(32); |
23 | - } while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
23 | + } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true)); |
|
24 | 24 | |
25 | 25 | // Инициализация таблицы для пакетной вставки информации |
26 | 26 | $sql_perform = array( |
@@ -108,24 +108,24 @@ discard block |
||
108 | 108 | $sql_str = "INSERT INTO `{{ube_report}}` |
109 | 109 | SET |
110 | 110 | `ube_report_cypher` = '{$ube->report_cypher}', |
111 | - `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "', |
|
111 | + `ube_report_time_combat` = '".date(FMT_DATE_TIME_SQL, $ube->combat_timestamp)."', |
|
112 | 112 | `ube_report_time_spent` = {$ube->time_spent}, |
113 | 113 | |
114 | - `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ", |
|
114 | + `ube_report_combat_admin` = ".(int) $ube->is_admin_in_combat.", |
|
115 | 115 | `ube_report_mission_type` = {$ube->mission_type_id}, |
116 | 116 | |
117 | 117 | `ube_report_combat_result` = {$ube->combat_result}, |
118 | - `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ", |
|
118 | + `ube_report_combat_sfr` = ".(int) $ube->is_small_fleet_recce.", |
|
119 | 119 | |
120 | - `ube_report_planet_id` = " . (int)$ube->ube_planet_info[PLANET_ID] . ", |
|
121 | - `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "', |
|
122 | - `ube_report_planet_size` = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ", |
|
123 | - `ube_report_planet_galaxy` = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ", |
|
124 | - `ube_report_planet_system` = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
125 | - `ube_report_planet_planet` = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ", |
|
126 | - `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ", |
|
120 | + `ube_report_planet_id` = " . (int) $ube->ube_planet_info[PLANET_ID].", |
|
121 | + `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME])."', |
|
122 | + `ube_report_planet_size` = " . (int) $ube->ube_planet_info[PLANET_SIZE].", |
|
123 | + `ube_report_planet_galaxy` = " . (int) $ube->ube_planet_info[PLANET_GALAXY].", |
|
124 | + `ube_report_planet_system` = " . (int) $ube->ube_planet_info[PLANET_SYSTEM].", |
|
125 | + `ube_report_planet_planet` = " . (int) $ube->ube_planet_info[PLANET_PLANET].", |
|
126 | + `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE].", |
|
127 | 127 | |
128 | - `ube_report_capture_result` = " . (int)$ube->capture_result . ", " |
|
128 | + `ube_report_capture_result` = " . (int) $ube->capture_result.", " |
|
129 | 129 | . $ube->debris->report_generate_sql() |
130 | 130 | . $ube->moon_calculator->report_generate_sql(); |
131 | 131 | |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | |
135 | 135 | // Сохраняем общую информацию по игрокам |
136 | 136 | $player_sides = $ube->players->get_player_sides(); |
137 | - foreach($player_sides as $player_id => $player_side) { |
|
137 | + foreach ($player_sides as $player_id => $player_side) { |
|
138 | 138 | $sql_perform['ube_report_player'][] = array( |
139 | 139 | $ube_report_id, |
140 | 140 | $player_id, |
141 | 141 | |
142 | - "'" . db_escape($ube->players[$player_id]->name) . "'", |
|
142 | + "'".db_escape($ube->players[$player_id]->name)."'", |
|
143 | 143 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
144 | 144 | |
145 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
146 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
147 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
145 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
146 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
147 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Всякая информация по флотам |
152 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
152 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
153 | 153 | // Сохраняем общую информацию по флотам |
154 | 154 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
155 | 155 | |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
166 | 166 | |
167 | 167 | // Пакетная вставка данных |
168 | - foreach($sql_perform as $table_name => $table_data) { |
|
169 | - if(count($table_data) < 2) { |
|
168 | + foreach ($sql_perform as $table_name => $table_data) { |
|
169 | + if (count($table_data) < 2) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | - foreach($table_data as &$record_data) { |
|
173 | - $record_data = '(' . implode(',', $record_data) . ')'; |
|
172 | + foreach ($table_data as &$record_data) { |
|
173 | + $record_data = '('.implode(',', $record_data).')'; |
|
174 | 174 | } |
175 | 175 | $fields = $table_data[0]; |
176 | 176 | unset($table_data[0]); |
177 | - doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data)); |
|
177 | + doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES ".implode(',', $table_data)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $ube->report_cypher; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $report_cypher = db_escape($report_cypher); |
193 | 193 | |
194 | 194 | $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true); |
195 | - if(!$report_row) { |
|
195 | + if (!$report_row) { |
|
196 | 196 | return UBE_REPORT_NOT_FOUND; |
197 | 197 | } |
198 | 198 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param $template_result |
209 | 209 | */ |
210 | 210 | function sn_ube_report_generate(UBE $ube, &$template_result) { |
211 | - if(!is_object($ube)) { |
|
211 | + if (!is_object($ube)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | |
224 | 224 | // Координаты, тип и название планеты - если есть |
225 | 225 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
226 | - if(isset($ube->ube_planet_info)) { |
|
226 | + if (isset($ube->ube_planet_info)) { |
|
227 | 227 | $template_result += $ube->ube_planet_info; |
228 | 228 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Обломки |
232 | 232 | $debris = array(); |
233 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
234 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
233 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
234 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
235 | 235 | $debris[] = array( |
236 | 236 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
237 | 237 | 'AMOUNT' => pretty_number($resource_amount), |