@@ -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 | } |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | 2 => 0.01, |
565 | 565 | ), |
566 | 566 | P_MISSION_EXPEDITION_OUTCOME_SECONDARY => array( |
567 | - 90 => [P_MULTIPLIER => 0.01, P_MESSAGE_ID => 2,], |
|
568 | - 99 => [P_MULTIPLIER => 0.02, P_MESSAGE_ID => 1,], |
|
569 | - 100 => [P_MULTIPLIER => 0.10, P_MESSAGE_ID => 0,], |
|
567 | + 90 => [P_MULTIPLIER => 0.01, P_MESSAGE_ID => 2, ], |
|
568 | + 99 => [P_MULTIPLIER => 0.02, P_MESSAGE_ID => 1, ], |
|
569 | + 100 => [P_MULTIPLIER => 0.10, P_MESSAGE_ID => 0, ], |
|
570 | 570 | ), |
571 | 571 | ), |
572 | 572 | FLT_EXPEDITION_OUTCOME_FOUND_RESOURCES => array( |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | 2 => 0.025, |
579 | 579 | ), |
580 | 580 | P_MISSION_EXPEDITION_OUTCOME_SECONDARY => array( |
581 | - 90 => [P_MULTIPLIER => 0.025, P_MESSAGE_ID => 2,], |
|
582 | - 99 => [P_MULTIPLIER => 0.050, P_MESSAGE_ID => 1,], |
|
583 | - 100 => [P_MULTIPLIER => 0.100, P_MESSAGE_ID => 0,], |
|
581 | + 90 => [P_MULTIPLIER => 0.025, P_MESSAGE_ID => 2, ], |
|
582 | + 99 => [P_MULTIPLIER => 0.050, P_MESSAGE_ID => 1, ], |
|
583 | + 100 => [P_MULTIPLIER => 0.100, P_MESSAGE_ID => 0, ], |
|
584 | 584 | ), |
585 | 585 | ), |
586 | 586 | FLT_EXPEDITION_OUTCOME_FOUND_DM => array( |