예제 #1
0
<?php

#$GLOBALS['DATABASE']->query("LOCK TABLE ".AKS." WRITE, ".RW." WRITE, ".MESSAGES." WRITE, ".CONFIG." WRITE, ".FLEETS_EVENT." WRITE, ".FLEETS." WRITE, ".PLANETS." WRITE, ".PLANETS." as p WRITE, ".TOPKB." WRITE, ".USERS." WRITE, ".USERS." as u WRITE, ".STATPOINTS." WRITE;");
$tickinicial = buscarTick();
$token = getRandomString();
$fleetResult = $GLOBALS['DATABASE']->query("UPDATE " . FLEETS_EVENT . " SET `lock` = '" . $token . "' WHERE `lock` IS NULL AND `time` <= " . TIMESTAMP . ";");
//$fleetResult	= $GLOBALS['DATABASE']->query("UPDATE ".FLEETS_EVENT." SET `lock` = '".$token."' WHERE `lock` IS NULL AND `time` <= ".$tickatual.";");
if ($GLOBALS['DATABASE']->affectedRows() !== 0) {
    require_once 'includes/classes/class.FlyingFleetHandler.php';
    $fleetObj = new FlyingFleetHandler();
    $fleetObj->setToken($token);
    $fleetObj->run();
    $GLOBALS['DATABASE']->query("UPDATE " . FLEETS_EVENT . " SET `lock` = NULL WHERE `lock` = '" . $token . "';");
    #UNLOCK TABLES
}
예제 #2
0
 public function show()
 {
     global $USER, $PLANET, $resource, $LNG, $CONF, $pricelist;
     $tickinicial = buscarTick();
     $UserDeuterium = $PLANET['deuterium'];
     $planetID = HTTP::_GP('planetID', 0);
     $targetMission = HTTP::_GP('mission', 0);
     $activeSlots = FleetFunctions::GetCurrentFleets($USER['id']);
     $maxSlots = FleetFunctions::GetMaxFleetSlots($USER);
     $this->returnData['slots'] = $activeSlots;
     if (IsVacationMode($USER)) {
         $this->sendData(620, $LNG['fa_vacation_mode_current']);
     }
     if (empty($planetID)) {
         $this->sendData(601, $LNG['fa_planet_not_exist']);
     }
     if ($maxSlots <= $activeSlots) {
         $this->sendData(612, $LNG['fa_no_more_slots']);
     }
     $fleetArray = array();
     switch ($targetMission) {
         case 6:
             if (!isModulAvalible(MODULE_MISSION_SPY)) {
                 $this->sendData(699, $LNG['sys_module_inactive']);
             }
             $ships = min($USER['spio_anz'], $PLANET[$resource[210]]);
             if (empty($ships)) {
                 $this->sendData(610, $LNG['fa_no_spios']);
             }
             $fleetArray = array(210 => $ships);
             $this->returnData['ships'][210] = $PLANET[$resource[210]] - $ships;
             break;
         case 8:
             if (!isModulAvalible(MODULE_MISSION_RECYCLE)) {
                 $this->sendData(699, $LNG['sys_module_inactive']);
             }
             $totalDebris = $GLOBALS['DATABASE']->getFirstCell("SELECT der_metal + der_crystal FROM " . PLANETS . " WHERE id = " . $planetID . ";");
             $usedDebris = 0;
             $recElementIDs = array(219, 209);
             $fleetArray = array();
             foreach ($recElementIDs as $elementID) {
                 $shipsNeed = min(ceil($totalDebris / $pricelist[$elementID]['capacity']), $PLANET[$resource[$elementID]]);
                 $totalDebris -= $shipsNeed * $pricelist[$elementID]['capacity'];
                 $fleetArray[$elementID] = $shipsNeed;
                 $this->returnData['ships'][$elementID] = $PLANET[$resource[$elementID]] - $shipsNeed;
                 if ($totalDebris <= 0) {
                     break;
                 }
             }
     }
     $fleetArray = array_filter($fleetArray);
     if (empty($fleetArray) && $targetMission == 6) {
         $this->sendData(610, $LNG['fa_not_enough_probes']);
     } elseif (empty($fleetArray) && $targetMission == 8) {
         $this->sendData(610, $LNG['fa_no_recyclers']);
     }
     $targetData = $GLOBALS['DATABASE']->getFirstRow("SELECT planet.id_owner as id_owner, \n\t\t\t\t\t\t\t\t\t\tplanet.galaxy as galaxy, \n\t\t\t\t\t\t\t\t\t\tplanet.system as system, \n\t\t\t\t\t\t\t\t\t\tplanet.planet as planet,\n\t\t\t\t\t\t\t\t\t\tplanet.planet_type as planet_type, \n\t\t\t\t\t\t\t\t\t\ttotal_points, onlinetime, urlaubs_modus, banaday, authattack\n\t\t\t\t\t\t\t\t\t\tFROM " . PLANETS . " planet\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . USERS . " user ON planet.id_owner = user.id\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . STATPOINTS . " as stat ON stat.id_owner = user.id AND stat.stat_type = '1' \n\t\t\t\t\t\t\t\t\t\tWHERE planet.id = " . $planetID . ";");
     if (empty($targetData)) {
         $this->sendData(601, $LNG['fa_planet_not_exist']);
     }
     if ($targetMission == 6) {
         if (Config::get('adm_attack') == 1 && $targetData['authattack'] > $USER['authlevel']) {
             $this->sendData(619, $LNG['fa_action_not_allowed']);
         }
         if (IsVacationMode($targetData)) {
             $this->sendData(605, $LNG['fa_vacation_mode']);
         }
         $IsNoobProtec = CheckNoobProtec($USER, $targetData, $targetData);
         if ($IsNoobProtec['NoobPlayer']) {
             $this->sendData(603, $LNG['fa_week_player']);
         }
         if ($IsNoobProtec['StrongPlayer']) {
             $this->sendData(604, $LNG['fa_strong_player']);
         }
         if ($USER['id'] == $targetData['id_owner']) {
             $this->sendData(618, $LNG['fa_not_spy_yourself']);
         }
     }
     $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $Distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($targetData['galaxy'], $targetData['system'], $targetData['planet']));
     $SpeedAllMin = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
     $Duration = FleetFunctions::GetMissionDuration(10, $SpeedAllMin, $Distance, $SpeedFactor, $USER);
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $Duration, $Distance, $SpeedAllMin, $USER, $SpeedFactor);
     $UserDeuterium -= $consumption;
     if ($UserDeuterium < 0) {
         $this->sendData(613, $LNG['fa_not_enough_fuel']);
     }
     if ($consumption > FleetFunctions::GetFleetRoom($fleetArray, $USER)) {
         $this->sendData(613, $LNG['fa_no_fleetroom']);
     }
     if (connection_aborted()) {
         exit;
     }
     $this->returnData['slots']++;
     $fleetRessource = array(901 => 0, 902 => 0, 903 => 0);
     $fleetStartTime = $Duration + TIMESTAMP;
     $fleetStayTime = $fleetStartTime;
     $fleetEndTime = $fleetStayTime + $Duration;
     $shipID = array_keys($fleetArray);
     if ($PLANET['system'] == $targetData['system']) {
         $tickfinal = $tickinicial + 9;
     } else {
         $tickfinal = $tickinicial + 11;
     }
     FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetData['id_owner'], $planetID, $targetData['galaxy'], $targetData['system'], $targetData['planet'], $targetData['planet_type'], $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $tickinicial, $tickfinal);
     $this->sendData(600, $LNG['fa_sending'] . " " . array_sum($fleetArray) . " " . $LNG['tech'][$shipID[0]] . " " . $LNG['gl_to'] . " " . $targetData['galaxy'] . ":" . $targetData['system'] . ":" . $targetData['planet'] . " ...");
 }
