@@ -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 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function report_generate_array() { |
137 | 137 | return array( |
138 | - 'ube_report_moon' => (int)$this->status, |
|
139 | - 'ube_report_moon_chance' => (int)$this->create_chance, |
|
140 | - 'ube_report_moon_size' => (float)$this->moon_diameter, |
|
141 | - 'ube_report_moon_reapers' => (int)$this->reapers_status, |
|
142 | - 'ube_report_moon_destroy_chance' => (int)$this->destroy_chance, |
|
143 | - 'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance, |
|
138 | + 'ube_report_moon' => (int) $this->status, |
|
139 | + 'ube_report_moon_chance' => (int) $this->create_chance, |
|
140 | + 'ube_report_moon_size' => (float) $this->moon_diameter, |
|
141 | + 'ube_report_moon_reapers' => (int) $this->reapers_status, |
|
142 | + 'ube_report_moon_destroy_chance' => (int) $this->destroy_chance, |
|
143 | + 'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance, |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param $planet_id |
172 | 172 | */ |
173 | 173 | public function db_apply_result($planet_info, $destination_user_id) { |
174 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
174 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
175 | 175 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
176 | 176 | $this->moon_name = $moon_row['name']; |
177 | 177 | unset($moon_row); |
178 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
178 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
179 | 179 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
180 | 180 | } |
181 | 181 | } |
@@ -184,18 +184,18 @@ discard block |
||
184 | 184 | $classLocale = classLocale::$lang; |
185 | 185 | |
186 | 186 | $text_defender = ''; |
187 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
187 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
188 | 188 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
189 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
189 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
190 | 190 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
191 | 191 | } |
192 | 192 | |
193 | - if($ube->mission_type_id == MT_DESTROY) { |
|
194 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
193 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
194 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
195 | 195 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
196 | 196 | } else { |
197 | 197 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
198 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
198 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
199 | 199 | |
200 | 200 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
201 | 201 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @version 2016-02-25 23:42:45 41a4.68 |
221 | 221 | */ |
222 | 222 | public function ubeInitLoadStatis($destination_planet) { |
223 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
223 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
224 | 224 | $this->status = UBE_MOON_EXISTS; |
225 | 225 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
226 | 226 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function report_render_rounds(&$template_result, UBE $ube) { |
27 | 27 | $round_count = $this->count(); |
28 | - for($round = 1; $round <= $round_count - 1; $round++) { |
|
28 | + for ($round = 1; $round <= $round_count - 1; $round++) { |
|
29 | 29 | $template_result['.']['round'][] = array( |
30 | 30 | 'NUMBER' => $round, |
31 | 31 | '.' => array( |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function sql_generate_unit_array(array &$sql_perform_ube_report_unit, $ube_report_id, UBEFleetList $UBEFleetList) { |
50 | 50 | $unit_sort_order = 1; |
51 | - foreach($this->_container as $round_number => $UBERound) { |
|
51 | + foreach ($this->_container as $round_number => $UBERound) { |
|
52 | 52 | $outer_prefix = array( |
53 | 53 | $ube_report_id, |
54 | 54 | $round_number, |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function db_load_round_list_from_report_row($report_row, UBE $ube) { |
68 | 68 | $query = doquery("SELECT * FROM {{ube_report_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_unit_id`"); |
69 | - while($report_unit_row = db_fetch($query)) { |
|
69 | + while ($report_unit_row = db_fetch($query)) { |
|
70 | 70 | $round_number = $report_unit_row['ube_report_unit_round']; |
71 | - if(!isset($this[$round_number])) { |
|
71 | + if (!isset($this[$round_number])) { |
|
72 | 72 | $this[$round_number] = new UBERound(); |
73 | 73 | $this[$round_number]->init_round_from_report_unit_row($report_unit_row); |
74 | 74 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function debris_add_resource($resource_id, $resource_amount) { |
29 | 29 | // В обломках может быть только металл или кристалл |
30 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
30 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | $this->debris[$resource_id] += $resource_amount; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param bool $is_simulator |
39 | 39 | */ |
40 | 40 | public function add_wrecks(array $wreckage, $is_simulator) { |
41 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
41 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
42 | 42 | $this->debris_add_resource($resource_id, floor($resource_amount * |
43 | 43 | ($is_simulator |
44 | 44 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param bool $is_simulator |
55 | 55 | */ |
56 | 56 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
57 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
57 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
58 | 58 | $this->debris_add_resource($resource_id, floor($resource_amount * |
59 | 59 | ($is_simulator |
60 | 60 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param $moon_debris_left_part |
94 | 94 | */ |
95 | 95 | public function debris_adjust_proportional($moon_debris_left_part) { |
96 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
96 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
97 | 97 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
98 | 98 | } |
99 | 99 | } |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function report_generate_array() { |
116 | 116 | return array( |
117 | - 'ube_report_debris_metal' => (float)$this->debris_get_resource(RES_METAL), |
|
118 | - 'ube_report_debris_crystal' => (float)$this->debris_get_resource(RES_CRYSTAL), |
|
119 | - 'ube_report_debris_total_in_metal' => (float)$this->debris_in_metal(), |
|
117 | + 'ube_report_debris_metal' => (float) $this->debris_get_resource(RES_METAL), |
|
118 | + 'ube_report_debris_crystal' => (float) $this->debris_get_resource(RES_CRYSTAL), |
|
119 | + 'ube_report_debris_total_in_metal' => (float) $this->debris_in_metal(), |
|
120 | 120 | ); |
121 | 121 | } |
122 | 122 |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | * @param array $arguments |
20 | 20 | */ |
21 | 21 | public function __call($method_name, array $arguments) { |
22 | - foreach($this->_container as $object) { |
|
23 | - if(is_object($object) && method_exists($object, $method_name)) { |
|
22 | + foreach ($this->_container as $object) { |
|
23 | + if (is_object($object) && method_exists($object, $method_name)) { |
|
24 | 24 | call_user_func_array(array($object, $method_name), $arguments); |
25 | 25 | } |
26 | 26 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function getSumProperty($property_name) { |
37 | 37 | $result = 0.0; |
38 | - foreach($this->_container as $object) { |
|
39 | - if(is_object($object) && property_exists($object, $property_name)) { |
|
38 | + foreach ($this->_container as $object) { |
|
39 | + if (is_object($object) && property_exists($object, $property_name)) { |
|
40 | 40 | $result += $object->$property_name; |
41 | 41 | } |
42 | 42 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | 54 | public function aggregateByMethod($method_name, &$result) { |
55 | - foreach($this->_container as $object) { |
|
56 | - if(is_object($object) && method_exists($object, $method_name)) { |
|
55 | + foreach ($this->_container as $object) { |
|
56 | + if (is_object($object) && method_exists($object, $method_name)) { |
|
57 | 57 | call_user_func(array($object, $method_name), $result); |
58 | 58 | } |
59 | 59 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | parent::setUnitId($unitId); |
51 | 51 | |
52 | 52 | // Reset combat stats?? |
53 | - if($this->_unitId) { |
|
53 | + if ($this->_unitId) { |
|
54 | 54 | $this->amplify = $this->info[P_AMPLIFY]; |
55 | 55 | $this->capacity = $this->info[P_CAPACITY]; |
56 | 56 | $this->price[RES_METAL] = $this->info[P_COST][RES_METAL]; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $this->bonus_attack = $this->info[P_ATTACK]; |
73 | 73 | $this->bonus_shield = $this->info[P_SHIELD]; |
74 | 74 | $this->bonus_armor = $this->info[P_ARMOR]; |
75 | - if(is_object($this->unit_bonus)) { |
|
75 | + if (is_object($this->unit_bonus)) { |
|
76 | 76 | $this->bonus_attack = floor($this->bonus_attack * $this->unit_bonus->calcBonus(P_ATTACK)); |
77 | 77 | $this->bonus_shield = floor($this->bonus_shield * $this->unit_bonus->calcBonus(P_SHIELD)); |
78 | 78 | $this->bonus_armor = floor($this->bonus_armor * $this->unit_bonus->calcBonus(P_ARMOR)); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $this->randomized_attack = $this->bonus_attack; |
81 | 81 | $this->randomized_shield = $this->bonus_shield; |
82 | 82 | $this->randomized_armor = $this->bonus_armor; |
83 | - if(!$is_simulator) { |
|
83 | + if (!$is_simulator) { |
|
84 | 84 | // TODO - randomize attack if is not simulator |
85 | 85 | $this->randomized_attack = floor($this->bonus_attack * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100)); |
86 | 86 | $this->randomized_shield = floor($this->bonus_shield * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100)); |
@@ -159,22 +159,22 @@ discard block |
||
159 | 159 | * @version 2016-02-25 23:42:45 41a4.68 |
160 | 160 | */ |
161 | 161 | public function restore_unit($is_simulator) { |
162 | - if($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) { |
|
162 | + if ($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - if($is_simulator) { |
|
166 | + if ($is_simulator) { |
|
167 | 167 | $units_giveback = round($this->units_lost * UBE_DEFENCE_RESTORATION_CHANCE_AVG / 100); // for simulation just return 75% of loss |
168 | 168 | } else { |
169 | 169 | // Checking - should we trigger mass-restore |
170 | - if($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) { |
|
170 | + if ($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) { |
|
171 | 171 | // For large amount - mass-restoring defence |
172 | 172 | $units_giveback = round($this->units_lost * mt_rand(UBE_DEFENCE_RESTORATION_CHANCE_MIN, UBE_DEFENCE_RESTORATION_CHANCE_MAX) / 100); |
173 | 173 | } else { |
174 | 174 | // For small amount - restoring defence per single unit |
175 | 175 | $units_giveback = 0; |
176 | - for($i = 1; $i <= $this->units_lost; $i++) { |
|
177 | - if(mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) { |
|
176 | + for ($i = 1; $i <= $this->units_lost; $i++) { |
|
177 | + if (mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) { |
|
178 | 178 | $units_giveback++; |
179 | 179 | } |
180 | 180 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function receive_damage($is_simulator) { |
195 | 195 | // TODO - Добавить взрывы от полуповрежденных юнитов - т.е. заранее вычислить из убитых юнитов еще количество убитых умножить на вероятность от структуры |
196 | - if($this->_count <= 0) { |
|
196 | + if ($this->_count <= 0) { |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $this->adjustCount(-$units_lost); |
217 | 217 | |
218 | 218 | // Проверяем - не взорвался ли текущий юнит |
219 | - while($this->_count > 0 && $this->attack_income > 0) { |
|
219 | + while ($this->_count > 0 && $this->attack_income > 0) { |
|
220 | 220 | $this->attack_damaged_unit($is_simulator); |
221 | 221 | } |
222 | 222 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $armor_left = $this->pool_armor % $this->randomized_armor; |
242 | 242 | // Проверка - не атакуем ли мы целый корабль |
243 | 243 | // Такое может быть, если на прошлой итерации поврежденный корабль был взорван и еще осталась входящяя атака |
244 | - if($shield_left == 0 && $armor_left == 0) { |
|
244 | + if ($shield_left == 0 && $armor_left == 0) { |
|
245 | 245 | $shield_left = $this->randomized_shield; |
246 | 246 | $armor_left = $this->randomized_armor; |
247 | 247 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | // Вычитаем этот дамадж из щитов пула |
256 | 256 | $this->pool_shield -= $damage_to_shield; |
257 | 257 | // Если весь дамадж был поглощён щитами - выходим |
258 | - if($this->attack_income <= 0) { |
|
258 | + if ($this->attack_income <= 0) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $armor_left -= $damage_to_armor; |
273 | 273 | |
274 | 274 | // Проверяем - осталась ли броня на текущем корабле и вааще |
275 | - if($this->pool_armor <= 0 || $armor_left <= 0) { |
|
275 | + if ($this->pool_armor <= 0 || $armor_left <= 0) { |
|
276 | 276 | // Не осталось - корабль уничтожен |
277 | 277 | $this->adjustCount(-1); |
278 | 278 | |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | $armor_left_percent = $armor_left / $this->randomized_armor * 100; |
284 | 284 | // Проверяем % здоровья |
285 | 285 | // TODO - сделать динамический процент для каждого вида юнитов |
286 | - if($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) { |
|
286 | + if ($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) { |
|
287 | 287 | // Дамадж пошёл по структуре. Чем более поврежден юнит - тем больше шансов у него взорваться |
288 | 288 | $random = $is_simulator ? UBE_CRITICAL_DAMAGE_THRESHOLD / 2 : mt_rand(0, 100); |
289 | - if($random >= $armor_left_percent) { |
|
289 | + if ($random >= $armor_left_percent) { |
|
290 | 290 | $this->adjustCount(-1); |
291 | 291 | $this->unit_count_boom++; |
292 | 292 |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @return string |
305 | 305 | */ |
306 | 306 | protected function stringValue($value) { |
307 | - return "'" . $this->escape((string)$value) . "'"; |
|
307 | + return "'".$this->escape((string) $value)."'"; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -315,20 +315,20 @@ discard block |
||
315 | 315 | * @return string |
316 | 316 | */ |
317 | 317 | public function quote($fieldName) { |
318 | - return "`" . $this->escape((string)$fieldName) . "`"; |
|
318 | + return "`".$this->escape((string) $fieldName)."`"; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | public function makeAdjustString($fieldValue, $fieldName) { |
322 | 322 | return is_int($fieldName) |
323 | 323 | ? $fieldValue |
324 | - : (($fieldNameQuoted = $this->quote($fieldName)) . " = " . |
|
325 | - $fieldNameQuoted . " + (" . $this->castAsDbValue($fieldValue) . ")"); |
|
324 | + : (($fieldNameQuoted = $this->quote($fieldName))." = ". |
|
325 | + $fieldNameQuoted." + (".$this->castAsDbValue($fieldValue).")"); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | public function makeFieldEqualValue($fieldValue, $fieldName) { |
329 | 329 | return is_int($fieldName) |
330 | 330 | ? $fieldValue |
331 | - : ($this->quote($fieldName) . " = " . $this->castAsDbValue($fieldValue)); |
|
331 | + : ($this->quote($fieldName)." = ".$this->castAsDbValue($fieldValue)); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return string |
340 | 340 | */ |
341 | 341 | protected function quoteTable($tableName) { |
342 | - return "`{{" . $this->escape((string)$tableName) . "}}`"; |
|
342 | + return "`{{".$this->escape((string) $tableName)."}}`"; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | public function castAsDbValue($value) { |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | protected function buildCommand() { |
377 | 377 | switch ($this->command) { |
378 | 378 | case static::UPDATE: |
379 | - $this->build[] = $this->command . " " . $this->quoteTable($this->table); |
|
379 | + $this->build[] = $this->command." ".$this->quoteTable($this->table); |
|
380 | 380 | break; |
381 | 381 | |
382 | 382 | case static::DELETE: |
383 | - $this->build[] = $this->command . " FROM " . $this->quoteTable($this->table); |
|
383 | + $this->build[] = $this->command." FROM ".$this->quoteTable($this->table); |
|
384 | 384 | break; |
385 | 385 | |
386 | 386 | case static::REPLACE: |
387 | 387 | case static::INSERT_IGNORE: |
388 | 388 | case static::INSERT: |
389 | - $this->build[] = $this->command . " INTO " . $this->quoteTable($this->table); |
|
389 | + $this->build[] = $this->command." INTO ".$this->quoteTable($this->table); |
|
390 | 390 | break; |
391 | 391 | |
392 | 392 | case static::SELECT: |
393 | - $this->build[] = $this->command . " "; |
|
393 | + $this->build[] = $this->command." "; |
|
394 | 394 | break; |
395 | 395 | } |
396 | 396 | } |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | protected function buildValuesVector() { |
432 | 432 | $compiled = array(); |
433 | 433 | |
434 | - if(!empty($this->valuesDanger)) { |
|
434 | + if (!empty($this->valuesDanger)) { |
|
435 | 435 | $compiled = $this->valuesDanger; |
436 | 436 | } |
437 | 437 | |
438 | 438 | foreach ($this->values as $valuesVector) { |
439 | - $compiled[] = '(' . implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))) . ')'; |
|
439 | + $compiled[] = '('.implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))).')'; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | $this->build[] = implode(',', $compiled); |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | $this->reset(); |
80 | 80 | $this->db = is_object($db) ? $db : classSupernova::$db; |
81 | 81 | |
82 | - foreach($this->table_check as $table_name) { |
|
83 | - if(empty($this->db->table_list[$table_name])) { |
|
82 | + foreach ($this->table_check as $table_name) { |
|
83 | + if (empty($this->db->table_list[$table_name])) { |
|
84 | 84 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
85 | 85 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
86 | 86 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | // OK v4.6 |
106 | 106 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
107 | - if(!$this->password_check($old_password_unsafe)) { |
|
107 | + if (!$this->password_check($old_password_unsafe)) { |
|
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // OK v4.5 |
126 | 126 | public function assign_from_db_row($row) { |
127 | 127 | $this->reset(); |
128 | - if(empty($row) || !is_array($row)) { |
|
128 | + if (empty($row) || !is_array($row)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | $this->account_id = $row['account_id']; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | `account_email` = LOWER('{$email_safe}'), |
243 | 243 | `account_language` = '{$language_safe}'" |
244 | 244 | ); |
245 | - if(!$result) { |
|
245 | + if (!$result) { |
|
246 | 246 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
247 | 247 | } |
248 | 248 | |
249 | - if(!($account_id = $this->db->db_insert_id())) { |
|
249 | + if (!($account_id = $this->db->db_insert_id())) { |
|
250 | 250 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
251 | 251 | } |
252 | 252 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | WHERE `account_id` = '{$account_id_safe}'" |
277 | 277 | ) ? true : false; |
278 | 278 | |
279 | - if($result) { |
|
279 | + if ($result) { |
|
280 | 280 | $result = $this->db_get_by_id($this->account_id); |
281 | 281 | } |
282 | 282 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) { |
364 | 364 | global $mm_change_legit; |
365 | 365 | |
366 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
366 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
367 | 367 | classSupernova::$debug->error('Ошибка при попытке манипуляции с ММ'); |
368 | 368 | |
369 | 369 | return false; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | $mm_change_legit = true; |
375 | 375 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
376 | - if($already_changed) { |
|
376 | + if ($already_changed) { |
|
377 | 377 | $metamatter_total_delta = 0; |
378 | 378 | $result = -1; |
379 | 379 | } else { |
@@ -383,17 +383,17 @@ discard block |
||
383 | 383 | $result = $this->db->doquery( |
384 | 384 | "UPDATE {{account}} |
385 | 385 | SET |
386 | - `account_metamatter` = `account_metamatter` + '{$metamatter}'" . |
|
387 | - ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
|
386 | + `account_metamatter` = `account_metamatter` + '{$metamatter}'". |
|
387 | + ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : ''). |
|
388 | 388 | " WHERE `account_id` = {$account_id_safe}" |
389 | 389 | ); |
390 | - if(!$result) { |
|
390 | + if (!$result) { |
|
391 | 391 | classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
392 | 392 | } |
393 | 393 | $result = classSupernova::$db->db_affected_rows(); |
394 | 394 | } |
395 | 395 | |
396 | - if(empty(core_auth::$user['id'])) { |
|
396 | + if (empty(core_auth::$user['id'])) { |
|
397 | 397 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
398 | 398 | reset($user_list); |
399 | 399 | $user_id_unsafe = key($user_list); |
@@ -402,30 +402,30 @@ discard block |
||
402 | 402 | } |
403 | 403 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
404 | 404 | |
405 | - if(!$result) { |
|
405 | + if (!$result) { |
|
406 | 406 | classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
407 | 407 | } |
408 | 408 | |
409 | - if(!$already_changed) { |
|
409 | + if (!$already_changed) { |
|
410 | 410 | $this->account_metamatter += $metamatter; |
411 | 411 | $this->account_metamatter_total += $metamatter_total_delta; |
412 | 412 | } |
413 | 413 | |
414 | - if(is_array($comment)) { |
|
414 | + if (is_array($comment)) { |
|
415 | 415 | $comment = call_user_func_array('sprintf', $comment); |
416 | 416 | } |
417 | 417 | |
418 | 418 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
419 | 419 | |
420 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
420 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
421 | 421 | $old_referral = db_referral_get_by_id($user_id_safe); |
422 | - if($old_referral['id']) { |
|
422 | + if ($old_referral['id']) { |
|
423 | 423 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
424 | 424 | db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter); |
425 | 425 | $new_referral = db_referral_get_by_id($user_id_safe); |
426 | 426 | |
427 | 427 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
428 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
428 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
429 | 429 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
430 | 430 | } |
431 | 431 | } |
@@ -45,8 +45,8 @@ |
||
45 | 45 | */ |
46 | 46 | protected function quoteStringAsFieldByRef(&$string) { |
47 | 47 | $string = $this->stringEscape($string); |
48 | - if ((string)$string && '*' != $string) { |
|
49 | - $string = '`' . $string . '`'; |
|
48 | + if ((string) $string && '*' != $string) { |
|
49 | + $string = '`'.$string.'`'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, |
15 | 15 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
16 | 16 | 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, |
17 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
17 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
18 | 18 | 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, |
19 | 19 | 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, |
20 | 20 | // 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $checkResult = call_user_func(array($this, $condition)); |
135 | 135 | defined('DEBUG_FLEET_MISSION_VALIDATE_DUMP_STEPS') |
136 | - ? pdump($action, $condition . ' ' . ($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
136 | + ? pdump($action, $condition.' '.($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
137 | 137 | |
138 | 138 | // If check failed and there no alternative actions - throw exception |
139 | 139 | // Shortcut ACTION => FAIL_STATUS instead of ACTION => array(false => FAIL_STATUS) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->checkMissionRestrictions($action); |
157 | 157 | } else { |
158 | 158 | // No - then just performing action |
159 | - if($exception) { |
|
159 | + if ($exception) { |
|
160 | 160 | throw new ExceptionFleetInvalid($action, $action); |
161 | 161 | } else { |
162 | 162 | return $action; |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | protected function checkMissionPrefix($name, $prefix) { |
599 | 599 | $result = false; |
600 | 600 | if (strpos($name, $prefix) === 0) { |
601 | - $mission = 'MT_' . strtoupper(substr($name, strlen($prefix))); |
|
601 | + $mission = 'MT_'.strtoupper(substr($name, strlen($prefix))); |
|
602 | 602 | if (!defined($mission)) { |
603 | 603 | // TODO - Ну, как-то получше это обделать |
604 | - throw new Exception('Mission type "' . $mission . '" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
604 | + throw new Exception('Mission type "'.$mission.'" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | $result = constant($mission); |