@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | // $same_user = false; |
48 | 48 | // } |
49 | 49 | |
50 | - if(!$user_data) { |
|
50 | + if (!$user_data) { |
|
51 | 51 | messageBox($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
52 | 52 | die(); |
53 | 53 | } |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | $stat_array = array(); |
59 | 59 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
60 | 60 | $stat_count = SN::$db->db_affected_rows(); |
61 | - while($row = db_fetch($query)) { |
|
62 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
61 | + while ($row = db_fetch($query)) { |
|
62 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
63 | 63 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
64 | 64 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
65 | 65 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $stat_array_date = $stat_array['STAT_DATE']; |
69 | 69 | empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false; |
70 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
70 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
71 | 71 | $template->assign_block_vars('stat_date', array( |
72 | 72 | 'ID' => $key, |
73 | 73 | 'VALUE' => $value, |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | |
78 | 78 | unset($stat_array['STAT_DATE']); |
79 | 79 | $template_data = array(); |
80 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
80 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
81 | 81 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
82 | 82 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
83 | 83 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
84 | 84 | $stat_type_data['AVG'] = avg($stat_type_data['DATA']); |
85 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
85 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
86 | 86 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
87 | 87 | $template_data[$stat_type][$key]['ID'] = $key; |
88 | 88 | $template_data[$stat_type][$key]['VALUE'] = $value; |
89 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
89 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
90 | 90 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
94 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
95 | 95 | $template->assign_block_vars('stat', array( |
96 | 96 | 'TYPE' => $stat_type, |
97 | 97 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | 'MAX' => $stat_array[$stat_type]['MAX'], |
100 | 100 | 'AVG' => $stat_array[$stat_type]['AVG'], |
101 | 101 | )); |
102 | - foreach($stat_type_data as $stat_entry) { |
|
102 | + foreach ($stat_type_data as $stat_entry) { |
|
103 | 103 | $template->assign_block_vars('stat.entry', $stat_entry); |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | - if($same_user) { |
|
108 | + if ($same_user) { |
|
109 | 109 | rpg_level_up($user, RPG_STRUCTURE); |
110 | 110 | rpg_level_up($user, RPG_RAID); |
111 | 111 | rpg_level_up($user, RPG_TECH); |
@@ -142,29 +142,29 @@ discard block |
||
142 | 142 | 'builder_xp' => HelperString::numberFloorAndFormat($user_data['xpminier']), |
143 | 143 | 'builder_lvl' => HelperString::numberFloorAndFormat($user_data['lvl_minier']), |
144 | 144 | 'builder_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'])), |
145 | - 'builder_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
145 | + 'builder_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
146 | 146 | 'raid_xp' => HelperString::numberFloorAndFormat($user_data['xpraid']), |
147 | 147 | 'raid_lvl' => HelperString::numberFloorAndFormat($user_data['lvl_raid']), |
148 | - 'raid_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
148 | + 'raid_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
149 | 149 | 'raids' => HelperString::numberFloorAndFormat($user_data['raids']), |
150 | 150 | 'raidswin' => HelperString::numberFloorAndFormat($user_data['raidswin']), |
151 | 151 | 'raidsloose' => HelperString::numberFloorAndFormat($user_data['raidsloose']), |
152 | 152 | 'tech_xp' => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_xp']), |
153 | 153 | 'tech_lvl' => HelperString::numberFloorAndFormat($user_data['player_rpg_tech_level']), |
154 | 154 | 'tech_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
155 | - 'tech_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
155 | + 'tech_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
156 | 156 | |
157 | 157 | 'explore_xp' => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_xp']), |
158 | 158 | 'explore_lvl' => HelperString::numberFloorAndFormat($user_data['player_rpg_explore_level']), |
159 | 159 | 'explore_lvl_st' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
160 | - 'explore_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
161 | - |
|
162 | - 'build_points' => HelperString::numberFloorAndFormat( $StatRecord['build_points'] ), |
|
163 | - 'tech_points' => HelperString::numberFloorAndFormat( $StatRecord['tech_points'] ), |
|
164 | - 'fleet_points' => HelperString::numberFloorAndFormat( $StatRecord['fleet_points'] ), |
|
165 | - 'defs_points' => HelperString::numberFloorAndFormat( $StatRecord['defs_points'] ), |
|
166 | - 'res_points' => HelperString::numberFloorAndFormat( $StatRecord['res_points'] ), |
|
167 | - 'total_points' => HelperString::numberFloorAndFormat( $StatRecord['total_points'] ), |
|
160 | + 'explore_lvl_up' => HelperString::numberFloorAndFormat(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
161 | + |
|
162 | + 'build_points' => HelperString::numberFloorAndFormat($StatRecord['build_points']), |
|
163 | + 'tech_points' => HelperString::numberFloorAndFormat($StatRecord['tech_points']), |
|
164 | + 'fleet_points' => HelperString::numberFloorAndFormat($StatRecord['fleet_points']), |
|
165 | + 'defs_points' => HelperString::numberFloorAndFormat($StatRecord['defs_points']), |
|
166 | + 'res_points' => HelperString::numberFloorAndFormat($StatRecord['res_points']), |
|
167 | + 'total_points' => HelperString::numberFloorAndFormat($StatRecord['total_points']), |
|
168 | 168 | 'user_rank' => $StatRecord['total_rank'], |
169 | 169 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
170 | 170 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -104,47 +104,47 @@ discard block |
||
104 | 104 | } |
105 | 105 | function linear_calc(&$linear, $from = 0, $debug = false) |
106 | 106 | { |
107 | - for($i = $from; $i < count($linear); $i++) |
|
107 | + for ($i = $from; $i < count($linear); $i++) |
|
108 | 108 | { |
109 | 109 | $eq = &$linear[$i]; |
110 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
111 | 111 | { |
112 | 112 | $eq[$j] /= $eq[$from]; |
113 | 113 | } |
114 | 114 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
115 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
116 | 116 | |
117 | - for($i = $from + 1; $i < count($linear); $i++) |
|
117 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
118 | 118 | { |
119 | 119 | $eq = &$linear[$i]; |
120 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
121 | 121 | { |
122 | 122 | $eq[$j] -= $linear[$from][$j]; |
123 | 123 | } |
124 | 124 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
125 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
126 | 126 | |
127 | - if($from < count($linear) - 1) |
|
127 | + if ($from < count($linear) - 1) |
|
128 | 128 | { |
129 | 129 | linear_calc($linear, $from + 1, $debug); |
130 | 130 | } |
131 | 131 | |
132 | - if($from) |
|
132 | + if ($from) |
|
133 | 133 | { |
134 | - for($i = 0; $i < $from; $i++) |
|
134 | + for ($i = 0; $i < $from; $i++) |
|
135 | 135 | { |
136 | 136 | $eq = &$linear[$i]; |
137 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
138 | 138 | { |
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | 143 | } |
144 | 144 | else |
145 | 145 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | - foreach($linear as $index => &$eq) |
|
146 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
147 | + foreach ($linear as $index => &$eq) |
|
148 | 148 | { |
149 | 149 | pdump($eq[count($linear)], 'x' . $index); |
150 | 150 | } |
@@ -4,16 +4,14 @@ discard block |
||
4 | 4 | return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
5 | 5 | } |
6 | 6 | |
7 | -function sn_floor($value) |
|
8 | -{ |
|
7 | +function sn_floor($value) { |
|
9 | 8 | return $value >= 0 ? floor($value) : ceil($value); |
10 | 9 | } |
11 | 10 | |
12 | 11 | // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma |
13 | 12 | // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma |
14 | 13 | // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера |
15 | -function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) |
|
16 | -{ |
|
14 | +function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
|
17 | 15 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
18 | 16 | // При $mu = 0 (график симметричный, цифры только для половины графика) |
19 | 17 | // От 0 до $sigma ~ 34.1% |
@@ -43,7 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return float|int |
45 | 43 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
44 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | 45 | if($cut_extreme) { |
48 | 46 | $range_start--; |
49 | 47 | $range_end++; |
@@ -98,12 +96,10 @@ discard block |
||
98 | 96 | * |
99 | 97 | * @return float |
100 | 98 | */ |
101 | -function avg($array) |
|
102 | -{ |
|
99 | +function avg($array) { |
|
103 | 100 | return is_array($array) && count($array) ? array_sum($array) / count($array) : 0; |
104 | 101 | } |
105 | -function linear_calc(&$linear, $from = 0, $debug = false) |
|
106 | -{ |
|
102 | +function linear_calc(&$linear, $from = 0, $debug = false) { |
|
107 | 103 | for($i = $from; $i < count($linear); $i++) |
108 | 104 | { |
109 | 105 | $eq = &$linear[$i]; |
@@ -112,7 +108,9 @@ discard block |
||
112 | 108 | $eq[$j] /= $eq[$from]; |
113 | 109 | } |
114 | 110 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
111 | + if($debug) { |
|
112 | + pdump($linear, 'Нормализовано по х' . $from); |
|
113 | + } |
|
116 | 114 | |
117 | 115 | for($i = $from + 1; $i < count($linear); $i++) |
118 | 116 | { |
@@ -122,7 +120,9 @@ discard block |
||
122 | 120 | $eq[$j] -= $linear[$from][$j]; |
123 | 121 | } |
124 | 122 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
123 | + if($debug) { |
|
124 | + pdump($linear, 'Подставили х' . $from); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | if($from < count($linear) - 1) |
128 | 128 | { |
@@ -139,11 +139,14 @@ discard block |
||
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | - } |
|
144 | - else |
|
142 | + if($debug) { |
|
143 | + pdump($linear, 'Подставили обратно х' . $from); |
|
144 | + } |
|
145 | + } else |
|
145 | 146 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | + if($debug) { |
|
148 | + pdump($linear, 'Результат' . $from); |
|
149 | + } |
|
147 | 150 | foreach($linear as $index => &$eq) |
148 | 151 | { |
149 | 152 | pdump($eq[count($linear)], 'x' . $index); |