@@ -3,7 +3,7 @@ |
||
3 | 3 | // ---------------------------------------------------------------------------------------------------------------- |
4 | 4 | function lng_try_filepath($path, $file_path_relative) |
5 | 5 | { |
6 | - $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
|
6 | + $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative; |
|
7 | 7 | return file_exists($file_path) ? $file_path : false; |
8 | 8 | } |
9 | 9 |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | ), |
23 | 23 | ); |
24 | 24 | |
25 | - foreach($queries as &$query) { |
|
26 | - if(!empty($query['query'])) { |
|
25 | + foreach ($queries as &$query) { |
|
26 | + if (!empty($query['query'])) { |
|
27 | 27 | $query['result'] = doquery($query['query']); |
28 | - } elseif(!empty($query['callable']) && is_callable($query['callable'])) { |
|
28 | + } elseif (!empty($query['callable']) && is_callable($query['callable'])) { |
|
29 | 29 | call_user_func($query['callable']); |
30 | 30 | } |
31 | 31 | $query['error'] = classSupernova::$db->db_error(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
70 | 70 | // pdump($prev_run_array); |
71 | 71 | $scheduleList = explode(',', $scheduleList); |
72 | - array_walk($scheduleList, function (&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
|
72 | + array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
|
73 | 73 | // pdump($schedule); |
74 | 74 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
75 | 75 | |
@@ -81,21 +81,21 @@ discard block |
||
81 | 81 | */ |
82 | 82 | // pdump($schedule); |
83 | 83 | |
84 | - foreach($prev_run_array as $index => $date_part) { |
|
84 | + foreach ($prev_run_array as $index => $date_part) { |
|
85 | 85 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
86 | 86 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
87 | 87 | } |
88 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
88 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
89 | 89 | unset($schedule['array']['now']); |
90 | 90 | } |
91 | 91 | |
92 | - foreach($schedule['array'] as $name => $array) { |
|
92 | + foreach ($schedule['array'] as $name => $array) { |
|
93 | 93 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
94 | - $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
|
95 | - $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
|
94 | + $schedule['string'][$name.'_next'] = $schedule['string'][$name].' +1 '.$interval; |
|
95 | + $schedule['string'][$name.'_prev'] = $schedule['string'][$name].' -1 '.$interval; |
|
96 | 96 | } |
97 | 97 | |
98 | - foreach($schedule['string'] as $string) { |
|
98 | + foreach ($schedule['string'] as $string) { |
|
99 | 99 | $timestamp = strtotime($string); |
100 | 100 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
101 | 101 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | $prev_run = 0; |
129 | 129 | $next_run = 0; |
130 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
130 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
131 | 131 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
132 | 132 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
133 | 133 | // pdump($schedule, '$schedule ' . date(FMT_DATE_TIME_SQL, $schedule)); |
@@ -107,23 +107,23 @@ |
||
107 | 107 | |
108 | 108 | !empty(classSupernova::$config->url_faq) ? $msg = str_replace('faq://', classSupernova::$config->url_faq, $msg) : false; |
109 | 109 | |
110 | - foreach($supernova->design['bbcodes'] as $auth_level => $replaces) { |
|
111 | - if($auth_level > $author_auth) { |
|
110 | + foreach ($supernova->design['bbcodes'] as $auth_level => $replaces) { |
|
111 | + if ($auth_level > $author_auth) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | - foreach($replaces as $key => $html) { |
|
115 | + foreach ($replaces as $key => $html) { |
|
116 | 116 | $msg = preg_replace(''.$key.'', $html, $msg); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - foreach($supernova->design['smiles'] as $auth_level => $replaces) { |
|
121 | - if($auth_level > $author_auth) { |
|
120 | + foreach ($supernova->design['smiles'] as $auth_level => $replaces) { |
|
121 | + if ($auth_level > $author_auth) { |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | - foreach($replaces as $key => $imgName) { |
|
126 | - $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU","<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">",$msg); |
|
125 | + foreach ($replaces as $key => $imgName) { |
|
126 | + $msg = preg_replace("#".addcslashes($key, '()[]{}')."#isU", "<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">", $msg); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update')); |
10 | 10 | $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update); |
11 | 11 | |
12 | - if(sys_get_param_int('admin_update')) { |
|
12 | + if (sys_get_param_int('admin_update')) { |
|
13 | 13 | define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1); |
14 | - if(USER_LEVEL > 0) { |
|
14 | + if (USER_LEVEL > 0) { |
|
15 | 15 | $is_admin_request = true; |
16 | 16 | $ts_scheduled_update = SN_TIME_NOW; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - if($ts_scheduled_update > $ts_var_stat_update) { |
|
20 | + if ($ts_scheduled_update > $ts_var_stat_update) { |
|
21 | 21 | lng_include('admin'); |
22 | 22 | sn_db_transaction_start(); |
23 | 23 | $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')); |
24 | - if(SN_TIME_NOW > $ts_var_stat_update_end) { |
|
24 | + if (SN_TIME_NOW > $ts_var_stat_update_end) { |
|
25 | 25 | $old_server_status = classSupernova::$config->db_loadItem('game_disable'); |
26 | 26 | classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT); |
27 | 27 | |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | |
32 | 32 | $msg = $is_admin_request ? 'admin request' : 'scheduler'; |
33 | 33 | $next_run = date(FMT_DATE_TIME_SQL, sys_schedule_get_prev_run(classSupernova::$config->stats_schedule, classSupernova::$config->var_stat_update, true)); |
34 | - $msg = "Running stat updates: {$msg}. Config->var_stat_update = " . classSupernova::$config->var_stat_update . |
|
35 | - ', $ts_scheduled_update = ' . date(FMT_DATE_TIME_SQL, $ts_scheduled_update) . |
|
36 | - ', next_stat_update = ' . $next_run; |
|
34 | + $msg = "Running stat updates: {$msg}. Config->var_stat_update = ".classSupernova::$config->var_stat_update. |
|
35 | + ', $ts_scheduled_update = '.date(FMT_DATE_TIME_SQL, $ts_scheduled_update). |
|
36 | + ', next_stat_update = '.$next_run; |
|
37 | 37 | classSupernova::$debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
38 | 38 | $total_time = microtime(true); |
39 | 39 | |
40 | 40 | // require_once('../includes/sys_stat.php'); |
41 | - require_once(SN_ROOT_PHYSICAL . 'includes/includes/sys_stat.php'); |
|
41 | + require_once(SN_ROOT_PHYSICAL.'includes/includes/sys_stat.php'); |
|
42 | 42 | sys_stat_calculate(); |
43 | 43 | |
44 | 44 | $total_time = microtime(true) - $total_time; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL); |
58 | 58 | |
59 | 59 | classSupernova::$config->db_saveItem('game_disable', $old_server_status); |
60 | - } elseif($ts_scheduled_update > $ts_var_stat_update) { |
|
60 | + } elseif ($ts_scheduled_update > $ts_var_stat_update) { |
|
61 | 61 | $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW; |
62 | 62 | $msg = classSupernova::$config->db_loadItem('var_stat_update_msg'); |
63 | 63 | $msg = "{$msg} ETA {$timeout} seconds. Please wait..."; |
64 | 64 | } |
65 | 65 | sn_db_transaction_rollback(); |
66 | - } elseif($is_admin_request) { |
|
66 | + } elseif ($is_admin_request) { |
|
67 | 67 | $msg = 'Stat is up to date'; |
68 | 68 | } |
69 | 69 |
@@ -11,38 +11,38 @@ discard block |
||
11 | 11 | |
12 | 12 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
13 | 13 | |
14 | - if($in_admin) { |
|
14 | + if ($in_admin) { |
|
15 | 15 | $quest_id = sys_get_param_id('id'); |
16 | 16 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
17 | - if(!empty($quest_name)) { |
|
17 | + if (!empty($quest_name)) { |
|
18 | 18 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
19 | 19 | try { |
20 | 20 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
21 | 21 | $quest_rewards = array(); |
22 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
22 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
24 | 24 | throw new Exception(classLocale::$lang['qst_adm_err_reward_type']); |
25 | 25 | } |
26 | 26 | |
27 | - if($quest_rewards_amount < 0) { |
|
27 | + if ($quest_rewards_amount < 0) { |
|
28 | 28 | throw new Exception(classLocale::$lang['qst_adm_err_reward_amount']); |
29 | - } elseif($quest_rewards_amount > 0) { |
|
29 | + } elseif ($quest_rewards_amount > 0) { |
|
30 | 30 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
31 | 31 | } |
32 | 32 | } |
33 | - if(empty($quest_rewards)) { |
|
33 | + if (empty($quest_rewards)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['qst_adm_err_reward_empty']); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $quest_rewards = implode(';', $quest_rewards); |
38 | 38 | |
39 | 39 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
40 | - if(!in_array($quest_unit_id, $quest_units_allowed)) { |
|
40 | + if (!in_array($quest_unit_id, $quest_units_allowed)) { |
|
41 | 41 | throw new Exception(classLocale::$lang['qst_adm_err_unit_id']); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
45 | - if($quest_unit_amount <= 0) { |
|
45 | + if ($quest_unit_amount <= 0) { |
|
46 | 46 | throw new Exception(classLocale::$lang['qst_adm_err_unit_amount']); |
47 | 47 | } |
48 | 48 | $quest_conditions = "{$quest_unit_id},{$quest_unit_amount}"; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // TODO: Change quest type |
51 | 51 | $quest_type = 0; |
52 | 52 | |
53 | - if($mode == 'edit') { |
|
53 | + if ($mode == 'edit') { |
|
54 | 54 | $quest_name = db_escape($quest_name); |
55 | 55 | $quest_description = db_escape($quest_description); |
56 | 56 | db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | // TODO: Add mass mail for new quests |
68 | - } catch(Exception $e) { |
|
68 | + } catch (Exception $e) { |
|
69 | 69 | message($e->getMessage(), classLocale::$lang['sys_error']); |
70 | 70 | } |
71 | 71 | |
72 | 72 | $mode = ''; |
73 | 73 | }; |
74 | 74 | |
75 | - switch($mode) { |
|
75 | + switch ($mode) { |
|
76 | 76 | case 'del': |
77 | 77 | db_quest_delete($quest_id); |
78 | 78 | $mode = ''; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | $query = db_quest_count(); |
89 | 89 | classSupernova::$config->db_saveItem('quest_total', $query['count']); |
90 | - } elseif(!$user_id) { |
|
90 | + } elseif (!$user_id) { |
|
91 | 91 | $user_id = $user['id']; |
92 | 92 | } |
93 | 93 | |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | 'IN_ADMIN' => $in_admin, |
101 | 101 | )); |
102 | 102 | |
103 | - if($quest) { |
|
103 | + if ($quest) { |
|
104 | 104 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
105 | 105 | } else { |
106 | 106 | $quest_templatized['quest_rewards_list'] = array(); |
107 | 107 | } |
108 | 108 | |
109 | - foreach($quest_reward_allowed as $unit_id) { |
|
109 | + foreach ($quest_reward_allowed as $unit_id) { |
|
110 | 110 | $found = false; |
111 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | - if($quest_templatized_reward['ID'] == $unit_id) { |
|
111 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | + if ($quest_templatized_reward['ID'] == $unit_id) { |
|
113 | 113 | $found = true; |
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if(!$found) { |
|
118 | + if (!$found) { |
|
119 | 119 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
120 | 120 | 'ID' => $unit_id, |
121 | 121 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | qst_assign_to_template($template, $quest_templatized); |
128 | 128 | |
129 | - foreach($quest_list as $quest_data) { |
|
129 | + foreach ($quest_list as $quest_data) { |
|
130 | 130 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($quest_units_allowed as $unit_id) { |
|
133 | + foreach ($quest_units_allowed as $unit_id) { |
|
134 | 134 | $template->assign_block_vars('allowed_unit', array( |
135 | 135 | 'ID' => $unit_id, |
136 | 136 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | function qst_get_quests($user_id = false, $status = false) { |
142 | 142 | $quest_list = array(); |
143 | 143 | |
144 | - if($user_id) { |
|
145 | - if($status !== false) { |
|
144 | + if ($user_id) { |
|
145 | + if ($status !== false) { |
|
146 | 146 | $query_add_where = "AND qs.quest_status_status "; |
147 | - if($status == null) { |
|
147 | + if ($status == null) { |
|
148 | 148 | $query_add_where .= "IS NULL"; |
149 | 149 | } else { |
150 | 150 | $query_add_where .= "= {$status}"; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $query = db_quest_list_get($query_add_select, $query_add_from, $query_add_where); |
158 | 158 | |
159 | - while($quest = db_fetch($query)) { |
|
159 | + while ($quest = db_fetch($query)) { |
|
160 | 160 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
161 | 161 | } |
162 | 162 | |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) { |
167 | - if($block_name) { |
|
167 | + if ($block_name) { |
|
168 | 168 | $template->assign_block_vars($block_name, $quest_templatized); |
169 | 169 | } else { |
170 | 170 | $template->assign_vars($quest_templatized); |
171 | - if(!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
173 | - $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
|
171 | + if (!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
173 | + $template->assign_block_vars(($block_name ? $block_name.'.' : '').'quest_rewards_list', $quest_reward); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | function qst_templatize($quest, $for_display = true) { |
188 | 188 | $tmp = array(); |
189 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
189 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
190 | 190 | $tmp[] = array( |
191 | 191 | 'ID' => $quest_reward_id, |
192 | 192 | 'NAME' => $for_display ? str_replace(' ', ' ', classLocale::$lang['tech'][$quest_reward_id]) : classLocale::$lang['tech'][$quest_reward_id], |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | |
212 | 212 | function qst_active_triggers($quest_list) { |
213 | 213 | $quest_triggers = array(); |
214 | - foreach($quest_list as $quest_id => $quest) { |
|
215 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
214 | + foreach ($quest_list as $quest_id => $quest) { |
|
215 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
216 | 216 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
217 | 217 | $quest_triggers[$quest_id] = $quest_unit_id; |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | function qst_reward(&$user, &$rewards, &$quest_list) { |
225 | - if(empty($rewards)) { |
|
225 | + if (empty($rewards)) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | $total_rewards = array(); |
233 | 233 | $comment_dm = ''; |
234 | 234 | |
235 | - foreach($rewards as $quest_id => $user_data) { |
|
236 | - foreach($user_data as $user_id => $planet_data) { |
|
237 | - foreach($planet_data as $planet_id => $reward_list) { |
|
235 | + foreach ($rewards as $quest_id => $user_data) { |
|
236 | + foreach ($user_data as $user_id => $planet_data) { |
|
237 | + foreach ($planet_data as $planet_id => $reward_list) { |
|
238 | 238 | $comment = sprintf(classLocale::$lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
239 | 239 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
240 | 240 | |
241 | 241 | $comment_reward = array(); |
242 | - foreach($reward_list as $unit_id => $unit_amount) { |
|
243 | - $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
|
242 | + foreach ($reward_list as $unit_id => $unit_amount) { |
|
243 | + $comment_reward[] = $unit_amount.' '.classLocale::$lang['tech'][$unit_id]; |
|
244 | 244 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
245 | 245 | } |
246 | - $comment .= " {$classLocale['qst_msg_your_reward']} " . implode(',', $comment_reward); |
|
246 | + $comment .= " {$classLocale['qst_msg_your_reward']} ".implode(',', $comment_reward); |
|
247 | 247 | |
248 | 248 | msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['msg_from_admin'], classLocale::$lang['qst_msg_complete_subject'], $comment); |
249 | 249 | |
@@ -258,19 +258,19 @@ discard block |
||
258 | 258 | |
259 | 259 | $group_resources = sn_get_groups('resources_loot'); |
260 | 260 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
261 | - if(!empty($total_rewards)) { |
|
262 | - foreach($total_rewards as $user_id => $planet_data) { |
|
261 | + if (!empty($total_rewards)) { |
|
262 | + foreach ($total_rewards as $user_id => $planet_data) { |
|
263 | 263 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
264 | - foreach($planet_data as $planet_id => $unit_data) { |
|
264 | + foreach ($planet_data as $planet_id => $unit_data) { |
|
265 | 265 | $local_changeset = array(); |
266 | - foreach($unit_data as $unit_id => $unit_amount) { |
|
267 | - if(!isset($quest_rewards_allowed[$unit_id])) { |
|
266 | + foreach ($unit_data as $unit_id => $unit_amount) { |
|
267 | + if (!isset($quest_rewards_allowed[$unit_id])) { |
|
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | |
271 | - if($unit_id == RES_DARK_MATTER) { |
|
271 | + if ($unit_id == RES_DARK_MATTER) { |
|
272 | 272 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
273 | - } elseif(isset($group_resources[$unit_id])) { |
|
273 | + } elseif (isset($group_resources[$unit_id])) { |
|
274 | 274 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
275 | 275 | } else // Проверим на юниты |
276 | 276 | { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // unit |
280 | 280 | } |
281 | 281 | |
282 | - if(!empty($local_changeset)) { |
|
282 | + if (!empty($local_changeset)) { |
|
283 | 283 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
284 | 284 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
285 | 285 | 'action' => SQL_OP_UPDATE, |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function debris_add_resource($resource_id, $resource_amount) { |
32 | 32 | // В обломках может быть только металл или кристалл |
33 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
33 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | $this->debris[$resource_id] += $resource_amount; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param bool $is_simulator |
42 | 42 | */ |
43 | 43 | public function add_wrecks(array $wreckage, $is_simulator) { |
44 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
44 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
45 | 45 | $this->debris_add_resource($resource_id, floor($resource_amount * |
46 | 46 | ($is_simulator |
47 | 47 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param bool $is_simulator |
58 | 58 | */ |
59 | 59 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
60 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
60 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
61 | 61 | $this->debris_add_resource($resource_id, floor($resource_amount * |
62 | 62 | ($is_simulator |
63 | 63 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param $moon_debris_left_part |
97 | 97 | */ |
98 | 98 | public function debris_adjust_proportional($moon_debris_left_part) { |
99 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
99 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
100 | 100 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
101 | 101 | } |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function report_generate_sql() { |
119 | 119 | return " |
120 | - `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ", |
|
121 | - `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ", |
|
122 | - `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal() . ", "; |
|
120 | + `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL).", |
|
121 | + `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL).", |
|
122 | + `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal().", "; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $debris_for_moon = $debris->debris_total(); |
72 | 72 | |
73 | - if(!$debris_for_moon) { |
|
73 | + if (!$debris_for_moon) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
80 | 80 | $this->create_chance = $moon_chance; |
81 | - if($moon_chance) { |
|
82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
81 | + if ($moon_chance) { |
|
82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
85 | 85 | |
86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
87 | 87 | $debris->_reset(); |
88 | 88 | } else { |
89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function moon_destroy_try($reapers) { |
104 | 104 | // TODO: $is_simulator |
105 | - if($reapers <= 0) { |
|
105 | + if ($reapers <= 0) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
121 | 121 | */ |
122 | 122 | public function calculate_moon(UBE $ube) { |
123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
126 | 126 | $this->moon_destroy_try($reapers); |
127 | 127 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | public function report_generate_sql() { |
134 | - return "`ube_report_moon` = " . (int)$this->status . ", |
|
135 | - `ube_report_moon_chance` = " . (int)$this->create_chance . ", |
|
136 | - `ube_report_moon_size` = " . (float)$this->moon_diameter . ", |
|
137 | - `ube_report_moon_reapers` = " . (int)$this->reapers_status . ", |
|
138 | - `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ", |
|
139 | - `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance; |
|
134 | + return "`ube_report_moon` = ".(int) $this->status.", |
|
135 | + `ube_report_moon_chance` = " . (int) $this->create_chance.", |
|
136 | + `ube_report_moon_size` = " . (float) $this->moon_diameter.", |
|
137 | + `ube_report_moon_reapers` = " . (int) $this->reapers_status.", |
|
138 | + `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance.", |
|
139 | + `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function report_render_moon() { |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | * @param $planet_id |
167 | 167 | */ |
168 | 168 | public function db_apply_result($planet_info, $destination_user_id) { |
169 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
169 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
170 | 170 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
171 | 171 | $this->moon_name = $moon_row['name']; |
172 | 172 | unset($moon_row); |
173 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
173 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
174 | 174 | db_planet_delete_by_id($planet_info[PLANET_ID]); |
175 | 175 | } |
176 | 176 | } |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | $classLocale = classLocale::$lang; |
180 | 180 | |
181 | 181 | $text_defender = ''; |
182 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
182 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
183 | 183 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
184 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
184 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
185 | 185 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
186 | 186 | } |
187 | 187 | |
188 | - if($ube->mission_type_id == MT_DESTROY) { |
|
189 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
188 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
189 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
190 | 190 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
191 | 191 | } else { |
192 | 192 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
193 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
193 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
194 | 194 | |
195 | 195 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
196 | 196 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @version 2016-02-25 23:42:45 41a4.68 |
216 | 216 | */ |
217 | 217 | public function ubeInitLoadStatis($destination_planet) { |
218 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
218 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
219 | 219 | $this->status = UBE_MOON_EXISTS; |
220 | 220 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
221 | 221 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @version 41a6.49 |
12 | 12 | */ |
13 | 13 | public static function unit_dump_header() { |
14 | - if(!defined('DEBUG_UBE')) { |
|
14 | + if (!defined('DEBUG_UBE')) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @version 41a6.49 |
49 | 49 | */ |
50 | 50 | public static function unit_dump(UBEUnit $unit, $desc = '', UBEUnit $before = null) { |
51 | - if(!defined('DEBUG_UBE')) { |
|
51 | + if (!defined('DEBUG_UBE')) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | // print("<td>" . $this->units_lost . "</td>"); |
76 | 76 | // print("<td>" . $this->units_restored . "</td>"); |
77 | 77 | // print("<td>" . $this->capacity . "</td>"); |
78 | - print("<td>" . round($unit->share_of_side_armor, 4) . "</td>"); |
|
78 | + print("<td>".round($unit->share_of_side_armor, 4)."</td>"); |
|
79 | 79 | print('</tr>'); |
80 | 80 | } |
81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @version 41a6.49 |
87 | 87 | */ |
88 | 88 | public static function unit_dump_footer() { |
89 | - if(!defined('DEBUG_UBE')) { |
|
89 | + if (!defined('DEBUG_UBE')) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @return UBEUnit |
102 | 102 | */ |
103 | 103 | public static function unit_dump_defender(UBEUnit $attacking_unit_pool, UBEUnit $defending_unit_pool, $defending_fleet_id) { |
104 | - if(!defined('DEBUG_UBE')) { |
|
104 | + if (!defined('DEBUG_UBE')) { |
|
105 | 105 | return null; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $classLocale = classLocale::$lang; |
109 | 109 | |
110 | - print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}" . |
|
111 | - ' attacks ' . |
|
112 | - $defending_fleet_id . '@' . "[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}" . |
|
113 | - ' with ' . pretty_number($defending_unit_pool->attack_income) . |
|
110 | + print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}". |
|
111 | + ' attacks '. |
|
112 | + $defending_fleet_id.'@'."[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}". |
|
113 | + ' with '.pretty_number($defending_unit_pool->attack_income). |
|
114 | 114 | '<br>' |
115 | 115 | ); |
116 | 116 | $before = clone $defending_unit_pool; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @version 41a6.49 |
128 | 128 | */ |
129 | 129 | public static function unit_dump_delta(UBEUnit $unit, $field, UBEUnit $before = null) { |
130 | - if(!defined('DEBUG_UBE')) { |
|
130 | + if (!defined('DEBUG_UBE')) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | print(pretty_number($unit->$field)); |
137 | 137 | print("</td>"); |
138 | 138 | print("<td>"); |
139 | - if(!empty($before)) { |
|
140 | - print('' . pretty_number($unit->$field - $before->$field) . ''); |
|
139 | + if (!empty($before)) { |
|
140 | + print(''.pretty_number($unit->$field - $before->$field).''); |
|
141 | 141 | } |
142 | 142 | print("</td>"); |
143 | 143 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function offsetSet($offset, $value) { |
91 | 91 | if (isset($this->mapUnitIdToDb[$value->unitId])) { |
92 | - classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists'); |
|
92 | + classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId '.$value->unitId.' already exists'); |
|
93 | 93 | } |
94 | 94 | $this->mapUnitIdToDb[$value->unitId] = $value; |
95 | 95 | parent::offsetSet($offset, $value); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | public function unitGetCount($unit_id) { |
204 | 204 | if (empty($this->mapUnitIdToDb[$unit_id])) { |
205 | - throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList'); |
|
205 | + throw new Exception('Unit ['.$unit_id.'] is not exists in UnitList'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return $this->mapUnitIdToDb[$unit_id]->count; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | $objFleet = $this->getLocatedAt(); |
323 | 323 | if (empty($objFleet)) { |
324 | - throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__); |
|
324 | + throw new Exception('No fleet owner on UnitList::unitsRender() in '.__FILE__.'@'.__LINE__); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | $tplShips = array(); |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | |
465 | 465 | // TODO - DEBUG - REMOVE ============================================================================================= |
466 | 466 | public function _dump() { |
467 | - print(__FILE__ . ':' . __LINE__ . "<br />"); |
|
468 | - print("Located at " . $this->getLocationDbId() . " type " . $this->getLocationType() . "<br />"); |
|
467 | + print(__FILE__.':'.__LINE__."<br />"); |
|
468 | + print("Located at ".$this->getLocationDbId()." type ".$this->getLocationType()."<br />"); |
|
469 | 469 | |
470 | 470 | print('<table border="1">'); |
471 | 471 | print('<tr>'); |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | |
522 | 522 | print('<td>'); |
523 | 523 | $type = $unit->getType(); |
524 | - print("[{$type}] " . classLocale::$lang['tech'][$type]); |
|
524 | + print("[{$type}] ".classLocale::$lang['tech'][$type]); |
|
525 | 525 | print('</td>'); |
526 | 526 | |
527 | 527 | print('<td>'); |
528 | - print("[{$unit->unitId}] " . classLocale::$lang['tech'][$unit->unitId]); |
|
528 | + print("[{$unit->unitId}] ".classLocale::$lang['tech'][$unit->unitId]); |
|
529 | 529 | print('</td>'); |
530 | 530 | |
531 | 531 | print('<td>'); |