예제 #3
0
 public function show()
 {
     global $USER, $PLANET, $resource, $pricelist, $reslist, $CONF, $LNG, $UNI;
     $tickinicial = buscarTick();
     if (IsVacationMode($USER)) {
         FleetFunctions::GotoFleetPage(0);
     }
     $targetMission = HTTP::_GP('mission', 3);
     $TransportMetal = max(0, round(HTTP::_GP('metal', 0.0)));
     $TransportCrystal = max(0, round(HTTP::_GP('crystal', 0.0)));
     $TransportDeuterium = max(0, round(HTTP::_GP('deuterium', 0.0)));
     $stayTime = HTTP::_GP('staytime', 0);
     $token = HTTP::_GP('token', '');
     if (!isset($_SESSION['fleet'][$token])) {
         FleetFunctions::GotoFleetPage(1);
     }
     if ($_SESSION['fleet'][$token]['time'] < TIMESTAMP - 600) {
         unset($_SESSION['fleet'][$token]);
         FleetFunctions::GotoFleetPage(0);
     }
     $maxFleetSpeed = $_SESSION['fleet'][$token]['speed'];
     $distance = $_SESSION['fleet'][$token]['distance'];
     $targetGalaxy = $_SESSION['fleet'][$token]['targetGalaxy'];
     $targetSystem = $_SESSION['fleet'][$token]['targetSystem'];
     $targetPlanet = $_SESSION['fleet'][$token]['targetPlanet'];
     $targetType = $_SESSION['fleet'][$token]['targetType'];
     $fleetGroup = $_SESSION['fleet'][$token]['fleetGroup'];
     $fleetArray = $_SESSION['fleet'][$token]['fleet'];
     $fleetStorage = $_SESSION['fleet'][$token]['fleetRoom'];
     $fleetSpeed = $_SESSION['fleet'][$token]['fleetSpeed'];
     unset($_SESSION['fleet'][$token]);
     if ($targetMission != 2) {
         $fleetGroup = 0;
     }
     if ($PLANET['galaxy'] == $targetGalaxy && $PLANET['system'] == $targetSystem && $PLANET['planet'] == $targetPlanet && $PLANET['planet_type'] == $targetType) {
         $this->printMessage($LNG['fl_error_same_planet']);
     }
     if ($targetGalaxy < 1 || $targetGalaxy > Config::get('max_galaxy') || $targetSystem < 1 || $targetSystem > Config::get('max_system') || $targetPlanet < 1 || $targetPlanet > Config::get('max_planets') + 1 || $targetType !== 1 && $targetType !== 2 && $targetType !== 3 && $targetType !== 4) {
         $this->printMessage($LNG['fl_invalid_target']);
     }
     if ($targetMission == 3 && $TransportMetal + $TransportCrystal + $TransportDeuterium < 1) {
         $this->printMessage($LNG['fl_no_noresource']);
     }
     $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
     if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
         $this->printMessage($LNG['fl_no_slots']);
     }
     $ACSTime = 0;
     if (!empty($fleetGroup)) {
         $ACSTime = $GLOBALS['DATABASE']->getFirstCell("SELECT ankunft\n\t\t\tFROM " . USERS_ACS . " \n\t\t\tINNER JOIN " . AKS . " ON id = acsID\n\t\t\tWHERE acsID = " . $fleetGroup . "\n\t\t\tAND " . Config::get('max_fleets_per_acs') . " > (SELECT COUNT(*) FROM " . FLEETS . " WHERE fleet_group = " . $fleetGroup . ");");
         if (empty($ACSTime)) {
             $fleetGroup = 0;
             $targetMission = 1;
         }
     }
     $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
     //$targetPlanetData  	= $GLOBALS['DATABASE']->getFirstRow("SELECT id, `planet_protection`, id_owner, `planet_type`, der_metal, der_crystal, destruyed, ally_deposit FROM ".PLANETS." WHERE universe = ".$UNI." AND galaxy = ".$targetGalaxy." AND system = ".$targetSystem." AND planet = ".$targetPlanet." AND planet_type = '".$targetType."';");
     $targetPlanetData = $GLOBALS['DATABASE']->getFirstRow("SELECT id, id_owner, `planet_protection`, der_metal, `planet_type`, der_crystal, destruyed, ally_deposit FROM " . PLANETS . " WHERE universe = " . $UNI . " AND galaxy = " . $targetGalaxy . " AND system = " . $targetSystem . " AND planet = " . $targetPlanet . " AND planet_type = '" . ($targetType == 2 ? 1 : $targetType) . "';");
     if ($targetMission == 7) {
         if (isset($targetPlanetData)) {
             $this->printMessage($LNG['fl_target_exists']);
         }
         if ($targetType != 1) {
             $this->printMessage($LNG['fl_only_planets_colonizable']);
         }
     }
     if ($targetMission == 7 || $targetMission == 15) {
         $targetPlanetData = array('id' => 0, 'id_owner' => 0, 'planettype' => 1);
     } else {
         if ($targetPlanetData["destruyed"] != 0) {
             $this->printMessage($LNG['fl_no_target']);
         }
         if (!isset($targetPlanetData)) {
             $this->printMessage($LNG['fl_no_target']);
         }
     }
     foreach ($fleetArray as $Ship => $Count) {
         if ($Count > $PLANET[$resource[$Ship]]) {
             $this->printMessage($LNG['fl_not_all_ship_avalible']);
         }
     }
     if ($targetMission == 11) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 11);
         $maxExpedition = FleetFunctions::getDMMissionLimit($USER);
         if ($activeExpedition >= $maxExpedition) {
             $this->printMessage($LNG['fl_no_expedition_slot']);
         }
     } elseif ($targetMission == 15) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 15);
         $maxExpedition = FleetFunctions::getExpeditionLimit($USER);
         if ($activeExpedition >= $maxExpedition) {
             $this->printMessage($LNG['fl_no_expedition_slot']);
         }
     } elseif ($targetMission == 20) {
         $activeExpedition = FleetFunctions::GetCurrentFleets($USER['id'], 20);
         $maxExpedition = FleetFunctions::getFortressLimit($USER);
         if ($activeExpedition >= $maxExpedition) {
             $this->printMessage($LNG['fl_no_expedition_slot']);
         }
     }
     $usedPlanet = isset($targetPlanetData['id_owner']);
     $myPlanet = $usedPlanet && $targetPlanetData['id_owner'] == $USER['id'];
     if ($targetMission == 7 || $targetMission == 15) {
         $targetPlayerData = array('id' => 0, 'onlinetime' => TIMESTAMP, 'ally_id' => 0, 'urlaubs_modus' => 0, 'authattack' => 0, 'total_points' => 0);
     } elseif ($myPlanet) {
         $targetPlayerData = $USER;
     } elseif (!empty($targetPlanetData['id_owner'])) {
         $targetPlayerData = $GLOBALS['DATABASE']->getFirstRow("SELECT \n\t\t\tuser.id, user.onlinetime, user.ally_id, user.urlaubs_modus, user.banaday, user.immunity_until, user.authattack, \n\t\t\tstat.total_points\n\t\t\tFROM " . USERS . " as user \n\t\t\tLEFT JOIN " . STATPOINTS . " as stat ON stat.id_owner = user.id AND stat.stat_type = '1' \n\t\t\tWHERE user.id = " . $targetPlanetData['id_owner'] . ";");
     } else {
         $this->printMessage($LNG['fl_empty_target']);
     }
     $MisInfo = array();
     $MisInfo['galaxy'] = $targetGalaxy;
     $MisInfo['system'] = $targetSystem;
     $MisInfo['planet'] = $targetPlanet;
     $MisInfo['planettype'] = $targetType;
     $MisInfo['IsAKS'] = $fleetGroup;
     $MisInfo['Ship'] = $fleetArray;
     $avalibleMissions = FleetFunctions::GetFleetMissions($USER, $MisInfo, $targetPlanetData);
     if (!in_array($targetMission, $avalibleMissions['MissionSelector'])) {
         $this->printMessage($LNG['fl_invalid_mission']);
     }
     if ($targetMission != 8 && IsVacationMode($targetPlayerData)) {
         $this->printMessage($LNG['fl_target_exists']);
     }
     if ($targetMission == 1 || $targetMission == 2 || $targetMission == 9) {
         if (FleetFunctions::CheckBash($targetPlanetData['id']) && $targetPlayerData['onlinetime'] < TIMESTAMP - 7 * 24 * 60 * 60) {
             $this->printMessage($LNG['fl_bash_protection']);
         }
     }
     if ($targetMission == 1 || $targetMission == 2 || $targetMission == 5 || $targetMission == 6 || $targetMission == 9) {
         if (Config::get('adm_attack') == 1 && $targetPlayerData['authattack'] > $USER['authlevel']) {
             $this->printMessage($LNG['fl_admin_attack']);
         }
         $IsNoobProtec = CheckNoobProtec($USER, $targetPlayerData, $targetPlayerData);
         if ($IsNoobProtec['NoobPlayer']) {
             $this->printMessage($LNG['fl_player_is_noob']);
         }
         if ($IsNoobProtec['StrongPlayer']) {
             $this->printMessage($LNG['fl_player_is_strong']);
         }
     }
     $PUSHED = $GLOBALS['DATABASE']->query("SELECT * FROM " . STATPOINTS . " WHERE id_owner = " . $USER['id'] . ";");
     $PUSGHING = $GLOBALS['DATABASE']->query("SELECT * FROM " . STATPOINTS . " WHERE id_owner = " . $targetPlanetData['id_owner'] . ";");
     $ADMIN = $GLOBALS['DATABASE']->query("SELECT authlevel FROM " . USERS . " WHERE id = " . $targetPlanetData['id_owner'] . ";");
     $ADMIN = mysqli_fetch_assoc($ADMIN);
     if ($GLOBALS['DATABASE']->numRows($PUSHED) > 0) {
         while ($xkf = mysqli_fetch_assoc($PUSHED)) {
             $ACTUA = $xkf['total_points'];
             $ACTUALA = $xkf['id_ally'];
         }
     }
     if ($GLOBALS['DATABASE']->numRows($PUSGHING) > 0) {
         while ($xkkf = mysqli_fetch_assoc($PUSGHING)) {
             $ACTUAL = $xkkf['total_points'];
             $ACTUALAT = $xkkf['id_ally'];
         }
     }
     if ($USER['authlevel'] != 3 || $ADMIN['authlevel'] != 3) {
         if ($targetMission == 3 && $ACTUA < $ACTUAL) {
             $this->printMessage('Pushing');
         }
     }
     if ($targetMission == 5) {
         if ($targetPlayerData['ally_id'] != $USER['ally_id']) {
             $buddy = $GLOBALS['DATABASE']->getFirstCell("\n\t\t\t\tSELECT COUNT(*) FROM " . BUDDY . " \n\t\t\t\tWHERE id NOT IN (SELECT id FROM " . BUDDY_REQUEST . " WHERE " . BUDDY_REQUEST . ".id = " . BUDDY . ".id) AND \n\t\t\t\t(owner = " . $targetPlayerData['id'] . " AND sender = " . $USER['id'] . ") OR\n\t\t\t\t(owner = " . $USER['id'] . " AND sender = " . $targetPlayerData['id'] . ");");
             if ($buddy == 0) {
                 $this->printMessage($LNG['fl_no_same_alliance']);
             }
         }
     }
     $fleetMaxSpeed = FleetFunctions::GetFleetMaxSpeed($fleetArray, $USER);
     $SpeedFactor = FleetFunctions::GetGameSpeedFactor();
     $duration = FleetFunctions::GetMissionDuration($fleetSpeed, $fleetMaxSpeed, $distance, $SpeedFactor, $USER);
     $consumption = FleetFunctions::GetFleetConsumption($fleetArray, $duration, $distance, $fleetMaxSpeed, $USER, $SpeedFactor);
     if ($PLANET[$resource[903]] < $consumption) {
         $this->printMessage($LNG['fl_not_enough_deuterium']);
     }
     $StayDuration = 0;
     if ($targetMission == 5 || $targetMission == 11 || $targetMission == 15) {
         if (!isset($avalibleMissions['StayBlock'][$stayTime])) {
             $this->printMessage($LNG['fl_hold_time_not_exists']);
         }
         $StayDuration = round($avalibleMissions['StayBlock'][$stayTime] * 3600, 0);
     }
     $fleetStorage -= $consumption;
     $fleetRessource = array(901 => min($TransportMetal, floor($PLANET[$resource[901]])), 902 => min($TransportCrystal, floor($PLANET[$resource[902]])), 903 => min($TransportDeuterium, floor($PLANET[$resource[903]] - $consumption)));
     $StorageNeeded = array_sum($fleetRessource);
     if ($StorageNeeded > $fleetStorage) {
         $this->printMessage($LNG['fl_not_enough_space']);
     }
     $PLANET[$resource[901]] -= $fleetRessource[901];
     $PLANET[$resource[902]] -= $fleetRessource[902];
     $PLANET[$resource[903]] -= $fleetRessource[903] + $consumption;
     if (connection_aborted()) {
         exit;
     }
     $fleetStartTime = $duration + TIMESTAMP;
     $timeDifference = round(max(0, $fleetStartTime - $ACSTime));
     if ($fleetGroup != 0) {
         if ($timeDifference != 0) {
             FleetFunctions::setACSTime($timeDifference, $fleetGroup);
         } else {
             $fleetStartTime = $ACSTime;
         }
     }
     $fleetStayTime = $fleetStartTime + $StayDuration;
     $fleetEndTime = $fleetStayTime + $duration;
     if ($PLANET['system'] == $targetSystem) {
         $tickfinal = $tickinicial + 9;
     } else {
         $tickfinal = $tickinicial + 11;
     }
     FleetFunctions::sendFleet($fleetArray, $targetMission, $USER['id'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $targetPlanetData['id_owner'], $targetPlanetData['id'], $targetGalaxy, $targetSystem, $targetPlanet, $targetType, $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $tickinicial, $tickfinal, $fleetGroup);
     foreach ($fleetArray as $Ship => $Count) {
         $fleetList[$LNG['tech'][$Ship]] = $Count;
     }
     $this->tplObj->loadscript('flotten.js');
     $this->tplObj->gotoside('game.php?page=fleetTable');
     $this->tplObj->assign_vars(array('targetMission' => $targetMission, 'distance' => $distance, 'consumption' => $consumption, 'from' => $PLANET['galaxy'] . ":" . $PLANET['system'] . ":" . $PLANET['planet'], 'destination' => $targetGalaxy . ":" . $targetSystem . ":" . $targetPlanet, 'fleetStartTime' => _date($LNG['php_tdformat'], $fleetStartTime, $USER['timezone']), 'fleetEndTime' => _date($LNG['php_tdformat'], $fleetEndTime, $USER['timezone']), 'MaxFleetSpeed' => $fleetMaxSpeed, 'FleetList' => $fleetArray));
     $this->display('page.fleetStep3.default.tpl');
 }
 function reduce()
 {
     global $USER, $PLANET, $LNG, $UNI;
     $tickinicial = buscarTick();
     if (!isset($_POST['palanets'])) {
         $this->redirectTo('game.php?page=reduceresources');
     }
     if (!isset($_POST['palanets'])) {
         $_POST['palanets'] = array();
     }
     foreach ($_POST['palanets'] as $ID => $Value) {
         $sur = $GLOBALS['DATABASE']->uniquequery("SELECT metal, crystal, deuterium, ev_transporter, id_owner, id, galaxy, system, planet FROM " . PLANETS . " where `id` = '" . $Value . "';");
         $total_res = $sur['metal'] + $sur['crystal'] + $sur['deuterium'];
         $needed_ships = ($sur['metal'] + $sur['crystal'] + $sur['deuterium']) / 390000000;
         if ($needed_ships < 1) {
             $needed_ships = 1;
         }
         $ships1 = min($needed_ships, $sur['ev_transporter']);
         $shipscapa = $ships1 * 390000000;
         $RecycledGoods = array('metal' => 0, 'crystal' => 0, 'deuterium' => 0);
         if ($total_res <= $shipscapa) {
             $RecycledGoods['metal'] = $sur['metal'];
             $RecycledGoods['crystal'] = $sur['crystal'];
             $RecycledGoods['deuterium'] = $sur['deuterium'];
         } elseif ($sur['metal'] > $shipscapa / 2 && $sur['crystal'] > $shipscapa / 2 && $sur['deuterium'] > $shipscapa / 2) {
             $RecycledGoods['metal'] = $shipscapa / 2;
             $RecycledGoods['crystal'] = $shipscapa / 2;
             $RecycledGoods['deuterium'] = $shipscapa / 2;
         } elseif ($sur['metal'] > $sur['crystal']) {
             $RecycledGoods['crystal'] = $sur['crystal'];
             if ($sur['metal'] > $shipscapa - $RecycledGoods['crystal']) {
                 $RecycledGoods['metal'] = $shipscapa - $RecycledGoods['crystal'];
             } else {
                 $RecycledGoods['metal'] = $sur['metal'];
             }
         } else {
             $RecycledGoods['metal'] = $sur['metal'];
             if ($sur['crystal'] > $shipscapa - $RecycledGoods['metal']) {
                 $RecycledGoods['crystal'] = $shipscapa - $RecycledGoods['metal'];
             } else {
                 $RecycledGoods['crystal'] = $sur['crystal'];
             }
         }
         if ($RecycledGoods['metal'] < 0) {
             $RecycledGoods['metal'] = 0;
         }
         if ($RecycledGoods['crystal'] < 0) {
             $RecycledGoods['crystal'] = 0;
         }
         if ($RecycledGoods['deuterium'] < 0) {
             $RecycledGoods['deuterium'] = 0;
         }
         $mission = 3;
         $galaxy = $PLANET['galaxy'];
         $system = $PLANET['system'];
         $planet = $PLANET['planet'];
         $planettype = 1;
         $fleet_group = 0;
         $GenFleetSpeed = 10;
         $TransportMetal = $RecycledGoods['metal'];
         $TransportCrystal = $RecycledGoods['crystal'];
         $TransportDeuterium = $RecycledGoods['deuterium'];
         $holdingtime = 0;
         $rawfleetarray = array(217 => $ships1);
         $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
         if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
             return false;
         }
         $FleetArray = $rawfleetarray;
         $GameSpeedFactor = FleetFunctions::GetGameSpeedFactor();
         $MaxFleetSpeed = FleetFunctions::GetFleetMaxSpeed($FleetArray, $USER);
         $distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($sur['galaxy'], $sur['system'], $sur['planet']));
         $duration = FleetFunctions::GetMissionDuration(10, $MaxFleetSpeed, $distance, $GameSpeedFactor, $USER);
         $consumption = FleetFunctions::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $GameSpeedFactor);
         $StayDuration = 0;
         if ($sur['deuterium'] < $consumption) {
             continue;
         }
         $PlanetRess = new ResourceUpdate();
         $PlanetRess->CalcResource();
         $fleetRessource = array(901 => $TransportMetal, 902 => $TransportCrystal, 903 => $TransportDeuterium);
         $GLOBALS['DATABASE']->multi_query("UPDATE " . PLANETS . " SET metal = metal - " . $RecycledGoods['metal'] . ", crystal = crystal - " . $RecycledGoods['crystal'] . ", deuterium = deuterium - " . $RecycledGoods['deuterium'] . " where `id` = '" . $sur['id'] . "';");
         $fleetStartTime = $duration + TIMESTAMP;
         $timeDifference = round(max(0, $fleetStartTime - 0));
         if ($fleet_group != 0) {
             if ($timeDifference != 0) {
                 FleetFunctions::setACSTime($timeDifference, $fleet_group);
             } else {
                 $fleetStartTime = $ACSTime;
             }
         }
         $fleetStayTime = $fleetStartTime + $StayDuration;
         $fleetEndTime = $fleetStayTime + $duration;
         if ($sur['system'] == $system) {
             $tickfinal = $tickinicial + 9;
         } else {
             $tickfinal = $tickinicial + 11;
         }
         FleetFunctions::sendFleet($FleetArray, $mission, $sur['id_owner'], $sur['id'], $sur['galaxy'], $sur['system'], $sur['planet'], 1, $PLANET['id_owner'], $PLANET['id'], $galaxy, $system, $planet, $planettype, $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $tickinicial, $tickfinal, $fleet_group);
     }
     $this->printMessage('Fleets Succesfully Send', true, array('game.php?page=reduceresources', 4));
 }
