@@ -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 | |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
| 39 | 39 | |
| 40 | 40 | $current_leaf = $this->__get(reset($offset)); |
| 41 | - while(($leaf_index = next($offset)) !== false) { |
|
| 42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
| 41 | + while (($leaf_index = next($offset)) !== false) { |
|
| 42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
| 43 | 43 | unset($current_leaf); |
| 44 | 44 | break; |
| 45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
| 66 | 66 | |
| 67 | - if($this->offsetExists($offset)) { |
|
| 67 | + if ($this->offsetExists($offset)) { |
|
| 68 | 68 | $result = $this->__get(reset($offset)); |
| 69 | - while(($leaf_index = next($offset)) !== false) { |
|
| 69 | + while (($leaf_index = next($offset)) !== false) { |
|
| 70 | 70 | $result = $result[$leaf_index]; |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function offsetSet($offset, $value = null) { |
| 93 | 93 | // Если нет никакого индекса - значит нечего записывать |
| 94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
| 94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
| 99 | - if(is_array($offset) && count($offset) == 1) { |
|
| 99 | + if (is_array($offset) && count($offset) == 1) { |
|
| 100 | 100 | // Разворачиваем его в индекс |
| 101 | 101 | $offset = array(reset($offset) => $value); |
| 102 | 102 | unset($value); |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Адресация многомерного массива через массив индексов в $option |
| 107 | - if(is_array($offset) && isset($value)) { |
|
| 107 | + if (is_array($offset) && isset($value)) { |
|
| 108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
| 109 | 109 | //pdump($offset, '$offset'); |
| 110 | 110 | //pdump($value, '$value'); |
| 111 | 111 | // Вытаскиваем корневой элемент |
| 112 | 112 | $root = $this->__get(reset($offset)); |
| 113 | 113 | $current_leaf = &$root; |
| 114 | - while(($leaf_index = next($offset)) !== false) { |
|
| 114 | + while (($leaf_index = next($offset)) !== false) { |
|
| 115 | 115 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
| 116 | 116 | $current_leaf = &$current_leaf[$leaf_index]; |
| 117 | 117 | } |
| 118 | 118 | //pdump($current_leaf, '$current_leaf'); |
| 119 | 119 | //pdump($value, '$value'); |
| 120 | - if($current_leaf != $value) { |
|
| 120 | + if ($current_leaf != $value) { |
|
| 121 | 121 | $current_leaf = $value; |
| 122 | 122 | //pdump(reset($offset), 'reset($offset)'); |
| 123 | 123 | //pdump($root, '$root'); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // Пакетная запись из массива ключ -> значение |
| 129 | 129 | !is_array($offset) ? $offset = array($offset => $value) : false; |
| 130 | 130 | |
| 131 | - foreach($offset as $key => $value) { |
|
| 131 | + foreach ($offset as $key => $value) { |
|
| 132 | 132 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function offsetUnset($offset) { |
| 151 | 151 | // Если нет никакого индекса - значит нечего записывать |
| 152 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
| 152 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | !is_array($offset) ? $offset = array($offset) : false; |
| 157 | 157 | |
| 158 | - if($this->offsetExists($offset)) { |
|
| 158 | + if ($this->offsetExists($offset)) { |
|
| 159 | 159 | //pdump($offset); |
| 160 | 160 | // Перематываем массив в конец |
| 161 | 161 | $key_to_delete = end($offset); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | //pdump($key_to_delete, '$key_to_delete'); |
| 164 | 164 | $parent_offset = $offset; |
| 165 | 165 | array_pop($parent_offset); |
| 166 | - if(!count($parent_offset)) { |
|
| 166 | + if (!count($parent_offset)) { |
|
| 167 | 167 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
| 168 | 168 | $this->__unset($key_to_delete); |
| 169 | 169 | } else { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | // OK 4.9 |
| 37 | 37 | public function __construct($filename = __FILE__) { |
| 38 | - if($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
| 38 | + if ($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
| 39 | 39 | die('У всех провайдеров должен быть $provider_id!'); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | // OK 4.6 |
| 134 | 134 | public function player_name_suggest() { |
| 135 | 135 | $name = ''; |
| 136 | - if(is_object($this->account) && !empty($this->account->account_email)) { |
|
| 136 | + if (is_object($this->account) && !empty($this->account->account_email)) { |
|
| 137 | 137 | list($name) = explode('@', $this->account->account_email); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true); |
| 42 | 42 | // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем" |
| 43 | 43 | $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true); |
| 44 | - } while($query); |
|
| 44 | + } while ($query); |
|
| 45 | 45 | |
| 46 | 46 | $this->db->doquery( |
| 47 | 47 | "REPLACE INTO {{confirmations}} |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | * @return int|mixed |
| 229 | 229 | */ |
| 230 | 230 | public function calcColonyMaxCount($astrotech = -1) { |
| 231 | - if($astrotech == -1) { |
|
| 232 | - if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 231 | + if ($astrotech == -1) { |
|
| 232 | + if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 233 | 233 | |
| 234 | 234 | $expeditions = get_player_max_expeditons($this->_dbRow); |
| 235 | 235 | $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | public function expeditionsMax() { |
| 305 | - if($this->expeditionsMax === null) { |
|
| 305 | + if ($this->expeditionsMax === null) { |
|
| 306 | 306 | $this->expeditionsMax = get_player_max_expeditons($this->_dbRow); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | public function expeditionsFlying() { |
| 313 | - if($this->expeditionsFlying === null) { |
|
| 313 | + if ($this->expeditionsFlying === null) { |
|
| 314 | 314 | $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | |
| 321 | 321 | public function fleetsMax() { |
| 322 | - if($this->fleetMax === null) { |
|
| 322 | + if ($this->fleetMax === null) { |
|
| 323 | 323 | $this->fleetMax = GetMaxFleets($this->_dbRow); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | public function fleetsFlying() { |
| 330 | - if($this->fleetFlying === null) { |
|
| 330 | + if ($this->fleetFlying === null) { |
|
| 331 | 331 | $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | |
| 338 | 338 | public function coloniesMax() { |
| 339 | - if($this->coloniesMax === null) { |
|
| 339 | + if ($this->coloniesMax === null) { |
|
| 340 | 340 | $this->coloniesMax = get_player_max_colonies($this->_dbRow); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | public function coloniesCurrent() { |
| 347 | - if($this->coloniesCurrent === null) { |
|
| 347 | + if ($this->coloniesCurrent === null) { |
|
| 348 | 348 | $this->coloniesCurrent = get_player_current_colonies($this->_dbRow); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | * @param $unit_level |
| 29 | 29 | */ |
| 30 | 30 | public function add_unit_by_snid($unit_id, $unit_level) { |
| 31 | - if(!$unit_level) { |
|
| 31 | + if (!$unit_level) { |
|
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - foreach(static::$_bonus_group as $param_name => $unit_list) { |
|
| 36 | - if(!empty($unit_list[$unit_id])) { |
|
| 35 | + foreach (static::$_bonus_group as $param_name => $unit_list) { |
|
| 36 | + if (!empty($unit_list[$unit_id])) { |
|
| 37 | 37 | // Простейший вариант - мультипликатор по базе |
| 38 | 38 | // Общий мультипликатор добавляется в конец |
| 39 | 39 | $this->grants[$param_name][$unit_id] = $unit_level; |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | // $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;; |
| 83 | 83 | $value_add = floatval($base_value); |
| 84 | 84 | $cumulative = 1.0; // Для случая BONUS_PERCENT |
| 85 | - if(!empty($this->grants[$param]) && is_array($this->grants[$param])) { |
|
| 86 | - foreach($this->grants[$param] as $unit_id => $unit_level) { |
|
| 85 | + if (!empty($this->grants[$param]) && is_array($this->grants[$param])) { |
|
| 86 | + foreach ($this->grants[$param] as $unit_id => $unit_level) { |
|
| 87 | 87 | $unit_bonus = 0; |
| 88 | - if($unit_id < 0) { |
|
| 88 | + if ($unit_id < 0) { |
|
| 89 | 89 | // Meta-unit - leave as is |
| 90 | 90 | } else { |
| 91 | 91 | // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать |
| 92 | 92 | $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE); |
| 93 | 93 | $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE); |
| 94 | - switch($bonus_type) { |
|
| 94 | + switch ($bonus_type) { |
|
| 95 | 95 | case BONUS_PERCENT: |
| 96 | 96 | $unit_bonus = $unit_level * $bonus_value / 100; |
| 97 | 97 | $cumulative += $unit_bonus; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function castAs($type, $value) { |
| 14 | 14 | // TODO: Here should be some conversions to property type |
| 15 | - switch($type) { |
|
| 15 | + switch ($type) { |
|
| 16 | 16 | case TYPE_INTEGER: |
| 17 | 17 | $value = intval($value); |
| 18 | 18 | break; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | break; |
| 31 | 31 | |
| 32 | 32 | case TYPE_ARRAY: |
| 33 | - $value = (array)$value; |
|
| 33 | + $value = (array) $value; |
|
| 34 | 34 | break; |
| 35 | 35 | |
| 36 | 36 | case TYPE_STRING: |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | case TYPE_EMPTY: |
| 39 | 39 | // No-type defaults to string |
| 40 | 40 | default: |
| 41 | - $value = (string)$value; |
|
| 41 | + $value = (string) $value; |
|
| 42 | 42 | break; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @package Buddy |
| 22 | 22 | */ |
| 23 | -class BuddyModel extends \Entity\KeyedModel{ |
|
| 23 | +class BuddyModel extends \Entity\KeyedModel { |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Name of table for this entity |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | |
| 240 | 240 | $factory = $this->values[$id]; |
| 241 | 241 | |
| 242 | - $extended = function ($c) use ($callable, $factory) { |
|
| 242 | + $extended = function($c) use ($callable, $factory) { |
|
| 243 | 243 | return $callable($factory($c), $c); |
| 244 | 244 | }; |
| 245 | 245 | |