Example #1
0
 function show()
 {
     global $USER, $PLANET, $LNG, $UNI, $CONF, $resource, $pricelist, $reslist, $CONF;
     if ($CONF['dmenabled'] == 0) {
         $this->printMessage("This add-on is disabled", true, array('game.php?page=overview', 2));
         die;
     }
     $this->tplObj->loadscript("dmfleet.js");
     if ($PLANET[$resource[21]] == 0) {
         $this->printMessage($LNG['bd_shipyard_required']);
     }
     if ($CONF['fleetconf'] > TIMESTAMP) {
         $elementIDs = array(401, 402, 403, 404, 405, 406, 410, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422);
     } else {
         $elementIDs = array(401, 402, 403, 404, 405, 406, 410, 412, 413, 414, 416, 417, 418, 419);
     }
     foreach ($elementIDs as $Element) {
         if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]]);
     }
     $this->tplObj->assign_vars(array('elementList' => $elementList, 'ChargeDM' => self::$ChargeDM['defence'], 'ChargeDN' => self::$ChargeDN['fleets']));
     $this->display("page.dmdeff.default.tpl");
 }
Example #2
0
/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * 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 <http://www.gnu.org/licenses/>.
 *
 * @package 2Moons
 * @author Jan Kröpke <*****@*****.**>
 * @copyright 2012 Jan Kröpke <*****@*****.**>
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.7.2 (2013-03-18)
 * @info $Id$
 * @link http://2moons.cc/
 */