예제 #5
0
 public static function SendFleetBack($USER, $FleetID)
 {
     $tickatual = buscarTick();
     $FleetRow = $GLOBALS['DATABASE']->getFirstRow("SELECT start_time, fleet_mission, fleet_group, fleet_owner, fleet_mess, tickinicial, tickfinal, tickretorno FROM " . FLEETS . " WHERE fleet_id = '" . $FleetID . "';");
     if ($FleetRow['fleet_owner'] != $USER['id'] || $FleetRow['fleet_mess'] == 1) {
         return;
     }
     $sqlWhere = 'fleet_id';
     if ($FleetRow['fleet_mission'] == 1 && $FleetRow['fleet_group'] != 0) {
         $acsResult = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . USERS_ACS . " WHERE acsID = " . $FleetRow['fleet_group'] . ";");
         if ($acsResult != 0) {
             $GLOBALS['DATABASE']->multi_query("DELETE FROM " . AKS . " WHERE id = " . $FleetRow['fleet_group'] . ";\n\t\t\t\t\t\t\t\t  DELETE FROM " . USERS_ACS . " WHERE acsID = " . $FleetRow['fleet_group'] . ";");
             $FleetID = $FleetRow['fleet_group'];
             $sqlWhere = 'fleet_group';
         }
     }
     $tickretorno = $tickatual - $FleetRow['tickinicial'] + $tickatual;
     $tickfinal = $tickatual;
     $fleetEndTime = TIMESTAMP - $FleetRow['start_time'] + TIMESTAMP;
     $GLOBALS['DATABASE']->multi_query("UPDATE " . FLEETS . ", " . FLEETS_EVENT . " SET \n\t\t\t\t\t\t  fleet_group = 0,\n\t\t\t\t\t\t  fleet_end_stay = " . TIMESTAMP . ",\n\t\t\t\t\t\t  fleet_end_time = " . $fleetEndTime . ",\n\t\t\t\t\t\t  tickfinal = " . $tickfinal . ",\n\t\t\t\t\t\t  tickretorno = " . $tickretorno . ",\n\t\t\t\t\t\t  fleet_mess = 1,\n\t\t\t\t\t\t  hasCanceled = 1,\n\t\t\t\t\t\t  time = " . $fleetEndTime . "\n\t\t\t\t\t\t  WHERE " . $sqlWhere . " = " . $FleetID . " AND fleet_id = fleetID;\n\t\t\t\t\t\t  UPDATE " . LOG_FLEETS . " SET\n\t\t\t\t\t\t  fleet_end_stay = " . TIMESTAMP . ",\n\t\t\t\t\t\t  fleet_end_time = " . $fleetEndTime . ",\n\t\t\t\t\t\t  tickfinal = " . $tickfinal . ",\n\t\t\t\t\t\t  tickretorno = " . $tickretorno . ",\n\t\t\t\t\t\t  fleet_mess = 1,\n\t\t\t\t\t\t  fleet_state = 2\n\t\t\t\t\t\t  WHERE " . $sqlWhere . " = " . $FleetID . ";");
 }
