function ReturnEvent() { $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']); $sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;'; $planetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name'); $Message = sprintf($LNG['sys_fleet_won'], $planetName, GetTargetAddressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]); PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'], $Message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']); $this->RestoreFleet(); }
function TargetEvent() { $sql = 'SELECT name FROM %%PLANETS%% WHERE `id` = :planetId;'; $startPlanetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name'); $targetPlanetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']), 'name'); $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']); $Message = sprintf($LNG['sys_tran_mess_owner'], $targetPlanetName, GetTargetAddressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]); PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 5, $LNG['sys_mess_transport'], $Message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); if ($this->_fleet['fleet_target_owner'] != $this->_fleet['fleet_owner']) { $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_target_owner']); $Message = sprintf($LNG['sys_tran_mess_user'], $startPlanetName, GetStartAddressLink($this->_fleet, ''), $targetPlanetName, GetTargetAddressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]); PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_tower'], 5, $LNG['sys_mess_transport'], $Message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); } $this->StoreGoodsToPlanet(); $this->setState(FLEET_RETURN); $this->SaveFleet(); }
function TargetEvent() { $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;'; $senderUser = Database::get()->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'])); $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']); $fleetArray = FleetFunctions::unserialize($this->_fleet['fleet_array']); $duration = $this->_fleet['fleet_start_time'] - $this->_fleet['start_time']; $SpeedFactor = FleetFunctions::GetGameSpeedFactor(); $distance = FleetFunctions::GetTargetDistance(array($this->_fleet['fleet_start_galaxy'], $this->_fleet['fleet_start_system'], $this->_fleet['fleet_start_planet']), array($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'])); $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $senderUser, $SpeedFactor); $this->UpdateFleet('fleet_resource_deuterium', $this->_fleet['fleet_resource_deuterium'] + $consumption / 2); $LNG = $this->getLanguage($senderUser['lang']); $TargetUserID = $this->_fleet['fleet_target_owner']; $TargetMessage = sprintf($LNG['sys_stat_mess'], GetTargetAddressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]); PlayerUtil::sendMessage($TargetUserID, 0, $LNG['sys_mess_tower'], 5, $LNG['sys_stat_mess_stay'], $TargetMessage, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); $this->RestoreFleet(false); }
public function getEventData($fleetRow, $Status) { global $LNG; $Owner = $fleetRow['fleet_owner'] == $this->userId; $FleetStyle = array(1 => 'attack', 2 => 'federation', 3 => 'transport', 4 => 'deploy', 5 => 'hold', 6 => 'espionage', 7 => 'colony', 8 => 'harvest', 9 => 'destroy', 10 => 'missile', 11 => 'transport', 15 => 'transport'); $GoodMissions = array(3, 5); $MissionType = $fleetRow['fleet_mission']; $FleetPrefix = $Owner == true ? 'own' : ''; $FleetType = $FleetPrefix . $FleetStyle[$MissionType]; $FleetName = !$Owner && ($MissionType == 1 || $MissionType == 2) && $Status == FLEET_OUTWARD && $fleetRow['fleet_target_owner'] != $this->userId ? $LNG['cff_acs_fleet'] : $LNG['ov_fleet']; $FleetContent = $this->CreateFleetPopupedFleetLink($fleetRow, $FleetName, $FleetPrefix . $FleetStyle[$MissionType]); $FleetCapacity = $this->CreateFleetPopupedMissionLink($fleetRow, $LNG['type_mission'][$MissionType], $FleetPrefix . $FleetStyle[$MissionType]); $FleetStatus = array(0 => 'flight', 1 => 'return', 2 => 'holding'); $StartType = $LNG['type_planet'][$fleetRow['fleet_start_type']]; $TargetType = $LNG['type_planet'][$fleetRow['fleet_end_type']]; if ($MissionType == 8) { if ($Status == FLEET_OUTWARD) { $EventString = sprintf($LNG['cff_mission_own_recy_0'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity); } else { $EventString = sprintf($LNG['cff_mission_own_recy_1'], $FleetContent, GetTargetAddressLink($fleetRow, $FleetType), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $FleetCapacity); } } elseif ($MissionType == 10) { if ($Owner) { $EventString = sprintf($LNG['cff_mission_own_mip'], $fleetRow['fleet_amount'], $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType)); } else { $EventString = sprintf($LNG['cff_mission_target_mip'], $fleetRow['fleet_amount'], $this->BuildHostileFleetPlayerLink($fleetRow, $fleetRow), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType)); } } elseif ($MissionType == 11 || $MissionType == 15) { if ($Status == FLEET_OUTWARD) { $EventString = sprintf($LNG['cff_mission_own_expo_0'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity); } elseif ($Status == FLEET_HOLD) { $EventString = sprintf($LNG['cff_mission_own_expo_2'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity); } else { $EventString = sprintf($LNG['cff_mission_own_expo_1'], $FleetContent, GetTargetAddressLink($fleetRow, $FleetType), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $FleetCapacity); } } else { if ($Owner == true) { if ($Status == FLEET_OUTWARD) { if (!$Owner && ($MissionType == 1 || $MissionType == 2)) { $Message = $LNG['cff_mission_acs']; } else { $Message = $LNG['cff_mission_own_0']; } $EventString = sprintf($Message, $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity); } elseif ($Status == FLEET_RETURN) { $EventString = sprintf($LNG['cff_mission_own_1'], $FleetContent, $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $FleetCapacity); } else { $EventString = sprintf($LNG['cff_mission_own_2'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity); } } else { if ($Status == FLEET_HOLD) { $Message = $LNG['cff_mission_target_stay']; } elseif (in_array($MissionType, $GoodMissions)) { $Message = $LNG['cff_mission_target_good']; } else { $Message = $LNG['cff_mission_target_bad']; } $EventString = sprintf($Message, $FleetContent, $this->BuildHostileFleetPlayerLink($fleetRow, $fleetRow), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity); } } $EventString = '<span class="' . $FleetStatus[$Status] . ' ' . $FleetType . '">' . $EventString . '</span>'; if ($Status == FLEET_OUTWARD) { $Time = $fleetRow['fleet_start_time']; } elseif ($Status == FLEET_RETURN) { $Time = $fleetRow['fleet_end_time']; } elseif ($Status == FLEET_HOLD) { $Time = $fleetRow['fleet_end_stay']; } else { $Time = TIMESTAMP; } $Rest = $Time - TIMESTAMP; return array($Rest, $EventString, $Time); }
function TargetEvent() { $db = Database::get(); $sql = 'SELECT * FROM %%USERS%% WHERE `id` = :userId;'; $senderUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'])); $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']); $LNG = $this->getLanguage($senderUser['lang']); $checkPosition = PlayerUtil::checkPosition($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']); $isPositionFree = PlayerUtil::isPositionFree($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']); if (!$isPositionFree || !$checkPosition) { $message = sprintf($LNG['sys_colo_notfree'], GetTargetAddressLink($this->_fleet, '')); } else { $allowPlanetPosition = PlayerUtil::allowPlanetPosition($this->_fleet['fleet_end_planet'], $senderUser); if (!$allowPlanetPosition) { $message = sprintf($LNG['sys_colo_notech'], GetTargetAddressLink($this->_fleet, '')); } else { $sql = 'SELECT COUNT(*) as state FROM %%PLANETS%% WHERE `id_owner` = :userId AND `planet_type` = :type AND `destruyed` = :destroyed;'; $currentPlanetCount = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'], ':type' => 1, ':destroyed' => 0), 'state'); $maxPlanetCount = PlayerUtil::maxPlanetCount($senderUser); if ($currentPlanetCount >= $maxPlanetCount) { $message = sprintf($LNG['sys_colo_maxcolo'], GetTargetAddressLink($this->_fleet, ''), $maxPlanetCount); } else { $NewOwnerPlanet = PlayerUtil::createPlanet($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $this->_fleet['fleet_owner'], $LNG['fcp_colony'], false, $senderUser['authlevel']); if ($NewOwnerPlanet === false) { $message = sprintf($LNG['sys_colo_badpos'], GetTargetAddressLink($this->_fleet, '')); $this->setState(FLEET_RETURN); } else { $this->_fleet['fleet_end_id'] = $NewOwnerPlanet; $message = sprintf($LNG['sys_colo_allisok'], GetTargetAddressLink($this->_fleet, '')); $this->StoreGoodsToPlanet(); if ($this->_fleet['fleet_amount'] == 1) { $this->KillFleet(); } else { $CurrentFleet = explode(";", $this->_fleet['fleet_array']); $NewFleet = ''; foreach ($CurrentFleet as $Group) { if (empty($Group)) { continue; } $Class = explode(",", $Group); if ($Class[0] == 208 && $Class[1] > 1) { $NewFleet .= $Class[0] . "," . ($Class[1] - 1) . ";"; } elseif ($Class[0] != 208 && $Class[1] > 0) { $NewFleet .= $Class[0] . "," . $Class[1] . ";"; } } $this->UpdateFleet('fleet_array', $NewFleet); $this->UpdateFleet('fleet_amount', $this->_fleet['fleet_amount'] - 1); $this->UpdateFleet('fleet_resource_metal', 0); $this->UpdateFleet('fleet_resource_crystal', 0); $this->UpdateFleet('fleet_resource_deuterium', 0); } } } } } PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_colo_mess_from'], 4, $LNG['sys_colo_mess_report'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); $this->setState(FLEET_RETURN); $this->SaveFleet(); }
function TargetEvent() { global $resource, $reslist; $db = Database::get(); $sqlFields = array(); $elementIDs = array_merge($reslist['defense'], $reslist['missile']); foreach ($elementIDs as $elementID) { $sqlFields[] = '%%PLANETS%%.`' . $resource[$elementID] . '`'; } $sql = 'SELECT lang, shield_tech, %%PLANETS%%.id, name, id_owner, ' . implode(', ', $sqlFields) . ' FROM %%PLANETS%% INNER JOIN %%USERS%% ON id_owner = %%USERS%%.id WHERE %%PLANETS%%.id = :planetId;'; $targetData = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id'])); if ($this->_fleet['fleet_end_type'] == 3) { $sql = 'SELECT ' . $resource[502] . ' FROM %%PLANETS%% WHERE id_luna = :moonId;'; $targetData[$resource[502]] = $db->selectSingle($sql, array(':moonId' => $this->_fleet['fleet_end_id']), $resource[502]); } $sql = 'SELECT lang, military_tech FROM %%USERS%% WHERE id = :userId;'; $senderData = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'])); if (!in_array($this->_fleet['fleet_target_obj'], $reslist['defense']) || !in_array($this->_fleet['fleet_target_obj'], $reslist['missile']) || $this->_fleet['fleet_target_obj'] == 502 || $this->_fleet['fleet_target_obj'] == 0) { $primaryTarget = 401; } else { $primaryTarget = $this->_fleet['fleet_target_obj']; } $targetDefensive = array(); foreach ($elementIDs as $elementID) { $targetDefensive[$elementID] = $targetData[$resource[$elementID]]; } unset($targetDefensive[502]); $LNG = $this->getLanguage(Config::get($this->_fleet['fleet_universe'])->lang, array('L18N', 'FLEET', 'TECH')); if ($targetData[$resource[502]] >= $this->_fleet['fleet_amount']) { $message = $LNG['sys_irak_no_att']; $where = $this->_fleet['fleet_end_type'] == 3 ? 'id_luna' : 'id'; $sql = 'UPDATE %%PLANETS%% SET ' . $resource[502] . ' = ' . $resource[502] . ' - :amount WHERE ' . $where . ' = :planetId;'; $db->update($sql, array(':amount' => $this->_fleet['fleet_amount'], ':planetId' => $targetData['id'])); } else { if ($targetData[$resource[502]] > 0) { $where = $this->_fleet['fleet_end_type'] == 3 ? 'id_luna' : 'id'; $sql = 'UPDATE %%PLANETS%% SET ' . $resource[502] . ' = :amount WHERE ' . $where . ' = :planetId;'; $db->update($sql, array(':amount' => 0, ':planetId' => $targetData['id'])); } $targetDefensive = array_filter($targetDefensive); if (!empty($targetDefensive)) { require_once 'includes/classes/missions/functions/calculateMIPAttack.php'; $result = calculateMIPAttack($targetData["shield_tech"], $senderData["military_tech"], $this->_fleet['fleet_amount'], $targetDefensive, $primaryTarget, $targetData[$resource[502]]); $result = array_filter($result); $message = sprintf($LNG['sys_irak_def'], $targetData[$resource[502]]) . '<br><br>'; ksort($result, SORT_NUMERIC); foreach ($result as $Element => $destroy) { $message .= sprintf('%s (- %d)<br>', $LNG['tech'][$Element], $destroy); $sql = 'UPDATE %%PLANETS%% SET ' . $resource[$Element] . ' = ' . $resource[$Element] . ' - :amount WHERE id = :planetId;'; $db->update($sql, array(':planetId' => $targetData['id'], ':amount' => $destroy)); } } else { $message = $LNG['sys_irak_no_def']; } } $sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;'; $planetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name'); $ownerLink = $planetName . " " . GetStartAddressLink($this->_fleet); $targetLink = $targetData['name'] . " " . GetTargetAddressLink($this->_fleet); $message = sprintf($LNG['sys_irak_mess'], $this->_fleet['fleet_amount'], $ownerLink, $targetLink) . $message; PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 3, $LNG['sys_irak_subject'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_tower'], 3, $LNG['sys_irak_subject'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']); $this->KillFleet(); }