@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * @version 41a6.16 |
| 24 | 24 | */ |
| 25 | 25 | protected function db_load_player_by_id($player_id) { |
| 26 | - if(isset($this[$player_id])) { |
|
| 26 | + if (isset($this[$player_id])) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | UBE_PLAYER_IS_DEFENDER => array(), |
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
| 58 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
| 59 | 59 | $result[$UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER][$player_id] = $UBEPlayer->getDbRow(); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function get_first_player_on_side($side) { |
| 72 | 72 | $result = null; |
| 73 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
| 74 | - if($UBEPlayer->getSide() == $side) { |
|
| 73 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
| 74 | + if ($UBEPlayer->getSide() == $side) { |
|
| 75 | 75 | $result = $UBEPlayer; |
| 76 | 76 | break; |
| 77 | 77 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function get_player_sides() { |
| 90 | 90 | $result = array(); |
| 91 | - foreach($this->_container as $player_id => $UBEPlayer) { |
|
| 91 | + foreach ($this->_container as $player_id => $UBEPlayer) { |
|
| 92 | 92 | $result[$player_id] = $UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | public function ubeLoadPlayersAndSetSideFromFleetIdList(array $added_fleets, UBEFleetList $fleetList, $side = UBE_PLAYER_IS_DEFENDER) { |
| 99 | - foreach($added_fleets as $fleet_id) { |
|
| 99 | + foreach ($added_fleets as $fleet_id) { |
|
| 100 | 100 | $this->db_load_player_by_id($fleetList[$fleet_id]->owner_id, $side); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | * @version 2016-02-25 23:42:45 41a4.68 |
| 37 | 37 | */ |
| 38 | 38 | public function make_snapshot(UBEFleetList $UBEFleetList) { |
| 39 | - foreach($UBEFleetList->_container as $fleet_id => $UBEFleet) { |
|
| 40 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
| 39 | + foreach ($UBEFleetList->_container as $fleet_id => $UBEFleet) { |
|
| 40 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
| 41 | 41 | $this->snapshot[$fleet_id][$UBEUnit->unitId] = new UBESnapshotUnit(); |
| 42 | 42 | $this->snapshot[$fleet_id][$UBEUnit->unitId]->init_from_UBEUnit($UBEUnit); |
| 43 | 43 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | * @version 2016-02-25 23:42:45 41a4.68 |
| 54 | 54 | */ |
| 55 | 55 | public function sql_generate_unit_array(array &$sql_perform_ube_report_unit, &$unit_sort_order, UBEFleetList $UBEFleetList, array $outer_prefix) { |
| 56 | - foreach($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
| 56 | + foreach ($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
| 57 | 57 | $inner_prefix = array( |
| 58 | 58 | $UBEFleetList[$fleet_id]->owner_id, |
| 59 | 59 | $fleet_id, |
| 60 | 60 | ); |
| 61 | - foreach($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
| 61 | + foreach ($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
| 62 | 62 | $sql_perform_ube_report_unit[] = array_merge( |
| 63 | 63 | $outer_prefix, |
| 64 | 64 | $inner_prefix, |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | UBE_PLAYER_IS_DEFENDER => array(), |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - foreach($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
| 104 | + foreach ($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
| 105 | 105 | $fleet_owner_id = $ube->fleet_list[$fleet_id]->owner_id; |
| 106 | 106 | $planet_ube_row = $ube->fleet_list[$fleet_id]->UBE_PLANET; |
| 107 | 107 | |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | 'PLAYER_NAME' => htmlentities($ube->players[$fleet_owner_id]->name, ENT_COMPAT, 'UTF-8'), |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - if(is_array($planet_ube_row)) { |
|
| 114 | + if (is_array($planet_ube_row)) { |
|
| 115 | 115 | $template_fleet += $planet_ube_row; |
| 116 | 116 | $template_fleet[PLANET_NAME] = $template_fleet[PLANET_NAME] ? htmlentities($template_fleet[PLANET_NAME], ENT_COMPAT, 'UTF-8') : ''; |
| 117 | 117 | $template_fleet['PLANET_TYPE_TEXT'] = $lang['sys_planet_type_sh'][$template_fleet['PLANET_TYPE']]; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
| 120 | + foreach ($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
| 121 | 121 | $template_fleet['.']['ship'][] = $unit_snapshot->report_render_unit($prevSnapshot[$fleet_id][$unit_id]); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -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 | |
@@ -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 | |