@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function offsetSet($offset, $value) { |
91 | 91 | if (isset($this->mapUnitIdToDb[$value->unitId])) { |
92 | - classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists'); |
|
92 | + classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId '.$value->unitId.' already exists'); |
|
93 | 93 | } |
94 | 94 | $this->mapUnitIdToDb[$value->unitId] = $value; |
95 | 95 | parent::offsetSet($offset, $value); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | public function unitGetCount($unit_id) { |
204 | 204 | if (empty($this->mapUnitIdToDb[$unit_id])) { |
205 | - throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList'); |
|
205 | + throw new Exception('Unit ['.$unit_id.'] is not exists in UnitList'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return $this->mapUnitIdToDb[$unit_id]->count; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function unitsCostInMetal($shipCostInMetalPerPiece) { |
249 | 249 | $shipsCostInMetal = array(); |
250 | - foreach($this->mapUnitIdToDb as $ship_id => $ship) { |
|
250 | + foreach ($this->mapUnitIdToDb as $ship_id => $ship) { |
|
251 | 251 | $shipsCostInMetal[$ship_id] = $ship->count * $shipCostInMetalPerPiece[$ship_id]; |
252 | 252 | } |
253 | 253 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | */ |
330 | 330 | $objFleet = $this->getLocatedAt(); |
331 | 331 | if (empty($objFleet)) { |
332 | - throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__); |
|
332 | + throw new Exception('No fleet owner on UnitList::unitsRender() in '.__FILE__.'@'.__LINE__); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | $tplShips = array(); |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | |
473 | 473 | // TODO - DEBUG - REMOVE ============================================================================================= |
474 | 474 | public function _dump() { |
475 | - print(__FILE__ . ':' . __LINE__ . "<br />"); |
|
476 | - print("Located at " . $this->getLocationDbId() . " type " . $this->getLocationType() . "<br />"); |
|
475 | + print(__FILE__.':'.__LINE__."<br />"); |
|
476 | + print("Located at ".$this->getLocationDbId()." type ".$this->getLocationType()."<br />"); |
|
477 | 477 | |
478 | 478 | print('<table border="1">'); |
479 | 479 | print('<tr>'); |
@@ -529,11 +529,11 @@ discard block |
||
529 | 529 | |
530 | 530 | print('<td>'); |
531 | 531 | $type = $unit->getType(); |
532 | - print("[{$type}] " . classLocale::$lang['tech'][$type]); |
|
532 | + print("[{$type}] ".classLocale::$lang['tech'][$type]); |
|
533 | 533 | print('</td>'); |
534 | 534 | |
535 | 535 | print('<td>'); |
536 | - print("[{$unit->unitId}] " . classLocale::$lang['tech'][$unit->unitId]); |
|
536 | + print("[{$unit->unitId}] ".classLocale::$lang['tech'][$unit->unitId]); |
|
537 | 537 | print('</td>'); |
538 | 538 | |
539 | 539 | print('<td>'); |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | parent::__construct(); |
325 | 325 | $this->exists_missions = sn_get_groups('missions'); |
326 | 326 | $this->allowed_missions = $this->exists_missions; |
327 | - if(empty(static::$snGroupFleet)) { |
|
327 | + if (empty(static::$snGroupFleet)) { |
|
328 | 328 | static::$snGroupFleet = sn_get_groups('fleet'); |
329 | 329 | static::$snGroupFleetAndMissiles = sn_get_groups(array('fleet', 'missile')); |
330 | 330 | static::$snGroupRecyclers = sn_get_groups('flt_recyclers'); |
@@ -407,31 +407,31 @@ discard block |
||
407 | 407 | |
408 | 408 | return doquery( |
409 | 409 | // Блокировка самого флота |
410 | - "SELECT 1 FROM {{fleets}} AS f " . |
|
410 | + "SELECT 1 FROM {{fleets}} AS f ". |
|
411 | 411 | |
412 | 412 | // Блокировка всех юнитов, принадлежащих этому флоту |
413 | - "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " . |
|
413 | + "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ". |
|
414 | 414 | |
415 | 415 | // Блокировка всех прилетающих и улетающих флотов, если нужно |
416 | 416 | // TODO - lock fleets by COORDINATES |
417 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') . |
|
417 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : ''). |
|
418 | 418 | // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination |
419 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') . |
|
419 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : ''). |
|
420 | 420 | |
421 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') . |
|
421 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : ''). |
|
422 | 422 | // Блокировка всех юнитов, принадлежащих владельцу планеты-цели |
423 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') . |
|
423 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : ''). |
|
424 | 424 | // Блокировка планеты-цели |
425 | - ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') . |
|
425 | + ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : ''). |
|
426 | 426 | // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели |
427 | 427 | // ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') . |
428 | 428 | |
429 | 429 | |
430 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') . |
|
430 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : ''). |
|
431 | 431 | // Блокировка всех юнитов, принадлежащих владельцу флота |
432 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') . |
|
432 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : ''). |
|
433 | 433 | // Блокировка планеты отправления |
434 | - ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') . |
|
434 | + ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : ''). |
|
435 | 435 | // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота |
436 | 436 | // ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') . |
437 | 437 | |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | public function dbGetLockById($dbId) { |
449 | 449 | doquery( |
450 | 450 | // Блокировка самого флота |
451 | - "SELECT 1 FROM {{fleets}} AS FLEET0 " . |
|
451 | + "SELECT 1 FROM {{fleets}} AS FLEET0 ". |
|
452 | 452 | // Lock fleet owner |
453 | - "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " . |
|
453 | + "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ". |
|
454 | 454 | // Блокировка всех юнитов, принадлежащих этому флоту |
455 | - "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " . |
|
455 | + "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ". |
|
456 | 456 | |
457 | 457 | // Без предварительной выборки неизвестно - куда летит этот флот. |
458 | 458 | // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота. |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | FLEET1.fleet_end_planet = FLEET0.fleet_end_planet |
469 | 469 | " . |
470 | 470 | // Блокировка всех юнитов, принадлежащих этим флотам |
471 | - "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " . |
|
471 | + "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ". |
|
472 | 472 | // Lock fleet owner |
473 | - "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " . |
|
473 | + "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ". |
|
474 | 474 | |
475 | 475 | "LEFT JOIN {{fleets}} AS FLEET2 ON |
476 | 476 | FLEET2.fleet_mess = 1 AND FLEET0.fleet_mess = 0 AND |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | " . |
481 | 481 | // Блокировка всех юнитов, принадлежащих этим флотам |
482 | 482 | "LEFT JOIN {{unit}} as UNIT2 ON |
483 | - UNIT2.unit_location_type = " . LOC_FLEET . " AND |
|
483 | + UNIT2.unit_location_type = " . LOC_FLEET." AND |
|
484 | 484 | UNIT2.unit_location_id = FLEET2.fleet_id |
485 | 485 | " . |
486 | 486 | // Lock fleet owner |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | " . |
498 | 498 | // Блокировка всех юнитов, принадлежащих этим флотам |
499 | 499 | "LEFT JOIN {{unit}} as UNIT3 ON |
500 | - UNIT3.unit_location_type = " . LOC_FLEET . " AND |
|
500 | + UNIT3.unit_location_type = " . LOC_FLEET." AND |
|
501 | 501 | UNIT3.unit_location_id = FLEET3.fleet_id |
502 | 502 | " . |
503 | 503 | // Lock fleet owner |
504 | - "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " . |
|
504 | + "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ". |
|
505 | 505 | |
506 | 506 | "LEFT JOIN {{fleets}} AS FLEET4 ON |
507 | 507 | FLEET4.fleet_mess = 1 AND FLEET0.fleet_mess = 1 AND |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | " . |
512 | 512 | // Блокировка всех юнитов, принадлежащих этим флотам |
513 | 513 | "LEFT JOIN {{unit}} as UNIT4 ON |
514 | - UNIT4.unit_location_type = " . LOC_FLEET . " AND |
|
514 | + UNIT4.unit_location_type = " . LOC_FLEET." AND |
|
515 | 515 | UNIT4.unit_location_id = FLEET4.fleet_id |
516 | 516 | " . |
517 | 517 | // Lock fleet owner |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | " . |
534 | 534 | // Блокировка всех юнитов, принадлежащих этой планете |
535 | 535 | "LEFT JOIN {{unit}} as UNIT5 ON |
536 | - UNIT5.unit_location_type = " . LOC_PLANET . " AND |
|
536 | + UNIT5.unit_location_type = " . LOC_PLANET." AND |
|
537 | 537 | UNIT5.unit_location_id = PLANETS5.id |
538 | 538 | " . |
539 | 539 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | " . |
552 | 552 | // Блокировка всех юнитов, принадлежащих этой планете |
553 | 553 | "LEFT JOIN {{unit}} as UNIT6 ON |
554 | - UNIT6.unit_location_type = " . LOC_PLANET . " AND |
|
554 | + UNIT6.unit_location_type = " . LOC_PLANET." AND |
|
555 | 555 | UNIT6.unit_location_id = PLANETS6.id |
556 | 556 | " . |
557 | 557 | "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE" |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | } elseif ($this->isResource($unit_id)) { |
671 | 671 | $this->resource_list[$unit_id] = $unit_count; |
672 | 672 | } else { |
673 | - throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); |
|
673 | + throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | } |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | * @param int $unit_count |
801 | 801 | */ |
802 | 802 | public function shipSetCount($unit_id, $unit_count = 0) { |
803 | -pdump(__CLASS__ . '->' . __FUNCTION__); |
|
803 | +pdump(__CLASS__.'->'.__FUNCTION__); |
|
804 | 804 | $this->shipAdjustCount($unit_id, $unit_count, true); |
805 | 805 | } |
806 | 806 | |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | */ |
877 | 877 | public function shipsGetCapacityRecyclers($recycler_info) { |
878 | 878 | $recyclers_incoming_capacity = 0; |
879 | - foreach($this->shipsIterator() as $unitId => $unit) { |
|
880 | - if(!empty(static::$snGroupRecyclers[$unitId]) && $unit->count >= 1) { |
|
879 | + foreach ($this->shipsIterator() as $unitId => $unit) { |
|
880 | + if (!empty(static::$snGroupRecyclers[$unitId]) && $unit->count >= 1) { |
|
881 | 881 | $recyclers_incoming_capacity += $unit->count * $recycler_info[$unitId]['capacity']; |
882 | 882 | } |
883 | 883 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | public function resourcesSet($resource_list) { |
1010 | 1010 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
1011 | - throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
|
1011 | + throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR); |
|
1012 | 1012 | } |
1013 | 1013 | $this->resourcesAdjust($resource_list, true); |
1014 | 1014 | } |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | // Check for negative unit value |
1043 | 1043 | if ($this->resource_list[$resource_id] < 0) { |
1044 | 1044 | // TODO |
1045 | - throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
|
1045 | + throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR); |
|
1046 | 1046 | } |
1047 | 1047 | } |
1048 | 1048 | } |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | protected function printErrorIfNoShips() { |
1217 | 1217 | if ($this->unitList->unitsCount() <= 0) { |
1218 | - message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
1218 | + message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5); |
|
1219 | 1219 | } |
1220 | 1220 | } |
1221 | 1221 | |
@@ -1550,8 +1550,8 @@ discard block |
||
1550 | 1550 | |
1551 | 1551 | public function fleetSpeed() { |
1552 | 1552 | $maxSpeed = PHP_INT_MAX; |
1553 | - foreach($this->shipsIterator() as $ship_id => $unit) { |
|
1554 | - if($unit->count > 0 && empty(static::$snGroupFleetAndMissiles[$ship_id])) { |
|
1553 | + foreach ($this->shipsIterator() as $ship_id => $unit) { |
|
1554 | + if ($unit->count > 0 && empty(static::$snGroupFleetAndMissiles[$ship_id])) { |
|
1555 | 1555 | $single_ship_data = get_ship_data($ship_id, $this->dbOwnerRow); |
1556 | 1556 | $maxSpeed = min($maxSpeed, $single_ship_data['speed']); |
1557 | 1557 | } |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | } catch (Exception $e) { |
1575 | 1575 | |
1576 | 1576 | // TODO - MESSAGE BOX |
1577 | - if($e instanceof ExceptionFleetInvalid) { |
|
1577 | + if ($e instanceof ExceptionFleetInvalid) { |
|
1578 | 1578 | sn_db_transaction_rollback(); |
1579 | 1579 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
1580 | 1580 | } else { |
@@ -1663,7 +1663,7 @@ discard block |
||
1663 | 1663 | $validator->validate(); |
1664 | 1664 | } catch (Exception $e) { |
1665 | 1665 | // TODO - MESSAGE BOX |
1666 | - if($e instanceof ExceptionFleetInvalid) { |
|
1666 | + if ($e instanceof ExceptionFleetInvalid) { |
|
1667 | 1667 | sn_db_transaction_rollback(); |
1668 | 1668 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
1669 | 1669 | } else { |
@@ -1724,7 +1724,7 @@ discard block |
||
1724 | 1724 | |
1725 | 1725 | |
1726 | 1726 | if (!empty($this->captain['unit_id'])) { |
1727 | - DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}"); |
|
1727 | + DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}"); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | // return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration']; |
@@ -1736,7 +1736,7 @@ discard block |
||
1736 | 1736 | $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob); |
1737 | 1737 | |
1738 | 1738 | $template_result += array( |
1739 | - 'mission' => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''), |
|
1739 | + 'mission' => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''), |
|
1740 | 1740 | 'dist' => pretty_number($this->travelData['distance']), |
1741 | 1741 | 'speed' => pretty_number($this->travelData['fleet_speed']), |
1742 | 1742 | 'deute_need' => pretty_number($this->travelData['consumption']), |
@@ -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 |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | // Compare function to sort fleet in time order |
4 | 4 | function tpl_assign_fleet_compare($a, $b) { |
5 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
5 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
7 | 7 | return 0; |
8 | 8 | } |
9 | 9 | |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | * @param string $js_name |
20 | 20 | */ |
21 | 21 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
22 | - if(!$fleets) { |
|
22 | + if (!$fleets) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | 26 | usort($fleets, 'tpl_assign_fleet_compare'); |
27 | 27 | |
28 | - foreach($fleets as $fleet_data) { |
|
28 | + foreach ($fleets as $fleet_data) { |
|
29 | 29 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
30 | 30 | |
31 | - if($fleet_data['ships']) { |
|
32 | - foreach($fleet_data['ships'] as $ship_data) { |
|
31 | + if ($fleet_data['ships']) { |
|
32 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
33 | 33 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
34 | 34 | } |
35 | 35 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
51 | 51 | ); |
52 | 52 | |
53 | - foreach($fleet as $ship_id => $ship_amount) { |
|
54 | - if(in_array($ship_id, Fleet::$snGroupFleet)) { |
|
53 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
54 | + if (in_array($ship_id, Fleet::$snGroupFleet)) { |
|
55 | 55 | $single_ship_data = get_ship_data($ship_id, $user_data); |
56 | 56 | $return['ships'][$ship_id] = array( |
57 | 57 | 'ID' => $ship_id, |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | $result = array(); |
92 | 92 | |
93 | - if(!$user_data) { |
|
93 | + if (!$user_data) { |
|
94 | 94 | $user_data = $user; |
95 | 95 | } |
96 | 96 | |
97 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
97 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) { |
|
98 | 98 | $aks = DBStaticFleetACS::db_acs_get_by_group_id($objFleet->group_id); |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'MISSION' => $objFleet->mission_type, |
114 | 114 | 'MISSION_NAME' => classLocale::$lang['type_mission'][$objFleet->mission_type], |
115 | 115 | 'ACS' => !empty($aks['name']) ? $aks['name'] : (!empty($objFleet->group_id) ? $objFleet->group_id : ''), |
116 | - 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()) . (array_sum($fleet_resources) ? '+' : '')) : '?', |
|
116 | + 'AMOUNT' => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()).(array_sum($fleet_resources) ? '+' : '')) : '?', |
|
117 | 117 | |
118 | 118 | 'METAL' => $spy_level >= 8 ? $fleet_resources[RES_METAL] : 0, |
119 | 119 | 'CRYSTAL' => $spy_level >= 8 ? $fleet_resources[RES_CRYSTAL] : 0, |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
136 | 136 | ); |
137 | 137 | |
138 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
138 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
139 | 139 | $result['START_NAME'] = $objFleet->fleet_start_name; |
140 | 140 | } |
141 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
141 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
142 | 142 | $result['END_NAME'] = $objFleet->fleet_end_name; |
143 | 143 | } |
144 | 144 | |
145 | - if(property_exists($objFleet, 'event_time')) { |
|
145 | + if (property_exists($objFleet, 'event_time')) { |
|
146 | 146 | $result['fleet'] = array_merge($result['fleet'], array( |
147 | 147 | 'OV_LABEL' => $objFleet->ov_label, |
148 | 148 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | |
154 | 154 | $ship_id = 0; |
155 | 155 | $result['ships'] = array(); |
156 | - if($spy_level >= 6) { |
|
157 | - foreach($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
158 | - if($spy_level >= 10) { |
|
156 | + if ($spy_level >= 6) { |
|
157 | + foreach ($objFleet->shipsIterator() as $ship_sn_id => $ship) { |
|
158 | + if ($spy_level >= 10) { |
|
159 | 159 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
160 | 160 | $result['ships'][$ship_sn_id] = array( |
161 | 161 | 'ID' => $ship_sn_id, |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | function tpl_parse_planet_que($que, $planet, $que_id) { |
189 | 189 | $hangar_que = array(); |
190 | 190 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
191 | - if(!empty($que_hangar)) { |
|
192 | - foreach($que_hangar as $que_item) { |
|
191 | + if (!empty($que_hangar)) { |
|
192 | + foreach ($que_hangar as $que_item) { |
|
193 | 193 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
194 | 194 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
195 | 195 | } |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
250 | 250 | ); |
251 | 251 | |
252 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
252 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
253 | 253 | $result['building_que'] = array(); |
254 | 254 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
255 | - foreach($building_que as $que_element) { |
|
255 | + foreach ($building_que as $que_element) { |
|
256 | 256 | $result['building_que'][] = que_tpl_parse_element($que_element); |
257 | 257 | } |
258 | 258 | } |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | static $snGroupFleet; |
272 | 272 | !$snGroupFleet ? $snGroupFleet = Fleet::$snGroupFleet : false; |
273 | 273 | |
274 | - if(empty($array_of_Fleet)) { |
|
274 | + if (empty($array_of_Fleet)) { |
|
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | 278 | $fleet_list = array(); |
279 | - foreach($array_of_Fleet as $fleet) { |
|
280 | - if($fleet->playerOwnerId == $user['id']) { |
|
281 | - if($fleet->mission_type == MT_MISSILE) { |
|
279 | + foreach ($array_of_Fleet as $fleet) { |
|
280 | + if ($fleet->playerOwnerId == $user['id']) { |
|
281 | + if ($fleet->mission_type == MT_MISSILE) { |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | $fleet_ownage = 'own'; |
285 | 285 | } else { |
286 | - switch($fleet->mission_type) { |
|
286 | + switch ($fleet->mission_type) { |
|
287 | 287 | case MT_ATTACK: |
288 | 288 | case MT_ACS: |
289 | 289 | case MT_DESTROY: |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | |
301 | 301 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
302 | 302 | |
303 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
304 | - foreach($fleet->shipsIterator() as $ship_id => $ship) { |
|
305 | - if(!empty($snGroupFleet[$ship_id])) { |
|
303 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
304 | + foreach ($fleet->shipsIterator() as $ship_id => $ship) { |
|
305 | + if (!empty($snGroupFleet[$ship_id])) { |
|
306 | 306 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship->count; |
307 | 307 | } |
308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | return $fleet_list; |
320 | 320 | } |
321 | 321 | |
322 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
322 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
323 | 323 | $template->assign_vars(array( |
324 | 324 | 'RESOURCE_ROUNDING' => $round, |
325 | 325 |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function flt_fleet_speed($user, $fleet) { |
4 | - if(!is_array($fleet)) { |
|
4 | + if (!is_array($fleet)) { |
|
5 | 5 | $fleet = array($fleet => 1); |
6 | 6 | } |
7 | 7 | |
8 | 8 | $speeds = array(); |
9 | - if(!empty($fleet)) { |
|
10 | - foreach($fleet as $ship_id => $amount) { |
|
11 | - if($amount && in_array($ship_id, Fleet::$snGroupFleetAndMissiles)) { |
|
9 | + if (!empty($fleet)) { |
|
10 | + foreach ($fleet as $ship_id => $amount) { |
|
11 | + if ($amount && in_array($ship_id, Fleet::$snGroupFleetAndMissiles)) { |
|
12 | 12 | $single_ship_data = get_ship_data($ship_id, $user); |
13 | 13 | $speeds[] = $single_ship_data['speed']; |
14 | 14 | } |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | |
41 | 41 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
42 | 42 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
43 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
43 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) { |
|
44 | 44 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
45 | 45 | $real_speed = $speed_percent * sqrt($fleet_speed); |
46 | 46 | |
47 | 47 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
48 | 48 | |
49 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
50 | - if(!$ship_id || !$ship_count) { |
|
49 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
50 | + if (!$ship_id || !$ship_count) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) { |
76 | 76 | $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks; |
77 | 77 | $config_bashing_interval = classSupernova::$config->fleet_bashing_interval; |
78 | - if(!$config_bashing_attacks) { |
|
78 | + if (!$config_bashing_attacks) { |
|
79 | 79 | // Bashing allowed - protection disabled |
80 | 80 | return FLIGHT_ALLOWED; |
81 | 81 | } |
82 | 82 | |
83 | 83 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING; |
84 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
84 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
85 | 85 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
86 | - if(!empty($relations)) { |
|
86 | + if (!empty($relations)) { |
|
87 | 87 | $relations = $relations[$enemy['ally_id']]; |
88 | - switch($relations['alliance_diplomacy_relation']) { |
|
88 | + switch ($relations['alliance_diplomacy_relation']) { |
|
89 | 89 | case ALLY_DIPLOMACY_WAR: |
90 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
90 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) { |
|
91 | 91 | $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY; |
92 | 92 | } else { |
93 | 93 | return FLIGHT_ALLOWED; |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | |
110 | 110 | // Retrieving flying fleets |
111 | 111 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst); |
112 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
112 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
113 | 113 | // Checking for ACS - each ACS count only once |
114 | - if($fleetBashing->group_id) { |
|
114 | + if ($fleetBashing->group_id) { |
|
115 | 115 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
116 | 116 | } else { |
117 | 117 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
122 | - if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
122 | + if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
123 | 123 | return FLIGHT_ALLOWED; |
124 | 124 | } |
125 | 125 | |
126 | 126 | $query = DBStaticFleetBashing::db_bashing_list_get($user, $planet_dst, $time_limit); |
127 | - while($bashing_row = db_fetch($query)) { |
|
127 | + while ($bashing_row = db_fetch($query)) { |
|
128 | 128 | $bashing_list[] = $bashing_row['bashing_time']; |
129 | 129 | } |
130 | 130 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | $last_attack = 0; |
134 | 134 | $wave = 0; |
135 | 135 | $attack = 1; |
136 | - foreach($bashing_list as &$bash_time) { |
|
136 | + foreach ($bashing_list as &$bash_time) { |
|
137 | 137 | $attack++; |
138 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
138 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
139 | 139 | $attack = 1; |
140 | 140 | $wave++; |
141 | 141 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | //TODO: try..catch |
153 | 153 | global $user; |
154 | 154 | |
155 | - if($user['vacation']) { |
|
155 | + if ($user['vacation']) { |
|
156 | 156 | return $result = FLIGHT_PLAYER_VACATION_OWN; |
157 | 157 | } |
158 | 158 | |
159 | - if(empty($fleet) || !is_array($fleet)) { |
|
159 | + if (empty($fleet) || !is_array($fleet)) { |
|
160 | 160 | return $result = FLIGHT_SHIPS_NO_SHIPS; |
161 | 161 | } |
162 | 162 | |
163 | 163 | $sn_groups_mission = sn_get_groups('missions'); |
164 | - if(!isset($sn_groups_mission[$mission])) { |
|
164 | + if (!isset($sn_groups_mission[$mission])) { |
|
165 | 165 | return $result = FLIGHT_MISSION_UNKNOWN; |
166 | 166 | } |
167 | 167 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -180,32 +180,32 @@ discard block |
||
180 | 180 | $resources = 0; |
181 | 181 | $ship_ids = Fleet::$snGroupFleet; |
182 | 182 | $resource_ids = sn_get_groups('resources_loot'); |
183 | - foreach($fleet as $ship_id => $ship_count) { |
|
183 | + foreach ($fleet as $ship_id => $ship_count) { |
|
184 | 184 | $is_ship = in_array($ship_id, $ship_ids); |
185 | 185 | $is_resource = in_array($ship_id, $resource_ids); |
186 | - if(!$is_ship && !$is_resource) { |
|
186 | + if (!$is_ship && !$is_resource) { |
|
187 | 187 | // TODO Спецобработчик для Капитана и модулей |
188 | 188 | // return FLIGHT_SHIPS_UNIT_WRONG; |
189 | 189 | } |
190 | 190 | |
191 | - if($ship_count < 0) { |
|
191 | + if ($ship_count < 0) { |
|
192 | 192 | return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE; |
193 | 193 | } |
194 | 194 | |
195 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
195 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
196 | 196 | // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES |
197 | 197 | return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH; |
198 | 198 | } |
199 | 199 | |
200 | - if($is_ship) { |
|
200 | + if ($is_ship) { |
|
201 | 201 | $single_ship_data = get_ship_data($ship_id, $user); |
202 | - if($single_ship_data[P_SPEED] <= 0) { |
|
202 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
203 | 203 | return $result = FLIGHT_SHIPS_UNMOVABLE; |
204 | 204 | } |
205 | 205 | $ships += $ship_count; |
206 | 206 | $recyclers += in_array($ship_id, Fleet::$snGroupRecyclers) ? $ship_count : 0; |
207 | 207 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
208 | - } elseif($is_resource) { |
|
208 | + } elseif ($is_resource) { |
|
209 | 209 | $resources += $ship_count; |
210 | 210 | } |
211 | 211 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | */ |
218 | 218 | |
219 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
219 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
220 | 220 | return $result = FLIGHT_RESOURCES_FORBIDDEN; |
221 | 221 | } |
222 | 222 | |
@@ -228,78 +228,78 @@ discard block |
||
228 | 228 | */ |
229 | 229 | |
230 | 230 | $speed = $options['fleet_speed_percent']; |
231 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
231 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
232 | 232 | return $result = FLIGHT_FLEET_SPEED_WRONG; |
233 | 233 | } |
234 | 234 | |
235 | 235 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
236 | 236 | |
237 | 237 | |
238 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
238 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
239 | 239 | return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH; |
240 | 240 | } |
241 | 241 | |
242 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
242 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
243 | 243 | return $result = FLIGHT_FLEET_TOO_FAR; |
244 | 244 | } |
245 | 245 | |
246 | - if($travel_data['hold'] < $resources) { |
|
246 | + if ($travel_data['hold'] < $resources) { |
|
247 | 247 | return $result = FLIGHT_FLEET_OVERLOAD; |
248 | 248 | } |
249 | 249 | |
250 | 250 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
251 | 251 | |
252 | 252 | $fleet_group = $options['fleet_group']; |
253 | - if($fleet_group) { |
|
254 | - if($mission != MT_ACS) { |
|
253 | + if ($fleet_group) { |
|
254 | + if ($mission != MT_ACS) { |
|
255 | 255 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
256 | 256 | }; |
257 | 257 | |
258 | 258 | $acs = DBStaticFleetACS::db_acs_get_by_group_id($fleet_group); |
259 | - if(!$acs['id']) { |
|
259 | + if (!$acs['id']) { |
|
260 | 260 | return $result = FLIGHT_MISSION_ACS_NOT_EXISTS; |
261 | 261 | } |
262 | 262 | |
263 | - if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
263 | + if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) { |
|
264 | 264 | return $result = FLIGHT_MISSION_ACS_WRONG_TARGET; |
265 | 265 | } |
266 | 266 | |
267 | - if($fleet_start_time > $acs['ankunft']) { |
|
267 | + if ($fleet_start_time > $acs['ankunft']) { |
|
268 | 268 | return $result = FLIGHT_MISSION_ACS_TOO_LATE; |
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | 272 | $flying_fleets = $options['flying_fleets']; |
273 | - if(!$flying_fleets) { |
|
273 | + if (!$flying_fleets) { |
|
274 | 274 | $flying_fleets = FleetList::fleet_count_flying($user['id']); |
275 | 275 | } |
276 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
276 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
277 | 277 | return $result = FLIGHT_FLEET_NO_SLOTS; |
278 | 278 | } |
279 | 279 | |
280 | 280 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
281 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
281 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
282 | 282 | return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES; |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Checking for no planet |
286 | - if(!$planet_dst['id_owner']) { |
|
287 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
286 | + if (!$planet_dst['id_owner']) { |
|
287 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
288 | 288 | return $result = FLIGHT_SHIPS_NO_COLONIZER; |
289 | 289 | } |
290 | 290 | |
291 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
291 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
292 | 292 | return $result = FLIGHT_ALLOWED; |
293 | 293 | } |
294 | 294 | |
295 | 295 | return $result = FLIGHT_VECTOR_NO_TARGET; |
296 | 296 | } |
297 | 297 | |
298 | - if($mission == MT_RECYCLE) { |
|
299 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
298 | + if ($mission == MT_RECYCLE) { |
|
299 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
300 | 300 | return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS; |
301 | 301 | } |
302 | - if($recyclers <= 0) { |
|
302 | + if ($recyclers <= 0) { |
|
303 | 303 | return $result = FLIGHT_SHIPS_NO_RECYCLERS; |
304 | 304 | } |
305 | 305 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | // Got planet. Checking if it is ours |
310 | - if($planet_dst['id_owner'] == $user['id']) { |
|
311 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
310 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
311 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
312 | 312 | return $result = FLIGHT_ALLOWED; |
313 | 313 | } |
314 | 314 | |
@@ -316,19 +316,19 @@ discard block |
||
316 | 316 | } |
317 | 317 | |
318 | 318 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
319 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
319 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
320 | 320 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
321 | 321 | } |
322 | 322 | |
323 | 323 | $enemy = DBStaticUser::db_user_by_id($planet_dst['id_owner']); |
324 | 324 | // We cannot attack or send resource to users in VACATION mode |
325 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
325 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
326 | 326 | return $result = FLIGHT_PLAYER_VACATION; |
327 | 327 | } |
328 | 328 | |
329 | 329 | // Multi IP protection |
330 | 330 | // TODO: Here we need a procedure to check proxies |
331 | - if(sys_is_multiaccount($user, $enemy)) { |
|
331 | + if (sys_is_multiaccount($user, $enemy)) { |
|
332 | 332 | return $result = FLIGHT_PLAYER_SAME_IP; |
333 | 333 | } |
334 | 334 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | $enemy_points = $enemy['total_points']; |
337 | 337 | |
338 | 338 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
339 | - if($mission == MT_TRANSPORT) { |
|
340 | - if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
339 | + if ($mission == MT_TRANSPORT) { |
|
340 | + if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) { |
|
341 | 341 | return $result = FLIGHT_ALLOWED; |
342 | 342 | } else { |
343 | 343 | return $result = FLIGHT_PLAYER_BUFFING; |
@@ -347,66 +347,66 @@ discard block |
||
347 | 347 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
348 | 348 | |
349 | 349 | // Is it admin with planet protection? |
350 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
350 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
351 | 351 | return $result = FLIGHT_PLAYER_ADMIN; |
352 | 352 | } |
353 | 353 | |
354 | 354 | // Okay. Now skipping protection checks for inactive longer then 1 week |
355 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
356 | - if( |
|
355 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
356 | + if ( |
|
357 | 357 | ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points) |
358 | 358 | || |
359 | 359 | (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor) |
360 | 360 | ) { |
361 | - if($mission != MT_HOLD) { |
|
361 | + if ($mission != MT_HOLD) { |
|
362 | 362 | return $result = FLIGHT_PLAYER_NOOB; |
363 | 363 | } |
364 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
364 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) { |
|
365 | 365 | return $result = FLIGHT_PLAYER_NOOB; |
366 | 366 | } |
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | // Is it HOLD mission? If yes - there should be ally deposit |
371 | - if($mission == MT_HOLD) { |
|
372 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
371 | + if ($mission == MT_HOLD) { |
|
372 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
373 | 373 | return $result = FLIGHT_ALLOWED; |
374 | 374 | } |
375 | 375 | |
376 | 376 | return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT; |
377 | 377 | } |
378 | 378 | |
379 | - if($mission == MT_SPY) { |
|
379 | + if ($mission == MT_SPY) { |
|
380 | 380 | return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Is it MISSILE mission? |
384 | - if($mission == MT_MISSILE) { |
|
384 | + if ($mission == MT_MISSILE) { |
|
385 | 385 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
386 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
386 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
387 | 387 | return $result = FLIGHT_MISSION_MISSILE_NO_SILO; |
388 | 388 | } |
389 | 389 | |
390 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
390 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
391 | 391 | return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES; |
392 | 392 | } |
393 | 393 | |
394 | 394 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
395 | 395 | $mip_range = flt_get_missile_range($user); |
396 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
396 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
397 | 397 | return $result = FLIGHT_MISSION_MISSILE_TOO_FAR; |
398 | 398 | } |
399 | 399 | |
400 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
400 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
401 | 401 | return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE; |
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
405 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
406 | 406 | return $result = FLIGHT_MISSION_IMPOSSIBLE; |
407 | 407 | } |
408 | 408 | |
409 | - if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
409 | + if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) { |
|
410 | 410 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
411 | 411 | } |
412 | 412 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $from = $from['planet']; |
434 | 434 | |
435 | 435 | $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options); |
436 | - if($can_attack != FLIGHT_ALLOWED) { |
|
436 | + if ($can_attack != FLIGHT_ALLOWED) { |
|
437 | 437 | $internal_transaction ? sn_db_transaction_rollback() : false; |
438 | 438 | |
439 | 439 | return $can_attack; |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']); |
445 | 445 | |
446 | 446 | $time_on_mission = 0; |
447 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
447 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
448 | 448 | // TODO - include some checks about maximum and minumum stay_duration |
449 | 449 | $time_on_mission = $options['stay_time'] * 3600; |
450 | 450 | } |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
468 | 468 | $db_changeset = array(); |
469 | 469 | $planet_row_changed_fields = array(); |
470 | - foreach($fleet_REAL_array as $unit_id => $amount) { |
|
471 | - if(!$amount || !$unit_id) { |
|
470 | + foreach ($fleet_REAL_array as $unit_id => $amount) { |
|
471 | + if (!$amount || !$unit_id) { |
|
472 | 472 | continue; |
473 | 473 | } |
474 | 474 | |
475 | - if(in_array($unit_id, $sn_group_fleet)) { |
|
475 | + if (in_array($unit_id, $sn_group_fleet)) { |
|
476 | 476 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$amount, $user, $from['id']); |
477 | - } elseif(in_array($unit_id, $sn_group_resources_loot)) { |
|
477 | + } elseif (in_array($unit_id, $sn_group_resources_loot)) { |
|
478 | 478 | $planet_row_changed_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
479 | 479 | } |
480 | 480 | } |
@@ -513,16 +513,16 @@ discard block |
||
513 | 513 | |
514 | 514 | $ship_data = array(); |
515 | 515 | $fleet_array = array(); |
516 | - foreach($ship_list as $transport_id => $cork) { |
|
516 | + foreach ($ship_list as $transport_id => $cork) { |
|
517 | 517 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
518 | 518 | } |
519 | 519 | uasort($ship_data, 'flt_calculate_ship_to_transport_sort'); |
520 | 520 | |
521 | 521 | $fleet_capacity = 0; |
522 | 522 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
523 | - foreach($ship_data as $transport_id => &$ship_info) { |
|
523 | + foreach ($ship_data as $transport_id => &$ship_info) { |
|
524 | 524 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
525 | - if($ship_loaded) { |
|
525 | + if ($ship_loaded) { |
|
526 | 526 | $fleet_array[$transport_id] = $ship_loaded; |
527 | 527 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
528 | 528 | $fuel_left -= $ship_info['consumption'] * $ship_loaded; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | function flt_mission_recycle($mission_data) { |
13 | 13 | $objFleet = $mission_data->fleet; |
14 | 14 | $destination_planet = &$mission_data->dst_planet; |
15 | - if(empty($destination_planet['id'])) { |
|
15 | + if (empty($destination_planet['id'])) { |
|
16 | 16 | $objFleet->markReturned(); |
17 | 17 | $objFleet->dbSave(); |
18 | 18 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | $RecyclerCapacity = 0; |
23 | 23 | $OtherFleetCapacity = 0; |
24 | 24 | |
25 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
26 | - if(in_array($unit_id, Fleet::$snGroupFleet)) { |
|
25 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
26 | + if (in_array($unit_id, Fleet::$snGroupFleet)) { |
|
27 | 27 | $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count; |
28 | - if(in_array($unit_id, Fleet::$snGroupRecyclers)) { |
|
28 | + if (in_array($unit_id, Fleet::$snGroupRecyclers)) { |
|
29 | 29 | $RecyclerCapacity += $capacity; |
30 | 30 | } else { |
31 | 31 | $OtherFleetCapacity += $capacity; |
@@ -34,33 +34,33 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | $fleet_resources_amount = $objFleet->resourcesGetTotal(); |
37 | - if($fleet_resources_amount > $OtherFleetCapacity) { |
|
37 | + if ($fleet_resources_amount > $OtherFleetCapacity) { |
|
38 | 38 | // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков |
39 | 39 | // Уменьшаем ёмкость переработчиков на указанную величину |
40 | 40 | $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity); |
41 | 41 | } |
42 | 42 | |
43 | 43 | $resources_recycled = array(); |
44 | - if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
44 | + if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) { |
|
45 | 45 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
46 | 46 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
47 | 47 | } else { |
48 | - if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
48 | + if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) && |
|
49 | 49 | ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2) |
50 | 50 | ) { |
51 | 51 | $resources_recycled[RES_METAL] = $RecyclerCapacity / 2; |
52 | 52 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2; |
53 | 53 | } else { |
54 | - if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
54 | + if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) { |
|
55 | 55 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
56 | - if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
56 | + if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) { |
|
57 | 57 | $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL]; |
58 | 58 | } else { |
59 | 59 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
60 | 60 | } |
61 | 61 | } else { |
62 | 62 | $resources_recycled[RES_METAL] = $destination_planet["debris_metal"]; |
63 | - if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
63 | + if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) { |
|
64 | 64 | $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL]; |
65 | 65 | } else { |
66 | 66 | $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"]; |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | */ |
12 | 12 | // ---------------------------------------------------------------------------------------------------------------- |
13 | 13 | function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) { |
14 | - foreach($unit_group as $unit_id) { |
|
15 | - if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
14 | + foreach ($unit_group as $unit_id) { |
|
15 | + if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
16 | 16 | $compress_data[$unit_id] = $unit_count; |
17 | 17 | } |
18 | 18 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | $classLocale = classLocale::$lang; |
23 | 23 | |
24 | 24 | $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>"; |
25 | - foreach(sn_get_groups($group_name) as $unit_id) { |
|
26 | - if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
25 | + foreach (sn_get_groups($group_name) as $unit_id) { |
|
26 | + if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) { |
|
27 | 27 | $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>"; |
28 | 28 | } |
29 | 29 | |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | |
56 | 56 | $objFleet = $mission_data->fleet; |
57 | 57 | |
58 | - if(empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
58 | + if (empty($target_user_row['id']) || empty($target_planet_row['id']) || empty($spying_user_row['id'])) { |
|
59 | 59 | $objFleet->markReturnedAndSave(); |
60 | 60 | |
61 | 61 | return $result; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY); |
65 | - if($spy_probes > 0) { |
|
65 | + if ($spy_probes > 0) { |
|
66 | 66 | $TargetSpyLvl = GetSpyLevel($target_user_row); |
67 | 67 | $CurrentSpyLvl = GetSpyLevel($spying_user_row); |
68 | 68 | $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl; |
@@ -80,26 +80,26 @@ discard block |
||
80 | 80 | $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} "; |
81 | 81 | $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target); |
82 | 82 | $spy_message .= "</td></tr><tr>"; |
83 | - $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>"; |
|
84 | - $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>"; |
|
83 | + $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>"; |
|
84 | + $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>"; |
|
85 | 85 | $spy_message .= "</tr><tr>"; |
86 | - $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>"; |
|
87 | - $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>"; |
|
86 | + $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>"; |
|
87 | + $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>"; |
|
88 | 88 | $spy_message .= "</tr>"; |
89 | - if($spy_diff >= 2) { |
|
90 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>"; |
|
89 | + if ($spy_diff >= 2) { |
|
90 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>"; |
|
91 | 91 | coe_compress_add_units(Fleet::$snGroupFleet, $target_planet_row, $combat_pack[0]); |
92 | 92 | } |
93 | - if($spy_diff >= 3) { |
|
94 | - $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>"; |
|
93 | + if ($spy_diff >= 3) { |
|
94 | + $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>"; |
|
95 | 95 | coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]); |
96 | 96 | } |
97 | - if($spy_diff >= 5) { |
|
98 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>"; |
|
97 | + if ($spy_diff >= 5) { |
|
98 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>"; |
|
99 | 99 | } |
100 | 100 | |
101 | - if($spy_diff_empire >= 0) { |
|
102 | - $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>"; |
|
101 | + if ($spy_diff_empire >= 0) { |
|
102 | + $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>"; |
|
103 | 103 | coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row); |
104 | 104 | } |
105 | 105 | // TODO: Наемники, губернаторы, артефакты и прочее имперское |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D'); |
108 | 108 | |
109 | 109 | $target_unit_list = 0; |
110 | - foreach(Fleet::$snGroupFleet as $unit_id) { |
|
110 | + foreach (Fleet::$snGroupFleet as $unit_id) { |
|
111 | 111 | $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true)); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl); |
115 | 115 | |
116 | - if(mt_rand(0, 99) > $spy_detected) { |
|
116 | + if (mt_rand(0, 99) > $spy_detected) { |
|
117 | 117 | $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected); |
118 | 118 | $spy_detected = false; |
119 | 119 | } else { |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | |
131 | 131 | DBStaticMessages::msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message); |
132 | 132 | |
133 | - $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3); |
|
134 | - $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row); |
|
133 | + $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3); |
|
134 | + $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row); |
|
135 | 135 | |
136 | - if($spy_detected) { |
|
136 | + if ($spy_detected) { |
|
137 | 137 | $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet']; |
138 | 138 | |
139 | 139 | $spy_cost = get_unit_param(SHIP_SPY, P_COST); |
140 | 140 | |
141 | 141 | DBStaticPlanet::db_planet_set_by_id($debris_planet_id, |
142 | - "`debris_metal` = `debris_metal` + " . floor($spy_probes * $spy_cost[RES_METAL] * 0.3) . ", `debris_crystal` = `debris_crystal` + " . floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3)); |
|
142 | + "`debris_metal` = `debris_metal` + ".floor($spy_probes * $spy_cost[RES_METAL] * 0.3).", `debris_crystal` = `debris_crystal` + ".floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3)); |
|
143 | 143 | |
144 | 144 | $target_message .= "<br />{$classLocale['sys_mess_spy_destroyed_enemy']}"; |
145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message); |
151 | 151 | } |
152 | 152 | |
153 | - if($spy_detected) { |
|
153 | + if ($spy_detected) { |
|
154 | 154 | $objFleet->dbDelete(); |
155 | 155 | } else { |
156 | 156 | $objFleet->markReturnedAndSave(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $destination_planet = &$mission_data->dst_planet; |
16 | 16 | |
17 | - if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
17 | + if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
18 | 18 | $objFleet->markReturnedAndSave(); |
19 | 19 | |
20 | 20 | return CACHE_FLEET; |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | $fleet_resources[RES_METAL], classLocale::$lang['Metal'], |
28 | 28 | $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'], |
29 | 29 | $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium'] |
30 | - ) . '<br />' . classLocale::$lang['sys_relocate_mess_user']; |
|
31 | - foreach($objFleet->shipsIterator() as $ship_id => $ship) { |
|
32 | - $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship->count . '<br />'; |
|
30 | + ).'<br />'.classLocale::$lang['sys_relocate_mess_user']; |
|
31 | + foreach ($objFleet->shipsIterator() as $ship_id => $ship) { |
|
32 | + $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship->count.'<br />'; |
|
33 | 33 | } |
34 | 34 | DBStaticMessages::msg_send_simple_message( |
35 | 35 | $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | // TODO - Currently $ship_data is one for all players |
22 | 22 | static $shipCostInMetalPerPiece, $rates; |
23 | 23 | |
24 | - if(empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
24 | + if (empty($mission_data->fleet_event) || $mission_data->fleet_event != EVENT_FLT_ACOMPLISH) { |
|
25 | 25 | return CACHE_NONE; |
26 | 26 | } |
27 | 27 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $outcome_value = &$result['$outcome_value']; |
47 | 47 | $outcome_list = &$result['$outcome_list']; |
48 | 48 | |
49 | - if(!$shipCostInMetalPerPiece) { |
|
49 | + if (!$shipCostInMetalPerPiece) { |
|
50 | 50 | $rates = get_resource_exchange(); |
51 | 51 | |
52 | - foreach(Fleet::$snGroupFleet as $unit_id) { |
|
52 | + foreach (Fleet::$snGroupFleet as $unit_id) { |
|
53 | 53 | $unit_info = get_unit_param($unit_id); |
54 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
54 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | $shipCostInMetalPerPiece[$unit_id] = get_unit_cost_in($unit_info[P_COST], RES_METAL); |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
72 | 72 | |
73 | 73 | $chance_max = 0; |
74 | - foreach($outcome_list as $key => &$value) { |
|
75 | - if(!$value['chance']) { |
|
74 | + foreach ($outcome_list as $key => &$value) { |
|
75 | + if (!$value['chance']) { |
|
76 | 76 | unset($outcome_list[$key]); |
77 | 77 | continue; |
78 | 78 | } |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | } |
81 | 81 | $outcome_value = mt_rand(0, $chance_max); |
82 | 82 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
83 | - foreach($outcome_list as $key => &$value) { |
|
84 | - if(!$value['chance']) { |
|
83 | + foreach ($outcome_list as $key => &$value) { |
|
84 | + if (!$value['chance']) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | $mission_outcome = $key; |
88 | 88 | $outcome_description = $value; |
89 | - if($outcome_value <= $outcome_description['value']) { |
|
89 | + if ($outcome_value <= $outcome_description['value']) { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // $outcome_mission_sub = -1; |
104 | 104 | |
105 | 105 | $fleet_found = array(); |
106 | - switch($mission_outcome) { |
|
106 | + switch ($mission_outcome) { |
|
107 | 107 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
108 | 108 | $objFleet->shipsCountApplyLossMultiplier(mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000); |
109 | 109 | break; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
126 | 126 | $can_be_found = array(); |
127 | - foreach($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
128 | - if($shipMetalCost < $max_metal_cost) { |
|
127 | + foreach ($shipCostInMetalPerPiece as $ship_id => $shipMetalCost) { |
|
128 | + if ($shipMetalCost < $max_metal_cost) { |
|
129 | 129 | $can_be_found[$ship_id] = $shipMetalCost; |
130 | 130 | } |
131 | 131 | } |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | unset($can_be_found[SHIP_COLONIZER]); |
134 | 134 | unset($can_be_found[SHIP_SPY]); |
135 | 135 | |
136 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
136 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
137 | 137 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
138 | 138 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
139 | 139 | $found_ship_cost = reset($found_ship); |
140 | 140 | $found_ship_id = key($found_ship); |
141 | 141 | |
142 | - if($found_ship_cost > $found_in_metal) { |
|
142 | + if ($found_ship_cost > $found_in_metal) { |
|
143 | 143 | unset($can_be_found[$found_ship_id]); |
144 | 144 | } else { |
145 | 145 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if(empty($fleet_found)) { |
|
151 | + if (empty($fleet_found)) { |
|
152 | 152 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
153 | 153 | } else { |
154 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
154 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
155 | 155 | $objFleet->shipAdjustCount($unit_id, $unit_amount); |
156 | 156 | } |
157 | 157 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $objFleet->resourcesAdjust($resources_found); |
177 | 177 | |
178 | - if(array_sum($resources_found) == 0) { |
|
178 | + if (array_sum($resources_found) == 0) { |
|
179 | 179 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
180 | 180 | } |
181 | 181 | break; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | // Рассчитываем количество найденной ТМ |
187 | 187 | $found_dark_matter = floor(min($outcome_percent * $result['$fleet_metal_points'] / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
188 | 188 | |
189 | - if(!$found_dark_matter) { |
|
189 | + if (!$found_dark_matter) { |
|
190 | 190 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
191 | 191 | } |
192 | 192 | break; |
@@ -200,46 +200,45 @@ discard block |
||
200 | 200 | |
201 | 201 | mission_expedition_result_adjust($result, $objFleet); |
202 | 202 | |
203 | - if($found_dark_matter) { |
|
203 | + if ($found_dark_matter) { |
|
204 | 204 | rpg_points_change($objFleet->playerOwnerId, RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
205 | 205 | $msg_text_addon = sprintf(classLocale::$lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
206 | 206 | } |
207 | 207 | |
208 | - if(!empty($fleet_lost)) { |
|
208 | + if (!empty($fleet_lost)) { |
|
209 | 209 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['lost_fleet']; |
210 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
211 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
210 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
211 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if(!empty($fleet_found)) { |
|
215 | + if (!empty($fleet_found)) { |
|
216 | 216 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_fleet']; |
217 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
218 | - $msg_text_addon .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
|
217 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
218 | + $msg_text_addon .= classLocale::$lang['tech'][$ship_id].' - '.$ship_amount."\r\n"; |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
222 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
223 | 223 | $msg_text_addon = classLocale::$lang['flt_mission_expedition']['found_resources']; |
224 | - foreach($resources_found as $resource_id => $resource_amount) { |
|
225 | - $msg_text_addon .= classLocale::$lang['tech'][$resource_id] . ' - ' . $resource_amount . "\r\n"; |
|
224 | + foreach ($resources_found as $resource_id => $resource_amount) { |
|
225 | + $msg_text_addon .= classLocale::$lang['tech'][$resource_id].' - '.$resource_amount."\r\n"; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if(!$msg_text) { |
|
229 | + if (!$msg_text) { |
|
230 | 230 | $messages = &classLocale::$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
231 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
231 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
232 | 232 | $messages = &$messages[$outcome_mission_sub]; |
233 | 233 | } |
234 | 234 | |
235 | - $msg_text = is_string($messages) ? $messages : |
|
236 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
235 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
237 | 236 | } |
238 | 237 | |
239 | 238 | $fleet_row_end_coordinates_without_type = $objFleet->target_coordinates_without_type(); |
240 | 239 | |
241 | - $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)) . |
|
242 | - ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
240 | + $msg_text = sprintf($msg_text, $objFleet->dbId, uni_render_coordinates($fleet_row_end_coordinates_without_type)). |
|
241 | + ($msg_text_addon ? "\r\n".$msg_text_addon : ''); |
|
243 | 242 | |
244 | 243 | DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_mission_job_complete, MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
245 | 244 |