function ReturnEvent()
 {
     $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
     $Message = sprintf($LNG['sys_stat_mess'], GetStartAddressLink($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 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_tran_mess_back'], $planetName, GetStartAddressLink($this->_fleet, ''));
     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();
 }
 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);
 }
Example #4
0
    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();
    }