@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | unset($player_options[PLAYER_OPTION_TUTORIAL_CURRENT]); |
402 | 402 | } |
403 | 403 | |
404 | - array_walk($player_options, function (&$value) { |
|
404 | + array_walk($player_options, function(&$value) { |
|
405 | 405 | // TODO - Когда будет больше параметров - сделать больше проверок |
406 | 406 | $value = intval($value); |
407 | 407 | }); |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $user['id'], |
451 | 451 | RPG_NAME_CHANGE, |
452 | 452 | -$config->game_user_changename_cost, |
453 | - vsprintf('Пользователь ID %1$d сменил имя с "%2$s" на "%3$s"', [$user['id'], $user['username'], $username,]) |
|
453 | + vsprintf('Пользователь ID %1$d сменил имя с "%2$s" на "%3$s"', [$user['id'], $user['username'], $username, ]) |
|
454 | 454 | ); |
455 | 455 | |
456 | 456 | case SERVER_PLAYER_NAME_CHANGE_FREE: |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
151 | 151 | |
152 | 152 | // Alliance bonus calculations |
153 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
153 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
154 | 154 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
155 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
155 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
156 | 156 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
157 | 157 | 'ali_bonus_members' => 10, // Minimum alliance size to start using bonus |
158 | 158 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | 'Defs_Cdr' => 30, |
187 | 187 | 'eco_scale_storage' => 1, |
188 | 188 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
189 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
189 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
190 | 190 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
191 | 191 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
192 | 192 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | 'energy_basic_income' => 0, |
198 | 198 | |
199 | 199 | // Bashing protection settings |
200 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
201 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
202 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
203 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
204 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
200 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
201 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
202 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
203 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
204 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
205 | 205 | |
206 | 206 | 'Fleet_Cdr' => 30, |
207 | 207 | 'fleet_speed' => 1, |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | 'fleet_update_interval' => 4, |
210 | 210 | 'fleet_update_lock' => '', // SQL time when lock was acquired |
211 | 211 | |
212 | - 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
213 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
212 | + 'game_adminEmail' => 'root@localhost', // Admin's email to show to users |
|
213 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
214 | 214 | // Defaults |
215 | 215 | 'game_default_language' => 'ru', |
216 | 216 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | 'game_maxSystem' => 199, |
225 | 225 | 'game_maxPlanet' => 15, |
226 | 226 | // Game global settings |
227 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
227 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
228 | 228 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
229 | 229 | |
230 | 230 | 'game_news_actual' => PERIOD_DAY_3, // How long announcement would be marked as "New". In seconds. Default - 3 days |
231 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
232 | - 'game_news_overview_show' => PERIOD_WEEK_2, // How long news will be shown in Overview page in seconds. Default - 2 weeks |
|
231 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
232 | + 'game_news_overview_show' => PERIOD_WEEK_2, // How long news will be shown in Overview page in seconds. Default - 2 weeks |
|
233 | 233 | // Noob protection |
234 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
234 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
235 | 235 | 'game_noob_points' => 5000, // Below this point user threated as noob. 0 to disable |
236 | 236 | |
237 | 237 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts) |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | 'payment_currency_exchange_wmu' => 30, |
286 | 286 | 'payment_currency_exchange_wmz' => 1, |
287 | 287 | |
288 | - 'payment_lot_price' => 1, // Lot price in default currency |
|
289 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
288 | + 'payment_lot_price' => 1, // Lot price in default currency |
|
289 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
290 | 290 | |
291 | 291 | 'planet_capital_cost' => 25000, // Cost in DM to move Capital to current planet |
292 | - 'planet_capital_mining_rate' => 2.0, // Capital Mining rates |
|
293 | - 'planet_capital_building_rate' => 2.0, // Capital Building rates |
|
292 | + 'planet_capital_mining_rate' => 2.0, // Capital Mining rates |
|
293 | + 'planet_capital_building_rate' => 2.0, // Capital Building rates |
|
294 | 294 | 'planet_teleport_cost' => 50000, // Cost of planet teleportation |
295 | 295 | 'planet_teleport_timeout' => 86400, // Timeout for next teleportation |
296 | 296 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | 'resource_multiplier' => 1, |
313 | 313 | |
314 | 314 | //Roleplay system |
315 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
315 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral shoud get for partner have 1 DM bonus |
|
316 | 316 | 'rpg_bonus_minimum' => 10000, // Minimum DM ammount for starting paying bonuses to affiliate |
317 | 317 | |
318 | 318 | // Black Market - General |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
113 | 113 | if (preg_match($rexep, $date, $out)) { |
114 | 114 | $ret = array( |
115 | - "tm_sec" => (int)$out['S'], |
|
116 | - "tm_min" => (int)$out['M'], |
|
117 | - "tm_hour" => (int)$out['H'], |
|
118 | - "tm_mday" => (int)$out['d'], |
|
115 | + "tm_sec" => (int) $out['S'], |
|
116 | + "tm_min" => (int) $out['M'], |
|
117 | + "tm_hour" => (int) $out['H'], |
|
118 | + "tm_mday" => (int) $out['d'], |
|
119 | 119 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
120 | 120 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
121 | 121 | ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return int |
151 | 151 | */ |
152 | 152 | function datePart($fullDate) { |
153 | - return (int)strtotime(date('Y-m-d', $fullDate)); |
|
153 | + return (int) strtotime(date('Y-m-d', $fullDate)); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return bool |
179 | 179 | * @throws ErrorException |
180 | 180 | */ |
181 | - function ($errno, $errstr, $errfile, $errline) { |
|
181 | + function($errno, $errstr, $errfile, $errline) { |
|
182 | 182 | throw new ErrorException($errstr, 0, $errno, $errfile, $errline); |
183 | 183 | } |
184 | 184 | ); |
@@ -67,8 +67,7 @@ discard block |
||
67 | 67 | ->doInsert(); |
68 | 68 | |
69 | 69 | $accept_offer = false; |
70 | - } |
|
71 | - else |
|
70 | + } else |
|
72 | 71 | { |
73 | 72 | $accept_offer = true; |
74 | 73 | $autoAccept = true; |
@@ -80,8 +79,7 @@ discard block |
||
80 | 79 | 'alliance_negotiation_relation' => $alliance_negotiation_relation, |
81 | 80 | ); |
82 | 81 | } |
83 | -} |
|
84 | -else |
|
82 | +} else |
|
85 | 83 | { |
86 | 84 | $offer_id = sys_get_param_id('offer_id'); |
87 | 85 | if($offer_id) |
@@ -92,31 +90,26 @@ discard block |
||
92 | 90 | if(!$negotiation) |
93 | 91 | { |
94 | 92 | messageBox($lang['ali_dip_err_offer_none'], $page_title); |
95 | - } |
|
96 | - elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
93 | + } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
97 | 94 | { |
98 | 95 | // TODO: Add log of hack attempt |
99 | 96 | messageBox($lang['ali_dip_err_offer_alien'], $page_title); |
100 | - } |
|
101 | - elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
97 | + } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
102 | 98 | { |
103 | 99 | if($offer_answer == 'accept') |
104 | 100 | { |
105 | 101 | // TODO: Add log of hack attempt |
106 | 102 | messageBox($lang['ali_dip_err_offer_accept_own'], $page_title); |
107 | - } |
|
108 | - elseif($offer_answer == 'deny') |
|
103 | + } elseif($offer_answer == 'deny') |
|
109 | 104 | { |
110 | 105 | doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;"); |
111 | 106 | } |
112 | - } |
|
113 | - else |
|
107 | + } else |
|
114 | 108 | { |
115 | 109 | if($offer_answer == 'accept') |
116 | 110 | { |
117 | 111 | $accept_offer = true; |
118 | - } |
|
119 | - elseif($offer_answer == 'deny') |
|
112 | + } elseif($offer_answer == 'deny') |
|
120 | 113 | { |
121 | 114 | DBStaticAlly::db_ally_negotiation_update_status_1($offer_id); |
122 | 115 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Alliance\DBStaticAlly; |
4 | 4 | use \DBAL\DbQuery; |
5 | 5 | |
6 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
6 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
7 | 7 | { |
8 | 8 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
9 | 9 | } |
@@ -18,28 +18,28 @@ discard block |
||
18 | 18 | $ally_name_safe = db_escape($user['ally_name']); |
19 | 19 | |
20 | 20 | $autoAccept = false; |
21 | -if(sys_get_param_str('ali_dip_offer_make')) |
|
21 | +if (sys_get_param_str('ali_dip_offer_make')) |
|
22 | 22 | { |
23 | 23 | $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation'); |
24 | - if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) |
|
24 | + if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) |
|
25 | 25 | { |
26 | 26 | messageBox($lang['ali_dip_err_wrong_offer'], $page_title); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id'); |
30 | - if($alliance_negotiation_contr_ally_id == $user['ally_id']) |
|
30 | + if ($alliance_negotiation_contr_ally_id == $user['ally_id']) |
|
31 | 31 | { |
32 | 32 | messageBox($lang['ali_dip_err_same_ally'], $page_title); |
33 | 33 | } |
34 | 34 | |
35 | 35 | $contr_ally_row = doquery("SELECT `ally_name` FROM {{alliance}} WHERE `id` = {$alliance_negotiation_contr_ally_id} LIMIT 1;", '', true); |
36 | - if(!$contr_ally_row) |
|
36 | + if (!$contr_ally_row) |
|
37 | 37 | { |
38 | 38 | messageBox($lang['ali_dip_err_no_ally'], $page_title); |
39 | 39 | } |
40 | 40 | |
41 | 41 | $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id); |
42 | - if($alliance_negotiation_relation == $relation_current_id) |
|
42 | + if ($alliance_negotiation_relation == $relation_current_id) |
|
43 | 43 | { |
44 | 44 | messageBox(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title); |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation]; |
53 | 53 | $relation_current = $sn_diplomacy_relation_list[$relation_current_id]; |
54 | - if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) |
|
54 | + if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) |
|
55 | 55 | { |
56 | 56 | DbQuery::build() |
57 | 57 | ->setTable('alliance_negotiation') |
@@ -85,39 +85,39 @@ discard block |
||
85 | 85 | else |
86 | 86 | { |
87 | 87 | $offer_id = sys_get_param_id('offer_id'); |
88 | - if($offer_id) |
|
88 | + if ($offer_id) |
|
89 | 89 | { |
90 | 90 | $offer_answer = sys_get_param_str('answer'); |
91 | 91 | |
92 | 92 | $negotiation = doquery("SELECT * FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;", '', true); |
93 | - if(!$negotiation) |
|
93 | + if (!$negotiation) |
|
94 | 94 | { |
95 | 95 | messageBox($lang['ali_dip_err_offer_none'], $page_title); |
96 | 96 | } |
97 | - elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
97 | + elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
98 | 98 | { |
99 | 99 | // TODO: Add log of hack attempt |
100 | 100 | messageBox($lang['ali_dip_err_offer_alien'], $page_title); |
101 | 101 | } |
102 | - elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
102 | + elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
103 | 103 | { |
104 | - if($offer_answer == 'accept') |
|
104 | + if ($offer_answer == 'accept') |
|
105 | 105 | { |
106 | 106 | // TODO: Add log of hack attempt |
107 | 107 | messageBox($lang['ali_dip_err_offer_accept_own'], $page_title); |
108 | 108 | } |
109 | - elseif($offer_answer == 'deny') |
|
109 | + elseif ($offer_answer == 'deny') |
|
110 | 110 | { |
111 | 111 | doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;"); |
112 | 112 | } |
113 | 113 | } |
114 | 114 | else |
115 | 115 | { |
116 | - if($offer_answer == 'accept') |
|
116 | + if ($offer_answer == 'accept') |
|
117 | 117 | { |
118 | 118 | $accept_offer = true; |
119 | 119 | } |
120 | - elseif($offer_answer == 'deny') |
|
120 | + elseif ($offer_answer == 'deny') |
|
121 | 121 | { |
122 | 122 | DBStaticAlly::db_ally_negotiation_update_status_1($offer_id); |
123 | 123 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -if($accept_offer) |
|
128 | +if ($accept_offer) |
|
129 | 129 | { |
130 | 130 | sn_db_transaction_start(); |
131 | 131 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | sn_db_transaction_commit(); |
186 | 186 | } |
187 | 187 | |
188 | -foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) |
|
188 | +foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) |
|
189 | 189 | { |
190 | 190 | $template->assign_block_vars('relation', array( |
191 | 191 | 'ID' => $diplomacy_relation_id, |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | $query = doquery("SELECT id, ally_name, ally_tag FROM {{alliance}} WHERE `id` != {$user['ally_id']} ORDER BY ally_name;"); |
197 | -while($alliance = db_fetch($query)) |
|
197 | +while ($alliance = db_fetch($query)) |
|
198 | 198 | { |
199 | 199 | $template->assign_block_vars('alliance', array( |
200 | 200 | 'ID' => $alliance['id'], |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | WHERE |
214 | 214 | alliance_negotiation_ally_id = {$user['ally_id']} OR alliance_negotiation_contr_ally_id = {$user['ally_id']};" |
215 | 215 | ); |
216 | -while($offer = db_fetch($query)) |
|
216 | +while ($offer = db_fetch($query)) |
|
217 | 217 | { |
218 | 218 | $template->assign_block_vars('offer', array( |
219 | 219 | 'ID' => $offer['alliance_negotiation_id'], |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | protected static $autoloaderRegistered = false; |
25 | 25 | |
26 | 26 | protected static function _constructorStatic() { |
27 | - if(!static::$autoloaderRegistered) { |
|
27 | + if (!static::$autoloaderRegistered) { |
|
28 | 28 | spl_autoload_register(array(__CLASS__, 'autoloader')); |
29 | 29 | static::$autoloaderRegistered = true; |
30 | 30 | } |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | public static function autoloader($class) { |
37 | 37 | static::_constructorStatic(); |
38 | 38 | |
39 | - foreach(static::$folders as $data) { |
|
39 | + foreach (static::$folders as $data) { |
|
40 | 40 | $theClassFile = $class; |
41 | 41 | |
42 | - if($data[static::P_PREFIX] && strrpos($class, $data[static::P_PREFIX]) !== false) { |
|
42 | + if ($data[static::P_PREFIX] && strrpos($class, $data[static::P_PREFIX]) !== false) { |
|
43 | 43 | $theClassFile = substr($class, strlen($data[static::P_PREFIX])); |
44 | 44 | } |
45 | 45 | |
46 | 46 | $classFullFileName = str_replace('\\', '/', $data[static::P_FOLDER] . $theClassFile) . DOT_PHP_EX; |
47 | - if(file_exists($classFullFileName) && is_file($classFullFileName)) { |
|
47 | + if (file_exists($classFullFileName) && is_file($classFullFileName)) { |
|
48 | 48 | require_once($classFullFileName); |
49 | - if(method_exists($class, '_constructorStatic')) { |
|
49 | + if (method_exists($class, '_constructorStatic')) { |
|
50 | 50 | $class::_constructorStatic(); |
51 | 51 | } |
52 | 52 | } |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | |
63 | 63 | $absoluteClassRoot = str_replace('\\', '/', SN_ROOT_PHYSICAL . $absoluteClassRoot); |
64 | 64 | |
65 | - if(!($absoluteClassRoot = realpath($absoluteClassRoot))) { |
|
65 | + if (!($absoluteClassRoot = realpath($absoluteClassRoot))) { |
|
66 | 66 | // TODO - throw new \Exception("There is some error when installing autoloader for '{$absoluteClassRoot}' class prefix '{$classPrefix}'"); |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | $absoluteClassRoot = str_replace('\\', '/', $absoluteClassRoot) . '/'; |
70 | 70 | |
71 | - if($classPrefix && strrpos($classPrefix, 1) != '\\') { |
|
71 | + if ($classPrefix && strrpos($classPrefix, 1) != '\\') { |
|
72 | 72 | $classPrefix .= '\\'; |
73 | 73 | } |
74 | 74 |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
115 | -array_walk($payment_methods_available, function (&$value, $index) { |
|
115 | +array_walk($payment_methods_available, function(&$value, $index) { |
|
116 | 116 | $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value; |
117 | 117 | }); |
118 | 118 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | if ($request['metamatter'] && $payment_module_request) { |
224 | 224 | try { |
225 | 225 | $paymentModuleReal = SN::$gc->modules->getModule($payment_module_request); |
226 | - if(!is_object($paymentModuleReal)) { |
|
226 | + if (!is_object($paymentModuleReal)) { |
|
227 | 227 | throw new Exception('{ Менеджер модулей вернул null вместо платёжного модуля для }' . $payment_module_request, ERR_ERROR); |
228 | 228 | } |
229 | 229 | /** |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | 'PLAYER_CURRENCY' => $player_currency, |
313 | 313 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
314 | 314 | |
315 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
315 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
316 | 316 | 'UNIT_AMOUNT_TEXT' => HelperString::numberFloorAndFormat($request['metamatter']), |
317 | 317 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
318 | 318 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | */ |
14 | 14 | function eco_get_lab_max_effective_level(&$user, $lab_require) |
15 | 15 | { |
16 | - if(!$user['user_as_ally'] && !isset($user['laboratories_active'])) |
|
16 | + if (!$user['user_as_ally'] && !isset($user['laboratories_active'])) |
|
17 | 17 | { |
18 | 18 | $user['laboratories_active'] = array(); |
19 | 19 | $query = DBStaticUnit::db_unit_list_laboratories($user['id']); |
20 | - while($row = db_fetch($query)) |
|
20 | + while ($row = db_fetch($query)) |
|
21 | 21 | { |
22 | - if(!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) |
|
22 | + if (!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) |
|
23 | 23 | { |
24 | 24 | $row += array( |
25 | 25 | STRUC_LABORATORY => $level_lab = mrc_get_level($user, $row, STRUC_LABORATORY), |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | uasort($user['laboratories_active'], 'eco_lab_sort_effectivness'); |
34 | 34 | } |
35 | 35 | |
36 | - if(!isset($user['research_effective_level'][$lab_require])) |
|
36 | + if (!isset($user['research_effective_level'][$lab_require])) |
|
37 | 37 | { |
38 | - if($user['user_as_ally']) |
|
38 | + if ($user['user_as_ally']) |
|
39 | 39 | { |
40 | 40 | $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true); |
41 | 41 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1; |
45 | 45 | $lab_level['effective_level'] = 0; |
46 | 46 | |
47 | - foreach($user['laboratories_active'] as $data) |
|
47 | + foreach ($user['laboratories_active'] as $data) |
|
48 | 48 | { |
49 | - if($tech_intergalactic <= 0) |
|
49 | + if ($tech_intergalactic <= 0) |
|
50 | 50 | { |
51 | 51 | break; |
52 | 52 | } |
53 | - if($data[STRUC_LABORATORY] >= $lab_require) |
|
53 | + if ($data[STRUC_LABORATORY] >= $lab_require) |
|
54 | 54 | { |
55 | 55 | $lab_level['effective_level'] += $data['laboratory_effective_level']; |
56 | 56 | $tech_intergalactic--; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $cost[P_OPTIONS][P_TIME_RAW] = 0; |
91 | 91 | $only_dark_matter = 0; |
92 | 92 | $cost_in_metal = 0; |
93 | - foreach($unit_data[P_COST] as $resource_id => $resource_amount) { |
|
94 | - if($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { |
|
93 | + foreach ($unit_data[P_COST] as $resource_id => $resource_amount) { |
|
94 | + if ($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | |
103 | 103 | $cost_in_metal += $cost[BUILD_CREATE][$resource_id] * $currentResourceExchange; |
104 | 104 | |
105 | - if(in_array($resource_id, $resources_loot)) { |
|
105 | + if (in_array($resource_id, $resources_loot)) { |
|
106 | 106 | $cost[P_OPTIONS][P_TIME_RAW] += $resource_cost * $currentResourceExchange / $rpg_exchange_deuterium; |
107 | 107 | $resource_got = mrc_get_level($user, $planet, $resource_id); |
108 | - } elseif($resource_id == RES_DARK_MATTER) { |
|
108 | + } elseif ($resource_id == RES_DARK_MATTER) { |
|
109 | 109 | $resource_got = mrc_get_level($user, null, $resource_id); |
110 | - } elseif($resource_id == RES_ENERGY) { |
|
110 | + } elseif ($resource_id == RES_ENERGY) { |
|
111 | 111 | $resource_got = max(0, $planet['energy_max'] - $planet['energy_used']); |
112 | 112 | } else { |
113 | 113 | $resource_got = 0; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | $resources_normalized = 0; |
122 | - foreach($resources_loot as $resource_id) { |
|
122 | + foreach ($resources_loot as $resource_id) { |
|
123 | 123 | $resources_normalized += floor(mrc_get_level($user, $planet, $resource_id)) * $config->__get('rpg_exchange_' . pname_resource_name($resource_id)); |
124 | 124 | } |
125 | 125 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $cost[P_OPTIONS][P_TIME_RAW] = $cost[P_OPTIONS][P_TIME_RAW] * 60 * 60 / get_game_speed() / 2500; |
136 | 136 | |
137 | 137 | // TODO - Вынести в отдельную процедуру расчёт стоимости |
138 | - if($only_cost) { |
|
138 | + if ($only_cost) { |
|
139 | 139 | return $cost; |
140 | 140 | } |
141 | 141 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $cost['RESULT'][BUILD_DESTROY] = BUILD_INDESTRUCTABLE; |
148 | 148 | |
149 | 149 | $mercenary = 0; |
150 | - if(in_array($unit_id, sn_get_groups('structures'))) { |
|
150 | + if (in_array($unit_id, sn_get_groups('structures'))) { |
|
151 | 151 | $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1); |
152 | 152 | $cost['RESULT'][BUILD_DESTROY] = |
153 | 153 | mrc_get_level($user, $planet, $unit_id, false, true) |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | ) |
158 | 158 | : BUILD_NO_UNITS; |
159 | 159 | $mercenary = MRC_ENGINEER; |
160 | - } elseif(in_array($unit_id, sn_get_groups('tech'))) { |
|
160 | + } elseif (in_array($unit_id, sn_get_groups('tech'))) { |
|
161 | 161 | $lab_level = eco_get_lab_max_effective_level($user, intval($unit_data[P_REQUIRE][STRUC_LABORATORY])); |
162 | 162 | $cost[RES_TIME][BUILD_CREATE] /= $lab_level; |
163 | 163 | $mercenary = MRC_ACADEMIC; |
164 | - } elseif(in_array($unit_id, sn_get_groups('defense'))) { |
|
165 | - $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1) ; |
|
164 | + } elseif (in_array($unit_id, sn_get_groups('defense'))) { |
|
165 | + $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
|
166 | 166 | $mercenary = MRC_FORTIFIER; |
167 | - } elseif(in_array($unit_id, sn_get_groups('fleet'))) { |
|
167 | + } elseif (in_array($unit_id, sn_get_groups('fleet'))) { |
|
168 | 168 | $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
169 | 169 | $mercenary = MRC_ENGINEER; |
170 | 170 | } |
171 | 171 | |
172 | - if( |
|
172 | + if ( |
|
173 | 173 | // If planet is capital |
174 | 174 | $user['id_planet'] == $planet['id'] |
175 | 175 | && |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] / SN::$gc->config->planet_capital_building_rate; |
181 | 181 | } |
182 | 182 | |
183 | - if($mercenary) { |
|
183 | + if ($mercenary) { |
|
184 | 184 | $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] / mrc_modify_value($user, $planet, $mercenary, 1); |
185 | 185 | } |
186 | 186 | |
187 | - if(in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { |
|
187 | + if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { |
|
188 | 188 | $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0; |
189 | 189 | } else { |
190 | 190 | $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] > 1 ? round($cost[RES_TIME][BUILD_CREATE]) : 1; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | return $cost; |
195 | 195 | } |
196 | 196 | |
197 | -function eco_can_build_unit($user, $planet, $unit_id){$result = null;return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result));} |
|
197 | +function eco_can_build_unit($user, $planet, $unit_id) {$result = null; return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result)); } |
|
198 | 198 | function sn_eco_can_build_unit($user, $planet, $unit_id, &$result) { |
199 | 199 | global $config; |
200 | 200 | |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result; |
203 | 203 | |
204 | 204 | $unit_param = get_unit_param($unit_id); |
205 | - if($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) { |
|
205 | + if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) { |
|
206 | 206 | $requirement = &$unit_param[P_REQUIRE]; |
207 | - if($result == BUILD_ALLOWED && $requirement) { |
|
208 | - foreach($requirement as $require_id => $require_level) { |
|
209 | - if(mrc_get_level($user, $planet, $require_id) < $require_level) { |
|
207 | + if ($result == BUILD_ALLOWED && $requirement) { |
|
208 | + foreach ($requirement as $require_id => $require_level) { |
|
209 | + if (mrc_get_level($user, $planet, $require_id) < $require_level) { |
|
210 | 210 | $result = BUILD_REQUIRE_NOT_MEET; |
211 | 211 | break; |
212 | 212 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | |
224 | 224 | $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list); |
225 | 225 | $planet_que = explode(';', $planet_que); |
226 | - foreach($planet_que as $planet_que_item) |
|
226 | + foreach ($planet_que as $planet_que_item) |
|
227 | 227 | { |
228 | - if($planet_que_item) |
|
228 | + if ($planet_que_item) |
|
229 | 229 | { |
230 | 230 | list($planet_que_item) = explode(',', $planet_que_item); |
231 | - if(in_array($planet_que_item, $unit_list)) |
|
231 | + if (in_array($planet_que_item, $unit_list)) |
|
232 | 232 | { |
233 | 233 | $eco_is_builds_in_que = true; |
234 | 234 | break; |
@@ -239,21 +239,21 @@ discard block |
||
239 | 239 | return $eco_is_builds_in_que; |
240 | 240 | } |
241 | 241 | |
242 | -function eco_unit_busy(&$user, &$planet, $unit_id){$result = null;return sn_function_call('eco_unit_busy', [&$user, &$planet, $unit_id, &$result]);} |
|
242 | +function eco_unit_busy(&$user, &$planet, $unit_id) {$result = null; return sn_function_call('eco_unit_busy', [&$user, &$planet, $unit_id, &$result]); } |
|
243 | 243 | function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) |
244 | 244 | { |
245 | 245 | global $config; |
246 | 246 | |
247 | 247 | $result = isset($result) ? $result : false; |
248 | - if(!$result) |
|
248 | + if (!$result) |
|
249 | 249 | { |
250 | - if(($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun) |
|
250 | + if (($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun) |
|
251 | 251 | { |
252 | 252 | $global_que = que_get($user['id'], $planet['id'], QUE_RESEARCH, false); |
253 | - if(is_array($global_que['ques'][QUE_RESEARCH][$user['id']])) |
|
253 | + if (is_array($global_que['ques'][QUE_RESEARCH][$user['id']])) |
|
254 | 254 | { |
255 | 255 | $first_element = reset($global_que['ques'][QUE_RESEARCH][$user['id']]); |
256 | - if(is_array($first_element)) |
|
256 | + if (is_array($first_element)) |
|
257 | 257 | { |
258 | 258 | $result = true; |
259 | 259 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | // $result = true; |
264 | 264 | //} |
265 | 265 | } |
266 | - elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
266 | + elseif (($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
267 | 267 | { |
268 | 268 | $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO)); |
269 | 269 | } |
@@ -2,8 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use Unit\DBStaticUnit; |
4 | 4 | |
5 | -function eco_lab_sort_effectivness($a, $b) |
|
6 | -{ |
|
5 | +function eco_lab_sort_effectivness($a, $b) { |
|
7 | 6 | return $a['laboratory_effective_level'] > $b['laboratory_effective_level'] ? -1 : ($a['laboratory_effective_level'] < $b['laboratory_effective_level'] ? 1 : 0); |
8 | 7 | } |
9 | 8 | |
@@ -13,8 +12,7 @@ discard block |
||
13 | 12 | * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
14 | 13 | * @version 1.0 |
15 | 14 | */ |
16 | -function eco_get_lab_max_effective_level(&$user, $lab_require) |
|
17 | -{ |
|
15 | +function eco_get_lab_max_effective_level(&$user, $lab_require) { |
|
18 | 16 | if(!$user['user_as_ally'] && !isset($user['laboratories_active'])) |
19 | 17 | { |
20 | 18 | $user['laboratories_active'] = array(); |
@@ -40,8 +38,7 @@ discard block |
||
40 | 38 | if($user['user_as_ally']) |
41 | 39 | { |
42 | 40 | $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true); |
43 | - } |
|
44 | - else |
|
41 | + } else |
|
45 | 42 | { |
46 | 43 | $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1; |
47 | 44 | $lab_level['effective_level'] = 0; |
@@ -219,8 +216,7 @@ discard block |
||
219 | 216 | return $result; |
220 | 217 | } |
221 | 218 | |
222 | -function eco_is_builds_in_que($planet_que, $unit_list) |
|
223 | -{ |
|
219 | +function eco_is_builds_in_que($planet_que, $unit_list) { |
|
224 | 220 | $eco_is_builds_in_que = false; |
225 | 221 | |
226 | 222 | $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list); |
@@ -242,8 +238,7 @@ discard block |
||
242 | 238 | } |
243 | 239 | |
244 | 240 | function eco_unit_busy(&$user, &$planet, $unit_id){$result = null;return sn_function_call('eco_unit_busy', [&$user, &$planet, $unit_id, &$result]);} |
245 | -function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) |
|
246 | -{ |
|
241 | +function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) { |
|
247 | 242 | global $config; |
248 | 243 | |
249 | 244 | $result = isset($result) ? $result : false; |
@@ -264,8 +259,7 @@ discard block |
||
264 | 259 | //{ |
265 | 260 | // $result = true; |
266 | 261 | //} |
267 | - } |
|
268 | - elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
262 | + } elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
269 | 263 | { |
270 | 264 | $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO)); |
271 | 265 | } |
@@ -191,18 +191,18 @@ discard block |
||
191 | 191 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
192 | 192 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
193 | 193 | |
194 | - if(sys_get_param('login_player_register_logout')) { |
|
194 | + if (sys_get_param('login_player_register_logout')) { |
|
195 | 195 | $this->logout(); |
196 | 196 | } |
197 | 197 | |
198 | 198 | $original_suggest = ''; |
199 | 199 | // Смотрим - есть ли у нас данные от пользователя |
200 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
200 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
201 | 201 | // Попытка регистрации нового игрока из данных, введенных пользователем |
202 | 202 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
203 | 203 | } else { |
204 | - foreach($this->providers_authorised as $provider) { |
|
205 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
204 | + foreach ($this->providers_authorised as $provider) { |
|
205 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
206 | 206 | $original_suggest = $provider->player_name_suggest(); |
207 | 207 | break; |
208 | 208 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
213 | - if(!$this->player_suggested_name) { |
|
213 | + if (!$this->player_suggested_name) { |
|
214 | 214 | $max_user_id = db_player_get_max_id(); // 4.5 |
215 | 215 | // TODO - предлагать имя игрока по локали |
216 | 216 | |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | sn_db_transaction_rollback(); |
220 | 220 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
221 | 221 | sn_db_transaction_start(); |
222 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
222 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if($player_name_submitted) { |
|
226 | + if ($player_name_submitted) { |
|
227 | 227 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
228 | - if($this->register_status == LOGIN_SUCCESS) { |
|
228 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
229 | 229 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
230 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
230 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
231 | 231 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
232 | 232 | } |
233 | 233 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | : false |
252 | 252 | ); |
253 | 253 | |
254 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
254 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
255 | 255 | $prohibited_characters = array_map(function($value) { |
256 | 256 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
257 | 257 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -284,18 +284,18 @@ discard block |
||
284 | 284 | |
285 | 285 | // !self::$is_init ? self::init() : false; |
286 | 286 | |
287 | - if(!SN::$gc->modules->countModulesInGroup('auth')) { |
|
287 | + if (!SN::$gc->modules->countModulesInGroup('auth')) { |
|
288 | 288 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
289 | 289 | } |
290 | 290 | |
291 | 291 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
292 | 292 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
293 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
293 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
294 | 294 | |
295 | 295 | $this->auth_reset(); // OK v4.5 |
296 | 296 | |
297 | 297 | $this->providers = array(); |
298 | - foreach(SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) { |
|
298 | + foreach (SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) { |
|
299 | 299 | /** |
300 | 300 | * @var auth_abstract $module |
301 | 301 | */ |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | |
305 | 305 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
306 | 306 | //pdump($this->providers); |
307 | - foreach($this->providers as $provider_id => $provider) { |
|
307 | + foreach ($this->providers as $provider_id => $provider) { |
|
308 | 308 | $login_status = $provider->login(); // OK v4.5 |
309 | 309 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
310 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
310 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
311 | 311 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
312 | 312 | |
313 | 313 | $this->user_id_to_provider = array_replace_recursive( |
@@ -315,20 +315,20 @@ discard block |
||
315 | 315 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
316 | 316 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
317 | 317 | ); |
318 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
318 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
319 | 319 | $this->provider_error_list[$provider_id] = $login_status; |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - if(empty($this->providers_authorised)) { |
|
323 | + if (empty($this->providers_authorised)) { |
|
324 | 324 | // Ни один аккаунт не авторизирован |
325 | 325 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
326 | - if(!empty($this->provider_error_list)) { |
|
326 | + if (!empty($this->provider_error_list)) { |
|
327 | 327 | // Если есть - выводим их |
328 | 328 | self::$login_status = reset($this->provider_error_list); |
329 | 329 | $providerError = $this->providers[key($this->provider_error_list)]->account_login_message; |
330 | 330 | |
331 | - if(!empty($providerError)) { |
|
331 | + if (!empty($providerError)) { |
|
332 | 332 | self::$login_message = $providerError; |
333 | 333 | } |
334 | 334 | } |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
344 | 344 | |
345 | 345 | // Остались ли у нас в списке доступные игроки? |
346 | - if(empty($this->accessible_user_row_list)) { |
|
346 | + if (empty($this->accessible_user_row_list)) { |
|
347 | 347 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
348 | 348 | // Надо регать нового игрока |
349 | 349 | |
350 | 350 | // Сейчас происходит процесс регистрации игрока? |
351 | - if(!$this->is_player_register) { |
|
351 | + if (!$this->is_player_register) { |
|
352 | 352 | // Нет - отправляем на процесс регистрации |
353 | 353 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
354 | 354 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | // Да, есть доступные игроки, которые так же прописаны в базе |
358 | 358 | $this->get_active_user(); // 4.5 |
359 | 359 | |
360 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
360 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
361 | 361 | $a_user = db_user_by_id($this->is_impersonating); |
362 | 362 | $this->impersonator_username = $a_user['username']; |
363 | 363 | } |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | |
366 | 366 | //Прописываем текущего игрока на все авторизированные аккаунты |
367 | 367 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
368 | - if(empty($this->is_impersonating)) { |
|
369 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
370 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
368 | + if (empty($this->is_impersonating)) { |
|
369 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
370 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
371 | 371 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
372 | 372 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
373 | 373 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | - if(empty(self::$user['id'])) { |
|
380 | + if (empty(self::$user['id'])) { |
|
381 | 381 | self::cookie_set(''); // OK 4.5 |
382 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
382 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
383 | 383 | self::cookie_set(self::$user['id']); // OK 4.5 |
384 | 384 | } |
385 | 385 | |
@@ -398,21 +398,21 @@ discard block |
||
398 | 398 | */ |
399 | 399 | // OK v4.7 |
400 | 400 | public function logout($redirect = true) { |
401 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
401 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
402 | 402 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
403 | 403 | self::cookie_set(0, true); |
404 | 404 | self::$main_provider->logout(); |
405 | 405 | } else { |
406 | - foreach($this->providers as $provider_name => $provider) { |
|
406 | + foreach ($this->providers as $provider_name => $provider) { |
|
407 | 407 | $provider->logout(); |
408 | 408 | } |
409 | 409 | |
410 | 410 | self::cookie_set(0); |
411 | 411 | } |
412 | 412 | |
413 | - if($redirect === true) { |
|
413 | + if ($redirect === true) { |
|
414 | 414 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
415 | - } elseif($redirect !== false) { |
|
415 | + } elseif ($redirect !== false) { |
|
416 | 416 | sys_redirect($redirect); |
417 | 417 | } |
418 | 418 | } |
@@ -423,15 +423,15 @@ discard block |
||
423 | 423 | * @param $user_selected |
424 | 424 | */ |
425 | 425 | public function impersonate($user_selected) { |
426 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
426 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
427 | 427 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
428 | 428 | } |
429 | 429 | |
430 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
430 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
431 | 431 | die('You can\'t impersonate - too low level'); // TODO: Log it |
432 | 432 | } |
433 | 433 | |
434 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
434 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
435 | 435 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
436 | 436 | } |
437 | 437 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
440 | 440 | $account_to_impersonate = new Account(self::$main_provider->db); |
441 | 441 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
442 | - if(!$account_to_impersonate->is_exists) { |
|
442 | + if (!$account_to_impersonate->is_exists) { |
|
443 | 443 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
444 | 444 | } |
445 | 445 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | public function password_check($password_unsafe) { |
466 | 466 | $result = false; |
467 | 467 | |
468 | - if(empty($this->providers_authorised)) { |
|
468 | + if (empty($this->providers_authorised)) { |
|
469 | 469 | // TODO - такого быть не может! |
470 | 470 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
471 | 471 | } else { |
472 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
473 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
472 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
473 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
474 | 474 | $result = $result || $provider->password_check($password_unsafe); |
475 | 475 | } |
476 | 476 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
492 | 492 | global $lang; |
493 | 493 | |
494 | - if(empty($this->providers_authorised)) { |
|
494 | + if (empty($this->providers_authorised)) { |
|
495 | 495 | // TODO - такого быть не может! |
496 | 496 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
497 | 497 | return false; |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | $salt_unsafe = self::password_salt_generate(); |
505 | 505 | |
506 | 506 | $providers_changed_password = array(); |
507 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
508 | - if( |
|
507 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
508 | + if ( |
|
509 | 509 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
510 | 510 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
511 | 511 | ) { |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
518 | 518 | |
519 | 519 | // Рассылаем уведомления о смене пароля в ЛС |
520 | - foreach($account_translation as $user_id => $provider_info) { |
|
520 | + foreach ($account_translation as $user_id => $provider_info) { |
|
521 | 521 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
522 | 522 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
523 | 523 | $lang['sys_administration'], $lang['sys_login_register_message_title'], |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | sn_db_transaction_start(); |
565 | 565 | // Проверить наличие такого имени в истории имён |
566 | 566 | |
567 | - if(db_player_name_exists($player_name_unsafe)) { |
|
567 | + if (db_player_name_exists($player_name_unsafe)) { |
|
568 | 568 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
569 | 569 | } |
570 | 570 | |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | $player_language = ''; |
573 | 573 | $player_email = ''; |
574 | 574 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
575 | - foreach($this->providers_authorised as $provider) { |
|
576 | - if(!$player_language && $provider->account->account_language) { |
|
575 | + foreach ($this->providers_authorised as $provider) { |
|
576 | + if (!$player_language && $provider->account->account_language) { |
|
577 | 577 | $player_language = $provider->account->account_language; |
578 | 578 | } |
579 | - if(!$player_email && $provider->account->account_email) { |
|
579 | + if (!$player_email && $provider->account->account_email) { |
|
580 | 580 | $player_email = $provider->account->account_email; |
581 | 581 | } |
582 | 582 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | )); |
593 | 593 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
594 | 594 | $a_user = self::$user; |
595 | - foreach($this->providers_authorised as $provider) { |
|
595 | + foreach ($this->providers_authorised as $provider) { |
|
596 | 596 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
597 | 597 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
598 | 598 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | |
605 | 605 | sn_db_transaction_commit(); |
606 | 606 | $this->register_status = LOGIN_SUCCESS; |
607 | - } catch(Exception $e) { |
|
607 | + } catch (Exception $e) { |
|
608 | 608 | sn_db_transaction_rollback(); |
609 | 609 | |
610 | 610 | // Если старое имя занято |
@@ -623,10 +623,10 @@ discard block |
||
623 | 623 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
624 | 624 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
625 | 625 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
626 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
626 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
627 | 627 | $user = db_user_by_id($user_id); |
628 | 628 | // Если записи игрока в БД не существует? |
629 | - if(empty($user['id'])) { |
|
629 | + if (empty($user['id'])) { |
|
630 | 630 | // Удаляем этого и переходим к следующему |
631 | 631 | unset($this->user_id_to_provider[$user_id]); |
632 | 632 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | // OK v4.5 |
648 | 648 | protected function get_active_user() { |
649 | 649 | // Проверяем куку "текущего игрока" из браузера |
650 | - if( |
|
650 | + if ( |
|
651 | 651 | // Кука не пустая |
652 | 652 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
653 | 653 | // И в куке находится ID |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | } |
673 | 673 | |
674 | 674 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
675 | - if(empty(self::$user['id'])) { |
|
675 | + if (empty(self::$user['id'])) { |
|
676 | 676 | // Берем первого из доступных |
677 | 677 | // TODO - default_user |
678 | 678 | self::$user = reset($this->accessible_user_row_list); |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | |
697 | 697 | $result = array(); |
698 | 698 | |
699 | - if($user_id && empty($this->is_impersonating)) { |
|
699 | + if ($user_id && empty($this->is_impersonating)) { |
|
700 | 700 | // self::db_counter_insert(); |
701 | 701 | self::$device->db_counter_insert($user_id); |
702 | 702 | |
@@ -704,12 +704,12 @@ discard block |
||
704 | 704 | |
705 | 705 | sys_user_options_unpack($user); |
706 | 706 | |
707 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
707 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
708 | 708 | $user['banaday'] = 0; |
709 | 709 | $user['vacation'] = SN_TIME_NOW; |
710 | 710 | } |
711 | 711 | |
712 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
712 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
713 | 713 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
714 | 714 | |
715 | 715 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -723,13 +723,13 @@ discard block |
||
723 | 723 | ); |
724 | 724 | } |
725 | 725 | |
726 | - if($extra = $config->security_ban_extra) { |
|
726 | + if ($extra = $config->security_ban_extra) { |
|
727 | 727 | $extra = explode(',', $extra); |
728 | - array_walk($extra,'trim'); |
|
728 | + array_walk($extra, 'trim'); |
|
729 | 729 | in_array(self::$device->device_id, $extra) and die(); |
730 | 730 | } |
731 | 731 | |
732 | - if(self::$login_message) { |
|
732 | + if (self::$login_message) { |
|
733 | 733 | $result[F_LOGIN_MESSAGE] = self::$login_message; |
734 | 734 | } |
735 | 735 | |
@@ -765,21 +765,21 @@ discard block |
||
765 | 765 | protected function register_player_name_validate($player_name_unsafe) { |
766 | 766 | // TODO - переделать под RAW-строки |
767 | 767 | // Если имя игрока пустое - NO GO! |
768 | - if(trim($player_name_unsafe) == '') { |
|
768 | + if (trim($player_name_unsafe) == '') { |
|
769 | 769 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
770 | 770 | } |
771 | 771 | // Проверяем, что бы в начале и конце не было пустых символов |
772 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
772 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
773 | 773 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
774 | 774 | } |
775 | 775 | // Если логин имеет запрещенные символы - NO GO! |
776 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
776 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
777 | 777 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
778 | 778 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
779 | 779 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
780 | 780 | } |
781 | 781 | // Если логин меньше минимальной длины - NO GO! |
782 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
782 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
783 | 783 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
784 | 784 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
785 | 785 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | } |
838 | 838 | |
839 | 839 | protected static function flog($message, $die = false) { |
840 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
840 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
841 | 841 | return; |
842 | 842 | } |
843 | 843 | list($called, $caller) = debug_backtrace(false); |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
851 | 851 | |
852 | 852 | SN::log_file("$message - $caller_name"); |
853 | - if($die) { |
|
853 | + if ($die) { |
|
854 | 854 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
855 | 855 | } |
856 | 856 | } |
@@ -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 | } else { |
109 | 109 | return parent::update(); |
@@ -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) || empty($resourceCount)) { |
|
188 | + if (!array_key_exists($resourceId, $this->resources) || empty($resourceCount)) { |
|
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 |