* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
includeLang('fleet');
$session = Wootook::getSession('fleet');
$galaxy = isset($_POST['galaxy']) ? intval($_POST['galaxy']) : 0;
$system = isset($_POST['system']) ? intval($_POST['system']) : 0;
$planet = isset($_POST['planet']) ? intval($_POST['planet']) : 0;
$planettype = isset($_POST['planettype']) ? intval($_POST['planettype']) : 0;
$speed = isset($_POST['speed']) ? intval($_POST['speed']) : 10;
$coords = array(
'galaxy' => $galaxy,
'system' => $system,
'position' => $planet
);
$destination = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $planettype);
$session['planet_destination'] = $destination->getId();
$user = Wootook_Empire_Model_User::getSingleton();
$planetrow = $user->getCurrentPlanet();
$YourPlanet = false;
if ($destination->getUserId() == $user->getId()) {
$YourPlanet = true;
}
$UsedPlanet = false;
if ($destination->getId()) {
$UsedPlanet = true;
}
$fleetArray = $session['fleet'];
$missionTypes = array();
// Determinons les type de missions possibles par rapport a la planete cible
if ($position == (Wootook::getGameConfig('engine/universe/positions') + 1)) {
$missionTypes[Legacies_Empire::ID_MISSION_EXPEDITION] = $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION];
} else {
if ($planettype == Wootook_Empire_Model_Planet::TYPE_DEBRIS) {
if (isset($fleetArray[Legacies_Empire::ID_SHIP_RECYCLER]) && $fleetArray[Legacies_Empire::ID_SHIP_RECYCLER] > 0) {
$missionTypes[Legacies_Empire::ID_MISSION_RECYCLE] = $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE];
}
} else if ($planettype == Wootook_Empire_Model_Planet::TYPE_PLANET) {
if (isset($fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP] > 0 && !$UsedPlanet) {
$missionTypes[Legacies_Empire::ID_MISSION_SETTLE_COLONY] = $lang['type_mission'][7];
}
} else if ($planettype == Wootook_Empire_Model_Planet::TYPE_MOON) {
if (((isset($fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR]) && $fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA]) && $fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA] > 0)) &&
!$YourPlanet && $UsedPlanet) {
$missionTypes[Legacies_Empire::ID_MISSION_DESTROY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_DESTROY];
}
}
if (in_array($planettype, array(Wootook_Empire_Model_Planet::TYPE_MOON, Wootook_Empire_Model_Planet::TYPE_PLANET))) {
if (isset($fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE]) && $fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE] > 0 && !$YourPlanet) {
$missionTypes[Legacies_Empire::ID_MISSION_SPY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_SPY];
}
if ((isset($fleetArray[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT]) && $fleetArray[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT]) && $fleetArray[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_LIGHT_FIGHTER]) && $fleetArray[Legacies_Empire::ID_SHIP_LIGHT_FIGHTER] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_HEAVY_FIGHTER]) && $fleetArray[Legacies_Empire::ID_SHIP_HEAVY_FIGHTER] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_CRUISER]) && $fleetArray[Legacies_Empire::ID_SHIP_CRUISER] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_BATTLESHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_BATTLESHIP] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_RECYCLER]) && $fleetArray[Legacies_Empire::ID_SHIP_RECYCLER] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE]) && $fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE] > 0 && Wootook::getGameConfig('engine/combat/allow_spy_drone_attacks')) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_BOMBER]) && $fleetArray[Legacies_Empire::ID_SHIP_BOMBER] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_DESTRUCTOR]) && $fleetArray[Legacies_Empire::ID_SHIP_DESTRUCTOR] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR]) && $fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_BATTLECRUISER]) && $fleetArray[Legacies_Empire::ID_SHIP_BATTLECRUISER] > 0) ||
(isset($fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA]) && $fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA] > 0)) {
if (!$YourPlanet) {
$missionTypes[Legacies_Empire::ID_MISSION_ATTACK] = $lang['type_mission'][Legacies_Empire::ID_MISSION_ATTACK];
$missionTypes[Legacies_Empire::ID_MISSION_GROUP_ATTACK] = $lang['type_mission'][Legacies_Empire::ID_MISSION_GROUP_ATTACK];
$missionTypes[Legacies_Empire::ID_MISSION_STATION_ALLY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION_ALLY];
}
$missionTypes[Legacies_Empire::ID_MISSION_TRANSPORT] = $lang['type_mission'][Legacies_Empire::ID_MISSION_TRANSPORT];
}
if ($YourPlanet) {
$missionTypes[Legacies_Empire::ID_MISSION_STATION] = $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION];
}
}
}
if (isset($fleetArray[Legacies_Empire::ID_SHIP_SOLAR_SATELLITE])) {
$missionTypes = array();
}
$mission = isset($_POST['target_mission']) ? $_POST['target_mission'] : 0;
$SpeedFactor = GetGameSpeedFactor();
$AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user);
$MaxFleetSpeed = min($AllFleetSpeed);
$distance = GetTargetDistance($planetrow->getGalaxy(), $galaxy, $planetrow->getSystem(), $system, $planetrow->getPosition(), $planet);
$duration = GetMissionDuration($speed, $MaxFleetSpeed, $distance, $SpeedFactor);
$consumption = GetFleetConsumption($fleetArray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $user );
$session['distance'] = $distance;
$session['duration'] = $duration;
$session['consumption'] = $consumption;
$session['speed'] = $speed;
$session['galaxy'] = $galaxy;
$session['system'] = $system;
$session['position'] = $planet;
$session['type'] = $planettype;
$MissionSelector = "";
if (count($missionTypes) > 0) {
if ($planet == (Wootook::getGameConfig('engine/universe/positions') + 1)) {
$MissionSelector .= "
";
$MissionSelector .= "";
$MissionSelector .= "". $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION] ."
";
$MissionSelector .= "". $lang['fl_expe_warning'] ."";
$MissionSelector .= " | ";
$MissionSelector .= "
";
} else {
$i = 0;
foreach ($missionTypes as $a => $b) {
$MissionSelector .= "";
$MissionSelector .= "";
$MissionSelector .= "";
$MissionSelector .= " ";
$MissionSelector .= " | ";
$MissionSelector .= "
";
$i++;
}
}
} else {
$MissionSelector .= "";
$MissionSelector .= "| ";
$MissionSelector .= "". $lang['fl_bad_mission'] ."";
$MissionSelector .= " | ";
$MissionSelector .= "
";
}
if ($planetrow->isPlanet()) {
$TableTitle = "{$planetrow->getCoords()} - {$lang['fl_planet']}";
} elseif ($planetrow->isMoon()) {
$TableTitle = "{$planetrow->getCoords()} - {$lang['fl_moon']}";
}
$maxExpedition = $user->getElement(Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY);
$ExpeditionEnCours = 0;
$EnvoiMaxExpedition = 0;
if ($maxExpedition >= 1) {
$maxexpde = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."' AND `fleet_mission` = '15';", 'fleets');
$ExpeditionEnCours = $maxexpde->rowCount();
$maxexpde->closeCursor();
$EnvoiMaxExpedition = 1 + floor($maxExpedition / 3);
}
$maxfleet = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."';", 'fleets');
$MaxFlyingFleets = $maxfleet->rowCount();
$maxfleet->closeCursor();
$page = "";
$page .= "\n";
$page .= "
";
$page .= "\n";
display($page, $lang['fl_title']);