function getFactors($USER, $Type = 'basic', $TIME = NULL)
{
    global $resource, $pricelist, $reslist;
    if (empty($TIME)) {
        $TIME = TIMESTAMP;
    }
    $bonusList = BuildFunctions::getBonusList();
    $factor = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
    foreach ($reslist['bonus'] as $elementID) {
        $bonus = $pricelist[$elementID]['bonus'];
        if (isset($PLANET[$resource[$elementID]])) {
            $elementLevel = $PLANET[$resource[$elementID]];
        } elseif (isset($USER[$resource[$elementID]])) {
            $elementLevel = $USER[$resource[$elementID]];
        } else {
            continue;
        }
        if (in_array($elementID, $reslist['dmfunc'])) {
            if (DMExtra($elementLevel, $TIME, false, true)) {
                continue;
            }
            foreach ($bonusList as $bonusKey) {
                $factor[$bonusKey] += $bonus[$bonusKey][0];
            }
        } else {
            foreach ($bonusList as $bonusKey) {
                $factor[$bonusKey] += $elementLevel * $bonus[$bonusKey][0];
            }
        }
    }
    return $factor;
}
Example #3
0
 function show()
 {
     global $USER, $PLANET, $LNG, $UNI, $CONF, $resource, $pricelist;
     $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_planets` WHERE id_owner = " . $USER['id'] . " AND destruyed = '0' ORDER by ordernumber ASC;");
     $number = 1;
     if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
         while ($messageRow = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
             if ($messageRow['b_building'] - TIMESTAMP > 0) {
                 $Queue = unserialize($messageRow['b_building_id']);
                 $buildInfo['buildings'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $messageRow['b_building'] - TIMESTAMP, 'time' => $messageRow['b_building'], 'starttime' => pretty_time($messageRow['b_building'] - TIMESTAMP));
             } else {
                 $buildInfo['buildings'] = false;
             }
             /* As FR#206 (http://tracker.2moons.cc/view.php?id=206), i added the shipyard and research status here, but i add not them the template. */
             if (!empty($messageRow['b_hangar_id'])) {
                 $Queue = unserialize($messageRow['b_hangar_id']);
                 //$time	= BuildFunctions::getBuildingTime($USER, $messageRow['id'], $Queue[0][0]) * $Queue[0][1];
                 $time = BuildFunctions::getBuildingTime($USER, 1, $Queue[0][0]) * $Queue[0][1];
                 $buildInfo['fleet'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $messageRow['b_hangar'], 'time' => $time, 'starttime' => pretty_time($time - $messageRow['b_hangar']));
             } else {
                 $buildInfo['fleet'] = false;
             }
             if (!empty($messageRow['b_defense_id'])) {
                 $Queue = unserialize($messageRow['b_defense_id']);
                 //$time	= BuildFunctions::getBuildingTime($USER, $messageRow['id'], $Queue[0][0]) * $Queue[0][1];
                 $time = BuildFunctions::getBuildingTime($USER, 1, $Queue[0][0]) * $Queue[0][1];
                 $buildInfo['defense'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $messageRow['b_defense'], 'time' => $time, 'starttime' => pretty_time($time - $messageRow['b_defense']));
             } else {
                 $buildInfo['defense'] = false;
             }
             if ($USER['b_tech'] - TIMESTAMP > 0) {
                 $Queue = unserialize($USER['b_tech_queue']);
                 $buildInfo['tech'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $USER['b_tech'] - TIMESTAMP, 'time' => $USER['b_tech'], 'starttime' => pretty_time($USER['b_tech'] - TIMESTAMP));
             } else {
                 $buildInfo['tech'] = false;
             }
             $messageList[$messageRow['id']] = array('buildInfo' => $buildInfo, 'name' => $messageRow['name'], 'galaxy' => $messageRow['galaxy'], 'system' => $messageRow['system'], 'planet' => $messageRow['planet'], 'plid' => $messageRow['id'], 'gmetal' => pretty_number($messageRow['metal']), 'gcrystal' => pretty_number($messageRow['crystal']), 'gdeuterium' => pretty_number($messageRow['deuterium']), 'gelyrium' => pretty_number($messageRow['elyrium']), 'gmetalpircent' => round($messageRow['metal'] * 100 / $messageRow['metal_max']), 'gcrystalpircent' => round($messageRow['crystal'] * 100 / $messageRow['crystal_max']), 'gdeuteriumpircent' => round($messageRow['deuterium'] * 100 / $messageRow['deuterium_max']), 'gelyriumpircent' => round($messageRow['elyrium'] * 100 / $messageRow['elyrium_max']), 'energypircent' => round(abs($messageRow['energy'] * ($messageRow['energy'] - abs($messageRow['energy_used'])) / 2)), 'field_current' => $messageRow['field_current'], 'field_max' => $messageRow['field_max'], 'teleport_portal' => $messageRow['teleport_portal'], 'image' => $messageRow['image'], 'force_field_timer' => $messageRow['force_field_timer'], 'energy' => $messageRow['energy'], 'energy_used' => $messageRow['energy_used'], 'metal_mine_porcent' => $messageRow['metal_mine_porcent'] * 10, 'crystal_mine_porcent' => $messageRow['crystal_mine_porcent'] * 10, 'deuterium_sintetizer_porcent' => $messageRow['deuterium_sintetizer_porcent'] * 10, 'elyrium_mine_porcent' => $messageRow['elyrium_mine_porcent'] * 10, 'number' => $number++);
         }
     }
     $this->tplObj->assign_vars(array('messageList' => $messageList, 'timinger' => TIMESTAMP));
     $this->display("page.gestion.default.tpl");
 }
 public function show()
 {
     global $ProdGrid, $LNG, $resource, $reslist, $CONF, $PLANET, $USER, $pricelist;
     $TheCommand = HTTP::_GP('cmd', '');
     $mode = HTTP::_GP('cmdd', 'build');
     // wellformed buildURLs
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         $Element = HTTP::_GP('building', 0);
         $ListID = HTTP::_GP('listid', 0);
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue();
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
         $this->redirectTo('game.php?page=buildings&cmdd=' . $mode . '');
     }
     $queueData = $this->getQueueData();
     $Queue = $queueData['queue'];
     $QueueCount = count($Queue);
     $max_build = Config::get('max_elements_build');
     if ($USER['mode_chaine'] > TIMESTAMP) {
         $max_build += 2;
     }
     $CanBuildElement = isVacationMode($USER) || $max_build == 0 || $QueueCount < $max_build;
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET['field_current'] < $CurrentMaxFields - $QueueCount;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     $BuildInfoList = array();
     if ($mode == 'hangars') {
         $Elements = array(22, 23, 24, 25);
     } elseif ($mode == 'militar') {
         $Elements = array(45, 21, 46, 14, 31, 5, 33, 47);
     } else {
         $Elements = array(4, 10, 1, 2, 3, 48, 7, 8, 9, 11);
     }
     foreach ($Elements as $ID => $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $infoEnergy = "";
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $PLANET[$resource[$Element]];
         }
         if (in_array($Element, $reslist['prod'])) {
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = round(eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])));
             $BuildLevel = $levelToBuild + 1;
             $Prod = round(eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])));
             $requireEnergy = $Prod - $Need;
             if ($requireEnergy < 0) {
                 $infoEnergy = sprintf($LNG['bd_need_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             } else {
                 $infoEnergy = sprintf($LNG['bd_more_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $destroyRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, true);
         $destroyTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $destroyRessources);
         $destroyOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $destroyRessources);
         $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $BuildInfoList[$Element] = array('level' => $PLANET[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'infoEnergy' => $infoEnergy, 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'destroyRessources' => $destroyRessources, 'destroyTime' => $destroyTime, 'destroyOverflow' => $destroyOverflow, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     if ($QueueCount != 0) {
         $this->tplObj->loadscript('buildlist.js');
     }
     $Tab = 'Energy & resources';
     if ($mode == 'build') {
         $Tab = 'Energy & resources';
     } elseif ($mode == 'hangars') {
         $Tab = 'Storages';
     } elseif ($mode == 'militar') {
         $Tab = 'Military & science';
     }
     $this->tplObj->assign_vars(array('Tab' => $Tab, 'BuildInfoList' => $BuildInfoList, 'CanBuildElement' => $CanBuildElement, 'RoomIsOk' => $RoomIsOk, 'Queue' => $Queue, 'isBusy' => array('shipyard' => !empty($PLANET['b_hangar_id']), 'research' => $USER['b_tech_planet'] != 0), 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]], 'mode' => $mode));
     $this->display('page.buildings.default.tpl');
 }
 public function show()
 {
     global $ProdGrid, $LNG, $resource, $reslist, $PLANET, $USER, $pricelist;
     $TheCommand = HTTP::_GP('cmd', '');
     // wellformed buildURLs
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         $Element = HTTP::_GP('building', 0);
         $ListID = HTTP::_GP('listid', 0);
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue();
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
         $this->redirectTo('game.php?page=buildings');
     }
     $config = Config::get();
     $queueData = $this->getQueueData();
     $Queue = $queueData['queue'];
     $QueueCount = count($Queue);
     $CanBuildElement = isVacationMode($USER) || $config->max_elements_build == 0 || $QueueCount < $config->max_elements_build;
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET['field_current'] < $CurrentMaxFields - $QueueCount;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     $BuildInfoList = array();
     $Elements = $reslist['allow'][$PLANET['planet_type']];
     foreach ($Elements as $Element) {
         if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $infoEnergy = "";
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $PLANET[$resource[$Element]];
         }
         if (in_array($Element, $reslist['prod'])) {
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911]));
             $BuildLevel = $levelToBuild + 1;
             $Prod = eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911]));
             $requireEnergy = $Prod - $Need;
             $requireEnergy = round($requireEnergy * $config->energySpeed);
             if ($requireEnergy < 0) {
                 $infoEnergy = sprintf($LNG['bd_need_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             } else {
                 $infoEnergy = sprintf($LNG['bd_more_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             }
         }
         $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costResources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costResources);
         $destroyResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, true);
         $destroyTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $destroyResources);
         $destroyOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $destroyResources);
         $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costResources);
         $BuildInfoList[$Element] = array('level' => $PLANET[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'infoEnergy' => $infoEnergy, 'costResources' => $costResources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'destroyResources' => $destroyResources, 'destroyTime' => $destroyTime, 'destroyOverflow' => $destroyOverflow, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild);
     }
     if ($QueueCount != 0) {
         $this->tplObj->loadscript('buildlist.js');
     }
     $this->assign(array('BuildInfoList' => $BuildInfoList, 'CanBuildElement' => $CanBuildElement, 'RoomIsOk' => $RoomIsOk, 'Queue' => $Queue, 'isBusy' => array('shipyard' => !empty($PLANET['b_hangar_id']), 'research' => $USER['b_tech_planet'] != 0), 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]]));
     $this->display('page.buildings.default.tpl');
 }
Example #6
0
 function HangarBuild($Element, $Count)
 {
     global $SHIPYARD;
     $this->setGlobal();
     BuildFunctions::addShipsToQueue(array($Element => $Count));
     $this->getGlobal();
 }
    function EndStayEvent()
    {
        global $pricelist, $reslist, $resource;
        $LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
        $config = Config::get($this->_fleet['fleet_universe']);
        $expeditionPoints = array();
        foreach ($reslist['fleet'] as $shipId) {
            $expeditionPoints[$shipId] = ($pricelist[$shipId]['cost'][901] + $pricelist[$shipId]['cost'][902]) * 5 / 1000;
        }
        $fleetArray = FleetFunctions::unserialize($this->_fleet['fleet_array']);
        $fleetPoints = 0;
        $fleetCapacity = 0;
        foreach ($fleetArray as $shipId => $shipAmount) {
            $fleetCapacity += $shipAmount * $pricelist[$shipId]['capacity'];
            $fleetPoints += $shipAmount * $expeditionPoints[$shipId];
        }
        $fleetCapacity -= $this->_fleet['fleet_resource_metal'] + $this->_fleet['fleet_resource_crystal'] + $this->_fleet['fleet_resource_deuterium'] + $this->_fleet['fleet_resource_darkmatter'];
        $GetEvent = mt_rand(1, 9);
        $Message = $LNG['sys_expe_nothing_' . mt_rand(1, 8)];
        switch ($GetEvent) {
            case 1:
                $eventSize = mt_rand(0, 100);
                $factor = 0;
                if (10 < $eventSize) {
                    $Message = $LNG['sys_expe_found_ress_1_' . mt_rand(1, 4)];
                    $factor = mt_rand(10, 50);
                } elseif (0 < $eventSize && 10 >= $eventSize) {
                    $Message = $LNG['sys_expe_found_ress_2_' . mt_rand(1, 3)];
                    $factor = mt_rand(50, 100);
                } elseif (0 == $eventSize) {
                    $Message = $LNG['sys_expe_found_ress_3_' . mt_rand(1, 2)];
                    $factor = mt_rand(100, 200);
                }
                $chanceToFound = mt_rand(1, 6);
                if ($chanceToFound > 3) {
                    $resourceId = 901;
                } elseif ($chanceToFound > 1) {
                    $resourceId = 902;
                    $factor = $factor / 2;
                } else {
                    $resourceId = 903;
                    $factor = $factor / 3;
                }
                $sql = "SELECT MAX(total_points) as total FROM %%STATPOINTS%%\n\t\t\t\tWHERE `stat_type` = :type AND `universe` = :universe;";
                $topPoints = Database::get()->selectSingle($sql, array(':type' => 1, ':universe' => $this->_fleet['fleet_universe']), 'total');
                if ($topPoints > 5000000) {
                    $maxFactor = 12000;
                } elseif ($topPoints > 1000000) {
                    $maxFactor = 9000;
                } elseif ($topPoints > 100000) {
                    $maxFactor = 6000;
                } else {
                    $maxFactor = 2400;
                }
                $founded = round(min($maxFactor, max(200, $factor)) * $fleetPoints);
                $fleetColName = 'fleet_resource_' . $resource[$resourceId];
                $this->UpdateFleet($fleetColName, $this->_fleet[$fleetColName] + $founded);
                break;
            case 2:
                $eventSize = mt_rand(0, 100);
                $Size = 0;
                if (10 < $eventSize) {
                    $Size = mt_rand(100, 300);
                    $Message = $LNG['sys_expe_found_dm_1_' . mt_rand(1, 5)];
                } elseif (0 < $eventSize && 10 >= $eventSize) {
                    $Size = mt_rand(301, 600);
                    $Message = $LNG['sys_expe_found_dm_2_' . mt_rand(1, 3)];
                } elseif (0 == $eventSize) {
                    $Size = mt_rand(601, 3000);
                    $Message = $LNG['sys_expe_found_dm_3_' . mt_rand(1, 2)];
                }
                $this->UpdateFleet('fleet_resource_darkmatter', $this->_fleet['fleet_resource_darkmatter'] + $Size);
                break;
            case 3:
                $eventSize = mt_rand(0, 100);
                $Size = 0;
                $Message = "";
                if (10 < $eventSize) {
                    $Size = mt_rand(10, 50);
                    $Message = $LNG['sys_expe_found_ships_1_' . mt_rand(1, 4)];
                } elseif (0 < $eventSize && 10 >= $eventSize) {
                    $Size = mt_rand(52, 100);
                    $Message = $LNG['sys_expe_found_ships_2_' . mt_rand(1, 2)];
                } elseif (0 == $eventSize) {
                    $Size = mt_rand(102, 200);
                    $Message = $LNG['sys_expe_found_ships_3_' . mt_rand(1, 2)];
                }
                $sql = "SELECT MAX(total_points) as total FROM %%STATPOINTS%%\n\t\t\t\tWHERE `stat_type` = :type AND `universe` = :universe;";
                $topPoints = Database::get()->selectSingle($sql, array(':type' => 1, ':universe' => $this->_fleet['fleet_universe']), 'total');
                $MaxPoints = $topPoints < 5000000 ? 4500 : 6000;
                $FoundShips = max(round($Size * min($fleetPoints, $MaxPoints)), 10000);
                $FoundShipMess = "";
                $NewFleetArray = "";
                $Found = array();
                foreach ($reslist['fleet'] as $ID) {
                    if (!isset($fleetArray[$ID]) || $ID == 208 || $ID == 209 || $ID == 214) {
                        continue;
                    }
                    $MaxFound = floor($FoundShips / ($pricelist[$ID]['cost'][901] + $pricelist[$ID]['cost'][902]));
                    if ($MaxFound <= 0) {
                        continue;
                    }
                    $Count = mt_rand(0, $MaxFound);
                    if ($Count <= 0) {
                        continue;
                    }
                    $Found[$ID] = $Count;
                    $FoundShips -= $Count * ($pricelist[$ID]['cost'][901] + $pricelist[$ID]['cost'][902]);
                    $FoundShipMess .= '<br>' . $LNG['tech'][$ID] . ': ' . pretty_number($Count);
                    if ($FoundShips <= 0) {
                        break;
                    }
                }
                if (empty($Found)) {
                    $FoundShipMess .= '<br><br>' . $LNG['sys_expe_found_ships_nothing'];
                }
                foreach ($fleetArray as $ID => $Count) {
                    if (!empty($Found[$ID])) {
                        $Count += $Found[$ID];
                    }
                    $NewFleetArray .= $ID . "," . floatToString($Count) . ';';
                }
                $Message .= $FoundShipMess;
                $this->UpdateFleet('fleet_array', $NewFleetArray);
                $this->UpdateFleet('fleet_amount', array_sum($fleetArray));
                break;
            case 4:
                $messageHTML = <<<HTML
<div class="raportMessage">
<table>
<tr>
<td colspan="2"><a href="CombatReport.php?raport=%s" target="_blank"><span class="%s">%s %s (%s)</span></a></td>
</tr>
<tr>
<td>%s</td><td><span class="%s">%s: %s</span>&nbsp;<span class="%s">%s: %s</span></td>
</tr>
<tr>
<td>%s</td><td><span>%s:&nbsp;<span class="raportSteal element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="raportSteal element902">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="raportSteal element903">%s</span></span></td>
</tr>
<tr>
<td>%s</td><td><span>%s:&nbsp;<span class="raportDebris element901">%s</span>&nbsp;</span><span>%s:&nbsp;<span class="raportDebris element902">%s</span></span></td>
</tr>
</table>
</div>
HTML;
                //Minize HTML
                $messageHTML = str_replace(array("\n", "\t", "\r"), "", $messageHTML);
                // pirate or alien
                $attackType = mt_rand(1, 2);
                $eventSize = mt_rand(0, 100);
                $targetFleetData = array();
                if ($attackType == 1) {
                    $techBonus = -3;
                    $targetName = $LNG['sys_expe_attackname_1'];
                    $roundFunction = 'floor';
                    if (10 < $eventSize) {
                        $Message = $LNG['sys_expe_attack_1_1_5'];
                        $attackFactor = 30 + mt_rand(-3, 3) / 100;
                        $targetFleetData[204] = 5;
                    } elseif (0 < $eventSize && 10 >= $eventSize) {
                        $Message = $LNG['sys_expe_attack_1_2_3'];
                        $attackFactor = 50 + mt_rand(-5, 5) / 100;
                        $targetFleetData[206] = 3;
                    } else {
                        $Message = $LNG['sys_expe_attack_1_3_2'];
                        $attackFactor = 80 + mt_rand(-8, 8) / 100;
                        $targetFleetData[207] = 2;
                    }
                } else {
                    $techBonus = 3;
                    $targetName = $LNG['sys_expe_attackname_2'];
                    $roundFunction = 'ceil';
                    if (10 < $eventSize) {
                        $Message = $LNG['sys_expe_attack_1_1_5'];
                        $attackFactor = 40 + mt_rand(-4, 4) / 100;
                        $targetFleetData[204] = 5;
                    } elseif (0 < $eventSize && 10 >= $eventSize) {
                        $Message = $LNG['sys_expe_attack_1_3_3'];
                        $attackFactor = 60 + mt_rand(-6, 6) / 100;
                        $targetFleetData[215] = 3;
                    } else {
                        $Message = $LNG['sys_expe_attack_1_3_2'];
                        $attackFactor = 90 + mt_rand(-9, 9) / 100;
                        $targetFleetData[213] = 2;
                    }
                }
                foreach ($fleetArray as $shipId => $shipAmount) {
                    if (isset($targetFleetData[$shipId])) {
                        $targetFleetData[$shipId] = 0;
                    }
                    $targetFleetData[$shipId] = $roundFunction($shipAmount * $attackFactor);
                }
                $targetFleetData = array_filter($targetFleetData);
                $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
                $senderData = Database::get()->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
                $targetData = array('id' => 0, 'username' => $targetName, 'military_tech' => min($senderData['military_tech'] + $techBonus, 0), 'defence_tech' => min($senderData['defence_tech'] + $techBonus, 0), 'shield_tech' => min($senderData['shield_tech'] + $techBonus, 0), 'rpg_amiral' => 0, 'dm_defensive' => 0, 'dm_attack' => 0);
                $fleetID = $this->_fleet['fleet_id'];
                $fleetAttack[$fleetID]['fleetDetail'] = $this->_fleet;
                $fleetAttack[$fleetID]['player'] = $senderData;
                $fleetAttack[$fleetID]['player']['factor'] = getFactors($fleetAttack[$this->_fleet['fleet_id']]['player'], 'attack', $this->_fleet['fleet_start_time']);
                $fleetAttack[$fleetID]['unit'] = $fleetArray;
                $fleetDefend = array();
                $fleetDefend[0]['fleetDetail'] = array('fleet_start_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_start_system' => $this->_fleet['fleet_end_system'], 'fleet_start_planet' => $this->_fleet['fleet_end_planet'], 'fleet_start_type' => 1, 'fleet_end_galaxy' => $this->_fleet['fleet_end_galaxy'], 'fleet_end_system' => $this->_fleet['fleet_end_system'], 'fleet_end_planet' => $this->_fleet['fleet_end_planet'], 'fleet_end_type' => 1, 'fleet_resource_metal' => 0, 'fleet_resource_crystal' => 0, 'fleet_resource_deuterium' => 0);
                $bonusList = BuildFunctions::getBonusList();
                $fleetDefend[0]['player'] = $targetData;
                $fleetDefend[0]['player']['factor'] = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
                $fleetDefend[0]['unit'] = $targetFleetData;
                require_once 'includes/classes/missions/functions/calculateAttack.php';
                $combatResult = calculateAttack($fleetAttack, $fleetDefend, $config->Fleet_Cdr, $config->Defs_Cdr);
                $fleetArray = '';
                $totalCount = 0;
                $fleetAttack[$fleetID]['unit'] = array_filter($fleetAttack[$fleetID]['unit']);
                foreach ($fleetAttack[$fleetID]['unit'] as $element => $amount) {
                    $fleetArray .= $element . ',' . $amount . ';';
                    $totalCount += $amount;
                }
                if ($totalCount <= 0) {
                    $this->KillFleet();
                } else {
                    $this->UpdateFleet('fleet_array', substr($fleetArray, 0, -1));
                    $this->UpdateFleet('fleet_amount', $totalCount);
                }
                require_once 'includes/classes/missions/functions/GenerateReport.php';
                $debrisResource = array(901, 902);
                $debris = array();
                foreach ($debrisResource as $elementID) {
                    $debris[$elementID] = 0;
                }
                $stealResource = array(901 => 0, 902 => 0, 903 => 0);
                $reportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => 0, 'moonDestroy' => false, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => NULL);
                $reportData = GenerateReport($combatResult, $reportInfo);
                $reportID = md5(uniqid('', true) . TIMESTAMP);
                $sql = "INSERT INTO %%RW%% SET\n\t\t\t\trid\t\t\t= :reportId,\n\t\t\t\traport\t\t= :reportData,\n\t\t\t\ttime\t\t= :time,\n\t\t\t\tattacker\t= :attacker;";
                Database::get()->insert($sql, array(':reportId' => $reportID, ':reportData' => serialize($reportData), ':time' => $this->_fleet['fleet_start_time'], ':attacker' => $this->_fleet['fleet_owner']));
                switch ($combatResult['won']) {
                    case "a":
                        $attackClass = 'raportWin';
                        $defendClass = 'raportLose';
                        break;
                    case "r":
                        $attackClass = 'raportLose';
                        $defendClass = 'raportWin';
                        break;
                    default:
                        $attackClass = 'raportDraw';
                        $defendClass = 'raportDraw';
                        break;
                }
                $message = sprintf($messageHTML, $reportID, $attackClass, $LNG['sys_mess_attack_report'], sprintf($LNG['sys_adress_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']), $LNG['type_planet_short'][$this->_fleet['fleet_end_type']], $LNG['sys_lost'], $attackClass, $LNG['sys_attack_attacker_pos'], pretty_number($combatResult['unitLost']['attacker']), $defendClass, $LNG['sys_attack_defender_pos'], pretty_number($combatResult['unitLost']['defender']), $LNG['sys_gain'], $LNG['tech'][901], pretty_number($stealResource[901]), $LNG['tech'][902], pretty_number($stealResource[902]), $LNG['tech'][903], pretty_number($stealResource[903]), $LNG['sys_debris'], $LNG['tech'][901], pretty_number($debris[901]), $LNG['tech'][902], pretty_number($debris[902]));
                PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $this->_fleet['fleet_end_stay'], 3, $LNG['sys_mess_tower'], $LNG['sys_mess_attack_report'], $message);
                break;
            case 5:
                $this->KillFleet();
                $Message = $LNG['sys_expe_lost_fleet_' . mt_rand(1, 4)];
                break;
            case 6:
                # http://owiki.de/Expedition#Ver.C3.A4nderte_Flugzeit
                $chance = mt_rand(0, 100);
                $Wrapper = array();
                $Wrapper[] = 2;
                $Wrapper[] = 2;
                $Wrapper[] = 2;
                $Wrapper[] = 2;
                $Wrapper[] = 2;
                $Wrapper[] = 2;
                $Wrapper[] = 2;
                $Wrapper[] = 3;
                $Wrapper[] = 3;
                $Wrapper[] = 5;
                if ($chance < 75) {
                    // More return time
                    $normalBackTime = $this->_fleet['fleet_end_time'] - $this->_fleet['fleet_end_stay'];
                    $stayTime = $this->_fleet['fleet_end_stay'] - $this->_fleet['fleet_start_time'];
                    $factor = $Wrapper[mt_rand(0, 9)];
                    $endTime = $this->_fleet['fleet_end_stay'] + $normalBackTime + $stayTime + $factor;
                    $this->UpdateFleet('fleet_end_time', $endTime);
                    $Message = $LNG['sys_expe_time_slow_' . mt_rand(1, 6)];
                } else {
                    $normalBackTime = $this->_fleet['fleet_end_time'] - $this->_fleet['fleet_end_stay'];
                    $stayTime = $this->_fleet['fleet_end_stay'] - $this->_fleet['fleet_start_time'];
                    $factor = $Wrapper[mt_rand(0, 9)];
                    $endTime = max(1, $normalBackTime - $stayTime / 3 * $factor);
                    $this->UpdateFleet('fleet_end_time', $endTime);
                    $Message = $LNG['sys_expe_time_fast_' . mt_rand(1, 3)];
                }
                break;
        }
        PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 15, $LNG['sys_expe_report'], $Message, $this->_fleet['fleet_end_stay'], NULL, 1, $this->_fleet['fleet_universe']);
        $this->setState(FLEET_RETURN);
        $this->SaveFleet();
    }
Example #8
0
 public static function addResearchToQueue($Element, $AddMode = true)
 {
     global $PLANET, $USER, $resource, $CONF, $reslist, $pricelist;
     $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET);
     if (!in_array($Element, $reslist['tech']) || !BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element) || !BuildFunctions::CheckLabSettingsInQueue($PLANET)) {
         return;
     }
     $CurrentQueue = unserialize($USER['b_tech_queue']);
     if (!empty($CurrentQueue)) {
         $ActualCount = count($CurrentQueue);
     } else {
         $CurrentQueue = array();
         $ActualCount = 0;
     }
     if (Config::get('max_elements_tech') != 0 && Config::get('max_elements_tech') <= $ActualCount) {
         return false;
     }
     $BuildLevel = $USER[$resource[$Element]] + 1;
     if ($ActualCount == 0) {
         if ($pricelist[$Element]['max'] < $BuildLevel) {
             return;
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, !$AddMode);
         if (!BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources)) {
             return;
         }
         if (isset($costRessources[901])) {
             $PLANET[$resource[901]] -= $costRessources[901];
         }
         if (isset($costRessources[902])) {
             $PLANET[$resource[902]] -= $costRessources[902];
         }
         if (isset($costRessources[903])) {
             $PLANET[$resource[903]] -= $costRessources[903];
         }
         if (isset($costRessources[921])) {
             $USER[$resource[921]] -= $costRessources[921];
         }
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $BuildEndTime = TIMESTAMP + $elementTime;
         $USER['b_tech_queue'] = serialize(array(array($Element, $BuildLevel, $elementTime, $BuildEndTime, $PLANET['id'])));
         $USER['b_tech'] = $BuildEndTime;
         $USER['b_tech_id'] = $Element;
         $USER['b_tech_planet'] = $PLANET['id'];
     } else {
         $addLevel = 0;
         foreach ($CurrentQueue as $QueueSubArray) {
             if ($QueueSubArray[0] != $Element) {
                 continue;
             }
             $addLevel++;
         }
         $BuildLevel += $addLevel;
         if ($pricelist[$Element]['max'] < $BuildLevel) {
             return;
         }
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, NULL, !$AddMode, $BuildLevel);
         $BuildEndTime = $CurrentQueue[$ActualCount - 1][3] + $elementTime;
         $CurrentQueue[] = array($Element, $BuildLevel, $elementTime, $BuildEndTime, $PLANET['id']);
         $USER['b_tech_queue'] = serialize($CurrentQueue);
     }
 }
 public function show()
 {
     global $PLANET, $USER, $UNI, $LNG, $resource, $reslist, $CONF, $pricelist;
     if ($PLANET[$resource[31]] == 0) {
         $this->printMessage($LNG['bd_lab_required']);
     }
     $TheCommand = HTTP::_GP('cmd', '');
     $Element = HTTP::_GP('tech', 0);
     $ListID = HTTP::_GP('listid', 0);
     $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET);
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         switch ($TheCommand) {
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
         }
         $this->redirectTo('game.php?page=dmtech');
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET);
     $queueData = $this->getQueueData();
     $TechQueue = $queueData['queue'];
     $QueueCount = count($TechQueue);
     $ResearchList = array();
     $Elements = array(106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 131, 132, 133);
     foreach ($Elements as $ID => $Element) {
         if (!BuildFunctions::isBusyToBuild($USER, $PLANET, $Element)) {
             continue;
         }
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $USER[$resource[$Element]];
         }
         $costRessources = max(1, ($pricelist[$Element]['cost']['901'] + $pricelist[$Element]['cost']['902'] * 2 + $pricelist[$Element]['cost']['903'] * 4) * pow($pricelist[$Element]['factor'], $USER[$resource[$Element]]) / 2500);
         $elementTime = 0;
         $ResearchList[$Element] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => pretty_number($costRessources), 'levelToBuild' => $levelToBuild, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element), 'AllTech' => $AllTech);
     }
     $premium_stage = 0;
     if ($USER['premium_reward_stage'] > 0 && $USER['premium_reward_days'] > TIMESTAMP) {
         $premium_stage = $USER['premium_reward_stage'];
     }
     $this->tplObj->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => Config::get('max_elements_tech') == 0 || Config::get('max_elements_tech') + $premium_stage == count($TechQueue), 'Queue' => $TechQueue));
     $this->display('page.dmtech.default.tpl');
 }
 function show()
 {
     global $USER, $PLANET, $LNG, $resource, $dpath, $reslist, $CONF;
     $elementIDs = $reslist['population'];
     foreach ($elementIDs as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, false);
         $Produced = 0;
         $Cost = 0;
         if ($Element == 301) {
             $Cost = 1;
         } elseif ($Element == 302) {
             $Cost = 3;
         } elseif ($Element == 303) {
             $Cost = 4;
         } elseif ($Element == 304) {
             $Cost = 50;
         } elseif ($Element == 305) {
             $Cost = 20;
         } elseif ($Element == 306) {
             $Cost = 12;
         } elseif ($Element == 307) {
             $Cost = 44;
         } elseif ($Element == 308) {
             $Cost = 4;
         }
         if ($Element != 309) {
             $Produced = $PLANET[$resource[$Element] . '_prod'];
             $TotalCost = $Produced * $Cost;
         }
         $elementList[$Element] = array('amount' => pretty_number(round($PLANET[$resource[$Element]])), 'costRessources' => $costRessources, 'Produced' => $Produced, 'TotalCost' => $TotalCost, 'id' => $Element, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $this->tplObj->loadscript("population.js");
     $this->tplObj->assign_vars(array('notused' => pretty_number($PLANET['formation'] - $PLANET['formation_used']), 'elementList' => $elementList, 'formation' => pretty_number($PLANET['formation']), 'formationBis' => $PLANET['formation']));
     $this->display('page.population.default.tpl');
 }
Example #11
0
 public function show()
 {
     global $USER, $PLANET, $LNG, $resource, $dpath, $reslist, $CONF;
     $fmenge = isset($_POST['fmenge']) ? $_POST['fmenge'] : array();
     $action = HTTP::_GP('action', '');
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = unserialize($PLANET['b_building_id']);
         foreach ($CurrentQueue as $ElementArray) {
             if ($ElementArray[0] == 21 || $ElementArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     if (empty($ElementQueue)) {
         $Count = 0;
     } else {
         $Count = count($ElementQueue);
     }
     if ($USER['urlaubs_modus'] == 0) {
         if (!empty($fmenge) && $NotBuilding == true) {
             if (Config::get('max_elements_ships') != 0 && $Count >= Config::get('max_elements_ships')) {
                 $this->printMessage(sprintf($LNG['bd_max_builds'], Config::get('max_elements_ships')));
                 exit;
             }
             $this->BuildAuftr($fmenge);
         }
         if ($action == "delete") {
             $this->CancelAuftr();
         }
     }
     $elementInQueue = array();
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     $Buildlist = array();
     if (!empty($ElementQueue)) {
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $Element) {
             if (empty($Element)) {
                 continue;
             }
             $elementInQueue[$Element[0]] = true;
             $ElementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime, $Element[0]);
         }
         $this->tplObj->loadscript('bcmath.js');
         $this->tplObj->loadscript('shipyard.js');
         $this->tplObj->execscript('ShipyardInit();');
         $Buildlist = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0)));
     }
     $mode = HTTP::_GP('mode', 'fleet');
     if ($mode == 'defense') {
         $elementIDs = array(401, 402, 403, 404, 405, 406);
     } elseif ($mode == 'orbit') {
         $elementIDs = array(407, 408);
     } elseif ($mode == 'recy') {
         $elementIDs = array(209, 223, 219);
     } elseif ($mode == 'energy') {
         $elementIDs = array(221, 222);
     } elseif ($mode == 'combat') {
         $elementIDs = array(204, 205, 206, 207, 211, 214, 215, 216);
     } else {
         $elementIDs = array(202, 203, 210, 224);
     }
     $inmode = 0;
     if ($mode == 'recy' || $mode == 'energy' || $mode == 'combat' || $mode == 'fleet') {
         $inmode = 1;
     }
     $Missiles = array();
     foreach ($reslist['missile'] as $elementID) {
         $Missiles[$elementID] = $PLANET[$resource[$elementID]];
     }
     $MaxMissiles = BuildFunctions::getMaxConstructibleRockets($USER, $PLANET, $Missiles);
     foreach ($elementIDs as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $this->tplObj->assign_vars(array('inmode' => $inmode, 'elementList' => $elementList, 'NotBuilding' => $NotBuilding, 'BuildList' => $Buildlist, 'maxlength' => strlen(Config::get('max_fleet_per_build')), 'mode' => $mode));
     $this->display('page.shipyard.default.tpl');
 }
 public function show()
 {
     global $ProdGrid, $LNG, $UNI, $resource, $reslist, $CONF, $PLANET, $USER, $pricelist;
     $TheCommand = HTTP::_GP('cmd', '');
     // wellformed buildURLs
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         $Element = HTTP::_GP('building', 0);
         $ListID = HTTP::_GP('listid', 0);
         switch ($TheCommand) {
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
         }
         $this->redirectTo('game.php?page=dmbuild');
     }
     $premium_stage = 0;
     if ($USER['premium_reward_stage'] > 0 && $USER['premium_reward_days'] > TIMESTAMP) {
         $premium_stage = $USER['premium_reward_stage'];
     }
     $queueData = $this->getQueueData();
     $Queue = $queueData['queue'];
     $QueueCount = count($Queue);
     $CanBuildElement = isVacationMode($USER) || Config::get('max_elements_build') == 0 || $QueueCount < Config::get('max_elements_build') + $premium_stage;
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET['field_current'] < $CurrentMaxFields - $QueueCount;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     $BuildInfoList = array();
     if ($PLANET['planet_type'] == 1) {
         $Elements = $reslist['allow'][$PLANET['planet_type']];
     } elseif ($PLANET['planet_type'] == 3) {
         $Elements = array(14, 15, 21, 22, 23, 24, 41, 42, 43);
     }
     foreach ($Elements as $ID => $Element) {
         if (!BuildFunctions::isBusyToBuild($USER, $PLANET, $Element)) {
             continue;
         }
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $infoEnergy = "";
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $PLANET[$resource[$Element]];
         }
         if (in_array($Element, $reslist['prod'])) {
             $premium_resource = 0;
             if ($USER['premium_reward_extraction'] > 0 && $USER['premium_reward_extraction_days'] > TIMESTAMP) {
                 $premium_resource = $USER['premium_reward_extraction'];
             }
             $premium_resource = $premium_resource;
             $peacefull_resource = 0;
             if ($USER['experience_peace_level'] > 0) {
                 $peacefull_resource = $USER['experience_peace_level'];
             }
             $peacefull_resource = $peacefull_resource;
             $combat_collider = 0;
             if ($USER['combat_reward_collider'] > 0) {
                 $combat_collider = $USER['combat_reward_collider'];
             }
             $combat_collider = $combat_collider;
             $academy_mines = 0;
             if ($USER['academy_1201'] > 0) {
                 $academy_mines = getbonusOneBis(1201, $USER['academy_1201']);
             }
             $academy_mines = $academy_mines;
             $daily_prod_bonus = 0;
             if ($USER['daily_produ'] > TIMESTAMP) {
                 $daily_prod_bonus = 30;
             }
             $daily_prod_bonus = $daily_prod_bonus;
             $academy_energy = 0;
             if ($USER['academy_1202'] > 0) {
                 $academy_energy = getbonusOneBis(1202, $USER['academy_1202']);
             }
             $academy_energy = $academy_energy;
             $academy_fusion = 0;
             if ($USER['academy_1209'] > 0) {
                 $academy_fusion = getbonusOneBis(1209, $USER['academy_1209']);
             }
             $academy_fusion = $academy_fusion;
             $academy_solar = 0;
             if ($USER['academy_1210'] > 0) {
                 $academy_solar = getbonusOneBis(1210, $USER['academy_1210']);
             }
             $academy_solar = $academy_solar;
             $allyInfo = $GLOBALS['DATABASE']->query("SELECT alliance_prod FROM `uni1_alliance` WHERE id = " . $USER['ally_id'] . ";");
             $allyInfo = $GLOBALS['DATABASE']->fetch_array($allyInfo);
             $alliance_prod = 0;
             if ($allyInfo['alliance_prod'] > 0) {
                 $alliance_prod = $allyInfo['alliance_prod'];
             }
             $alliance_prod = $alliance_prod;
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = round(eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])));
             $BuildLevel = $levelToBuild + 1;
             $Prod = round(eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])));
             $requireEnergy = $Prod - $Need;
             if ($requireEnergy < 0) {
                 $infoEnergy = sprintf($LNG['bd_need_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             } else {
                 $infoEnergy = sprintf($LNG['bd_more_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             }
         }
         $costRessources = round(max(1, ($pricelist[$Element]['cost']['901'] + $pricelist[$Element]['cost']['902'] + $pricelist[$Element]['cost']['903']) * pow($pricelist[$Element]['factor'], $PLANET[$resource[$Element]]) / 5000));
         $elementTime = 0;
         $BuildInfoList[$Element] = array('level' => $PLANET[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'infoEnergy' => $infoEnergy, 'costRessources' => pretty_number($costRessources), 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element), 'elementTime' => $elementTime, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech);
     }
     $this->tplObj->loadscript('buildlist.js');
     $this->tplObj->assign_vars(array('BuildInfoList' => $BuildInfoList, 'CanBuildElement' => $CanBuildElement, 'RoomIsOk' => $RoomIsOk, 'Queue' => $Queue, 'isBusy' => array('shipyard' => !empty($PLANET['b_hangar_id']), 'research' => $USER['b_tech_planet'] != 0), 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]], 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]], 'field_used' => $PLANET['field_current'], 'field_max' => CalculateMaxPlanetFields($PLANET), 'field_left' => CalculateMaxPlanetFields($PLANET) - $PLANET['field_current'], 'field_percent' => $PLANET['field_current'] * 100 / CalculateMaxPlanetFields($PLANET)));
     $this->display('page.dmbuild.default.tpl');
 }
Example #13
0
 function show()
 {
     global $CONF, $LNG, $PLANET, $USER, $resource, $UNI, $ALLIANCE;
     $AdminsOnline = array();
     $chatOnline = array();
     $AllPlanets = array();
     $Moon = array();
     $RefLinks = array();
     $Buildtime = 0;
     foreach ($USER['PLANETS'] as $ID => $CPLANET) {
         if ($ID == $PLANET['id'] || $CPLANET['planet_type'] == 3) {
             continue;
         }
         if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) {
             $Queue = unserialize($CPLANET['b_building_id']);
             $BuildPlanet = $LNG['tech'][$Queue[0][0]] . " (" . $Queue[0][1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($Queue[0][3] - TIMESTAMP) . ")</span>";
         } else {
             $BuildPlanet = $LNG['ov_free'];
         }
         $AllPlanets[] = array('id' => $CPLANET['id'], 'name' => $CPLANET['name'], 'image' => $CPLANET['image'], 'build' => $BuildPlanet);
     }
     if ($PLANET['id_luna'] != 0) {
         $Moon = $GLOBALS['DATABASE']->getFirstRow("SELECT id, name FROM " . PLANETS . " WHERE id = '" . $PLANET['id_luna'] . "';");
     }
     $overmessage = 0;
     if ($PLANET['b_building'] - TIMESTAMP > 0) {
         $Queue = unserialize($PLANET['b_building_id']);
         $temp_total = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1));
         $temps_rest = $PLANET['b_building'] - TIMESTAMP;
         $pourc = 100 - 100 / $temp_total * $temps_rest;
         $buildInfo['buildings'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1), 'elementime' => pretty_time(BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $PLANET['b_building'] - TIMESTAMP, 'time' => $PLANET['b_building'], 'endtime' => date('d/m/Y H:i:s', $PLANET['b_building']), 'percenting' => round($pourc), 'starttime' => pretty_time($PLANET['b_building'] - TIMESTAMP), 'starttimeego' => date('d/m/Y H:i:s', $PLANET['b_building'] - BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))));
         $overmessage = 1;
     } else {
         $buildInfo['buildings'] = false;
     }
     /* As FR#206 (http://tracker.2moons.cc/view.php?id=206), i added the shipyard and research status here, but i add not them the template. */
     if (!empty($PLANET['b_hangar_id'])) {
         $Queue = unserialize($PLANET['b_hangar_id']);
         $time = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]) * $Queue[0][1];
         $times = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]);
         $buildInfo['fleet'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0]), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_hangar'], 'timelefts' => date('d/m/Y H:i:s', TIMESTAMP + ($times - $PLANET['b_hangar'])), 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_hangar']), 'endtime' => date('d/m/Y H:i:s', TIMESTAMP + $time - $PLANET['b_hangar']));
         $overmessage = 1;
     } else {
         $buildInfo['fleet'] = false;
     }
     if (!empty($PLANET['b_defense_id'])) {
         $Queue = unserialize($PLANET['b_defense_id']);
         $time = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]) * $Queue[0][1];
         $times = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]);
         $buildInfo['defense'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0]), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_defense'], 'timelefts' => date('d/m/Y H:i:s', TIMESTAMP + ($times - $PLANET['b_defense'])), 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_defense']), 'endtime' => date('d/m/Y H:i:s', TIMESTAMP + $time - $PLANET['b_defense']));
         $overmessage = 1;
     } else {
         $buildInfo['defense'] = false;
     }
     if ($USER['b_tech'] - TIMESTAMP > 0) {
         $Queue = unserialize($USER['b_tech_queue']);
         $temp_total = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1));
         $temps_rest = $PLANET['b_building'] - TIMESTAMP;
         $pourc = 100 - 100 / $temp_total * $temps_rest;
         $buildInfo['tech'] = array('price' => BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1), 'elementime' => pretty_time(BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))), 'id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $USER['b_tech'] - TIMESTAMP, 'endtime' => date('d/m/Y H:i:s', $USER['b_tech']), 'percenting' => round($pourc), 'starttime' => pretty_time($USER['b_tech'] - TIMESTAMP), 'starttimeego' => date('d/m/Y H:i:s', $USER['b_tech'] - BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0], BuildFunctions::getElementPrice($USER, $PLANET, $Queue[0][0], false, $Queue[0][1] - 1))));
         $overmessage = 1;
     } else {
         $buildInfo['tech'] = false;
     }
     $OnlineAdmins = $GLOBALS['DATABASE']->query("SELECT id,username FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime >= " . (TIMESTAMP - 10 * 60) . " AND authlevel > '" . AUTH_USR . "';");
     while ($AdminRow = $GLOBALS['DATABASE']->fetch_array($OnlineAdmins)) {
         $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
     }
     $GLOBALS['DATABASE']->free_result($OnlineAdmins);
     $Messages = $USER['messages'];
     // Fehler: Wenn Spieler gelöscht werden, werden sie nicht mehr in der Tabelle angezeigt.
     $RefLinksRAW = $GLOBALS['DATABASE']->query("SELECT u.id, u.username, s.total_points FROM " . USERS . " as u LEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE ref_id = " . $USER['id'] . ";");
     if (Config::get('ref_active')) {
         while ($RefRow = $GLOBALS['DATABASE']->fetch_array($RefLinksRAW)) {
             $RefLinks[$RefRow['id']] = array('username' => $RefRow['username'], 'points' => min($RefRow['total_points'], Config::get('ref_minpoints')));
         }
     }
     if ($USER['total_rank'] == 0) {
         $rankInfo = "-";
     } else {
         $rankInfo = sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $LNG['ov_of'], Config::get('users_amount'));
     }
     if ($USER['total_rank'] == 0) {
         $userRank = "-";
         $userTotal = Config::get('users_amount');
     } else {
         $userRank = $USER['total_rank'];
         $userTotal = Config::get('users_amount');
     }
     $AllFeeds = array();
     $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_newsfeed` WHERE accepted = '1' AND valid_until > " . TIMESTAMP . " ORDER BY date DESC LIMIT 6;");
     if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
         while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
             $AllFeeds[] = $x;
         }
     }
     $allianceData = $GLOBALS['DATABASE']->query("SELECT DISTINCT a.*, s.total_rank, s.total_points FROM " . ALLIANCE . " as a\n                INNER JOIN " . STATPOINTS . " as s ON a.id = s.id_owner\n                WHERE `universe` = 1 AND `id` = " . $USER['ally_id'] . ";");
     $Total_alliance = $GLOBALS['DATABASE']->query("SELECT COUNT(id) FROM " . ALLIANCE . ";");
     $Total_alliance = $GLOBALS['DATABASE']->fetch_array($Total_alliance);
     $ally_tag = $this->getAllianceTag($USER['ally_id']);
     $ally_name = $this->getAllianceName($USER['ally_id']);
     $ally_members = '';
     $ally_points = '';
     $ally_rank = '';
     if ($GLOBALS['DATABASE']->numRows($allianceData) > 0) {
         while ($as = $GLOBALS['DATABASE']->fetch_array($allianceData)) {
             $ally_members = $as['ally_members'];
             $ally_points = pretty_number($as['total_points']);
             $ally_rank = $as['total_rank'];
         }
     }
     $statinfo = $GLOBALS['DATABASE']->query("SELECT s.total_points, s.popu_points, s.defs_points, s.build_points, s.fleet_points, s.tech_points, s.total_old_rank, s.total_rank, h.history_total_points  FROM " . USERS . " as u \n\t\t\tLEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1'\n\t\t\tLEFT JOIN " . STATHISTORY . " as h ON h.id_owner = u.id WHERE id = " . $USER['id'] . ";");
     while ($game = $GLOBALS['DATABASE']->fetch_array($statinfo)) {
         $ranking = $game['total_old_rank'] - $game['total_rank'];
         $totalo = $game['total_points'] - $game['history_total_points'];
         $totalP = $game['total_points'];
         $totalBuild = $game['build_points'];
         $totalResearch = $game['tech_points'];
         $totalFleet = $game['fleet_points'];
         $totalDefense = $game['defs_points'];
         $totalPopu = $game['popu_points'];
         if ($ranking == 0) {
             $position = "<span style='color:orange'>0";
         } elseif ($ranking < 0) {
             $position = "<img src='media/ingame/image/diminue.png' /><span style='color:rouge'>(" . $ranking . ")";
         } elseif ($ranking > 0) {
             $position = "<img src='media/ingame/image/augmente.png' /><span style='color:vert'>(+" . $ranking . ")";
         }
         if ($totalo == 0) {
             $positionP = "<span style='color:orange'>0";
         } elseif ($totalo < 0) {
             $positionP = "<img src='media/ingame/image/diminue.png' /><span style='color:rouge'> (" . pretty_number($totalo) . ")";
         } elseif ($totalo > 0) {
             $positionP = "<img src='media/ingame/image/augmente.png' /><span style='color:vert'> (+" . pretty_number($totalo) . ")";
         }
     }
     $post = $position;
     $postP = $positionP;
     $GetAll99 = $GLOBALS['DATABASE']->query("SELECT id FROM " . PLANETS . " WHERE id != " . $PLANET['id'] . " AND id_owner = " . $USER['id'] . " AND destruyed = '0' ;");
     $GetAll99 = $GLOBALS['DATABASE']->numRows($GetAll99);
     $fleetCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . FLEETS . " WHERE fleet_owner = '" . $USER['id'] . "' OR fleet_target_owner = '" . $USER['id'] . "' AND hasCanceled = '0' AND fleet_mess = '0' AND fleet_mission != '8';");
     $defcontext = '';
     $defcon = '';
     if ($USER['ally_id'] != 0) {
         $textar = $GLOBALS['DATABASE']->query("SELECT defcon FROM " . ALLIANCE . " WHERE id = " . $USER['ally_id'] . " ;");
         while ($x = $GLOBALS['DATABASE']->fetch_array($textar)) {
             $defcontext = '';
             $defcon = $x['defcon'];
             if ($x['defcon'] == 5) {
                 $defcontext = 'Normal preparation in peacetime';
             } elseif ($x['defcon'] == 4) {
                 $defcontext = 'Normal preparation, but increased and enhanced information security measures';
                 //vert
             } elseif ($x['defcon'] == 3) {
                 $defcontext = 'Increased preparation of forces beyond the normal preparation';
                 //jaune
             } elseif ($x['defcon'] == 2) {
                 $defcontext = 'Further increase in the preparation of forces, but less than the maximum preparation';
                 //oramnge
             } elseif ($x['defcon'] == 1) {
                 $defcontext = 'State of War: Maximum forces Preparation';
                 //rouge
             }
         }
     }
     $GeTransportCount = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM `uni1_transport_player` WHERE senderID = " . $USER['id'] . " AND legal = '1' OR receiverID = " . $USER['id'] . " AND legal = '1';");
     //Bank Config
     if ($CONF['newbank'] < TIMESTAMP) {
         $Info = $GLOBALS['DATABASE']->query("SELECT taxe_metal, new_taxe_metal, taxe_crystal, new_taxe_crystal, taxe_deuterium, new_taxe_deuterium, taxe_elyrium, new_taxe_elyrium FROM `uni1_config` WHERE uni = '1';");
         $Info = $GLOBALS['DATABASE']->fetch_array($Info);
         $NewMet = $Info['taxe_metal'] + $Info['new_taxe_metal'];
         $NewCryt = $Info['taxe_crystal'] + $Info['new_taxe_crystal'];
         $NewDeut = $Info['taxe_deuterium'] + $Info['new_taxe_deuterium'];
         $NewElyr = $Info['taxe_elyrium'] + $Info['new_taxe_elyrium'];
         $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET taxe_metal = '" . $NewMet . "', taxe_crystal = '" . $NewCryt . "', taxe_deuterium = '" . $NewDeut . "', taxe_elyrium = '" . $NewElyr . "', new_taxe_metal = '0', new_taxe_crystal = '0', new_taxe_deuterium = '0', new_taxe_elyrium = '0', newbank = newbank + '" . (TIMESTAMP + 3600 * 24) . "';");
     }
     $this->tplObj->assign_vars(array('avatar' => $USER['avatar'], 'totalP' => pretty_number($totalP), 'totalBuild' => pretty_number($totalBuild), 'totalResearch' => pretty_number($totalResearch), 'totalFleet' => pretty_number($totalFleet), 'totalDefense' => pretty_number($totalDefense), 'totalPopu' => pretty_number($totalPopu), 'GetAll99' => $GetAll99, 'fleetCount' => $fleetCount, 'defcontext' => $defcontext, 'defcon' => $defcon, 'overmessage' => $overmessage, 'postal' => $post, 'postalP' => $postP, 'userRank' => $userRank, 'GeTransportCount' => $GeTransportCount, 'userTotal' => $userTotal, 'Total_alliance' => (int) $Total_alliance, 'ally_tag' => $ally_tag, 'ally_rank' => $ally_rank, 'ally_points' => $ally_points, 'ally_members' => $ally_members, 'ally_name' => $ally_name, 'rankInfo' => $rankInfo, 'userally' => $USER['ally_id'], 'AllFeeds' => $AllFeeds, 'is_news' => Config::get('OverviewNewsFrame'), 'news' => makebr(Config::get('OverviewNewsText')), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'cokies' => isset($_COOKIE['salle_de_controle-detail_statistique']) ? $_COOKIE['salle_de_controle-detail_statistique'] : 'false', 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'username' => $USER['username'], 'userid' => $USER['id'], 'allyID' => $USER['ally_id'], 'buildInfo' => $buildInfo, 'Moon' => $Moon, 'fleets' => $this->GetFleets(), 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'teamspeakData' => $this->GetTeamspeakData(), 'messages' => $Messages > 0 ? $Messages == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($Messages)) : false, 'planet_diameter' => pretty_number($PLANET['diameter']), 'teleport_portal' => $PLANET['teleport_portal'], 'force_field' => $PLANET['force_field_timer'], 'siege_active' => $PLANET['siege_on'], 'planet_field_current' => $PLANET['field_current'], 'planet_field_max' => CalculateMaxPlanetFields($PLANET), 'planet_temp_min' => $PLANET['temp_min'], 'planet_temp_max' => $PLANET['temp_max'], 'ref_active' => Config::get('ref_active'), 'ref_minpoints' => Config::get('ref_minpoints'), 'RefLinks' => $RefLinks, 'path' => HTTP_PATH, 'trem' => TIMESTAMP, 'taxe_metal' => $CONF['taxe_metal'], 'taxe_crystal' => $CONF['taxe_crystal'], 'taxe_deuterium' => $CONF['taxe_deuterium'], 'taxe_elyrium' => $CONF['taxe_elyrium']));
     $this->display('page.overview.default.tpl');
 }