예제 #6
0
 function reduce()
 {
     global $USER, $PLANET, $LNG, $UNI;
     $tickinicial = buscarTick();
     if (!isset($_POST['palanets'])) {
         $this->redirectTo('game.php?page=Reducefleet');
     }
     if (!isset($_POST['palanets'])) {
         $_POST['palanets'] = array();
     }
     foreach ($_POST['palanets'] as $ID => $Value) {
         $sur = $GLOBALS['DATABASE']->uniquequery("SELECT deuterium, small_ship_cargo, lune_noir, big_ship_cargo, light_hunter, heavy_hunter, crusher, battle_ship, recycler, bomber_ship, destructor, battleship, galleon, destroyer, frigate, black_wanderer, id_owner, id, galaxy, system, planet FROM " . PLANETS . " where `id` = '" . $Value . "';");
         $ships1 = $sur['small_ship_cargo'];
         $ships2 = $sur['big_ship_cargo'];
         $ships3 = $sur['light_hunter'];
         $ships4 = $sur['heavy_hunter'];
         $ships5 = $sur['crusher'];
         $ships6 = $sur['battle_ship'];
         $ships7 = $sur['recycler'];
         $ships8 = $sur['bomber_ship'];
         $ships9 = $sur['destructor'];
         $ships10 = $sur['battleship'];
         $ships11 = $sur['galleon'];
         $ships12 = $sur['destroyer'];
         $ships13 = $sur['frigate'];
         $ships14 = $sur['black_wanderer'];
         $ships15 = $sur['lune_noir'];
         $mission = 4;
         $galaxy = $PLANET['galaxy'];
         $system = $PLANET['system'];
         $planet = $PLANET['planet'];
         $planettype = 1;
         $fleet_group = 0;
         $GenFleetSpeed = 10;
         $TransportMetal = 0;
         $TransportCrystal = 0;
         $TransportDeuterium = 0;
         $holdingtime = 0;
         $rawfleetarray = array(202 => $ships1, 203 => $ships2, 204 => $ships3, 205 => $ships4, 206 => $ships5, 207 => $ships6, 209 => $ships7, 211 => $ships8, 213 => $ships9, 215 => $ships10, 225 => $ships11, 226 => $ships12, 227 => $ships13, 228 => $ships14, 216 => $ships15);
         $ActualFleets = FleetFunctions::GetCurrentFleets($USER['id']);
         if (FleetFunctions::GetMaxFleetSlots($USER) <= $ActualFleets) {
             return false;
         }
         $FleetArray = $rawfleetarray;
         $GameSpeedFactor = FleetFunctions::GetGameSpeedFactor();
         $MaxFleetSpeed = FleetFunctions::GetFleetMaxSpeed($FleetArray, $USER);
         $distance = FleetFunctions::GetTargetDistance(array($PLANET['galaxy'], $PLANET['system'], $PLANET['planet']), array($sur['galaxy'], $sur['system'], $sur['planet']));
         $duration = FleetFunctions::GetMissionDuration(10, $MaxFleetSpeed, $distance, $GameSpeedFactor, $USER);
         $consumption = FleetFunctions::GetFleetConsumption($FleetArray, $duration, $distance, $MaxFleetSpeed, $USER, $GameSpeedFactor);
         $StayDuration = 0;
         if ($sur['deuterium'] < $consumption) {
             continue;
         }
         $PlanetRess = new ResourceUpdate();
         $PlanetRess->CalcResource();
         $fleetRessource = array(901 => $TransportMetal, 902 => $TransportCrystal, 903 => $TransportDeuterium);
         $GLOBALS['DATABASE']->multi_query("UPDATE " . PLANETS . " SET deuterium = deuterium - " . $consumption . " where `id` = '" . $sur['id'] . "';");
         $fleetStartTime = $duration + TIMESTAMP;
         $timeDifference = round(max(0, $fleetStartTime - 0));
         if ($fleet_group != 0) {
             if ($timeDifference != 0) {
                 FleetFunctions::setACSTime($timeDifference, $fleet_group);
             } else {
                 $fleetStartTime = $ACSTime;
             }
         }
         $fleetStayTime = $fleetStartTime + $StayDuration;
         $fleetEndTime = $fleetStayTime + $duration;
         if ($sur['system'] == $system) {
             $tickfinal = $tickinicial + 9;
         } else {
             $tickfinal = $tickinicial + 11;
         }
         FleetFunctions::sendFleet($FleetArray, $mission, $sur['id_owner'], $sur['id'], $sur['galaxy'], $sur['system'], $sur['planet'], 1, $PLANET['id_owner'], $PLANET['id'], $galaxy, $system, $planet, $planettype, $fleetRessource, $fleetStartTime, $fleetStayTime, $fleetEndTime, $tickinicial, $tickfinal, $fleet_group);
     }
     $this->printMessage('Fleets Succesfully Send', true, array('game.php?page=Reducefleet', 4));
 }