@@ -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 | |
@@ -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 | } |
@@ -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 | } |
@@ -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 | |
@@ -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 | |
@@ -154,15 +154,15 @@ discard block |
||
| 154 | 154 | * @param string $group_name |
| 155 | 155 | */ |
| 156 | 156 | public static function _init($group_name = '') { |
| 157 | - if(static::$_is_static_init) { |
|
| 157 | + if (static::$_is_static_init) { |
|
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($group_name) { |
|
| 161 | + if ($group_name) { |
|
| 162 | 162 | static::$_sn_group_name = $group_name; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if(static::$_sn_group_name) { |
|
| 165 | + if (static::$_sn_group_name) { |
|
| 166 | 166 | static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name); |
| 167 | 167 | empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false; |
| 168 | 168 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | // TODO - Reset combat stats?? |
| 188 | 188 | $this->_unitId = $unitId; |
| 189 | 189 | |
| 190 | - if($this->_unitId) { |
|
| 190 | + if ($this->_unitId) { |
|
| 191 | 191 | $this->info = get_unit_param($this->_unitId); |
| 192 | 192 | $this->_type = $this->info[P_UNIT_TYPE]; |
| 193 | 193 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | protected function setCount($value) { |
| 200 | 200 | // TODO - Reset combat stats?? |
| 201 | - if($value < 0) { |
|
| 201 | + if ($value < 0) { |
|
| 202 | 202 | classSupernova::$debug->error('Can not set Unit::$count to negative value'); |
| 203 | 203 | } |
| 204 | 204 | $this->_count = $value; |
@@ -411,7 +411,7 @@ |
||
| 411 | 411 | /** |
| 412 | 412 | * @param array $field_set |
| 413 | 413 | * |
| 414 | - * @return int|string |
|
| 414 | + * @return integer |
|
| 415 | 415 | */ |
| 416 | 416 | protected function db_field_set_create(array $field_set) { |
| 417 | 417 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set) : false; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param db_mysql|null $db |
| 87 | 87 | */ |
| 88 | 88 | public static function setDb($db = null) { |
| 89 | - if(empty($db) || !($db instanceof db_mysql)) { |
|
| 89 | + if (empty($db) || !($db instanceof db_mysql)) { |
|
| 90 | 90 | $db = null; |
| 91 | 91 | } |
| 92 | 92 | static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function dbLoad($dbId, $lockSkip = false) { |
| 150 | 150 | $dbId = idval($dbId); |
| 151 | 151 | if ($dbId <= 0) { |
| 152 | - classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId); |
|
| 152 | + classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId); |
|
| 153 | 153 | |
| 154 | 154 | return; |
| 155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | $this->dbGetLockById($this->_dbId); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;", true); |
|
| 164 | + $db_row = doquery("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;", true); |
|
| 165 | 165 | if (empty($db_row)) { |
| 166 | 166 | return; |
| 167 | 167 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if ($this->isNew()) { |
| 194 | 194 | // No DB_ID - new unit |
| 195 | 195 | if ($this->isEmpty()) { |
| 196 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
|
| 196 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave'); |
|
| 197 | 197 | } |
| 198 | 198 | $this->dbInsert(); |
| 199 | 199 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $this->dbDelete(); |
| 203 | 203 | } else { |
| 204 | 204 | if (!sn_db_transaction_check(false)) { |
| 205 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
|
| 205 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate'); |
|
| 206 | 206 | } |
| 207 | 207 | $this->dbUpdate(); |
| 208 | 208 | } |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | // TODO - protected |
| 231 | 231 | public function dbInsert() { |
| 232 | 232 | if (!$this->isNew()) { |
| 233 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
|
| 233 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert'); |
|
| 234 | 234 | } |
| 235 | 235 | $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet()); |
| 236 | 236 | |
| 237 | 237 | if (empty($this->_dbId)) { |
| 238 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
|
| 238 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert'); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | return $this->_dbId; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | public function dbUpdate() { |
| 249 | 249 | // TODO - Update |
| 250 | 250 | if ($this->isNew()) { |
| 251 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
|
| 251 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate'); |
|
| 252 | 252 | } |
| 253 | 253 | $this->db_field_update($this->dbMakeFieldSet(true)); |
| 254 | 254 | } |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | // TODO - protected |
| 260 | 260 | public function dbDelete() { |
| 261 | 261 | if ($this->isNew()) { |
| 262 | - classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
|
| 262 | + classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete'); |
|
| 263 | 263 | } |
| 264 | - doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId); |
|
| 264 | + doquery("DELETE FROM {{".static::$_table."}} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId); |
|
| 265 | 265 | $this->_dbId = 0; |
| 266 | 266 | // Обо всём остальном должен позаботиться контейнер |
| 267 | 267 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $fields = implode(',', array_keys($field_set)); |
| 415 | 415 | |
| 416 | 416 | $result = 0; |
| 417 | - if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) { |
|
| 417 | + if (classSupernova::db_query("INSERT INTO `{{".static::$_table."}}` ({$fields}) VALUES ({$values});")) { |
|
| 418 | 418 | $result = db_insert_id(); |
| 419 | 419 | } |
| 420 | 420 | |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | |
| 451 | 451 | return empty($set_string) |
| 452 | 452 | ? true |
| 453 | - : classSupernova::db_query("UPDATE `{{" . static::$_table . "}}` SET {$set_string} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId); |
|
| 453 | + : classSupernova::db_query("UPDATE `{{".static::$_table."}}` SET {$set_string} WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | - * @param $ube_report_id |
|
| 153 | + * @param integer $ube_report_id |
|
| 154 | 154 | * |
| 155 | 155 | * @return array |
| 156 | 156 | * |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | |
| 290 | 290 | /** |
| 291 | - * @param $ube_report_id |
|
| 291 | + * @param integer $ube_report_id |
|
| 292 | 292 | * |
| 293 | 293 | * @return array |
| 294 | 294 | */ |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | // Рендерит таблицу общего результата боя |
| 337 | 337 | /** |
| 338 | 338 | * @param $array |
| 339 | - * @param $lang_header_index |
|
| 339 | + * @param string $lang_header_index |
|
| 340 | 340 | * |
| 341 | 341 | * @return array |
| 342 | 342 | */ |
@@ -362,6 +362,9 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | |
| 365 | + /** |
|
| 366 | + * @param integer $ube_report_id |
|
| 367 | + */ |
|
| 365 | 368 | public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) { |
| 366 | 369 | $fleet_id = $this->db_id; |
| 367 | 370 | |
@@ -468,6 +471,10 @@ discard block |
||
| 468 | 471 | $this->fleet_capacity -= $fleet_total_resources; |
| 469 | 472 | } |
| 470 | 473 | |
| 474 | + /** |
|
| 475 | + * @param integer $is_small_fleet_recce |
|
| 476 | + * @param integer $reapers_status |
|
| 477 | + */ |
|
| 471 | 478 | public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) { |
| 472 | 479 | $ship_count_initial = $this->unit_list->unitsCount(); |
| 473 | 480 | $ship_count_lost = $this->unit_list->unitCountLost(); |
@@ -535,7 +542,7 @@ discard block |
||
| 535 | 542 | |
| 536 | 543 | /** |
| 537 | 544 | * @param UBEFleetList $fleet_list |
| 538 | - * @param $is_simulator |
|
| 545 | + * @param boolean $is_simulator |
|
| 539 | 546 | * |
| 540 | 547 | * @version 2016-02-25 23:42:45 41a4.68 |
| 541 | 548 | */ |
@@ -162,20 +162,20 @@ discard block |
||
| 162 | 162 | $this->owner_id, |
| 163 | 163 | $this->db_id, |
| 164 | 164 | |
| 165 | - (float)$this->UBE_PLANET[PLANET_ID], |
|
| 166 | - "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'", |
|
| 167 | - (int)$this->UBE_PLANET[PLANET_GALAXY], |
|
| 168 | - (int)$this->UBE_PLANET[PLANET_SYSTEM], |
|
| 169 | - (int)$this->UBE_PLANET[PLANET_PLANET], |
|
| 170 | - (int)$this->UBE_PLANET[PLANET_TYPE], |
|
| 171 | - |
|
| 172 | - (float)$this->resource_list[RES_METAL], |
|
| 173 | - (float)$this->resource_list[RES_CRYSTAL], |
|
| 174 | - (float)$this->resource_list[RES_DEUTERIUM], |
|
| 175 | - |
|
| 176 | - (float)$this->fleet_bonus->calcBonus(P_ATTACK), |
|
| 177 | - (float)$this->fleet_bonus->calcBonus(P_SHIELD), |
|
| 178 | - (float)$this->fleet_bonus->calcBonus(P_ARMOR), |
|
| 165 | + (float) $this->UBE_PLANET[PLANET_ID], |
|
| 166 | + "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'", |
|
| 167 | + (int) $this->UBE_PLANET[PLANET_GALAXY], |
|
| 168 | + (int) $this->UBE_PLANET[PLANET_SYSTEM], |
|
| 169 | + (int) $this->UBE_PLANET[PLANET_PLANET], |
|
| 170 | + (int) $this->UBE_PLANET[PLANET_TYPE], |
|
| 171 | + |
|
| 172 | + (float) $this->resource_list[RES_METAL], |
|
| 173 | + (float) $this->resource_list[RES_CRYSTAL], |
|
| 174 | + (float) $this->resource_list[RES_DEUTERIUM], |
|
| 175 | + |
|
| 176 | + (float) $this->fleet_bonus->calcBonus(P_ATTACK), |
|
| 177 | + (float) $this->fleet_bonus->calcBonus(P_SHIELD), |
|
| 178 | + (float) $this->fleet_bonus->calcBonus(P_ARMOR), |
|
| 179 | 179 | ); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | $this->owner_id = $objFleet->playerOwnerId; |
| 190 | 190 | $this->group_id = $objFleet->group_id; |
| 191 | 191 | |
| 192 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
| 193 | - if(!$unit->count) { |
|
| 192 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
| 193 | + if (!$unit->count) { |
|
| 194 | 194 | continue; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
| 198 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
| 198 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
| 199 | 199 | $this->unit_list->unitAdjustCount($unit_id, $unit->count); |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -231,13 +231,13 @@ discard block |
||
| 231 | 231 | // } |
| 232 | 232 | // } |
| 233 | 233 | |
| 234 | - foreach($sn_group_combat as $unit_id) { |
|
| 235 | - if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
| 234 | + foreach ($sn_group_combat as $unit_id) { |
|
| 235 | + if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
| 236 | 236 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 240 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 241 | 241 | $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id)); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -296,27 +296,27 @@ discard block |
||
| 296 | 296 | $ube_report_id, |
| 297 | 297 | $this->db_id, |
| 298 | 298 | |
| 299 | - (float)$this->resources_lost_on_units[RES_METAL], |
|
| 300 | - (float)$this->resources_lost_on_units[RES_CRYSTAL], |
|
| 301 | - (float)$this->resources_lost_on_units[RES_DEUTERIUM], |
|
| 302 | - (float)$this->cargo_dropped[RES_METAL], |
|
| 303 | - (float)$this->cargo_dropped[RES_CRYSTAL], |
|
| 304 | - (float)$this->cargo_dropped[RES_DEUTERIUM], |
|
| 305 | - (float)$this->resources_looted[RES_METAL], |
|
| 306 | - (float)$this->resources_looted[RES_CRYSTAL], |
|
| 307 | - (float)$this->resources_looted[RES_DEUTERIUM], |
|
| 308 | - (float)$this->resources_lost_in_metal[RES_METAL], |
|
| 299 | + (float) $this->resources_lost_on_units[RES_METAL], |
|
| 300 | + (float) $this->resources_lost_on_units[RES_CRYSTAL], |
|
| 301 | + (float) $this->resources_lost_on_units[RES_DEUTERIUM], |
|
| 302 | + (float) $this->cargo_dropped[RES_METAL], |
|
| 303 | + (float) $this->cargo_dropped[RES_CRYSTAL], |
|
| 304 | + (float) $this->cargo_dropped[RES_DEUTERIUM], |
|
| 305 | + (float) $this->resources_looted[RES_METAL], |
|
| 306 | + (float) $this->resources_looted[RES_CRYSTAL], |
|
| 307 | + (float) $this->resources_looted[RES_DEUTERIUM], |
|
| 308 | + (float) $this->resources_lost_in_metal[RES_METAL], |
|
| 309 | 309 | ); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | public function report_render_outcome_side_fleet() { |
| 313 | 313 | $UBE_DEFENCE_RESTORE = array(); |
| 314 | 314 | $UBE_UNITS_LOST = array(); |
| 315 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
| 316 | - if($UBEUnit->units_restored) { |
|
| 315 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
| 316 | + if ($UBEUnit->units_restored) { |
|
| 317 | 317 | $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored; |
| 318 | 318 | } |
| 319 | - if($UBEUnit->units_lost) { |
|
| 319 | + if ($UBEUnit->units_lost) { |
|
| 320 | 320 | $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost; |
| 321 | 321 | } |
| 322 | 322 | } |
@@ -341,16 +341,16 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) { |
| 343 | 343 | $result = array(); |
| 344 | - if(!empty($array)) { |
|
| 345 | - foreach($array as $unit_id => $unit_count) { |
|
| 346 | - if($unit_count) { |
|
| 344 | + if (!empty($array)) { |
|
| 345 | + foreach ($array as $unit_id => $unit_count) { |
|
| 346 | + if ($unit_count) { |
|
| 347 | 347 | $result[] = array( |
| 348 | 348 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
| 349 | 349 | 'LOSS' => pretty_number($unit_count), |
| 350 | 350 | ); |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | - if($lang_header_index && count($result)) { |
|
| 353 | + if ($lang_header_index && count($result)) { |
|
| 354 | 354 | array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index])); |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -363,16 +363,16 @@ discard block |
||
| 363 | 363 | $fleet_id = $this->db_id; |
| 364 | 364 | |
| 365 | 365 | $unit_sort_order = 0; |
| 366 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
| 367 | - if($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
| 366 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
| 367 | + if ($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
| 368 | 368 | $unit_sort_order++; |
| 369 | 369 | $sql_perform_report_unit[] = array( |
| 370 | 370 | $ube_report_id, |
| 371 | 371 | $fleet_id, |
| 372 | 372 | |
| 373 | 373 | $UBEUnit->unitId, |
| 374 | - (float)$UBEUnit->units_restored, |
|
| 375 | - (float)$UBEUnit->units_lost, |
|
| 374 | + (float) $UBEUnit->units_restored, |
|
| 375 | + (float) $UBEUnit->units_lost, |
|
| 376 | 376 | |
| 377 | 377 | $unit_sort_order, |
| 378 | 378 | ); |
@@ -388,9 +388,9 @@ discard block |
||
| 388 | 388 | function ube_combat_result_calculate_resources() { |
| 389 | 389 | $resource_delta_fleet = array(); |
| 390 | 390 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
| 391 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 392 | - $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id]; |
|
| 393 | - if($resource_change) { |
|
| 391 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 392 | + $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id]; |
|
| 393 | + if ($resource_change) { |
|
| 394 | 394 | $resource_delta_fleet[$resource_id] = -($resource_change); |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -423,12 +423,12 @@ discard block |
||
| 423 | 423 | ); |
| 424 | 424 | |
| 425 | 425 | $this->fleet_capacity = 0; |
| 426 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
| 426 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
| 427 | 427 | $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount(); |
| 428 | 428 | |
| 429 | - if($UBEUnit->units_lost) { |
|
| 430 | - foreach($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
| 431 | - if(!$unit_resource_price) { |
|
| 429 | + if ($UBEUnit->units_lost) { |
|
| 430 | + foreach ($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
| 431 | + if (!$unit_resource_price) { |
|
| 432 | 432 | continue; |
| 433 | 433 | } |
| 434 | 434 | |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | $this->resources_lost_on_units[$resource_id] += $resources_lost; |
| 437 | 437 | // Если это корабль - прибавляем потери к обломкам на орбите |
| 438 | 438 | // TODO - опция выбрасывания обороны в обломки |
| 439 | - if($UBEUnit->getType() == UNIT_SHIPS) { |
|
| 439 | + if ($UBEUnit->getType() == UNIT_SHIPS) { |
|
| 440 | 440 | $this->resources_lost_on_ships[$resource_id] += $resources_lost; |
| 441 | 441 | } |
| 442 | 442 | } |
@@ -448,11 +448,11 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
| 450 | 450 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
| 451 | - if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
| 451 | + if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
| 452 | 452 | $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена |
| 453 | - foreach($this->resource_list as $resource_id => &$resource_amount) { |
|
| 453 | + foreach ($this->resource_list as $resource_id => &$resource_amount) { |
|
| 454 | 454 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
| 455 | - if(!$resource_amount) { |
|
| 455 | + if (!$resource_amount) { |
|
| 456 | 456 | continue; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -473,19 +473,19 @@ discard block |
||
| 473 | 473 | $objFleet2->setDbId($this->db_id); |
| 474 | 474 | |
| 475 | 475 | // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли |
| 476 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
| 476 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
| 477 | 477 | $objFleet2->dbDelete(); |
| 478 | - } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
| 478 | + } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
| 479 | 479 | $objFleet2->dbDelete(); |
| 480 | 480 | } else { |
| 481 | - if($ship_count_lost) { |
|
| 481 | + if ($ship_count_lost) { |
|
| 482 | 482 | // Просматриваем результаты изменения флотов |
| 483 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
| 483 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
| 484 | 484 | // Перебираем аутком на случай восстановления юнитов |
| 485 | 485 | // if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) { |
| 486 | 486 | // $fleet_real_array[$UBEUnit->unitId] = $units_left; |
| 487 | 487 | // }; |
| 488 | - if(floatval($UBEUnit->units_lost) != 0) { |
|
| 488 | + if (floatval($UBEUnit->units_lost) != 0) { |
|
| 489 | 489 | $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost)); |
| 490 | 490 | }; |
| 491 | 491 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | $objFleet2->resourcesAdjust($resource_delta_fleet); |
| 496 | 496 | |
| 497 | 497 | // Если защитник и не РМФ - отправляем флот назад |
| 498 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
| 498 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
| 499 | 499 | $objFleet2->markReturned(); |
| 500 | 500 | } |
| 501 | 501 | $objFleet2->dbSave(); |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | public function calculate_unit_partial_data(UBEASA $side_ASA) { |
| 526 | 526 | $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor(); |
| 527 | 527 | |
| 528 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
| 528 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
| 529 | 529 | $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor(); |
| 530 | 530 | } |
| 531 | 531 | } |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | * @version 2016-02-25 23:42:45 41a4.68 |
| 538 | 538 | */ |
| 539 | 539 | public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) { |
| 540 | - foreach($fleet_list->_container as $defending_fleet) { |
|
| 540 | + foreach ($fleet_list->_container as $defending_fleet) { |
|
| 541 | 541 | // Не атакуются флоты на своей стороне |
| 542 | - if($this->is_attacker == $defending_fleet->is_attacker) { |
|
| 542 | + if ($this->is_attacker == $defending_fleet->is_attacker) { |
|
| 543 | 543 | continue; |
| 544 | 544 | } |
| 545 | 545 | $this->attack_fleet($defending_fleet, $is_simulator); |
@@ -555,12 +555,12 @@ discard block |
||
| 555 | 555 | public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) { |
| 556 | 556 | UBEDebug::unit_dump_header(); |
| 557 | 557 | |
| 558 | - foreach($this->unit_list->_container as $attacking_unit_pool) { |
|
| 558 | + foreach ($this->unit_list->_container as $attacking_unit_pool) { |
|
| 559 | 559 | UBEDebug::unit_dump($attacking_unit_pool, 'attacker'); |
| 560 | 560 | |
| 561 | 561 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
| 562 | - foreach($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
| 563 | - if($defending_unit_pool->isEmpty()) { |
|
| 562 | + foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
| 563 | + if ($defending_unit_pool->isEmpty()) { |
|
| 564 | 564 | continue; |
| 565 | 565 | } |
| 566 | 566 | |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | * |
| 11 | 11 | * @param Fleet $objFleet |
| 12 | 12 | * @param bool $start |
| 13 | - * @param null $result |
|
| 13 | + * @param integer $result |
|
| 14 | 14 | * |
| 15 | 15 | * @return mixed |
| 16 | 16 | */ |
@@ -19,15 +19,11 @@ discard block |
||
| 19 | 19 | // ------------------------------------------------------------------ |
| 20 | 20 | function flt_flyingFleetsSort($a, $b) { |
| 21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
| 22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
| 23 | - // Если время - одинаковое, сравниваем события флотов |
|
| 22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
| 24 | 23 | // Если события - одинаковые, то флоты равны |
| 25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
| 26 | - // Если события разные - первыми считаем прибывающие флоты |
|
| 27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
| 28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
| 29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
| 30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
| 24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
| 25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
| 26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
| 31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
| 32 | 28 | ( |
| 33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -45,13 +41,13 @@ discard block |
||
| 45 | 41 | $handler = fopen('event.log', 'a+'); |
| 46 | 42 | } |
| 47 | 43 | |
| 48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
| 44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
| 49 | 45 | } |
| 50 | 46 | |
| 51 | 47 | // ------------------------------------------------------------------ |
| 52 | 48 | function flt_flying_fleet_handler($skip_fleet_update = false) { |
| 53 | 49 | if (true) { |
| 54 | - if(!defined('IN_AJAX')) { |
|
| 50 | + if (!defined('IN_AJAX')) { |
|
| 55 | 51 | print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>'); |
| 56 | 52 | pdump('Fleet handler is disabled'); |
| 57 | 53 | } |
@@ -177,7 +173,7 @@ discard block |
||
| 177 | 173 | MT_EXPLORE => 'flt_mission_explore', |
| 178 | 174 | ); |
| 179 | 175 | foreach ($missions_used as $mission_id => $cork) { |
| 180 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
| 176 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
| 181 | 177 | } |
| 182 | 178 | |
| 183 | 179 | //log_file('Обработка миссий'); |