Example #14
0
 public function show()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $pricelist;
     $TheCommand = HTTP::_GP('cmd', '');
     $Element = HTTP::_GP('tech', 0);
     $ListID = HTTP::_GP('listid', 0);
     $mode = HTTP::_GP('cmdd', 'physik');
     $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET);
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue();
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
         $this->redirectTo('game.php?page=research&cmdd=' . $mode . '');
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET);
     $queueData = $this->getQueueData();
     $TechQueue = $queueData['queue'];
     $QueueCount = count($TechQueue);
     $ResearchList = array();
     if ($mode == 'space') {
         $elementIDs = array(109, 110, 111, 115, 117, 118);
     } elseif ($mode == 'militar') {
         $elementIDs = array(145, 106, 146, 147, 148, 149);
     } else {
         $elementIDs = array(113, 140, 141, 142, 143, 144);
     }
     foreach ($elementIDs as $ID => $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $USER[$resource[$Element]];
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $ResearchList[$Element] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     if ($USER['b_tech_id'] != 0) {
         $this->tplObj->loadscript('research.js');
     }
     $max_build = Config::get('max_elements_tech');
     if ($USER['mode_chaine'] > TIMESTAMP) {
         $max_build += 2;
     }
     if ($mode == 'space') {
         $Tab = 'Space research';
     } elseif ($mode == 'militar') {
         $Tab = 'Military research';
     } else {
         $Tab = 'Theoretical Physics';
     }
     $this->tplObj->assign_vars(array('Tab' => $Tab, 'ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => $max_build == 0 || $max_build == count($TechQueue), 'Queue' => $TechQueue, 'mode' => $mode));
     $this->display('page.research.default.tpl');
 }
 public function show()
 {
     global $USER, $CONF, $PLANET, $resource, $reslist, $LNG, $pricelist;
     $updateID = HTTP::_GP('id', 0);
     if (!empty($updateID) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         if (isModulAvalible(MODULE_OFFICIER) && in_array($updateID, $reslist['officier'])) {
             $this->UpdateOfficier($updateID);
         } elseif (isModulAvalible(MODULE_DMEXTRAS) && in_array($updateID, $reslist['dmfunc'])) {
             $this->UpdateExtra($updateID);
         }
     }
     $this->tplObj->loadscript('officier.js');
     $darkmatterList = array();
     $officierList = array();
     if (isModulAvalible(MODULE_DMEXTRAS)) {
         foreach ($reslist['dmfunc'] as $Element) {
             if ($USER[$resource[$Element]] > TIMESTAMP) {
                 $this->tplObj->execscript("GetOfficerTime(" . $Element . ", " . ($USER[$resource[$Element]] - TIMESTAMP) . ");");
             }
             $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
             $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
             $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
             $elementBonus = BuildFunctions::getAvalibleBonus($Element);
             $darkmatterList[$Element] = array('timeLeft' => max($USER[$resource[$Element]] - TIMESTAMP, 0), 'costRessources' => $costRessources, 'buyable' => $buyable, 'time' => $pricelist[$Element]['time'], 'costOverflow' => $costOverflow, 'elementBonus' => $elementBonus);
         }
     }
     if (isModulAvalible(MODULE_OFFICIER)) {
         foreach ($reslist['officier'] as $Element) {
             $AllTech = array();
             $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
             if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
                 while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                     $AllTech[] = $x;
                 }
             }
             $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
             $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
             $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
             $elementBonus = BuildFunctions::getAvalibleBonus($Element);
             $officierList[$Element] = array('level' => $USER[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => $costRessources, 'buyable' => $buyable, 'costOverflow' => $costOverflow, 'elementBonus' => $elementBonus, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
         }
     }
     $close_to = 1;
     if ($USER['rpg_geologue'] >= 1 && $USER['rpg_amiral'] >= 1 && $USER['training_step'] == 23) {
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '24' WHERE `id` = " . $USER['id'] . ";");
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `experience_peace` = `experience_peace` + '24' WHERE `id` = " . $USER['id'] . ";");
         $close_to = 0;
     }
     $manual_23_step = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 23 && $close_to == 1) {
         $manual_23_step = 0;
     }
     $this->tplObj->assign_vars(array('manual_23_step' => $manual_23_step, 'close_to' => $close_to, 'officierList' => $officierList, 'darkmatterList' => $darkmatterList, 'of_dm_trade' => sprintf($LNG['of_dm_trade'], $LNG['tech'][921])));
     $this->display('page.officier.default.tpl');
 }
 public function show()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $pricelist;
     if ($PLANET[$resource[31]] == 0) {
         $this->printMessage($LNG['bd_lab_required']);
     }
     $TheCommand = HTTP::_GP('cmd', '');
     $elementId = HTTP::_GP('tech', 0);
     $ListID = HTTP::_GP('listid', 0);
     $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET);
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue();
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($elementId, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($elementId, false);
                 break;
         }
         $this->redirectTo('game.php?page=research');
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET);
     $queueData = $this->getQueueData();
     $TechQueue = $queueData['queue'];
     $QueueCount = count($TechQueue);
     $ResearchList = array();
     foreach ($reslist['tech'] as $elementId) {
         if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $elementId)) {
             continue;
         }
         if (isset($queueData['quickinfo'][$elementId])) {
             $levelToBuild = $queueData['quickinfo'][$elementId];
         } else {
             $levelToBuild = $USER[$resource[$elementId]];
         }
         $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $elementId, false, $levelToBuild);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $elementId, $costResources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $elementId, $costResources);
         $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $elementId, $costResources);
         $ResearchList[$elementId] = array('id' => $elementId, 'level' => $USER[$resource[$elementId]], 'maxLevel' => $pricelist[$elementId]['max'], 'costResources' => $costResources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild);
     }
     $this->assign(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => Config::get()->max_elements_tech == 0 || Config::get()->max_elements_tech == count($TechQueue), 'Queue' => $TechQueue));
     $this->display('page.research.default.tpl');
 }
 public function show()
 {
     global $USER, $UNI, $PLANET, $LNG, $resource, $dpath, $reslist, $pricelist, $requeriments, $CONF;
     if ($CONF['dmenabled'] == 0) {
         $this->printMessage("This add-on is disabled", true, array('game.php?page=overview', 2));
         die;
     }
     $fmenge = isset($_POST['fmenge']) ? $_POST['fmenge'] : array();
     $action = HTTP::_GP('action', '');
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = unserialize($PLANET['b_building_id']);
         foreach ($CurrentQueue as $ElementArray) {
             if ($ElementArray[0] == 21 || $ElementArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     if (empty($ElementQueue)) {
         $Count = 0;
     } else {
         $Count = count($ElementQueue);
     }
     if ($USER['urlaubs_modus'] == 0) {
         if (!empty($fmenge) && $NotBuilding == true) {
             if (Config::get('max_elements_ships') != 0 && $Count >= Config::get('max_elements_ships')) {
                 $this->printMessage(sprintf($LNG['bd_max_builds'], Config::get('max_elements_ships')));
                 exit;
             }
             $this->BuildAuftr($fmenge);
         }
         if ($action == "delete") {
             $this->CancelAuftr();
         }
     }
     $elementInQueue = array();
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     $Buildlist = array();
     if (!empty($ElementQueue)) {
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $Element) {
             if (empty($Element)) {
                 continue;
             }
             $elementInQueue[$Element[0]] = true;
             $ElementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime, $Element[0]);
         }
         $this->tplObj->loadscript('bcmath.js');
         $this->tplObj->execscript('ShipyardInit();');
         $Buildlist = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0)));
     }
     $mode = HTTP::_GP('mode', 'fleet');
     if ($mode == 'defense' && $CONF['fleetconf'] > TIMESTAMP) {
         $elementALL = array(401, 402, 403, 404, 405, 406, 410, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422);
         $elementIDs = array(411, 502, 503);
         $elementIDd = array(401, 402, 403, 420);
         $elementIDa = array(405, 404, 406, 416, 417, 421);
         $elementIDq = array(418, 412, 410, 413, 419, 414);
     } elseif ($mode == 'defense' && $CONF['fleetconf'] < TIMESTAMP) {
         $elementALL = array(401, 402, 403, 404, 405, 406, 410, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422);
         $elementIDs = array(411, 502, 503);
         $elementIDd = array(401, 402, 403);
         $elementIDa = array(405, 404, 406, 416, 417);
         $elementIDq = array(418, 412, 410, 413, 422, 419, 414, 422);
     } elseif ($mode == 'fleet' && $CONF['fleetconf'] > TIMESTAMP) {
         $elementALL = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230);
         $elementIDs = array(208, 210, 223);
         $elementIDd = array(212, 202, 203, 204, 205, 229);
         $elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219, 224);
         $elementIDq = array(225, 226, 214, 216, 230, 227, 228, 222, 218, 221);
     } elseif ($mode == 'fleet' && $CONF['fleetconf'] < TIMESTAMP) {
         $elementALL = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230);
         $elementIDs = array(208, 210, 223);
         $elementIDd = array(212, 202, 203, 204, 205);
         $elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219);
         $elementIDq = array(225, 226, 214, 216, 230, 227, 228, 222, 218, 221);
     }
     foreach ($elementALL as $Element) {
         $AllPrice = array();
         $GetAllPrice = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAllPrice) > 0) {
             while ($k = $GLOBALS['DATABASE']->fetch_array($GetAllPrice)) {
                 $AllPrice[] = $k;
             }
         }
         $costRessources = $k;
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = 0;
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElementsDM($USER, $PLANET, $Element, $costRessources);
         $elementListall[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AllPrice' => $AllPrice, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDs as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $AllPrice = array();
         $GetAllPrice = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAllPrice) > 0) {
             while ($k = $GLOBALS['DATABASE']->fetch_array($GetAllPrice)) {
                 $AllPrice[] = $k;
             }
         }
         $costRessources = $k;
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = 0;
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElementsDM($USER, $PLANET, $Element, $costRessources);
         $elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AllPrice' => $AllPrice, 'AllTech' => $AllTech, 'AllPrice' => $AllPrice, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDq as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $AllPrice = array();
         $GetAllPrice = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAllPrice) > 0) {
             while ($k = $GLOBALS['DATABASE']->fetch_array($GetAllPrice)) {
                 $AllPrice[] = $k;
             }
         }
         $costRessources = $k;
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = 0;
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElementsDM($USER, $PLANET, $Element, $costRessources);
         $elementListq[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AllTech' => $AllTech, 'AllPrice' => $AllPrice, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDa as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $AllPrice = array();
         $GetAllPrice = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAllPrice) > 0) {
             while ($k = $GLOBALS['DATABASE']->fetch_array($GetAllPrice)) {
                 $AllPrice[] = $k;
             }
         }
         $costRessources = $k;
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = 0;
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElementsDM($USER, $PLANET, $Element, $costRessources);
         $elementLista[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AllTech' => $AllTech, 'AllPrice' => $AllPrice, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDd as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $AllPrice = array();
         $GetAllPrice = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAllPrice) > 0) {
             while ($k = $GLOBALS['DATABASE']->fetch_array($GetAllPrice)) {
                 $AllPrice[] = $k;
             }
         }
         $costRessources = $k;
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = 0;
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElementsDM($USER, $PLANET, $Element, $costRessources);
         $elementListd[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AllTech' => $AllTech, 'AllPrice' => $AllPrice, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $this->tplObj->loadscript('shipyard.js');
     $this->tplObj->assign_vars(array('elementListall' => $elementListall, 'elementList' => $elementList, 'elementListd' => $elementListd, 'elementLista' => $elementLista, 'elementListq' => $elementListq, 'NotBuilding' => $NotBuilding, 'BuildList' => $Buildlist, 'maxlength' => strlen(Config::get('max_fleet_per_build')), 'mode' => $mode, 'instant_fleet' => pretty_number(40000000 - $USER['instant_fleet'])));
     $this->display('page.dmship.default.tpl');
 }
 public function show()
 {
     global $USER, $PLANET, $LNG, $resource, $pricelist, $reslist, $CombatCaps, $ProdGrid;
     $elementID = HTTP::_GP('id', 0);
     $this->setWindow('popup');
     $this->initTemplate();
     $productionTable = array();
     $FleetInfo = array();
     $MissileList = array();
     $gateData = array();
     $CurrentLevel = 0;
     $ressIDs = array_merge(array(), $reslist['resstype'][1], $reslist['resstype'][2]);
     if (in_array($elementID, $reslist['prod']) && in_array($elementID, $reslist['build'])) {
         /* Data for eval */
         $BuildEnergy = $USER[$resource[113]];
         $BuildTemp = $PLANET['temp_max'];
         $BuildLevelFactor = $PLANET[$resource[$elementID] . '_porcent'];
         $CurrentLevel = $PLANET[$resource[$elementID]];
         $BuildStartLvl = max($CurrentLevel - 2, 0);
         for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) {
             foreach ($ressIDs as $ID) {
                 if (!isset($ProdGrid[$elementID]['production'][$ID])) {
                     continue;
                 }
                 $Production = eval(ResourceUpdate::getProd($ProdGrid[$elementID]['production'][$ID]));
                 if (in_array($ID, $reslist['resstype'][2])) {
                     $Production *= Config::get()->energySpeed;
                 } else {
                     $Production *= Config::get()->resource_multiplier;
                 }
                 $productionTable['production'][$BuildLevel][$ID] = $Production;
             }
         }
         $productionTable['usedResource'] = array_keys($productionTable['production'][$BuildStartLvl]);
     } elseif (in_array($elementID, $reslist['storage'])) {
         $CurrentLevel = $PLANET[$resource[$elementID]];
         $BuildStartLvl = max($CurrentLevel - 2, 0);
         for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) {
             foreach ($ressIDs as $ID) {
                 if (!isset($ProdGrid[$elementID]['storage'][$ID])) {
                     continue;
                 }
                 $production = round(eval(ResourceUpdate::getProd($ProdGrid[$elementID]['storage'][$ID])));
                 $production *= Config::get()->resource_multiplier;
                 $production *= STORAGE_FACTOR;
                 $productionTable['storage'][$BuildLevel][$ID] = $production;
             }
         }
         $productionTable['usedResource'] = array_keys($productionTable['storage'][$BuildStartLvl]);
     } elseif (in_array($elementID, $reslist['fleet'])) {
         $FleetInfo = array('structure' => $pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902], 'tech' => $pricelist[$elementID]['tech'], 'attack' => $CombatCaps[$elementID]['attack'], 'shield' => $CombatCaps[$elementID]['shield'], 'capacity' => $pricelist[$elementID]['capacity'], 'speed1' => $pricelist[$elementID]['speed'], 'speed2' => $pricelist[$elementID]['speed2'], 'consumption1' => $pricelist[$elementID]['consumption'], 'consumption2' => $pricelist[$elementID]['consumption2'], 'rapidfire' => array('from' => array(), 'to' => array()));
         $fleetIDs = array_merge($reslist['fleet'], $reslist['defense']);
         foreach ($fleetIDs as $fleetID) {
             if (isset($CombatCaps[$elementID]['sd']) && !empty($CombatCaps[$elementID]['sd'][$fleetID])) {
                 $FleetInfo['rapidfire']['to'][$fleetID] = $CombatCaps[$elementID]['sd'][$fleetID];
             }
             if (isset($CombatCaps[$fleetID]['sd']) && !empty($CombatCaps[$fleetID]['sd'][$elementID])) {
                 $FleetInfo['rapidfire']['from'][$fleetID] = $CombatCaps[$fleetID]['sd'][$elementID];
             }
         }
     } elseif (in_array($elementID, $reslist['defense'])) {
         $FleetInfo = array('structure' => $pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902], 'attack' => $CombatCaps[$elementID]['attack'], 'shield' => $CombatCaps[$elementID]['shield'], 'rapidfire' => array('from' => array(), 'to' => array()));
         $fleetIDs = array_merge($reslist['fleet'], $reslist['defense']);
         foreach ($fleetIDs as $fleetID) {
             if (isset($CombatCaps[$elementID]['sd']) && !empty($CombatCaps[$elementID]['sd'][$fleetID])) {
                 $FleetInfo['rapidfire']['to'][$fleetID] = $CombatCaps[$elementID]['sd'][$fleetID];
             }
             if (isset($CombatCaps[$fleetID]['sd']) && !empty($CombatCaps[$fleetID]['sd'][$elementID])) {
                 $FleetInfo['rapidfire']['from'][$fleetID] = $CombatCaps[$fleetID]['sd'][$elementID];
             }
         }
     }
     if ($elementID == 43 && $PLANET[$resource[43]] > 0) {
         $this->tplObj->loadscript('gate.js');
         $nextTime = self::getNextJumpWaitTime($PLANET['last_jump_time']);
         $gateData = array('nextTime' => _date($LNG['php_tdformat'], $nextTime, $USER['timezone']), 'restTime' => max(0, $nextTime - TIMESTAMP), 'startLink' => $PLANET['name'] . ' ' . strip_tags(BuildPlanetAdressLink($PLANET)), 'gateList' => $this->getTargetGates(), 'fleetList' => $this->getAvailableFleets());
     } elseif ($elementID == 44 && $PLANET[$resource[44]] > 0) {
         $MissileList = array(502 => $PLANET[$resource[502]], 503 => $PLANET[$resource[503]]);
     }
     $this->assign(array('elementID' => $elementID, 'productionTable' => $productionTable, 'CurrentLevel' => $CurrentLevel, 'MissileList' => $MissileList, 'Bonus' => BuildFunctions::getAvalibleBonus($elementID), 'FleetInfo' => $FleetInfo, 'gateData' => $gateData));
     $this->display('page.information.default.tpl');
 }
