@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | function sn_eco_build($que_type, &$auser, &$planet) { |
19 | 19 | global $lang, $config, $template_result; |
20 | 20 | |
21 | - if($ally_id = sys_get_param_id('ally_id')) { |
|
21 | + if ($ally_id = sys_get_param_id('ally_id')) { |
|
22 | 22 | define('SN_IN_ALLY', true); |
23 | 23 | $ranks = \Alliance\Alliance::ally_get_ranks($auser['ally']); |
24 | - if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
24 | + if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
25 | 25 | $user = &$auser['ally']['player']; |
26 | 26 | $planet = array( |
27 | 27 | 'metal' => $user['metal'], |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | - if(!$user) { |
|
34 | + if (!$user) { |
|
35 | 35 | $user = &$auser; |
36 | 36 | } |
37 | 37 | |
38 | - switch($action = sys_get_param_escaped('action')) { |
|
38 | + switch ($action = sys_get_param_escaped('action')) { |
|
39 | 39 | case 'create': // Add unit to que for build |
40 | 40 | case 'create_autoconvert': // Add unit to que for build |
41 | 41 | case 'destroy': // Add unit to que for remove |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $group_missile = sn_get_groups('missile'); |
54 | 54 | $silo_capacity_free = 0; |
55 | - if($que_type == QUE_STRUCTURES) { |
|
55 | + if ($que_type == QUE_STRUCTURES) { |
|
56 | 56 | $build_unit_list = sn_get_groups('build_allow'); |
57 | 57 | $build_unit_list = $build_unit_list[$planet['planet_type']]; |
58 | 58 | $artifact_id = ART_NANO_BUILDER; |
59 | 59 | $page_header = $lang['tech'][UNIT_STRUCTURES]; |
60 | - } elseif($que_type == QUE_RESEARCH) { |
|
61 | - if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
60 | + } elseif ($que_type == QUE_RESEARCH) { |
|
61 | + if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
62 | 62 | messageBox($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]); |
63 | 63 | } |
64 | 64 | |
65 | - if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
65 | + if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
66 | 66 | messageBox($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]); |
67 | 67 | } |
68 | 68 | $build_unit_list = sn_get_groups('tech'); |
69 | 69 | $artifact_id = ART_HEURISTIC_CHIP; |
70 | 70 | $page_header = $lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : ''); |
71 | - } elseif($que_type == QUE_MERCENARY) { |
|
71 | + } elseif ($que_type == QUE_MERCENARY) { |
|
72 | 72 | // if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
73 | 73 | // messageBox($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]); |
74 | 74 | // } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $artifact_id = 0; |
81 | 81 | $page_header = $lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : ''); |
82 | 82 | } else { |
83 | - if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
83 | + if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
84 | 84 | messageBox($lang['need_hangar'], $lang['tech'][STRUC_FACTORY_HANGAR]); |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $artifact_id = 0; |
90 | 90 | |
91 | 91 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY); |
92 | - foreach($group_missile as $unit_id) { |
|
92 | + foreach ($group_missile as $unit_id) { |
|
93 | 93 | $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE); |
94 | 94 | } |
95 | 95 | $silo_capacity_free = max(0, $silo_capacity_free); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | |
108 | 108 | $template = gettemplate('buildings_builds', true); |
109 | - if(!empty($operation_result)) { |
|
109 | + if (!empty($operation_result)) { |
|
110 | 110 | $template_result['.']['result'][] = $operation_result; |
111 | 111 | } |
112 | 112 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $record_index = 0; |
138 | 138 | |
139 | - foreach($build_unit_list as $unit_id) { |
|
139 | + foreach ($build_unit_list as $unit_id) { |
|
140 | 140 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true); |
141 | 141 | $level_effective = mrc_get_level($user, $planet, $unit_id); |
142 | 142 | $level_in_que = $in_que[$unit_id]; |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE]; |
160 | 160 | // Restricting $can_build by free silo capacity |
161 | 161 | $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build; |
162 | - if(!$can_build) { |
|
163 | - if(!$build_data['CAN'][BUILD_CREATE]) { |
|
162 | + if (!$can_build) { |
|
163 | + if (!$build_data['CAN'][BUILD_CREATE]) { |
|
164 | 164 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES; |
165 | - } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
165 | + } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
166 | 166 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL; |
167 | - } elseif($unit_info[P_MAX_STACK]) { |
|
167 | + } elseif ($unit_info[P_MAX_STACK]) { |
|
168 | 168 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED; |
169 | 169 | } |
170 | 170 | } |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]), |
233 | 233 | ); |
234 | 234 | |
235 | - if($unit_stackable) { |
|
235 | + if ($unit_stackable) { |
|
236 | 236 | $level_production_base = array( |
237 | 237 | 'ACTUAL_SHIELD' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), |
238 | 238 | 'ACTUAL_ARMOR' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), |
239 | 239 | 'ACTUAL_WEAPON' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])), |
240 | 240 | ); |
241 | 241 | |
242 | - if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
242 | + if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
243 | 243 | $ship_data = get_ship_data($unit_id, $user); |
244 | 244 | |
245 | 245 | $level_production_base += array( |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | ); |
250 | 250 | } |
251 | 251 | |
252 | - if($unit_info[P_UNIT_PRODUCTION]) { |
|
253 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
254 | - if($resource_income = |
|
252 | + if ($unit_info[P_UNIT_PRODUCTION]) { |
|
253 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
254 | + if ($resource_income = |
|
255 | 255 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) |
256 | 256 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
257 | 257 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | $production['.']['resource'][] = $level_production_base; |
264 | - } elseif($unit_info[P_UNIT_PRODUCTION]) { |
|
264 | + } elseif ($unit_info[P_UNIT_PRODUCTION]) { |
|
265 | 265 | $level_production_base = array(); |
266 | 266 | $element_level_start = $level_effective + $in_que[$unit_id]; |
267 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | - if($resource_income = |
|
267 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | + if ($resource_income = |
|
269 | 269 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) |
270 | 270 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
271 | 271 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -275,24 +275,24 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
278 | - for($i = 0; $i < 6; $i++) { |
|
278 | + for ($i = 0; $i < 6; $i++) { |
|
279 | 279 | $level_production = array('LEVEL' => $level_start + $i); |
280 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
281 | - if( |
|
280 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
281 | + if ( |
|
282 | 282 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) |
283 | 283 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
284 | 284 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
285 | 285 | ) { |
286 | 286 | $level_production['R' . $resource_id] = $resource_income; |
287 | 287 | $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id]; |
288 | - if($level_production['D' . $resource_id] == 0) { |
|
288 | + if ($level_production['D' . $resource_id] == 0) { |
|
289 | 289 | $level_production['D' . $resource_id] = '-'; |
290 | 290 | } |
291 | 291 | } |
292 | 292 | } |
293 | 293 | $production['.']['resource'][] = $level_production; |
294 | 294 | } |
295 | - } elseif($unit_id == TECH_ASTROTECH) { |
|
295 | + } elseif ($unit_id == TECH_ASTROTECH) { |
|
296 | 296 | $element_level_start = $level_effective + $in_que[$unit_id]; |
297 | 297 | $level_production_base = array( |
298 | 298 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ); |
301 | 301 | |
302 | 302 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
303 | - for($i = 0; $i < 6; $i++) { |
|
303 | + for ($i = 0; $i < 6; $i++) { |
|
304 | 304 | $level_production = array('LEVEL' => $level_start + $i); |
305 | 305 | $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
306 | 306 | $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $template_result['.']['production'][] = $production; |
322 | 322 | } |
323 | 323 | |
324 | - foreach($lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
324 | + foreach ($lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
325 | 325 | $template->assign_block_vars('sort_values', array( |
326 | 326 | 'VALUE' => $sort_id, |
327 | 327 | 'TEXT' => $sort_text, |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | |
331 | 331 | $sort_option = classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $que_type)]; |
332 | 332 | $sort_option_inverse = classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $que_type)]; |
333 | - if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
334 | - switch($sort_option) { |
|
333 | + if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
334 | + switch ($sort_option) { |
|
335 | 335 | case PLAYER_OPTION_SORT_NAME: |
336 | 336 | $sort_option_field = 'NAME'; |
337 | 337 | break; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | break; |
347 | 347 | } |
348 | 348 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1; |
349 | - usort($template_result['.']['production'], function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
349 | + usort($template_result['.']['production'], function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
350 | 350 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : ( |
351 | 351 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0 |
352 | 352 | ); |
@@ -284,7 +284,7 @@ |
||
284 | 284 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
285 | 285 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
286 | 286 | |
287 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
287 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
288 | 288 | $value -= $cost_left; |
289 | 289 | }); |
290 | 290 | } |
@@ -12,24 +12,24 @@ discard block |
||
12 | 12 | global $debug, $template_result, $user, $lang, $planetrow; |
13 | 13 | |
14 | 14 | // Напоминание для Администрации, что игра отключена |
15 | -if($template_result[F_GAME_DISABLE]) { |
|
15 | +if ($template_result[F_GAME_DISABLE]) { |
|
16 | 16 | echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>'; |
17 | 17 | } |
18 | 18 | unset($disable_reason); |
19 | 19 | |
20 | 20 | |
21 | -if(defined('IN_ADMIN') && IN_ADMIN === true) { |
|
21 | +if (defined('IN_ADMIN') && IN_ADMIN === true) { |
|
22 | 22 | lng_include('admin'); |
23 | -} elseif($sys_user_logged_in) { |
|
23 | +} elseif ($sys_user_logged_in) { |
|
24 | 24 | sys_user_vacation($user); |
25 | 25 | |
26 | 26 | $planet_id = SetSelectedPlanet($user); |
27 | 27 | |
28 | 28 | // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!! |
29 | - if($user['ally_id']) { |
|
29 | + if ($user['ally_id']) { |
|
30 | 30 | sn_db_transaction_start(); |
31 | 31 | \Alliance\Alliance::sn_ali_fill_user_ally($user); |
32 | - if(!$user['ally']['player']['id']) { |
|
32 | + if (!$user['ally']['player']['id']) { |
|
33 | 33 | // sn_sys_logout(false, true); |
34 | 34 | // core_auth::logout(false); |
35 | 35 | classSupernova::$auth->logout(false); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
50 | 50 | $planetrow = $global_data['planet']; |
51 | - if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
51 | + if (!($planetrow && isset($planetrow['id']) && $planetrow['id'])) { |
|
52 | 52 | // sn_sys_logout(false, true); |
53 | 53 | // core_auth::logout(false); |
54 | 54 | classSupernova::$auth->logout(false); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | sys_user_options_unpack($user); |
64 | 64 | |
65 | 65 | global $sn_page_name, $sn_mvc; |
66 | -if(!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
66 | +if (!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) { |
|
67 | 67 | $title = !empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE]) ? $sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE] : ''; |
68 | 68 | renderHeader($page, $title, $template_result, false, $user, classSupernova::$config, $lang, $planetrow); |
69 | 69 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
19 | 19 | |
20 | -if(!sn_module::sn_module_get_active_count('payment')) { |
|
20 | +if (!sn_module::sn_module_get_active_count('payment')) { |
|
21 | 21 | sys_redirect(SN_ROOT_VIRTUAL . 'admin/overview.php'); |
22 | 22 | } |
23 | 23 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(sn_module::sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
5 | +if (sn_module::sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
6 | 6 | sys_redirect('metamatter.php'); |
7 | 7 | } |
8 | 8 |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | public function __construct(GlobalContainer $services = null) { |
77 | 77 | parent::__construct($services); |
78 | 78 | |
79 | - if(empty(static::$shipInfo)) { |
|
80 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
79 | + if (empty(static::$shipInfo)) { |
|
80 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
81 | 81 | static::$shipInfo[$unit_id] = get_unit_param($unit_id); |
82 | 82 | static::$shipInfo[$unit_id][P_COST_METAL] = get_unit_cost_in(static::$shipInfo[$unit_id][P_COST]); |
83 | 83 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @inheritdoc |
104 | 104 | */ |
105 | 105 | public function update() { |
106 | - if($this->getShipCount() < 1) { |
|
106 | + if ($this->getShipCount() < 1) { |
|
107 | 107 | return $this->delete(); |
108 | 108 | } |
109 | 109 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getCostInMetal() { |
129 | 129 | $result = 0; |
130 | - foreach($this->shipList as $shipId => $amount) { |
|
130 | + foreach ($this->shipList as $shipId => $amount) { |
|
131 | 131 | $result += $amount * $this->getShipCostInMetal($shipId); |
132 | 132 | } |
133 | 133 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function getCapacity() { |
150 | 150 | $result = 0; |
151 | - foreach($this->shipList as $shipId => $amount) { |
|
151 | + foreach ($this->shipList as $shipId => $amount) { |
|
152 | 152 | $result += $amount * $this->getShipCapacity($shipId); |
153 | 153 | } |
154 | 154 | |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function changeShipCount($shipSnId, $shipCount) { |
167 | 167 | !isset($this->shipList[$shipSnId]) ? $this->shipList[$shipSnId] = 0 : false; |
168 | - if($this->shipList[$shipSnId] + $shipCount < 0) { |
|
168 | + if ($this->shipList[$shipSnId] + $shipCount < 0) { |
|
169 | 169 | throw new \Exception("Trying to deduct more ships [{$shipSnId}] '{$shipCount}' then fleet has {$this->shipList[$shipSnId]}"); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $this->shipList[$shipSnId] += $shipCount; |
173 | - if($this->shipList[$shipSnId] <= 0) { |
|
173 | + if ($this->shipList[$shipSnId] <= 0) { |
|
174 | 174 | unset($this->shipList[$shipSnId]); |
175 | 175 | } |
176 | 176 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @throws \Exception |
186 | 186 | */ |
187 | 187 | public function changeResource($resourceId, $resourceCount) { |
188 | - if(!array_key_exists($resourceId, $this->resources)) { |
|
188 | + if (!array_key_exists($resourceId, $this->resources)) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | - if($this->resources[$resourceId] + $resourceCount < 0) { |
|
192 | + if ($this->resources[$resourceId] + $resourceCount < 0) { |
|
193 | 193 | throw new \Exception("Trying to deduct more resources [{$resourceId}] '{$resourceCount}' then fleet has {$this->resources[$resourceId]}"); |
194 | 194 | } |
195 | 195 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @var int[] $shipsToRemove |
35 | 35 | */ |
36 | - protected $shipsToRemove = [SHIP_COLONIZER, SHIP_SPY,]; |
|
36 | + protected $shipsToRemove = [SHIP_COLONIZER, SHIP_SPY, ]; |
|
37 | 37 | |
38 | 38 | // ------------------------------------------------------------------------------------------------------------------- |
39 | 39 | /** |
@@ -278,8 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | // Adding outcome message to the front of other info |
281 | - array_unshift($this->message, is_string($messages) ? $messages : |
|
282 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '')); |
|
281 | + array_unshift($this->message, is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '')); |
|
283 | 282 | } |
284 | 283 | |
285 | 284 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | |
134 | 134 | $update_cache = false; |
135 | 135 | |
136 | - if(!empty($this->to_write)) { |
|
137 | - foreach($this->to_write as $key => $cork) { |
|
136 | + if (!empty($this->to_write)) { |
|
137 | + foreach ($this->to_write as $key => $cork) { |
|
138 | 138 | $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД |
139 | 139 | $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')"; |
140 | 140 | } |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | $update_cache = true; |
146 | 146 | } |
147 | 147 | |
148 | - if(!empty($this->to_delete)) { |
|
149 | - foreach($this->to_delete as $key => &$value) { |
|
150 | - $value = is_string($key) ? "'". db_escape($key) . "'" : $key; |
|
148 | + if (!empty($this->to_delete)) { |
|
149 | + foreach ($this->to_delete as $key => &$value) { |
|
150 | + $value = is_string($key) ? "'" . db_escape($key) . "'" : $key; |
|
151 | 151 | } |
152 | 152 | |
153 | - doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") "); |
|
153 | + doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") "); |
|
154 | 154 | |
155 | 155 | $this->to_delete = array(); |
156 | 156 | $update_cache = true; |
157 | 157 | } |
158 | 158 | |
159 | - if($update_cache) { |
|
159 | + if ($update_cache) { |
|
160 | 160 | global $sn_cache; |
161 | 161 | |
162 | 162 | $field_name = $this->cached_name(); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | protected function load() { |
184 | 184 | global $sn_cache; |
185 | 185 | |
186 | - if($this->loaded) { |
|
186 | + if ($this->loaded) { |
|
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $this->to_write = array(); |
192 | 192 | $this->to_delete = array(); |
193 | 193 | |
194 | - if(!$this->user_id) { |
|
194 | + if (!$this->user_id) { |
|
195 | 195 | $this->loaded = true; |
196 | 196 | return; |
197 | 197 | } |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | $field_name = $this->cached_name(); |
200 | 200 | $a_data = $sn_cache->$field_name; |
201 | 201 | |
202 | - if(!empty($a_data)) { |
|
202 | + if (!empty($a_data)) { |
|
203 | 203 | $this->data = array_replace_recursive($this->data, $a_data); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE"); |
208 | - while($row = db_fetch($query)) { |
|
208 | + while ($row = db_fetch($query)) { |
|
209 | 209 | // $this->data[$row['option_id']] = $row['value']; |
210 | 210 | $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация |
211 | 211 | } |
@@ -58,8 +58,8 @@ |
||
58 | 58 | protected function bonusSort(BonusAtom $a, BonusAtom $b) { |
59 | 59 | static $bonusOrder = [BonusAtom::class, BonusAtomAbility::class, BonusAtomAdd::class, BonusAtomPercent::class, BonusAtomMultiply::class]; |
60 | 60 | |
61 | - $indexA = (int)array_search(get_class($a), $bonusOrder); |
|
62 | - $indexB = (int)array_search(get_class($b), $bonusOrder); |
|
61 | + $indexA = (int) array_search(get_class($a), $bonusOrder); |
|
62 | + $indexB = (int) array_search(get_class($b), $bonusOrder); |
|
63 | 63 | |
64 | 64 | return $indexA == $indexB ? 0 : ($indexA > $indexB ? +1 : -1); |
65 | 65 | } |