Example #19
0
 public function SetNextQueueTechOnTop()
 {
     global $resource, $LNG;
     if (empty($this->USER['b_tech_queue'])) {
         $this->USER['b_tech'] = 0;
         $this->USER['b_tech_id'] = 0;
         $this->USER['b_tech_planet'] = 0;
         $this->USER['b_tech_queue'] = '';
         return false;
     }
     $CurrentQueue = unserialize($this->USER['b_tech_queue']);
     $Loop = true;
     while ($Loop == true) {
         $ListIDArray = $CurrentQueue[0];
         if ($ListIDArray[4] != $this->PLANET['id']) {
             $PLANET = $GLOBALS['DATABASE']->getFirstRow("SELECT * FROM " . PLANETS . " WHERE id = '" . $ListIDArray[4] . "';");
         } else {
             $PLANET = $this->PLANET;
         }
         $PLANET[$resource[31] . '_inter'] = self::getNetworkLevel($this->USER, $PLANET);
         $Element = $ListIDArray[0];
         $Level = $ListIDArray[1];
         $costRessources = BuildFunctions::getElementPrice($this->USER, $PLANET, $Element);
         $BuildTime = BuildFunctions::getBuildingTime($this->USER, $PLANET, $Element, $costRessources);
         $HaveRessources = BuildFunctions::isElementBuyable($this->USER, $PLANET, $Element, $costRessources);
         $BuildEndTime = $this->USER['b_tech'] + $BuildTime;
         $CurrentQueue[0] = array($Element, $Level, $BuildTime, $BuildEndTime, $PLANET['id']);
         $isAnotherPlanet = $ListIDArray[4] != $this->PLANET['id'];
         if ($isAnotherPlanet) {
             $IsHash = !in_array($Element, array(131, 132, 133));
             $RPLANET = new ResourceUpdate(true, false);
             list(, $PLANET) = $RPLANET->CalcResource($this->USER, $PLANET, false, $this->USER['b_tech'], $IsHash);
         }
         if ($HaveRessources == true) {
             if (isset($costRessources[901])) {
                 $PLANET[$resource[901]] -= $costRessources[901];
             }
             if (isset($costRessources[902])) {
                 $PLANET[$resource[902]] -= $costRessources[902];
             }
             if (isset($costRessources[903])) {
                 $PLANET[$resource[903]] -= $costRessources[903];
             }
             if (isset($costRessources[904])) {
                 $PLANET[$resource[904]] -= $costRessources[904];
             }
             if (isset($costRessources[921])) {
                 $this->USER[$resource[921]] -= $costRessources[921];
             }
             $this->USER['b_tech_id'] = $Element;
             $this->USER['b_tech'] = $BuildEndTime;
             $this->USER['b_tech_planet'] = $PLANET['id'];
             $this->USER['b_tech_queue'] = serialize($CurrentQueue);
             $Loop = false;
         } else {
             if ($this->USER['hof'] == 1) {
                 if (!isset($costRessources[901])) {
                     $costRessources[901] = 0;
                 }
                 if (!isset($costRessources[902])) {
                     $costRessources[902] = 0;
                 }
                 if (!isset($costRessources[903])) {
                     $costRessources[903] = 0;
                 }
                 if (!isset($costRessources[904])) {
                     $costRessources[904] = 0;
                 }
                 $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['tech'][901], pretty_number($PLANET['crystal']), $LNG['tech'][902], pretty_number($PLANET['deuterium']), $LNG['tech'][903], pretty_number($costRessources[901]), $LNG['tech'][901], pretty_number($costRessources[902]), $LNG['tech'][902], pretty_number($costRessources[903]), $LNG['tech'][903], pretty_number($costRessources[904]), $LNG['tech'][904]);
                 SendSimpleMessage($this->USER['id'], 0, $this->USER['b_tech'], 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message);
             }
             array_shift($CurrentQueue);
             if (count($CurrentQueue) == 0) {
                 $this->USER['b_tech'] = 0;
                 $this->USER['b_tech_id'] = 0;
                 $this->USER['b_tech_planet'] = 0;
                 $this->USER['b_tech_queue'] = '';
                 $Loop = false;
             } else {
                 $BaseTime = $BuildEndTime - $BuildTime;
                 $NewQueue = array();
                 foreach ($CurrentQueue as $ListIDArray) {
                     $ListIDArray[2] = BuildFunctions::getBuildingTime($this->USER, $PLANET, $ListIDArray[0]);
                     $BaseTime += $ListIDArray[2];
                     $ListIDArray[3] = $BaseTime;
                     $NewQueue[] = $ListIDArray;
                 }
                 $CurrentQueue = $NewQueue;
             }
         }
         if ($isAnotherPlanet) {
             $RPLANET->SavePlanetToDB($this->USER, $PLANET);
         } else {
             $this->PLANET = $PLANET;
         }
     }
 }
    function show()
    {
        global $CONF, $LNG, $PLANET, $USER, $resource, $UNI;
        if ($CONF['treasure_event'] < TIMESTAMP) {
            $cautare = $GLOBALS['DATABASE']->query("SELECT * FROM " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id WHERE p.universe = " . $UNI . " AND u.universe = " . $UNI . " AND u.onlinetime < " . (TIMESTAMP - 60 * 60 * 24 * 7) . " AND u.urlaubs_modus = 0 AND p.planet_type = 1 ORDER BY RAND() LIMIT 20;");
            while ($xys = $GLOBALS['DATABASE']->fetch_array($cautare)) {
                $metal = 500000000000;
                $crystal = 400000000000;
                $deuterium = 300000000000;
                $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `metal` =   " . $metal . ", `crystal` = " . $crystal . ", `deuterium` = " . $deuterium . " WHERE id = " . $xys['id'] . ";");
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " WHERE universe = " . $UNI . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = "<span class='admin'>Treasure Hunt has started.<br>\n20 Inactive planets have big amounts of resources.<br>\nSearch for it, and steal it.<br>\nHappy Hunting !!!<br><br>\nLa chasse au tresor a commencer.<br>\n20 planets inactive sont rempli de resource.<br>\nChercher les, et vider les tous.<br>\nHappy Hunting !!!<br><br>\nSchatzJagd Hat Begonnen<br>\n20 inaktiver Planeten, ist voll mit vielen Rohstoffen<br>\nDu musst ihn finden, und hol dir die Rohstoffe<br>\nViel Spass beim Suchen !!! \n\t</span>";
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Treasure Event", $message);
            }
            $new_event = $CONF['treasure_event'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET treasure_event = '" . $new_event . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['treasure_event_1'] < TIMESTAMP) {
            $cautare = $GLOBALS['DATABASE']->query("SELECT * FROM " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id WHERE p.universe = " . $UNI . " AND u.universe = " . $UNI . " AND u.onlinetime < " . (TIMESTAMP - 60 * 60 * 24 * 7) . " AND u.urlaubs_modus = 0 AND p.planet_type = 1 AND p.universe = " . $UNI . " ORDER BY RAND() LIMIT 20;");
            while ($xys = $GLOBALS['DATABASE']->fetch_array($cautare)) {
                $metal = 500000000000;
                $crystal = 400000000000;
                $deuterium = 300000000000;
                $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET `metal` =   " . $metal . ", `crystal` = " . $crystal . ", `deuterium` = " . $deuterium . " WHERE id = " . $xys['id'] . ";");
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " WHERE universe = " . $UNI . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = "<span class='admin'>Treasure Hunt has started.<br>\n20 Inactive planets have big amounts of resources.<br>\nSearch for it, and steal it.<br>\nHappy Hunting !!!<br><br>\nLa chasse au tresor a commencer.<br>\n20 planets inactive sont rempli de resource.<br>\nChercher les, et vider les tous.<br>\nHappy Hunting !!!<br><br>\nSchatzJagd Hat Begonnen<br>\n20 inaktiver Planeten, ist voll mit vielen Rohstoffen<br>\nDu musst ihn finden, und hol dir die Rohstoffe<br>\nViel Spass beim Suchen !!! \n\t</span>";
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Treasure Event", $message);
            }
            $new_event = $CONF['treasure_event_1'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET treasure_event_1 = '" . $new_event . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['social_message'] < TIMESTAMP) {
            $query = $GLOBALS['DATABASE']->query("SELECT DISTINCT id FROM uni1_users;");
            while ($x = $GLOBALS['DATABASE']->fetch_array($query)) {
                $msg = '<span class="admin">"Like" & "Share" for the chance to win 50k darkmatter: Every 30 combined likes & shares will equal to one winner: <a href="https://www.facebook.com/pages/Dark-Space-Empire/1490309864518434">Dark-Space: Empire ! Social Page</a><br><br>
	"Aime" & "Partage" pour avoir la chance de gagner 50K matiere noire: tout les 30ieme aime & partage combinee recevera 50k de matiere noir: <a href="https://www.facebook.com/pages/Dark-Space-Empire/1490309864518434">Dark-Space: Empire ! Social Page</a><br><br>
	"Like" & "Teilen" für die Chance, 50k darkmatter gewinnen: Alle 30 kombiniert Vorlieben und Aktien werden gleich einen Gewinner: <a href="https://www.facebook.com/pages/Dark-Space-Empire/1490309864518434">Dark-Space: Empire ! Sozial Seite</a></span>';
                SendSimpleMessage($x['id'], '', TIMESTAMP, 50, 'System', 'Questions', $msg);
            }
            $GLOBALS['DATABASE']->query("UPDATE uni1_config SET social_message = '" . (TIMESTAMP + 2 * 24 * 60 * 60) . "';");
        }
        //END GLOBAL MESSAGES
        //BEGIN ASTEROID EVENT
        if ($CONF['asteroid_event'] < TIMESTAMP) {
            $GLOBALS['DATABASE']->query("DELETE FROM " . PLANETS . " where `id_owner` = '" . Asteroid_Id . "' ;");
            $galaxy = $this->randRange(1, 5, 5);
            foreach ($galaxy as $Element) {
                $system = $this->randRange(1, 200, 70);
                foreach ($system as $System_Element) {
                    $planets = rand(1, 15);
                    $cautare = $GLOBALS['DATABASE']->query("SELECT *FROM " . PLANETS . " where `galaxy` = '" . $Element . "' and `system` = '" . $System_Element . "' and `planet` = '" . $planets . "' AND `universe` = '" . $UNI . "';");
                    if ($GLOBALS['DATABASE']->numRows($cautare) == 0) {
                        $metal_rand = Config::get('asteroid_metal');
                        $crystal_rand = Config::get('asteroid_crystal');
                        $deuterium_rand = Config::get('asteroid_deuterium');
                        $GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . "(`name`,`id_owner`,`universe`,`galaxy`,`system`,`planet`,`planet_type`,`image`,`diameter`,`metal`,`crystal`,`deuterium`,`last_update`) \n\tVALUES('Asteroid','" . Asteroid_Id . "','" . $UNI . "','" . $Element . "','" . $System_Element . "','" . $planets . "','1','asteroid','9800','" . $metal_rand . "','" . $crystal_rand . "','" . $deuterium_rand . "','" . TIMESTAMP . "');");
                    }
                }
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Asteroid Event started<br>
	Every asteroid that you harvest will bring you resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">more details</a><br><br>
	Evenement asteroid a commencer<br>
	Chaque asteroid que tu harvest te raportera des resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">plus de details</a><br><br>
	Asteroid Ereignis begann <br>
	Jeder Asteroiden, die Sie ernten werden Sie Ressource bringen. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">weitere Informationen</a>
	</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevkaka = $CONF['asteroid_event'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET asteroid_event = '" . $newevkaka . "' where `uni` = '" . $UNI . "';");
        }
        //END ASTEROID EVENT
        //BEGIN ASTEROID EVENT
        if ($CONF['asteroid_event_1'] < TIMESTAMP) {
            $GLOBALS['DATABASE']->query("DELETE FROM " . PLANETS . " where `id_owner` = '" . Asteroid_Id . "' ;");
            $galaxy = $this->randRange(1, 5, 5);
            foreach ($galaxy as $Element) {
                $system = $this->randRange(1, 200, 70);
                foreach ($system as $System_Element) {
                    $planets = rand(1, 15);
                    $cautare = $GLOBALS['DATABASE']->query("SELECT *FROM " . PLANETS . " where `galaxy` = '" . $Element . "' and `system` = '" . $System_Element . "' and `planet` = '" . $planets . "' AND `universe` = '" . $UNI . "';");
                    if ($GLOBALS['DATABASE']->numRows($cautare) == 0) {
                        $metal_rand = Config::get('asteroid_metal');
                        $crystal_rand = Config::get('asteroid_crystal');
                        $deuterium_rand = Config::get('asteroid_deuterium');
                        $GLOBALS['DATABASE']->query("INSERT INTO " . PLANETS . "(`name`,`id_owner`,`universe`,`galaxy`,`system`,`planet`,`planet_type`,`image`,`diameter`,`metal`,`crystal`,`deuterium`,`last_update`) \n\tVALUES('Asteroid','" . Asteroid_Id . "','" . $UNI . "','" . $Element . "','" . $System_Element . "','" . $planets . "','1','asteroid','9800','" . $metal_rand . "','" . $crystal_rand . "','" . $deuterium_rand . "','" . TIMESTAMP . "');");
                    }
                }
            }
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . ";");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Asteroid Event started<br>
	Every asteroid that you harvest will bring you resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">more details</a><br><br>
	Evenement asteroid a commencer<br>
	Chaque asteroid que tu harvest te raportera des resource. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">plus de details</a><br><br>
	Asteroid Ereignis begann <br>
	Jeder Asteroiden, die Sie ernten werden Sie Ressource bringen. <a href="http://forum.dark-space.org/index.php?/topic/3-asteroid-event">weitere Informationen</a>
	</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevkaka = $CONF['asteroid_event_1'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET asteroid_event_1 = '" . $newevkaka . "' where `uni` = '" . $UNI . "';");
        }
        //END ASTEROID EVENT
        /* //BEGIN FORTRESS EVENT
        	if($CONF['fortress_event'] < TIMESTAMP){
        	$GLOBALS['DATABASE']->query("DELETE FROM ".PLANETS." where `planet_type` = '4' ;");
        	$galaxy = $this->randRange(1,5,5);
        	foreach($galaxy as $Element){
        	$system = $this->randRange(1,200,15);
        	foreach($system as $System_Element){
        	$planets = rand(1,15);
        	$timerforall = TIMESTAMP + 60*60*6;
        	$cautare = $GLOBALS['DATABASE']->query("SELECT *FROM ".PLANETS." where `galaxy` = '".$Element."' and `system` = '".$System_Element."' and `planet` = '".$planets."' AND `universe` = '".$UNI."';");
        	if($GLOBALS['DATABASE']->numRows($cautare)==0){
        	$metal_rand = Config::get('asteroid_metal');
        	$crystal_rand = Config::get('asteroid_crystal');
        	$deuterium_rand= Config::get('asteroid_deuterium');
        	$max_field= mt_rand(69,176);
        	$GLOBALS['DATABASE']->query("INSERT INTO ".PLANETS."(`name`,`id_owner`,`universe`,`galaxy`,`system`,`planet`,`planet_type`,`image`,`diameter`,`field_current`,`field_max`,`metal`,`crystal`,`deuterium`,`last_update`,`capture_not`) 
        	VALUES('Fortress Planet','".Fortress_Id."','".$UNI."','".$Element."','".$System_Element."','".$planets."','4','fortress','9800','0','".$max_field."','".$metal_rand."','".$crystal_rand."','".$deuterium_rand."','".TIMESTAMP."','".$timerforall."');");
        	}
            }
        	}
        	$totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM ".USERS.";");
        	while($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)){
        	$message = "<span class='admin'>Fortress Event started<br>
        	Capture your fortress and take advantage of the profits they offer you !<br><br>
        	Evenement Fortress a commencer<br>
        	Capturez votre forteresse et profiter des multiple avantage qu\'elles peuvent vous offrir ! 
        	</span>";
            SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
        	$newevkaka = $timerforall + 10;
            $GLOBALS['DATABASE']->query("UPDATE ".CONFIG." SET fortress_event = '".$newevkaka."' where `uni` = '".$UNI."';");
        	}
        	//END FORTRESS EVENT	 */
        //if($CONF['end_game'] < TIMESTAMP){
        //$GLOBALS['DATABASE']->query("UPDATE uni1_config SET game_disable = '0', close_reason = 'The first season of the game cames to hes end. the entire game will be reseted today at 20h' WHERE uni = ".$UNI.";");
        //}
        if ($CONF['question_message'] < TIMESTAMP) {
            $query = $GLOBALS['DATABASE']->query("SELECT DISTINCT id FROM uni1_users WHERE universe = " . $UNI . ";");
            while ($x = $GLOBALS['DATABASE']->fetch_array($query)) {
                $msg = '<span class="admin">If you have questions about the game: <a href="?page=ticket">Write them here</a><br>
		Si vous avez dues question sur le jeu: <a href="?page=ticket">Posez les ici</a><br>
		Falls du fragen über das Spiel hast: <a href="?page=ticket">Schreibe sie hier</a></span>';
                SendSimpleMessage($x['id'], '', TIMESTAMP, 50, 'System', 'Questions', $msg);
            }
            $GLOBALS['DATABASE']->query("UPDATE uni1_config SET question_message = '" . (TIMESTAMP + 3 * 24 * 60 * 60) . "' WHERE uni = " . $UNI . ";");
        }
        if ($CONF['referal_message'] < TIMESTAMP) {
            $query = $GLOBALS['DATABASE']->query("SELECT DISTINCT id FROM uni1_users WHERE universe = " . $UNI . ";");
            while ($x = $GLOBALS['DATABASE']->fetch_array($query)) {
                $msg = '<span class="admin"> Invite new players with your referral link and get for every new player 5,000,000 Dark Matter and 10.000 Antimatter: <a href="?page=Refystem">Referal System</a><br>
		Lade neue Spieler mit deinem Referral Link ein und bekomme 5.000.000 Dunkle Materie und 10.000 Anti Materie: <a href="?page=Refystem">Referal System</a></span>';
                SendSimpleMessage($x['id'], '', TIMESTAMP, 50, 'System', 'Referal', $msg);
            }
            $GLOBALS['DATABASE']->query("UPDATE uni1_config SET referal_message = '" . (TIMESTAMP + 7 * 24 * 60 * 60) . "' WHERE uni = " . $UNI . ";");
        }
        if ($CONF['fleet_event_active_1'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($x = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Friendly fleets landed on all your planets<br>
		Des vaisseaux allies ont atteris sur toutes vos planetes<br>
		Freundliche Flotten landen auf deinen Planeten</span>';
                SendSimpleMessage($x['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id SET \n        `light_hunter` = `light_hunter` + 500000000,\n        `bs_class_oneil` = `bs_class_oneil` + 20000,\n\t\t`frigate` = `frigate` + 50000\n        WHERE p.universe = '" . $UNI . "' AND u.urlaubs_modus = 0 AND p.planet_type = 1 AND u.onlinetime > " . (TIMESTAMP - 60 * 60 * 24 * 7) . ";");
            $newevent3 = $CONF['fleet_event_active_1'] + 2 * 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_active_1 = '" . $newevent3 . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['fleet_event_active_2'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">Friendly fleets landed on your home planet<br>
		Des vaisseaux allies ont atteris sur votre planete mere<br>
		Freundliche Flotten landen auf deinen Planeten</span>
                            ';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $totalPremiums1 = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id_planet` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($omt = $GLOBALS['DATABASE']->fetch_array($totalPremiums1)) {
                $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " p INNER JOIN " . USERS . " u ON p.id_owner = u.id SET \n       `light_hunter` = `light_hunter` + 500000000,\n        `bs_class_oneil` = `bs_class_oneil` + 20000,\n\t\t`frigate` = `frigate` + 50000\n        WHERE p.universe = '" . $UNI . "' AND p.id = " . $omt['id_planet'] . " AND u.urlaubs_modus = 0 AND p.planet_type = 1 AND u.onlinetime > " . (TIMESTAMP - 60 * 60 * 24 * 7) . ";");
                $newevent2 = $CONF['fleet_event_active_2'] + 2 * 60 * 60 * 24;
                $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_active_2 = '" . $newevent2 . "' where `uni` = '" . $UNI . "';");
            }
        }
        if ($CONF['fleet_event_inactive_1'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">All inactive planets are full of resources and fleets<br>
All inactive moons are full of  resources<br>
Toutes les planetes inactive sont remplis de vaisseaux et de resources<br>
Toutes les lunes inactives sont remplis de resources<br>
Alle inaktiven Planeten sind voll mit Resourcen und Flotten<br>
Alle inaktiven Monde sind voll mit Resourcen</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevent = $CONF['fleet_event_inactive_1'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_inactive_1 = '" . $newevent . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['fleet_event_inactive_2'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">All inactive planets are full of resources and fleets<br>
All inactive moons are full of  resources<br>
Toutes les planetes inactive sont remplis de vaisseaux et de resources<br>
Toutes les lunes inactives sont remplis de resources<br>
Alle inaktiven Planeten sind voll mit Resourcen und Flotten<br>
Alle inaktiven Monde sind voll mit Resourcen</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevent = $CONF['fleet_event_inactive_2'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_inactive_2 = '" . $newevent . "' where `uni` = '" . $UNI . "';");
        }
        if ($CONF['fleet_event_inactive_3'] < TIMESTAMP) {
            $totalPremiums = $GLOBALS['DATABASE']->query("SELECT DISTINCT `id` FROM " . USERS . " where `universe` = '" . $UNI . "';");
            while ($xy = $GLOBALS['DATABASE']->fetch_array($totalPremiums)) {
                $message = '<span class="admin">All inactive planets are full of resources and fleets<br>
All inactive moons are full of  resources<br>
Toutes les planetes inactive sont remplis de vaisseaux et de resources<br>
Toutes les lunes inactives sont remplis de resources<br>
Alle inaktiven Planeten sind voll mit Resourcen und Flotten<br>
Alle inaktiven Monde sind voll mit Resourcen</span>';
                SendSimpleMessage($xy['id'], 1, TIMESTAMP, 50, "Event System", "Event Info", $message);
            }
            $newevent = $CONF['fleet_event_inactive_3'] + 60 * 60 * 24;
            $GLOBALS['DATABASE']->query("UPDATE " . CONFIG . " SET fleet_event_inactive_3 = '" . $newevent . "' where `uni` = '" . $UNI . "';");
        }
        $AdminsOnline = array();
        $chatOnline = array();
        $AllPlanets = array();
        $Moon = array();
        $RefLinks = array();
        $Buildtime = 0;
        foreach ($USER['PLANETS'] as $ID => $CPLANET) {
            if ($ID == $PLANET['id'] || $CPLANET['planet_type'] == 3) {
                continue;
            }
            if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) {
                $Queue = unserialize($CPLANET['b_building_id']);
                $BuildPlanet = $LNG['tech'][$Queue[0][0]] . " (" . $Queue[0][1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($Queue[0][3] - TIMESTAMP) . ")</span>";
            } else {
                $BuildPlanet = $LNG['ov_free'];
            }
            $AllPlanets[] = array('id' => $CPLANET['id'], 'name' => $CPLANET['name'], 'image' => $CPLANET['image'], 'build' => $BuildPlanet);
        }
        if ($PLANET['id_luna'] != 0) {
            $Moon = $GLOBALS['DATABASE']->getFirstRow("SELECT id, name FROM " . PLANETS . " WHERE id = '" . $PLANET['id_luna'] . "';");
        }
        if ($PLANET['b_building'] - TIMESTAMP > 0) {
            $Queue = unserialize($PLANET['b_building_id']);
            $buildInfo['buildings'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $PLANET['b_building'] - TIMESTAMP, 'time' => $PLANET['b_building'], 'starttime' => pretty_time($PLANET['b_building'] - TIMESTAMP));
        } else {
            $buildInfo['buildings'] = false;
        }
        /* As FR#206 (http://tracker.2moons.cc/view.php?id=206), i added the shipyard and research status here, but i add not them the template. */
        if (!empty($PLANET['b_hangar_id'])) {
            $Queue = unserialize($PLANET['b_hangar_id']);
            $time = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]) * $Queue[0][1];
            $buildInfo['fleet'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_hangar'], 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_hangar']));
        } else {
            $buildInfo['fleet'] = false;
        }
        if ($USER['b_tech'] - TIMESTAMP > 0) {
            $Queue = unserialize($USER['b_tech_queue']);
            $buildInfo['tech'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $USER['b_tech'] - TIMESTAMP, 'time' => $USER['b_tech'], 'starttime' => pretty_time($USER['b_tech'] - TIMESTAMP));
        } else {
            $buildInfo['tech'] = false;
        }
        $OnlineAdmins = $GLOBALS['DATABASE']->query("SELECT id,username FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime >= " . (TIMESTAMP - 10 * 60) . " AND authlevel > '" . AUTH_USR . "';");
        while ($AdminRow = $GLOBALS['DATABASE']->fetch_array($OnlineAdmins)) {
            $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
        }
        $GLOBALS['DATABASE']->free_result($OnlineAdmins);
        $balken = $GLOBALS['DATABASE']->countquery("SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . $UNI . " AND onlinetime > '" . (TIMESTAMP - 15 * 60) . "';");
        $länge2 = 365 / $CONF['users_amount'];
        $länge = $balken * $länge2;
        $chatUsers = $GLOBALS['DATABASE']->query("SELECT userName FROM " . CHAT_ON . " WHERE dateTime > DATE_SUB(NOW(), interval 2 MINUTE) AND channel = 0");
        while ($chatRow = $GLOBALS['DATABASE']->fetch_array($chatUsers)) {
            $chatOnline[] = $chatRow['userName'];
        }
        $GLOBALS['DATABASE']->free_result($chatUsers);
        //$this->tplObj->loadscript('overview.js');
        $Messages = $USER['messages'];
        // Fehler: Wenn Spieler gelöscht werden, werden sie nicht mehr in der Tabelle angezeigt.
        $RefLinksRAW = $GLOBALS['DATABASE']->query("SELECT u.id, u.username, s.total_points FROM " . USERS . " as u LEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE ref_id = " . $USER['id'] . ";");
        if (Config::get('ref_active')) {
            while ($RefRow = $GLOBALS['DATABASE']->fetch_array($RefLinksRAW)) {
                $RefLinks[$RefRow['id']] = array('username' => $RefRow['username'], 'points' => min($RefRow['total_points'], Config::get('ref_minpoints')));
            }
        }
        $statinfo = $GLOBALS['DATABASE']->query("SELECT s.total_old_rank, s.total_rank FROM " . USERS . " as u LEFT JOIN " . STATPOINTS . " as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE id = " . $USER['id'] . ";");
        while ($game = $GLOBALS['DATABASE']->fetch_array($statinfo)) {
            $ranking = $game['total_old_rank'] - $game['total_rank'];
            if ($ranking == 0) {
                $position = "<span style='color:#87CEEB'>(*)</span>";
            } elseif ($ranking < 0) {
                $position = "<span style='color:red'>(" . $ranking . ")</span>";
            } elseif ($ranking > 0) {
                $position = "<span style='color:green'>(+" . $ranking . ")</span>";
            }
        }
        if ($USER['total_rank'] == 0) {
            $rankInfo = "-";
        } else {
            $rankInfo = sprintf($LNG['ov_userrank_info'], pretty_number($USER['total_points']), $LNG['ov_place'], $USER['total_rank'], $USER['total_rank'], $position, $LNG['ov_of'], Config::get('users_amount'));
        }
        $manual_start = 1;
        if ($USER['training'] == 0 && $USER['training_step'] == 0) {
            $manual_start = 0;
            $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET training_step = '1' WHERE id = " . $USER['id'] . ";");
        }
        $manual_12 = 1;
        if ($USER['training'] == 0 && $USER['training_step'] == 12) {
            $manual_12 = 0;
            $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET training_step = '13' WHERE id = " . $USER['id'] . ";");
        }
        $manual_20 = 1;
        if ($USER['training'] == 0 && $USER['training_step'] == 20) {
            $manual_20 = 0;
            $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET experience_peace = experience_peace + '650' WHERE id = " . $USER['id'] . ";");
        }
        $facebook_unliked = 1;
        if ($USER['training'] == 1 && $USER['facebook_liked'] == 0) {
            $facebook_unliked = 0;
        }
        $this->tplObj->loadscript("countdown.js");
        $this->tplObj->assign_vars(array('competition_active' => !empty($CONF['end_game']) && $CONF['end_game'] > TIMESTAMP ? $CONF['end_game'] - TIMESTAMP : 0, 'rankInfo' => $rankInfo, 'facebook_unliked' => $facebook_unliked, 'planet_protections' => $USER['immunity_until'] > TIMESTAMP ? $USER['immunity_until'] - TIMESTAMP : 0, 'planet_protectionbis' => $USER['immunity_until'], 'manual_12' => $manual_12, 'manual_20' => $manual_20, 'is_news' => Config::get('OverviewNewsFrame'), 'news' => makebr(Config::get('OverviewNewsText')), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'username' => $USER['username'], 'training' => $manual_start, 'userid' => $USER['id'], 'buildInfo' => $buildInfo, 'Moon' => $Moon, 'fleets' => $this->GetFleets(), 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'teamspeakData' => $this->GetTeamspeakData(), 'messages' => $Messages > 0 ? $Messages == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($Messages)) : false, 'planet_diameter' => pretty_number($PLANET['diameter']), 'planet_field_current' => $PLANET['field_current'], 'planet_field_max' => CalculateMaxPlanetFields($PLANET), 'planet_temp_min' => $PLANET['temp_min'], 'planet_temp_max' => $PLANET['temp_max'], 'ref_active' => Config::get('ref_active'), 'ref_minpoints' => Config::get('ref_minpoints'), 'RefLinks' => $RefLinks, 'chatOnline' => $chatOnline, 'servertime' => _date("M D d H:i:s", TIMESTAMP, $USER['timezone']), 'path' => HTTP_PATH, 'online_users' => $balken, 'balken'));
        $this->display('page.overview.default.tpl');
    }
Example #21
0
 public function show()
 {
     global $USER, $PLANET, $LNG, $resource, $reslist;
     if ($PLANET[$resource[21]] == 0) {
         $this->printMessage($LNG['bd_shipyard_required']);
     }
     $buildTodo = HTTP::_GP('fmenge', array());
     $action = HTTP::_GP('action', '');
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = unserialize($PLANET['b_building_id']);
         foreach ($CurrentQueue as $ElementArray) {
             if ($ElementArray[0] == 21 || $ElementArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     if (empty($ElementQueue)) {
         $Count = 0;
     } else {
         $Count = count($ElementQueue);
     }
     if ($USER['urlaubs_modus'] == 0 && $NotBuilding == true) {
         if (!empty($buildTodo)) {
             $maxBuildQueue = Config::get()->max_elements_ships;
             if ($maxBuildQueue != 0 && $Count >= $maxBuildQueue) {
                 $this->printMessage(sprintf($LNG['bd_max_builds'], $maxBuildQueue));
             }
             $this->BuildAuftr($buildTodo);
             $ElementQueue = unserialize($PLANET['b_hangar_id']);
         }
         if ($action == "delete") {
             $this->CancelAuftr();
         }
     }
     $elementInQueue = array();
     $buildList = array();
     $elementList = array();
     if (!empty($ElementQueue)) {
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $Element) {
             if (empty($Element)) {
                 continue;
             }
             $elementInQueue[$Element[0]] = true;
             $ElementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime, $Element[0]);
         }
         $buildList = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0)));
     }
     $mode = HTTP::_GP('mode', 'fleet');
     if ($mode == 'defense') {
         $elementIDs = array_merge($reslist['defense'], $reslist['missile']);
     } else {
         $elementIDs = $reslist['fleet'];
     }
     $Missiles = array();
     foreach ($reslist['missile'] as $elementID) {
         $Missiles[$elementID] = $PLANET[$resource[$elementID]];
     }
     $MaxMissiles = BuildFunctions::getMaxConstructibleRockets($USER, $PLANET, $Missiles);
     foreach ($elementIDs as $Element) {
         if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costResources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costResources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costResources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costResources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costResources' => $costResources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild);
     }
     $this->assign(array('elementList' => $elementList, 'NotBuilding' => $NotBuilding, 'BuildList' => $buildList, 'maxlength' => strlen(Config::get()->max_fleet_per_build), 'mode' => $mode));
     $this->display('page.shipyard.default.tpl');
 }
 public function SetNextQueueTechOnTop()
 {
     global $resource, $LNG;
     if (empty($this->USER['b_tech_queue'])) {
         $this->USER['b_tech'] = 0;
         $this->USER['b_tech_id'] = 0;
         $this->USER['b_tech_planet'] = 0;
         $this->USER['b_tech_queue'] = '';
         return false;
     }
     $CurrentQueue = unserialize($this->USER['b_tech_queue']);
     $Loop = true;
     while ($Loop == true) {
         $ListIDArray = $CurrentQueue[0];
         $isAnotherPlanet = $ListIDArray[4] != $this->PLANET['id'];
         if ($isAnotherPlanet) {
             $sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;';
             $PLANET = Database::get()->selectSingle($sql, array(':planetId' => $ListIDArray[4]));
             $RPLANET = new ResourceUpdate(true, false);
             list(, $PLANET) = $RPLANET->CalcResource($this->USER, $PLANET, false, $this->USER['b_tech']);
         } else {
             $PLANET = $this->PLANET;
         }
         $PLANET[$resource[31] . '_inter'] = self::getNetworkLevel($this->USER, $PLANET);
         $Element = $ListIDArray[0];
         $Level = $ListIDArray[1];
         $costResources = BuildFunctions::getElementPrice($this->USER, $PLANET, $Element);
         $BuildTime = BuildFunctions::getBuildingTime($this->USER, $PLANET, $Element, $costResources);
         $HaveResources = BuildFunctions::isElementBuyable($this->USER, $PLANET, $Element, $costResources);
         $BuildEndTime = $this->USER['b_tech'] + $BuildTime;
         $CurrentQueue[0] = array($Element, $Level, $BuildTime, $BuildEndTime, $PLANET['id']);
         if ($HaveResources == true) {
             if (isset($costResources[901])) {
                 $PLANET[$resource[901]] -= $costResources[901];
             }
             if (isset($costResources[902])) {
                 $PLANET[$resource[902]] -= $costResources[902];
             }
             if (isset($costResources[903])) {
                 $PLANET[$resource[903]] -= $costResources[903];
             }
             if (isset($costResources[921])) {
                 $this->USER[$resource[921]] -= $costResources[921];
             }
             $this->USER['b_tech_id'] = $Element;
             $this->USER['b_tech'] = $BuildEndTime;
             $this->USER['b_tech_planet'] = $PLANET['id'];
             $this->USER['b_tech_queue'] = serialize($CurrentQueue);
             $Loop = false;
         } else {
             if ($this->USER['hof'] == 1) {
                 if (!isset($costResources[901])) {
                     $costResources[901] = 0;
                 }
                 if (!isset($costResources[902])) {
                     $costResources[902] = 0;
                 }
                 if (!isset($costResources[903])) {
                     $costResources[903] = 0;
                 }
                 $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['tech'][901], pretty_number($PLANET['crystal']), $LNG['tech'][902], pretty_number($PLANET['deuterium']), $LNG['tech'][903], pretty_number($costResources[901]), $LNG['tech'][901], pretty_number($costResources[902]), $LNG['tech'][902], pretty_number($costResources[903]), $LNG['tech'][903]);
                 PlayerUtil::sendMessage($this->USER['id'], 0, $this->USER['b_tech'], 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message);
             }
             array_shift($CurrentQueue);
             if (count($CurrentQueue) == 0) {
                 $this->USER['b_tech'] = 0;
                 $this->USER['b_tech_id'] = 0;
                 $this->USER['b_tech_planet'] = 0;
                 $this->USER['b_tech_queue'] = '';
                 $Loop = false;
             } else {
                 $BaseTime = $BuildEndTime - $BuildTime;
                 $NewQueue = array();
                 foreach ($CurrentQueue as $ListIDArray) {
                     $ListIDArray[2] = BuildFunctions::getBuildingTime($this->USER, $PLANET, $ListIDArray[0]);
                     $BaseTime += $ListIDArray[2];
                     $ListIDArray[3] = $BaseTime;
                     $NewQueue[] = $ListIDArray;
                 }
                 $CurrentQueue = $NewQueue;
             }
         }
         if ($isAnotherPlanet) {
             $RPLANET->SavePlanetToDB($this->USER, $PLANET);
             $RPLANET = NULL;
             unset($RPLANET);
         } else {
             $this->PLANET = $PLANET;
         }
     }
     return true;
 }
 public function show()
 {
     global $USER, $PLANET, $dpath, $LNG, $resource, $pricelist, $reslist, $CombatCaps, $ProdGrid, $CONF;
     $elementID = HTTP::_GP('id', 0);
     $AllTech = array();
     $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $elementID . " ;");
     if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
         while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
             $AllTech[] = $x;
         }
     }
     $productionTable = array();
     $FleetInfo = array();
     $MissileList = array();
     $gateData = array();
     $CurrentLevel = 0;
     $ressIDs = array_merge(array(), $reslist['resstype'][1], $reslist['resstype'][2], $reslist['resstype'][4]);
     if (in_array($elementID, $reslist['prod']) && in_array($elementID, $reslist['build'])) {
         $BuildLevelFactor = 10;
         $BuildTemp = $PLANET['temp_max'];
         $CurrentLevel = $PLANET[$resource[$elementID]];
         $BuildEnergy = $USER[$resource[113]];
         $BuildLevel = max($CurrentLevel, 0);
         $BuildStartLvl = max($CurrentLevel - 0, 0);
         for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 8; $BuildLevel++) {
             foreach ($ressIDs as $ID) {
                 if (!isset($ProdGrid[$elementID]['production'][$ID])) {
                     continue;
                 }
                 $Production = eval(ResourceUpdate::getProd($ProdGrid[$elementID]['production'][$ID]));
                 if ($ID < 905) {
                     $Production *= Config::get('resource_multiplier');
                 }
                 $productionTable['production'][$BuildLevel][$ID] = $Production;
             }
         }
         $productionTable['usedResource'] = array_keys($productionTable['production'][$BuildStartLvl]);
     } elseif (in_array($elementID, $reslist['storage'])) {
         $BuildLevelFactor = 10;
         $BuildTemp = $PLANET['temp_max'];
         $CurrentLevel = $PLANET[$resource[$elementID]];
         $BuildEnergy = $USER[$resource[113]];
         $BuildLevel = max($CurrentLevel, 0);
         $BuildStartLvl = max($CurrentLevel - 0, 0);
         for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 8; $BuildLevel++) {
             foreach ($ressIDs as $ID) {
                 if (!isset($ProdGrid[$elementID]['storage'][$ID])) {
                     continue;
                 }
                 $productionTable['storage'][$BuildLevel][$ID] = round(eval(ResourceUpdate::getProd($ProdGrid[$elementID]['storage'][$ID]))) * Config::get('resource_multiplier') * STORAGE_FACTOR;
             }
         }
         $productionTable['usedResource'] = array_keys($productionTable['storage'][$BuildStartLvl]);
     } elseif (in_array($elementID, $reslist['fleet'])) {
         $MaxSpeed = 15000;
         $FleetInfo = array('structure' => ($pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902]) / 10, 'structureTech' => ($pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902]) / 10 * (1 + 0.1 * $USER['shield_tech'] + $USER['factor']['Shield']), 'tech' => $pricelist[$elementID]['tech'], 'attack' => $CombatCaps[$elementID]['attack'], 'attackTech' => $CombatCaps[$elementID]['attack'] * (1 + 0.1 * $USER['military_tech'] + $USER['factor']['Attack']) * (rand(80, 120) / 100), 'shield' => $CombatCaps[$elementID]['shield'], 'shieldTech' => $CombatCaps[$elementID]['shield'] * (1 + 0.1 * $USER['defence_tech'] + $USER['factor']['Defensive']), 'capacity' => $pricelist[$elementID]['capacity'], 'speed1' => 100 / 15000 * $pricelist[$elementID]['speed'], 'speed2' => $pricelist[$elementID]['speed2'], 'consumption1' => $pricelist[$elementID]['consumption'], 'consumption2' => $pricelist[$elementID]['consumption2'], 'rapidfire' => array('from' => array(), 'to' => array()));
         $fleetIDs = array_merge($reslist['fleet'], $reslist['defense']);
         foreach ($fleetIDs as $fleetID) {
             if (isset($CombatCaps[$elementID]['sd']) && !empty($CombatCaps[$elementID]['sd'][$fleetID])) {
                 $FleetInfo['rapidfire']['to'][$fleetID] = $CombatCaps[$elementID]['sd'][$fleetID];
             }
             if (isset($CombatCaps[$fleetID]['sd']) && !empty($CombatCaps[$fleetID]['sd'][$elementID])) {
                 $FleetInfo['rapidfire']['from'][$fleetID] = $CombatCaps[$fleetID]['sd'][$elementID];
             }
         }
     } elseif (in_array($elementID, $reslist['defense'])) {
         $FleetInfo = array('structure' => ($pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902]) / 10, 'structureTech' => ($pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902]) / 10 * (1 + 0.1 * $USER['shield_tech'] + $USER['factor']['Shield']), 'attack' => $CombatCaps[$elementID]['attack'], 'attackTech' => $CombatCaps[$elementID]['attack'] * (1 + 0.1 * $USER['military_tech'] + $USER['factor']['Attack']) * (rand(80, 120) / 100), 'shield' => $CombatCaps[$elementID]['shield'], 'shieldTech' => $CombatCaps[$elementID]['shield'] * (1 + 0.1 * $USER['defence_tech'] + $USER['factor']['Defensive']), 'capacity' => 0, 'speed1' => 0, 'rapidfire' => array('from' => array(), 'to' => array()));
         $fleetIDs = array_merge($reslist['fleet'], $reslist['defense']);
         foreach ($fleetIDs as $fleetID) {
             if (isset($CombatCaps[$elementID]['sd']) && !empty($CombatCaps[$elementID]['sd'][$fleetID])) {
                 $FleetInfo['rapidfire']['to'][$fleetID] = $CombatCaps[$elementID]['sd'][$fleetID];
             }
             if (isset($CombatCaps[$fleetID]['sd']) && !empty($CombatCaps[$fleetID]['sd'][$elementID])) {
                 $FleetInfo['rapidfire']['from'][$fleetID] = $CombatCaps[$fleetID]['sd'][$elementID];
             }
         }
     }
     if ($elementID == 43 && $PLANET[$resource[43]] > 0) {
         $this->tplObj->loadscript('gate.js');
         $nextTime = self::getNextJumpWaitTime($PLANET['last_jump_time']);
         $gateData = array('nextTime' => _date($LNG['php_tdformat'], $nextTime, $USER['timezone']), 'restTime' => max(0, $nextTime - TIMESTAMP), 'startLink' => $PLANET['name'] . ' ' . strip_tags(BuildPlanetAdressLink($PLANET)), 'gateList' => $this->getTargetGates(), 'fleetList' => $this->getAvalibleFleets());
     } elseif ($elementID == 44 && $PLANET[$resource[44]] > 0) {
         $MissileList = array(502 => $PLANET[$resource[502]], 503 => $PLANET[$resource[503]]);
     }
     $number = 1;
     $elementBonus = '';
     if ($LNG['gameeffect'][$elementID] != '') {
         $elementBonus = BuildFunctions::getAvalibleEffect($elementID);
     }
     if (!$elementBonus) {
         $number = 0;
     }
     $this->tplObj->assign_vars(array('planetinfo1' => $PLANET['metal_mine'], 'planetinfo2' => $PLANET['crystal_mine'], 'planetinfo3' => $PLANET['deuterium_sintetizer'], 'planetinfo4' => $PLANET['solar_plant'], 'planetinfo5' => $PLANET['headquarters_antaris'], 'planetinfo14' => $PLANET['robot_factory'], 'planetinfo21' => $PLANET['hangar'], 'planetinfo31' => $PLANET['laboratory'], 'planetinfo45' => $PLANET['barracks'], 'planetinfo46' => $PLANET['defense_base'], 'planetinfo48' => $PLANET['elyrium_mine'], 'planetinfo106' => $USER['spy_tech'], 'planetinfo109' => $USER['military_tech'], 'planetinfo110' => $USER['defence_tech'], 'planetinfo111' => $USER['shield_tech'], 'planetinfo113' => $USER['energy_tech'], 'planetinfo115' => $USER['combustion_tech'], 'planetinfo117' => $USER['impulse_motor_tech'], 'planetinfo118' => $USER['hyperspace_motor_tech'], 'planetinfo140' => $USER['extraction_tech'], 'planetinfo141' => $USER['control_room_tech'], 'planetinfo142' => $USER['subspace_tech'], 'planetinfo143' => $USER['particle_tech'], 'planetinfo144' => $USER['antaris_tech'], 'planetinfo145' => $USER['infrastructure_tech'], 'planetinfo146' => $USER['virus_tech'], 'number' => $number, 'elementBonus' => $elementBonus, 'elementID' => $elementID, 'productionTable' => $productionTable, 'CurrentLevel' => $CurrentLevel, 'MissileList' => $MissileList, 'Bonus' => BuildFunctions::getAvalibleBonus($elementID), 'FleetInfo' => $FleetInfo, 'gateData' => $gateData, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $elementID)));
     $this->display('page.infomation.default.tpl');
 }
 public function show()
 {
     global $USER, $PLANET, $LNG, $resource, $dpath, $reslist, $requeriments, $CONF;
     $fmenge = isset($_POST['fmenge']) ? $_POST['fmenge'] : array();
     $action = HTTP::_GP('action', '');
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = unserialize($PLANET['b_building_id']);
         foreach ($CurrentQueue as $ElementArray) {
             if ($ElementArray[0] == 21 || $ElementArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     if (empty($ElementQueue)) {
         $Count = 0;
     } else {
         $Count = count($ElementQueue);
     }
     if ($USER['urlaubs_modus'] == 0) {
         if (!empty($fmenge) && $NotBuilding == true) {
             if (Config::get('max_elements_ships') != 0 && $Count >= Config::get('max_elements_ships')) {
                 $this->printMessage(sprintf($LNG['bd_max_builds'], Config::get('max_elements_ships')));
                 exit;
             }
             $this->BuildAuftr($fmenge);
         }
         if ($action == "delete") {
             $this->CancelAuftr();
         }
     }
     $elementInQueue = array();
     $ElementQueue = unserialize($PLANET['b_hangar_id']);
     $Buildlist = array();
     if (!empty($ElementQueue)) {
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $Element) {
             if (empty($Element)) {
                 continue;
             }
             $elementInQueue[$Element[0]] = true;
             $ElementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime, $Element[0]);
         }
         $this->tplObj->loadscript('bcmath.js');
         $this->tplObj->execscript('ShipyardInit();');
         $Buildlist = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0)));
     }
     $mode = HTTP::_GP('mode', 'fleet');
     if ($mode != 'defense' && $PLANET['planet_type'] == 4) {
         $this->printMessage("You cant acces this page on a fortress");
     }
     if ($mode == 'defense' && $CONF['fleetconf'] == 1 && $CONF['purchase_bonus_timer'] > TIMESTAMP) {
         $elementALL = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422, 502, 503);
         $elementIDs = array(407, 408, 409, 411, 502, 503);
         $elementIDd = array(401, 402, 403, 420);
         $elementIDa = array(405, 404, 406, 416, 417, 421);
         $elementIDq = array(418, 412, 410, 413, 419, 414, 422, 415);
     } elseif ($mode == 'defense') {
         $elementALL = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 422, 502, 503);
         $elementIDs = array(407, 408, 409, 411, 502, 503);
         $elementIDd = array(401, 402, 403);
         $elementIDa = array(405, 404, 406, 416, 417);
         $elementIDq = array(418, 412, 410, 413, 419, 414, 415);
     } elseif ($mode == 'fleet' && $CONF['fleetconf'] == 1 && $CONF['purchase_bonus_timer'] > TIMESTAMP) {
         $elementALL = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230);
         $elementIDs = array(208, 210, 220, 223);
         $elementIDd = array(212, 202, 203, 204, 205, 229);
         $elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219, 224);
         $elementIDq = array(225, 226, 214, 216, 230, 227, 228, 222, 218, 221);
     } elseif ($mode == 'fleet') {
         $elementALL = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230);
         $elementIDs = array(208, 210, 220, 223);
         $elementIDd = array(212, 202, 203, 204, 205);
         $elementIDa = array(209, 206, 207, 217, 215, 213, 211, 219);
         $elementIDq = array(225, 226, 214, 216, 227, 228, 222, 218, 221);
     }
     $Missiles = array();
     $Domes = array();
     $Orbits = array();
     foreach ($reslist['missile'] as $elementID) {
         $Missiles[$elementID] = $PLANET[$resource[$elementID]];
     }
     foreach ($reslist['defense'] as $elementID) {
         $Domes[$elementID] = $PLANET[$resource[$elementID]];
         $Orbits[$elementID] = $PLANET[$resource[$elementID]];
     }
     $MaxMissiles = BuildFunctions::getMaxConstructibleRockets($USER, $PLANET, $Missiles);
     $MaxDomes = BuildFunctions::getMaxConstructibleDomes($USER, $PLANET, $Domes);
     $MaxOrbits = BuildFunctions::getMaxConstructibleOrbits($USER, $PLANET, $Orbits);
     foreach ($elementALL as $Element) {
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementListall[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDs as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementList[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDq as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementListq[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDa as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementLista[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     foreach ($elementIDd as $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $maxBuildable = BuildFunctions::getMaxConstructibleElements($USER, $PLANET, $Element, $costRessources);
         if (isset($MaxMissiles[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxMissiles[$Element]);
         }
         if (isset($MaxDomes[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxDomes[$Element]);
         }
         if (isset($MaxOrbits[$Element])) {
             $maxBuildable = min($maxBuildable, $MaxOrbits[$Element]);
         }
         $AlreadyBuild = in_array($Element, $reslist['one']) && (isset($elementInQueue[$Element]) || $PLANET[$resource[$Element]] != 0);
         $elementListd[$Element] = array('id' => $Element, 'available' => $PLANET[$resource[$Element]], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'maxBuildable' => floattostring($maxBuildable), 'AlreadyBuild' => $AlreadyBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $manual_step_9 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 9 && ($PLANET['misil_launcher'] < 25 || $PLANET['small_laser'] < 10)) {
         $manual_step_9 = 0;
     }
     $manual_step_10 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 9 && $PLANET['misil_launcher'] >= 25 && $PLANET['small_laser'] >= 10) {
         $manual_step_10 = 0;
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '11' WHERE `id` = " . $USER['id'] . ";");
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `experience_peace` = `experience_peace` + '650' WHERE `id` = '" . $USER['id'] . "';");
         require_once 'includes/classes/class.FleetFunctions.php';
         $rawfleetarray = array(204 => 8, 205 => 5, 206 => 3);
         $fleetRessource = array(901 => 0, 902 => 0, 903 => 0);
         FleetFunctions::sendFleet($rawfleetarray, '1', 1, 1, 1, 1, 1, 1, $PLANET['id_owner'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $fleetRessource, TIMESTAMP + 58, TIMESTAMP + 58, TIMESTAMP + 116, 0);
     }
     $manual_step_16 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 16) {
         $manual_step_16 = 0;
     }
     if ($USER['training'] == 0 && $USER['training_step'] == 16 && $PLANET['recycler'] >= 5) {
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '17' WHERE `id` = " . $USER['id'] . ";");
     }
     $this->tplObj->loadscript('shipyard.js');
     $this->tplObj->assign_vars(array('manual_step_16' => $manual_step_16, 'manual_step_10' => $manual_step_10, 'manual_step_9' => $manual_step_9, 'elementListall' => $elementListall, 'elementList' => $elementList, 'elementListd' => $elementListd, 'elementLista' => $elementLista, 'elementListq' => $elementListq, 'NotBuilding' => $NotBuilding, 'BuildList' => $Buildlist, 'maxlength' => strlen(Config::get('max_fleet_per_build')), 'mode' => $mode));
     $this->display('page.shipyard.default.tpl');
 }
 public function show()
 {
     global $ProdGrid, $LNG, $resource, $reslist, $CONF, $PLANET, $USER, $pricelist;
     $buscarTick = $GLOBALS['DATABASE']->query("SELECT tick FROM " . CONFIG . "");
     $tickinicial = $GLOBALS['DATABASE']->fetch_array($buscarTick);
     $tickinicial = $tickinicial['tick'];
     $TheCommand = HTTP::_GP('cmd', '');
     // wellformed buildURLs
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         $Element = HTTP::_GP('building', 0);
         $ListID = HTTP::_GP('listid', 0);
         $lvlup1 = HTTP::_GP('lvlup1', 0);
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue();
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, $lvlup1, true);
                 break;
             case 'destroy':
                 $this->DoAddBuildingToQueue($Element, false);
                 break;
         }
         $this->redirectTo('game.php?page=buildings');
     }
     $premium_stage = 0;
     if ($USER['premium_reward_stage'] > 0 && $USER['premium_reward_stage_days'] > TIMESTAMP) {
         $premium_stage = $USER['premium_reward_stage'];
     }
     $queueData = $this->getQueueData();
     $Queue = $queueData['queue'];
     $QueueCount = count($Queue);
     $CanBuildElement = isVacationMode($USER) || Config::get('max_elements_build') - 1 == 0 || $QueueCount < Config::get('max_elements_build') - 1 + $premium_stage;
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET['field_current'] < $CurrentMaxFields - $QueueCount;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     $BuildInfoList = array();
     $Elements = $reslist['allow'][$PLANET['planet_type']];
     foreach ($Elements as $ID => $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         $infoEnergy = "";
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $PLANET[$resource[$Element]];
         }
         if (in_array($Element, $reslist['prod'])) {
             $peacefull_resource = 0;
             if ($USER['experience_peace_level'] > 0) {
                 $peacefull_resource = $USER['experience_peace_level'];
             }
             $peacefull_resource = $peacefull_resource;
             $premium_resource = 0;
             if ($USER['premium_reward_extraction'] > 0 && $USER['premium_reward_extraction_days'] > TIMESTAMP) {
                 $premium_resource = $USER['premium_reward_extraction'];
             }
             $premium_resource = $premium_resource;
             $combat_collider = 0;
             if ($USER['combat_reward_collider'] > 0) {
                 $combat_collider = $USER['combat_reward_collider'];
             }
             $combat_collider = $combat_collider;
             $academy_mines = 0;
             if ($USER['academy_1201'] > 0) {
                 $academy_mines = getbonusOneBis(1201, $USER['academy_1201']);
             }
             $academy_mines = $academy_mines;
             $daily_prod_bonus = 0;
             if ($USER['daily_produ'] > TIMESTAMP) {
                 $daily_prod_bonus = 30;
             }
             $daily_prod_bonus = $daily_prod_bonus;
             $academy_energy = 0;
             if ($USER['academy_1202'] > 0) {
                 $academy_energy = getbonusOneBis(1202, $USER['academy_1202']);
             }
             $academy_energy = $academy_energy;
             $academy_fusion = 0;
             if ($USER['academy_1209'] > 0) {
                 $academy_fusion = getbonusOneBis(1209, $USER['academy_1209']);
             }
             $academy_fusion = $academy_fusion;
             $academy_solar = 0;
             if ($USER['academy_1210'] > 0) {
                 $academy_solar = getbonusOneBis(1210, $USER['academy_1210']);
             }
             $academy_solar = $academy_solar;
             $allyInfo = $GLOBALS['DATABASE']->query("SELECT alliance_prod FROM `uni1_alliance` WHERE id = " . $USER['ally_id'] . ";");
             $allyInfo = $GLOBALS['DATABASE']->fetch_array($allyInfo);
             $alliance_prod = 0;
             if ($allyInfo['alliance_prod'] > 0) {
                 $alliance_prod = $allyInfo['alliance_prod'];
             }
             $alliance_prod = $alliance_prod;
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = round(eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])));
             $BuildLevel = $levelToBuild + 1;
             $Prod = round(eval(ResourceUpdate::getProd($ProdGrid[$Element]['production'][911])));
             $requireEnergy = $Prod - $Need;
             if ($requireEnergy < 0) {
                 $infoEnergy = sprintf($LNG['bd_need_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             } else {
                 $infoEnergy = sprintf($LNG['bd_more_engine'], pretty_number(abs($requireEnergy)), $LNG['tech'][911]);
             }
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $destroyRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, true);
         $destroyTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $destroyRessources);
         $destroyOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $destroyRessources);
         $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $BuildInfoList[$Element] = array('level' => $PLANET[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'factor' => $pricelist[$Element]['factor'], 'infoEnergy' => $infoEnergy, 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'destroyRessources' => $destroyRessources, 'destroyTime' => $destroyTime, 'destroyOverflow' => $destroyOverflow, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $this->tplObj->loadscript('buildlist.js');
     $manual_step_2 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 2 && $PLANET['solar_plant'] < 1) {
         $manual_step_2 = 0;
     }
     $manual_step_2_1 = 1;
     if ($USER['training'] == 0 && $PLANET['solar_plant'] >= 1 && $USER['training_step'] == 2 && ($PLANET['metal_mine'] < 3 || $PLANET['crystal_mine'] < 2 || $PLANET['deuterium_sintetizer'] < 1)) {
         $manual_step_2_1 = 0;
     }
     $manual_step_2_2 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 2 && $PLANET['metal_mine'] >= 3 && $PLANET['crystal_mine'] >= 2 && $PLANET['deuterium_sintetizer'] >= 1 && $PLANET['solar_plant'] < 4) {
         $manual_step_2_2 = 0;
     }
     $manual_step_2_3 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 2 && $PLANET['metal_mine'] >= 3 && $PLANET['crystal_mine'] >= 2 && $PLANET['deuterium_sintetizer'] >= 1 && $PLANET['solar_plant'] >= 4) {
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '3' WHERE `id` = " . $USER['id'] . ";");
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `experience_peace` = `experience_peace` + '650' WHERE `id` = " . $USER['id'] . ";");
         $GLOBALS['DATABASE']->query("UPDATE " . PLANETS . " SET spy_sonde = spy_sonde + 5 WHERE id = 1;");
         // SEND PROBES FUNCTION HERE
         $rawfleetarray = array(210 => 5);
         $fleetRessource = array(901 => 0, 902 => 0, 903 => 0);
         if (1 == $PLANET['system']) {
             $tickfinal = $tickinicial + 9;
         } else {
             $tickfinal = $tickinicial + 11;
         }
         FleetFunctions::sendFleet($rawfleetarray, '6', 1, 1, 1, 1, 1, 1, $PLANET['id_owner'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $PLANET['planet_type'], $fleetRessource, TIMESTAMP + 40, TIMESTAMP + 40, TIMESTAMP + 80, $tickinicial, $tickfinal, 0);
         $manual_step_2_3 = 0;
     }
     $manual_step_5 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 5) {
         $manual_step_5 = 0;
     }
     $manual_step_9 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 9) {
         $manual_step_9 = 0;
     }
     $manual_step_16 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 16) {
         $manual_step_16 = 0;
     }
     if ($USER['training'] == 0 && $USER['training_step'] == 5 && $PLANET['laboratory'] >= 3) {
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '6' WHERE `id` = " . $USER['id'] . ";");
     }
     $this->tplObj->assign_vars(array('manual_step_16' => $manual_step_16, 'manual_step_9' => $manual_step_9, 'manual_step_2' => $manual_step_2, 'manual_step_2_1' => $manual_step_2_1, 'manual_step_2_2' => $manual_step_2_2, 'manual_step_2_3' => $manual_step_2_3, 'manual_step_5' => $manual_step_5, 'BuildInfoList' => $BuildInfoList, 'CanBuildElement' => $CanBuildElement, 'RoomIsOk' => $RoomIsOk, 'Planetas' => $PLANET, 'Queue' => $Queue, 'isBusy' => array('shipyard' => !empty($PLANET['b_hangar_id']), 'research' => $USER['b_tech_planet'] != 0), 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]], 'HaveMissiles' => (bool) $PLANET[$resource[503]] + $PLANET[$resource[502]], 'field_used' => $PLANET['field_current'], 'field_max' => CalculateMaxPlanetFields($PLANET), 'field_left' => CalculateMaxPlanetFields($PLANET) - $PLANET['field_current'], 'field_percent' => $PLANET['field_current'] * 100 / CalculateMaxPlanetFields($PLANET)));
     $this->display('page.buildings.default.tpl');
 }
    function show()
    {
        global $LNG, $PLANET, $USER;
        $AdminsOnline = array();
        $chatOnline = array();
        $AllPlanets = array();
        $Moon = array();
        $RefLinks = array();
        $db = Database::get();
        foreach ($USER['PLANETS'] as $ID => $CPLANET) {
            if ($ID == $PLANET['id'] || $CPLANET['planet_type'] == 3) {
                continue;
            }
            if (!empty($CPLANET['b_building']) && $CPLANET['b_building'] > TIMESTAMP) {
                $Queue = unserialize($CPLANET['b_building_id']);
                $BuildPlanet = $LNG['tech'][$Queue[0][0]] . " (" . $Queue[0][1] . ")<br><span style=\"color:#7F7F7F;\">(" . pretty_time($Queue[0][3] - TIMESTAMP) . ")</span>";
            } else {
                $BuildPlanet = $LNG['ov_free'];
            }
            $AllPlanets[] = array('id' => $CPLANET['id'], 'name' => $CPLANET['name'], 'image' => $CPLANET['image'], 'build' => $BuildPlanet);
        }
        if ($PLANET['id_luna'] != 0) {
            $sql = "SELECT id, name FROM %%PLANETS%% WHERE id = :lunaID;";
            $Moon = $db->selectSingle($sql, array(':lunaID' => $PLANET['id_luna']));
        }
        if ($PLANET['b_building'] - TIMESTAMP > 0) {
            $Queue = unserialize($PLANET['b_building_id']);
            $buildInfo['buildings'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $PLANET['b_building'] - TIMESTAMP, 'time' => $PLANET['b_building'], 'starttime' => pretty_time($PLANET['b_building'] - TIMESTAMP));
        } else {
            $buildInfo['buildings'] = false;
        }
        /* As FR#206 (http://tracker.2moons.cc/view.php?id=206), i added the shipyard and research status here, but i add not them the template. */
        if (!empty($PLANET['b_hangar_id'])) {
            $Queue = unserialize($PLANET['b_hangar_id']);
            $time = BuildFunctions::getBuildingTime($USER, $PLANET, $Queue[0][0]) * $Queue[0][1];
            $buildInfo['fleet'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $time - $PLANET['b_hangar'], 'time' => $time, 'starttime' => pretty_time($time - $PLANET['b_hangar']));
        } else {
            $buildInfo['fleet'] = false;
        }
        if ($USER['b_tech'] - TIMESTAMP > 0) {
            $Queue = unserialize($USER['b_tech_queue']);
            $buildInfo['tech'] = array('id' => $Queue[0][0], 'level' => $Queue[0][1], 'timeleft' => $USER['b_tech'] - TIMESTAMP, 'time' => $USER['b_tech'], 'starttime' => pretty_time($USER['b_tech'] - TIMESTAMP));
        } else {
            $buildInfo['tech'] = false;
        }
        $sql = "SELECT id,username FROM %%USERS%% WHERE universe = :universe AND onlinetime >= :onlinetime AND authlevel > :authlevel;";
        $onlineAdmins = $db->select($sql, array(':universe' => Universe::current(), ':onlinetime' => TIMESTAMP - 10 * 60, ':authlevel' => AUTH_USR));
        foreach ($onlineAdmins as $AdminRow) {
            $AdminsOnline[$AdminRow['id']] = $AdminRow['username'];
        }
        $sql = "SELECT userName FROM %%CHAT_ON%% WHERE dateTime > DATE_SUB(NOW(), interval 2 MINUTE) AND channel = 0";
        $chatUsers = $db->select($sql);
        foreach ($chatUsers as $chatRow) {
            $chatOnline[] = $chatRow['userName'];
        }
        $Messages = $USER['messages'];
        // Fehler: Wenn Spieler gelöscht werden, werden sie nicht mehr in der Tabelle angezeigt.
        $sql = "SELECT u.id, u.username, s.total_points FROM %%USERS%% as u\n\t\tLEFT JOIN %%STATPOINTS%% as s ON s.id_owner = u.id AND s.stat_type = '1' WHERE ref_id = :userID;";
        $RefLinksRAW = $db->select($sql, array(':userID' => $USER['id']));
        $config = Config::get();
        if ($config->ref_active) {
            foreach ($RefLinksRAW as $RefRow) {
                $RefLinks[$RefRow['id']] = array('username' => $RefRow['username'], 'points' => min($RefRow['total_points'], $config->ref_minpoints));
            }
        }
        $sql = 'SELECT total_points, total_rank
		FROM %%STATPOINTS%%
		WHERE id_owner = :userId AND stat_type = :statType';
        $statData = Database::get()->selectSingle($sql, array(':userId' => $USER['id'], ':statType' => 1));
        if ($statData['total_rank'] == 0) {
            $rankInfo = "-";
        } else {
            $rankInfo = sprintf($LNG['ov_userrank_info'], pretty_number($statData['total_points']), $LNG['ov_place'], $statData['total_rank'], $statData['total_rank'], $LNG['ov_of'], $config->users_amount);
        }
        $this->assign(array('rankInfo' => $rankInfo, 'is_news' => $config->OverviewNewsFrame, 'news' => makebr($config->OverviewNewsText), 'planetname' => $PLANET['name'], 'planetimage' => $PLANET['image'], 'galaxy' => $PLANET['galaxy'], 'system' => $PLANET['system'], 'planet' => $PLANET['planet'], 'planet_type' => $PLANET['planet_type'], 'username' => $USER['username'], 'userid' => $USER['id'], 'buildInfo' => $buildInfo, 'Moon' => $Moon, 'fleets' => $this->GetFleets(), 'AllPlanets' => $AllPlanets, 'AdminsOnline' => $AdminsOnline, 'teamspeakData' => $this->GetTeamspeakData(), 'messages' => $Messages > 0 ? $Messages == 1 ? $LNG['ov_have_new_message'] : sprintf($LNG['ov_have_new_messages'], pretty_number($Messages)) : false, 'planet_diameter' => pretty_number($PLANET['diameter']), 'planet_field_current' => $PLANET['field_current'], 'planet_field_max' => CalculateMaxPlanetFields($PLANET), 'planet_temp_min' => $PLANET['temp_min'], 'planet_temp_max' => $PLANET['temp_max'], 'ref_active' => $config->ref_active, 'ref_minpoints' => $config->ref_minpoints, 'RefLinks' => $RefLinks, 'chatOnline' => $chatOnline, 'servertime' => _date("M D d H:i:s", TIMESTAMP, $USER['timezone']), 'path' => HTTP_PATH));
        $this->display('page.overview.default.tpl');
    }
 public function show()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $pricelist;
     $TheCommand = HTTP::_GP('cmd', '');
     $Element = HTTP::_GP('tech', 0);
     $ListID = HTTP::_GP('listid', 0);
     $lvlup1 = HTTP::_GP('lvlup1', 0);
     $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET);
     if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue();
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID);
                 break;
             case 'instant':
                 $this->InstantBuildingFromQueue();
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, $lvlup1, true);
                 break;
             case 'destroy':
                 $this->DoAddBuildingToQueue($Element, false);
                 break;
         }
         $this->redirectTo('game.php?page=research');
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET);
     $queueData = $this->getQueueData();
     $TechQueue = $queueData['queue'];
     $QueueCount = count($TechQueue);
     $ResearchList = array();
     foreach ($reslist['tech'] as $ID => $Element) {
         $AllTech = array();
         $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;");
         if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) {
             while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) {
                 $AllTech[] = $x;
             }
         }
         if (isset($queueData['quickinfo'][$Element])) {
             $levelToBuild = $queueData['quickinfo'][$Element];
         } else {
             $levelToBuild = $USER[$resource[$Element]];
         }
         $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild);
         $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources);
         $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources);
         $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources);
         $ResearchList[$Element] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'factor' => $pricelist[$Element]['factor'], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element));
     }
     $this->tplObj->loadscript('research.js');
     $premium_stage = 0;
     if ($USER['premium_reward_stage'] > 0 && $USER['premium_reward_stage_days'] > TIMESTAMP) {
         $premium_stage = $USER['premium_reward_stage'];
     }
     $manual_step_5 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 5 && $PLANET['laboratory'] < 3) {
         $manual_step_5 = 0;
     }
     $manual_step_5_1 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 5 && $PLANET['laboratory'] >= 3) {
         $manual_step_5_1 = 0;
     }
     $manual_step_6 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 6) {
         $manual_step_6 = 0;
     }
     $manual_step_6_1 = 1;
     $manual_step_7 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 6 && $USER['spy_tech'] >= 3) {
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '8' WHERE `id` = " . $USER['id'] . ";");
         $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `experience_peace` = `experience_peace` + '650' WHERE `id` = " . $USER['id'] . ";");
         $manual_step_7 = 0;
     }
     $manual_step_9 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 9) {
         $manual_step_9 = 0;
     }
     $manual_step_16 = 1;
     if ($USER['training'] == 0 && $USER['training_step'] == 16) {
         $manual_step_16 = 0;
     }
     $this->tplObj->assign_vars(array('manual_step_5_1' => $manual_step_5_1, 'manual_step_16' => $manual_step_16, 'manual_step_5' => $manual_step_5, 'manual_step_9' => $manual_step_9, 'manual_step_6' => $manual_step_6, 'dmavaible' => $USER['darkmatter'], 'modinstant' => $CONF['modinstant'], 'mod_research_cost' => $CONF['modinstantresearch'], 'modinstantresen' => $CONF['modinstantresen'], 'manual_step_7' => $manual_step_7, 'ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => Config::get('max_elements_tech') == 0 || Config::get('max_elements_tech') + $premium_stage == count($TechQueue), 'Queue' => $TechQueue));
     $this->display('page.research.default.tpl');
 }
Example #28
0
 public function show()
 {
     global $USER, $PLANET, $resource, $reslist, $LNG, $pricelist;
     $updateID = HTTP::_GP('id', 0);
     if (!empty($updateID) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) {
         if (isModulAvalible(MODULE_OFFICIER) && in_array($updateID, $reslist['officier'])) {
             $this->UpdateOfficier($updateID);
         } elseif (isModulAvalible(MODULE_DMEXTRAS) && in_array($updateID, $reslist['dmfunc'])) {
             $this->UpdateExtra($updateID);
         }
     }
     $darkmatterList = array();
     $officierList = array();
     if (isModulAvalible(MODULE_DMEXTRAS)) {
         foreach ($reslist['dmfunc'] as $Element) {
             if ($USER[$resource[$Element]] > TIMESTAMP) {
                 $this->tplObj->execscript("GetOfficerTime(" . $Element . ", " . ($USER[$resource[$Element]] - TIMESTAMP) . ");");
             }
             $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
             $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costResources);
             $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costResources);
             $elementBonus = BuildFunctions::getAvalibleBonus($Element);
             $darkmatterList[$Element] = array('timeLeft' => max($USER[$resource[$Element]] - TIMESTAMP, 0), 'costResources' => $costResources, 'buyable' => $buyable, 'time' => $pricelist[$Element]['time'], 'costOverflow' => $costOverflow, 'elementBonus' => $elementBonus);
         }
     }
     if (isModulAvalible(MODULE_OFFICIER)) {
         foreach ($reslist['officier'] as $Element) {
             if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)) {
                 continue;
             }
             $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $Element);
             $buyable = BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costResources);
             $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costResources);
             $elementBonus = BuildFunctions::getAvalibleBonus($Element);
             $officierList[$Element] = array('level' => $USER[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'costResources' => $costResources, 'buyable' => $buyable, 'costOverflow' => $costOverflow, 'elementBonus' => $elementBonus);
         }
     }
     $this->assign(array('officierList' => $officierList, 'darkmatterList' => $darkmatterList, 'of_dm_trade' => sprintf($LNG['of_dm_trade'], $LNG['tech'][921])));
     $this->display('page.officier.default.tpl');
 }
 public function show()
 {
     global $USER, $PLANET, $dpath, $LNG, $resource, $pricelist, $reslist, $CombatCaps, $ProdGrid, $CONF;
     $elementID = HTTP::_GP('id', 0);
     $this->setWindow('popup');
     $this->initTemplate();
     $productionTable = array();
     $FleetInfo = array();
     $MissileList = array();
     $gateData = array();
     $CurrentLevel = 0;
     $ressIDs = array_merge(array(), $reslist['resstype'][1], $reslist['resstype'][2], $reslist['resstype'][3]);
     if (in_array($elementID, $reslist['prod']) && in_array($elementID, $reslist['build'])) {
         $BuildLevelFactor = 10;
         $BuildTemp = $PLANET['temp_max'];
         $CurrentLevel = $PLANET[$resource[$elementID]];
         $BuildEnergy = $USER[$resource[113]];
         $BuildLevel = max($CurrentLevel, 0);
         $BuildStartLvl = max($CurrentLevel - 2, 0);
         $premium_resource = 0;
         $peacefull_resource = 0;
         if ($USER['premium_reward_extraction'] > 0 && $USER['premium_reward_extraction_days'] > TIMESTAMP) {
             $premium_resource = $USER['premium_reward_extraction'];
         }
         $premium_resource = $premium_resource;
         if ($USER['experience_peace_level'] > 0) {
             $peacefull_resource = $USER['experience_peace_level'];
         }
         $peacefull_resource = $peacefull_resource;
         $academy_mines = 0;
         if ($USER['academy_1201'] > 0) {
             $academy_mines = getbonusOneBis(1201, $USER['academy_1201']);
         }
         $academy_mines = $academy_mines;
         $daily_prod_bonus = 0;
         if ($USER['daily_produ'] > TIMESTAMP) {
             $daily_prod_bonus = 30;
         }
         $daily_prod_bonus = $daily_prod_bonus;
         $academy_energy = 0;
         if ($USER['academy_1202'] > 0) {
             $academy_energy = getbonusOneBis(1202, $USER['academy_1202']);
         }
         $academy_energy = $academy_energy;
         $academy_fusion = 0;
         if ($USER['academy_1209'] > 0) {
             $academy_fusion = getbonusOneBis(1209, $USER['academy_1209']);
         }
         $academy_fusion = $academy_fusion;
         $academy_solar = 0;
         if ($USER['academy_1210'] > 0) {
             $academy_solar = getbonusOneBis(1210, $USER['academy_1210']);
         }
         $academy_solar = $academy_solar;
         $combat_collider = 0;
         if ($USER['combat_reward_collider'] > 0) {
             $combat_collider = $USER['combat_reward_collider'];
         }
         $combat_collider = $combat_collider;
         $allyInfo = $GLOBALS['DATABASE']->query("SELECT alliance_prod FROM `uni1_alliance` WHERE id = " . $USER['ally_id'] . ";");
         $allyInfo = $GLOBALS['DATABASE']->fetch_array($allyInfo);
         $alliance_prod = 0;
         if ($allyInfo['alliance_prod'] > 0) {
             $alliance_prod = $allyInfo['alliance_prod'];
         }
         $alliance_prod = $alliance_prod;
         for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) {
             foreach ($ressIDs as $ID) {
                 if (!isset($ProdGrid[$elementID]['production'][$ID])) {
                     continue;
                 }
                 $Production = eval(ResourceUpdate::getProd($ProdGrid[$elementID]['production'][$ID]));
                 if ($ID != 911 && $ID != 921) {
                     $Production *= Config::get('resource_multiplier');
                 }
                 $productionTable['production'][$BuildLevel][$ID] = $Production;
             }
         }
         $productionTable['usedResource'] = array_keys($productionTable['production'][$BuildStartLvl]);
     } elseif (in_array($elementID, $reslist['storage'])) {
         $BuildLevelFactor = 10;
         $BuildTemp = $PLANET['temp_max'];
         $CurrentLevel = $PLANET[$resource[$elementID]];
         $BuildEnergy = $USER[$resource[113]];
         $BuildLevel = max($CurrentLevel, 0);
         $BuildStartLvl = max($CurrentLevel - 2, 0);
         $premium_storage = 1;
         if ($USER['premium_reward_storing'] > 0 && $USER['premium_reward_storing_days'] > TIMESTAMP) {
             $premium_storage = $USER['premium_reward_storing'];
         }
         $premium_storage = $premium_storage;
         $academy_storage = 0;
         if ($USER['academy_1204'] > 0) {
             $academy_storage = getbonusOneBis(1204, $USER['academy_1204']);
         }
         $academy_storage = $academy_storage;
         for ($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 15; $BuildLevel++) {
             foreach ($ressIDs as $ID) {
                 if (!isset($ProdGrid[$elementID]['storage'][$ID])) {
                     continue;
                 }
                 $productionTable['storage'][$BuildLevel][$ID] = round(eval(ResourceUpdate::getProd($ProdGrid[$elementID]['storage'][$ID]))) * Config::get('resource_multiplier') * STORAGE_FACTOR;
             }
         }
         $productionTable['usedResource'] = array_keys($productionTable['storage'][$BuildStartLvl]);
     } elseif (in_array($elementID, $reslist['fleet'])) {
         $FleetInfo = array('structure' => $pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902], 'tech' => $pricelist[$elementID]['tech'], 'attack' => $CombatCaps[$elementID]['attack'], 'shield' => $CombatCaps[$elementID]['shield'], 'capacity' => $pricelist[$elementID]['capacity'], 'speed1' => $pricelist[$elementID]['speed'], 'speed2' => $pricelist[$elementID]['speed2'], 'consumption1' => $pricelist[$elementID]['consumption'], 'consumption2' => $pricelist[$elementID]['consumption2'], 'rapidfire' => array('from' => array(), 'to' => array()));
         $fleetIDs = array_merge($reslist['fleet'], $reslist['defense']);
         foreach ($fleetIDs as $fleetID) {
             if (isset($CombatCaps[$elementID]['sd']) && !empty($CombatCaps[$elementID]['sd'][$fleetID])) {
                 $FleetInfo['rapidfire']['to'][$fleetID] = $CombatCaps[$elementID]['sd'][$fleetID];
             }
             if (isset($CombatCaps[$fleetID]['sd']) && !empty($CombatCaps[$fleetID]['sd'][$elementID])) {
                 $FleetInfo['rapidfire']['from'][$fleetID] = $CombatCaps[$fleetID]['sd'][$elementID];
             }
         }
     } elseif (in_array($elementID, $reslist['defense'])) {
         $FleetInfo = array('structure' => $pricelist[$elementID]['cost'][901] + $pricelist[$elementID]['cost'][902], 'attack' => $CombatCaps[$elementID]['attack'], 'shield' => $CombatCaps[$elementID]['shield'], 'rapidfire' => array('from' => array(), 'to' => array()));
         $fleetIDs = array_merge($reslist['fleet'], $reslist['defense']);
         foreach ($fleetIDs as $fleetID) {
             if (isset($CombatCaps[$elementID]['sd']) && !empty($CombatCaps[$elementID]['sd'][$fleetID])) {
                 $FleetInfo['rapidfire']['to'][$fleetID] = $CombatCaps[$elementID]['sd'][$fleetID];
             }
             if (isset($CombatCaps[$fleetID]['sd']) && !empty($CombatCaps[$fleetID]['sd'][$elementID])) {
                 $FleetInfo['rapidfire']['from'][$fleetID] = $CombatCaps[$fleetID]['sd'][$elementID];
             }
         }
     }
     if ($elementID == 43 && $PLANET[$resource[43]] > 0) {
         $this->tplObj->loadscript('gate.js');
         $nextTime = self::getNextJumpWaitTime($PLANET['last_jump_time'], $PLANET['sprungtor']);
         $gateData = array('nextTime' => _date($LNG['php_tdformat'], $nextTime, $USER['timezone']), 'restTime' => max(0, $nextTime - TIMESTAMP), 'startLink' => $PLANET['name'] . ' ' . strip_tags(BuildPlanetAdressLink($PLANET)), 'gateList' => $this->getTargetGates(), 'fleetList' => $this->getAvalibleFleets());
     } elseif ($elementID == 44 && $PLANET[$resource[44]] > 0) {
         $MissileList = array(502 => $PLANET[$resource[502]], 503 => $PLANET[$resource[503]]);
     }
     $this->tplObj->assign_vars(array('elementID' => $elementID, 'productionTable' => $productionTable, 'CurrentLevel' => $CurrentLevel, 'MissileList' => $MissileList, 'Bonus' => BuildFunctions::getAvalibleBonus($elementID), 'FleetInfo' => $FleetInfo, 'gateData' => $gateData));
     $this->display('page.infomation.default.tpl');
 }