/**
 * This file is part of XNova:Legacies
 *
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 * @see http://www.xnova-ng.org/
 *
 * Copyright (c) 2009-Present, XNova Support Team <http://www.xnova-ng.org>
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *                                --> NOTICE <--
 *  This file is part of the core development branch, changing its contents will
 * make you unable to use the automatic updates manager. Please refer to the
 * documentation for further information about customizing XNova.
 *
 */
function HandleElementBuildingQueue($currentUser, &$currentPlanet, $productionTime)
{
    global $resource;
    // Pendant qu'on y est, si on verifiait ce qui se passe dans la queue de construction du chantier ?
    if ($currentPlanet['b_hangar_id']) {
        $buildArray = array();
        $currentPlanet['b_hangar'] += $productionTime;
        $buildQueue = explode(';', $currentPlanet['b_hangar_id']);
        $currentPlanet['b_hangar_id'] = '';
        foreach ($buildQueue as $element) {
            if (empty($element) || !($element = explode(',', $element)) || count($element) != 2) {
                continue;
            }
            list($item, $count) = $element;
            $buildTime = GetBuildingTime($currentUser, $currentPlanet, $item);
            if ($currentPlanet['b_hangar'] >= $buildTime && $count > 0) {
                $currentPlanet['b_hangar'] -= $buildTime * $count;
                $buildArray[$element] += $count;
                $currentPlanet[$resource[$element]] += $count;
                $currentPlanet['b_hangar_id'] .= "{$element},{$Count};";
            }
        }
    } else {
        $buildArray = array();
        $currentPlanet['b_hangar'] = 0;
    }
    return $buildArray;
}
Example #2
0
function ElementBuildListBox($CurrentUser, $CurrentPlanet)
{
    global $lang, $pricelist;
    // Array del b_hangar_id
    $ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']);
    $NbrePerType = "";
    $NamePerType = "";
    $TimePerType = "";
    foreach ($ElementQueue as $ElementLine => $Element) {
        if ($Element != '') {
            $Element = explode(',', $Element);
            $ElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element[0]);
            $QueueTime += $ElementTime * $Element[1];
            $TimePerType .= "" . $ElementTime . ",";
            $NamePerType .= "'" . html_entity_decode($lang['tech'][$Element[0]]) . "',";
            $NbrePerType .= "" . $Element[1] . ",";
        }
    }
    $parse = $lang;
    $parse['a'] = $NbrePerType;
    $parse['b'] = $NamePerType;
    $parse['c'] = $TimePerType;
    $parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
    $parse['pretty_time_b_hangar'] = pretty_time($QueueTime - $CurrentPlanet['b_hangar']);
    $text .= parsetemplate(gettemplate('buildings_script'), $parse);
    return $text;
}
function ElementBuildListQueue($CurrentUser, $CurrentPlanet)
{
    global $lang, $pricelist;
    $b_building_id = explode(';', $CurrentPlanet['b_building_queue']);
    $a = $b = $c = "";
    foreach ($b_hangar_id as $n => $array) {
        if ($array != '') {
            $array = explode(',', $array);
            // calculamos el tiempo
            $time = GetBuildingTime($user, $CurrentPlanet, $array[0]);
            $totaltime += $time * $array[1];
            $c .= "{$time},";
            $b .= "'{$lang['tech'][$array[0]]}',";
            $a .= "{$array[1]},";
        }
    }
    $parse = $lang;
    $parse['a'] = $a;
    $parse['b'] = $b;
    $parse['c'] = $c;
    $parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
    $parse['pretty_time_b_hangar'] = pretty_time($totaltime - $CurrentPlanet['b_hangar']);
    $text .= parsetemplate(gettemplate('buildings_script'), $parse);
    return $text;
}
/**
 * Check the hangar queue.
 *
 * @global array $resource @see vars.php
 * @param array $currentUser Similar as $user
 * @param array $currentPlanet Similar as $planetrow
 * @param int $productionTime Pass time beetween now and the last update
 * @return array Contain the builded element.
 */
function HandleElementBuildingQueue($currentUser, &$currentPlanet, $productionTime)
{
    global $resource;
    $buildArray = array();
    if ($currentPlanet['b_hangar_id'] !== 0) {
        $currentPlanet['b_hangar'] += $productionTime;
        $buildQueue = explode(';', $currentPlanet['b_hangar_id']);
        $currentPlanet['b_hangar_id'] = '';
        foreach ($buildQueue as $element) {
            if (empty($element) || !($element = explode(',', $element)) || count($element) != 2) {
                continue;
            }
            list($item, $count) = $element;
            $buildTime = GetBuildingTime($currentUser, $currentPlanet, $item);
            if ($currentPlanet['b_hangar'] >= $buildTime && $count > 0) {
                $buildedElements = floor($currentPlanet['b_hangar'] / $buildTime);
                $buildedElements = $buildedElements > $count ? $count : $buildedElements;
                if ($buildedElements < $count) {
                    $currentPlanet['b_hangar_id'] .= "{$item}," . ($count - $buildedElements) . ";";
                }
                $currentPlanet['b_hangar'] -= $buildTime * $buildedElements;
                $buildArray[$item] += $buildedElements;
                $currentPlanet[$resource[$item]] += $buildedElements;
            } else {
                $currentPlanet['b_hangar_id'] .= "{$item},{$count};";
            }
        }
    } else {
        $currentPlanet['b_hangar'] = 0;
    }
    return $buildArray;
}
Example #5
0
/**
 * eco_bld_handle_que.php
 * Handles building in hangar
 *
 * @oldname HandleElementBuildingQueue.php
 * @package economic
 * @version 2
 *
 * Revision History
 * ================
 *    2 - copyright (c) 2010 by Gorlum for http://supernova.ws
 *      [!] Full rewrite
 *      [%] Fixed stupid bug that allows to build several fast-build
 *          units utilizing build-time of slow-build units upper in que
 *      [~] Some optimizations and speedups
 *      [~] Complies with PCG1
 *
 *    1 - copyright 2008 By Chlorel for XNova
 */
function eco_bld_handle_que($user, &$planet, $production_time)
{
    global $sn_data;
    $quest_rewards = array();
    if ($planet['b_hangar_id'] != 0) {
        $hangar_time = $planet['b_hangar'] + $production_time;
        $que = explode(';', $planet['b_hangar_id']);
        $quest_list = qst_get_quests($user['id']);
        $quest_triggers = qst_active_triggers($quest_list);
        $built = array();
        $new_hangar = '';
        $skip_rest = false;
        foreach ($que as $que_string) {
            if ($que_string) {
                $que_data = explode(',', $que_string);
                $unit_id = $que_data[0];
                $count = $que_data[1];
                $build_time = GetBuildingTime($user, $planet, $unit_id);
                if (!$skip_rest) {
                    $unit_db_name = $sn_data[$unit_id]['name'];
                    $planet_unit = $planet[$unit_db_name];
                    while ($hangar_time >= $build_time && $count > 0) {
                        $hangar_time -= $build_time;
                        $count--;
                        $built[$unit_id]++;
                        $planet_unit++;
                    }
                    $planet[$unit_db_name] = $planet_unit;
                    // TODO: Check mutiply condition quests
                    $quest_trigger_list = array_keys($quest_triggers, $unit_id);
                    foreach ($quest_trigger_list as $quest_id) {
                        if ($quest_list[$quest_id]['quest_unit_amount'] <= $planet[$unit_db_name] && $quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) {
                            $quest_rewards[$quest_id] = $quest_list[$quest_id]['quest_rewards'];
                            $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE;
                        }
                    }
                    if ($count) {
                        $skip_rest = true;
                    }
                }
                if ($count > 0) {
                    $new_hangar .= "{$unit_id},{$count};";
                }
            }
        }
        if (!$new_hangar) {
            $hangar_time = 0;
        }
        $planet['b_hangar'] = $hangar_time;
        $planet['b_hangar_id'] = $new_hangar;
    } else {
        $built = '';
        $planet['b_hangar'] = 0;
    }
    return array('built' => $built, 'rewards' => $quest_rewards);
}
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime)
{
    global $resource;
    if ($CurrentPlanet['b_hangar_id'] != 0) {
        $Builded = array();
        $BuildArray = array();
        $CurrentPlanet['b_hangar'] += $ProductionTime;
        //$CurrentPlanet['b_hangar_id']=substr($CurrentPlanet['b_hangar_id'], 0, -1);
        $BuildQueue = explode(';', $CurrentPlanet['b_hangar_id']);
        foreach ($BuildQueue as $Node => $Array) {
            if ($Array != '') {
                $Item = explode(',', $Array);
                $AcumTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Item[0]);
                $BuildArray[$Node] = array($Item[0], $Item[1], $AcumTime);
            }
        }
        $CurrentPlanet['b_hangar_id'] = '';
        $UnFinished = false;
        foreach ($BuildArray as $Node => $Item) {
            $Element = $Item[0];
            $Count = $Item[1];
            $BuildTime = $Item[2];
            $Builded[$Element] = 0;
            if (!$UnFinished and $BuildTime > 0) {
                $AllTime = $BuildTime * $Count;
                if ($CurrentPlanet['b_hangar'] >= $BuildTime) {
                    $Done = min($Count, floor($CurrentPlanet['b_hangar'] / $BuildTime));
                    if ($Count > $Done) {
                        $CurrentPlanet['b_hangar'] -= $BuildTime * $Done;
                        $UnFinished = true;
                        $Count -= $Done;
                    } else {
                        $CurrentPlanet['b_hangar'] -= $AllTime;
                        $Count = 0;
                    }
                    $Builded[$Element] += $Done;
                    $CurrentPlanet[$resource[$Element]] += $Done;
                } else {
                    $UnFinished = true;
                }
            } elseif (!$UnFinished) {
                $Builded[$Element] += $Count;
                $CurrentPlanet[$resource[$Element]] += $Count;
                $Count = 0;
            }
            if ($Count != 0) {
                $CurrentPlanet['b_hangar_id'] .= $Element . "," . $Count . ";";
            }
        }
    } else {
        $Builded = '';
        $CurrentPlanet['b_hangar'] = 0;
    }
    return $Builded;
}
/**
 * HandleElementBuildingQueue.php
 *
 * @version 1
 * @copyright 2008 By Chlorel for XNova
 */
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime)
{
    global $resource;
    // Pendant qu'on y est, si on verifiait ce qui se passe dans la queue de construction du chantier ?
    if ($CurrentPlanet['b_hangar_id'] != 0) {
        $Builded = array();
        $CurrentPlanet['b_hangar'] += $ProductionTime;
        $BuildQueue = explode(';', $CurrentPlanet['b_hangar_id']);
        foreach ($BuildQueue as $Node => $Array) {
            if ($Array != '') {
                $Item = explode(',', $Array);
                // On stocke sous forme Element, Nombre, Duree de fab
                $BuildArray[$Node] = array($Item[0], $Item[1], GetBuildingTime($CurrentUser, $CurrentPlanet, $Item[0]));
            }
        }
        $CurrentPlanet['b_hangar_id'] = '';
        $UnFinished = false;
        foreach ($BuildArray as $Node => $Item) {
            if (!$UnFinished) {
                $Element = $Item[0];
                $Count = $Item[1];
                $BuildTime = $Item[2];
                while ($CurrentPlanet['b_hangar'] >= $BuildTime && !$UnFinished) {
                    if ($Count > 0) {
                        $CurrentPlanet['b_hangar'] -= $BuildTime;
                        $Builded[$Element]++;
                        $CurrentPlanet[$resource[$Element]]++;
                        $Count--;
                        if ($Count == 0) {
                            break;
                        }
                    } else {
                        $UnFinished = true;
                        break;
                    }
                }
            }
            if ($Count != 0) {
                $CurrentPlanet['b_hangar_id'] .= $Element . "," . $Count . ";";
            }
        }
    } else {
        $Builded = '';
        $CurrentPlanet['b_hangar'] = 0;
    }
    return $Builded;
}
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime)
{
    global $resource;
    if ($CurrentPlanet['b_hangar_id'] != 0) {
        $Builded = array();
        $CurrentPlanet['b_hangar'] += $ProductionTime;
        $BuildQueue = explode(';', $CurrentPlanet['b_hangar_id']);
        foreach ($BuildQueue as $Node => $Array) {
            if ($Array != '') {
                $Item = explode(',', $Array);
                $AcumTime += GetBuildingTime($CurrentUser, $CurrentPlanet, $Item[0]);
                $BuildArray[$Node] = array($Item[0], $Item[1], $AcumTime);
            }
        }
        $CurrentPlanet['b_hangar_id'] = '';
        $UnFinished = false;
        foreach ($BuildArray as $Node => $Item) {
            if (!$UnFinished) {
                $Element = $Item[0];
                $Count = $Item[1];
                $BuildTime = $Item[2];
                while ($CurrentPlanet['b_hangar'] >= $BuildTime && !$UnFinished) {
                    if ($Count > 0) {
                        $CurrentPlanet['b_hangar'] -= $BuildTime;
                        $Builded[$Element]++;
                        $CurrentPlanet[$resource[$Element]]++;
                        $Count--;
                        if ($Count == 0) {
                            break;
                        }
                    } else {
                        $UnFinished = true;
                        break;
                    }
                }
            }
            if ($Count != 0) {
                $CurrentPlanet['b_hangar_id'] .= $Element . "," . $Count . ";";
            }
        }
    } else {
        $Builded = '';
        $CurrentPlanet['b_hangar'] = 0;
    }
    return $Builded;
}
/**
 * ElementBuildListQueue.php
 *
 * @version 1.0
 * @copyright 2008 By Chlorel for XNova
 */
function ElementBuildListQueue($CurrentUser, $CurrentPlanet)
{
    // Jamais appelé pour le moment donc totalement modifiable !
    /*
    alter table `ogame`.`game_planets`
    change `name` `name` varchar (255) NULL COLLATE latin1_general_ci,
    change `b_building_id` `b_building_id` text NULL COLLATE latin1_general_ci,
    change `b_tech_id` `b_tech_id` text NULL COLLATE latin1_general_ci,
    change `b_hangar_id` `b_hangar_id` text NULL COLLATE latin1_general_ci,
    change `image` `image` varchar (32) DEFAULT 'normaltempplanet01' NOT NULL COLLATE latin1_general_ci,
    change `b_building_queue` `b_building_queue` text NULL COLLATE latin1_general_ci,
    change `unbau` `unbau` varchar (100) NULL COLLATE latin1_general_ci;
    */
    global $lang, $pricelist;
    // Array del b_hangar_id
    $b_building_id = explode(';', $CurrentPlanet['b_building_queue']);
    $a = $b = $c = "";
    foreach ($b_hangar_id as $n => $array) {
        if ($array != '') {
            $array = explode(',', $array);
            // calculamos el tiempo
            $time = GetBuildingTime($user, $CurrentPlanet, $array[0]);
            $totaltime += $time * $array[1];
            $c .= "{$time},";
            $Replace = array('&auml;' => 'ae', '&uuml;' => 'ü', '&ouml;' => 'ö');
            $Name = strtr($Replace, $lang['tech'][$array[0]]);
            $b .= "'Test',";
            $a .= "{$array[1]},";
        }
    }
    $parse = $lang;
    $parse['a'] = $a;
    $parse['b'] = $b;
    $parse['c'] = $c;
    $parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
    $parse['pretty_time_b_hangar'] = pretty_time($totaltime - $CurrentPlanet['b_hangar']);
    // //$CurrentPlanet['last_update']
    $text .= parsetemplate(gettemplate('buildings_script'), $parse);
    #return $text;
}
 public function __construct(&$CurrentPlanet, $CurrentUser)
 {
     global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
     include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
     include_once $xgp_root . 'includes/functions/CheckPlanetUsedFields.' . $phpEx;
     CheckPlanetUsedFields($CurrentPlanet);
     $parse = $lang;
     $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
     $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
     if (isset($_GET['cmd'])) {
         $bDoItNow = false;
         $TheCommand = $_GET['cmd'];
         $Element = $_GET['building'];
         $ListID = $_GET['listid'];
         if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
             unset($Element);
         }
         if (isset($Element)) {
             if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
                 if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                     $bDoItNow = true;
                 }
             } else {
                 header("location:game.php?page=buildings");
             }
         } elseif (isset($ListID)) {
             $bDoItNow = true;
         }
         if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
             $bDoItNow = false;
         }
         if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
             $bDoItNow = false;
         }
         if ($bDoItNow == true) {
             switch ($TheCommand) {
                 case 'cancel':
                     $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                     break;
                 case 'remove':
                     $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                     break;
                 case 'insert':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                     break;
                 case 'destroy':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                     break;
             }
         }
         if ($_GET['r'] == 'overview') {
             header('location:game.php?page=overview');
         } else {
             header("Location: game.php?page=buildings&mode=buildings");
         }
     }
     SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
     // $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); // OLD CODE
     // START FIX BY JSTAR
     $Sprice = array();
     $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser, $Sprice);
     // END FIX BY JSTAR
     $this->BuildingSavePlanetRecord($CurrentPlanet);
     if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
         $CanBuildElement = true;
     } else {
         $CanBuildElement = false;
     }
     $BuildingPage = "";
     $zaehler = 1;
     foreach ($lang['tech'] as $Element => $ElementName) {
         if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
             $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
             if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                 $RoomIsOk = true;
             } else {
                 $RoomIsOk = false;
             }
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                 $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                 $parse = array();
                 $parse = $lang;
                 $parse['dpath'] = $dpath;
                 $parse['i'] = $Element;
                 $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                 $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
                 $parse['n'] = $ElementName;
                 $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                 /* OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- //
                 					$ElementBuildTime      	= GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 					$parse['time']         	= ShowBuildTime($ElementBuildTime);
                 					$parse['price']        	= GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                    OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- //
                 */
                 // START FIX BY JSTAR
                 $really_lvl = isset($Sprice[$Element]) ? $Sprice[$Element] : $BuildingLevel;
                 $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element, $really_lvl);
                 $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, $really_lvl);
                 $parse['time'] = ShowBuildTime($ElementBuildTime);
                 // END FIX BY JSTAR
                 $parse['click'] = '';
                 $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                 if ($RoomIsOk && $CanBuildElement) {
                     if ($Queue['lenght'] == 0) {
                         if ($NextBuildLevel == 1) {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                             }
                         } else {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                             }
                         }
                     } else {
                         $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>";
                     }
                 } elseif ($RoomIsOk && !$CanBuildElement) {
                     if ($NextBuildLevel == 1) {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                     } else {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                     }
                 } else {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>";
                 }
                 if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse);
             }
         }
     }
     if ($Queue['lenght'] > 0) {
         include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
         $parse['BuildListScript'] = InsertBuildListScript("buildings");
         $parse['BuildList'] = $Queue['buildlist'];
     } else {
         $parse['BuildListScript'] = "";
         $parse['BuildList'] = "";
     }
     $parse['BuildingsList'] = $BuildingPage;
     display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse));
 }
Example #11
0
function ResearchBuildingPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
{
    global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    $NoResearchMessage = "";
    $bContinue = true;
    // Deja est qu'il y a un laboratoire sur la planete ???
    if ($CurrentPlanet[$resource[31]] == 0) {
        message($lang['no_laboratory'], $lang['Research']);
    }
    // Ensuite ... Est ce que la labo est en cours d'upgrade ?
    if (!CheckLabSettingsInQueue($CurrentPlanet)) {
        $NoResearchMessage = $lang['labo_on_update'];
        $bContinue = false;
    }
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        $TheCommand = $_GET['cmd'];
        $Techno = (int) $_GET['tech'];
        if (is_numeric($Techno)) {
            if (in_array($Techno, $reslist['tech'])) {
                // Bon quand on arrive ici ... On sait deja qu'on a une technologie valide
                if (is_array($ThePlanet)) {
                    $WorkingPlanet = $ThePlanet;
                } else {
                    $WorkingPlanet = $CurrentPlanet;
                }
                switch ($TheCommand) {
                    case 'cancel':
                        if ($ThePlanet['b_tech_id'] == $Techno) {
                            $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                            $WorkingPlanet['metal'] += $costs['metal'];
                            $WorkingPlanet['crystal'] += $costs['crystal'];
                            $WorkingPlanet['deuterium'] += $costs['deuterium'];
                            $WorkingPlanet['appolonium'] += $costs['appolonium'];
                            if ($WorkingPlanet['id'] == $CurrentPlanet['id']) {
                                $CurrentPlanet['metal'] += $costs['metal'];
                                $CurrentPlanet['crystal'] += $costs['crystal'];
                                $CurrentPlanet['deuterium'] += $costs['deuterium'];
                                $CurrentPlanet['appolonium'] += $costs['appolonium'];
                            }
                            $WorkingPlanet['b_tech_id'] = 0;
                            $WorkingPlanet["b_tech"] = 0;
                            $CurrentUser['b_tech_planet'] = 0;
                            $UpdateData = true;
                            $InResearch = false;
                        }
                        break;
                    case 'search':
                        if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) {
                            $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                            $WorkingPlanet['metal'] -= $costs['metal'];
                            $WorkingPlanet['crystal'] -= $costs['crystal'];
                            $WorkingPlanet['deuterium'] -= $costs['deuterium'];
                            $WorkingPlanet['appolonium'] -= $costs['appolonium'];
                            $WorkingPlanet["b_tech_id"] = $Techno;
                            $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno);
                            $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"];
                            $UpdateData = true;
                            $InResearch = true;
                        }
                        break;
                }
                if ($UpdateData == true) {
                    $QryUpdatePlanet = "UPDATE {{table}} SET ";
                    $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
                    $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
                    $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', ";
                    $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', ";
                    $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "', ";
                    $QryUpdatePlanet .= "`appolonium` = '" . $WorkingPlanet['appolonium'] . "' ";
                    $QryUpdatePlanet .= "WHERE ";
                    $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';";
                    doquery($QryUpdatePlanet, 'planets');
                    $QryUpdateUser = "******";
                    $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' ";
                    $QryUpdateUser .= "WHERE ";
                    $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
                    doquery($QryUpdateUser, 'users');
                }
                if (is_array($ThePlanet)) {
                    $ThePlanet = $WorkingPlanet;
                } else {
                    $CurrentPlanet = $WorkingPlanet;
                    if ($TheCommand == 'search') {
                        $ThePlanet = $CurrentPlanet;
                    }
                }
            }
        } else {
            $bContinue = false;
        }
    }
    $TechRowTPL = gettemplate('buildings_research_row');
    $TechScrTPL = gettemplate('buildings_research_script');
    foreach ($lang['tech'] as $Tech => $TechName) {
        if ($Tech > 105 && $Tech <= 199) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
                $RowParse = $lang;
                $RowParse['dpath'] = $dpath;
                $RowParse['tech_id'] = $Tech;
                $building_level = $CurrentUser[$resource[$Tech]];
                $RowParse['tech_level'] = $building_level == 0 ? "" : "( " . $lang['level'] . " " . $building_level . " )";
                $RowParse['tech_name'] = $TechName;
                $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech];
                $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech);
                $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech);
                $RowParse['search_time'] = ShowBuildTime($SearchTime);
                $RowParse['tech_restp'] = $lang['Rest_ress'] . " " . GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true);
                $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech);
                // Arbre de decision de ce que l'on met dans la derniere case de la ligne
                if (!$InResearch) {
                    $LevelToDo = 1 + $CurrentUser[$resource[$Tech]];
                    if ($CanBeDone) {
                        if (!CheckLabSettingsInQueue($CurrentPlanet)) {
                            // Le laboratoire est cours de construction ou d'evolution
                            // Et dans la config du systeme, on ne permet pas la recherche pendant
                            // que le labo est en construction ou evolution !
                            if ($LevelToDo == 1) {
                                $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>";
                            } else {
                                $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>";
                            }
                        } else {
                            $TechnoLink = "<a href=\"buildings.php?mode=research&cmd=search&tech=" . $Tech . "\">";
                            if ($LevelToDo == 1) {
                                $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "</font>";
                            } else {
                                $TechnoLink .= "<font color=#00FF00>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>";
                            }
                            $TechnoLink .= "</a>";
                        }
                    } else {
                        if ($LevelToDo == 1) {
                            $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "</font>";
                        } else {
                            $TechnoLink = "<font color=#FF0000>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</font>";
                        }
                    }
                } else {
                    // Y a une construction en cours
                    if ($ThePlanet["b_tech_id"] == $Tech) {
                        // C'est le technologie en cours de recherche
                        $bloc = $lang;
                        if ($ThePlanet['id'] != $CurrentPlanet['id']) {
                            // Ca se passe sur une autre planete
                            $bloc['tech_time'] = $ThePlanet["b_tech"] - time();
                            $bloc['tech_name'] = $lang['on'] . "<br>" . $ThePlanet["name"];
                            $bloc['tech_home'] = $ThePlanet["id"];
                            $bloc['tech_id'] = $ThePlanet["b_tech_id"];
                        } else {
                            // Ca se passe sur la planete actuelle
                            $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time();
                            $bloc['tech_name'] = "";
                            $bloc['tech_home'] = $CurrentPlanet["id"];
                            $bloc['tech_id'] = $CurrentPlanet["b_tech_id"];
                        }
                        $TechnoLink = parsetemplate($TechScrTPL, $bloc);
                    } else {
                        // Technologie pas en cours recherche
                        $TechnoLink = "<center>-</center>";
                    }
                }
                $RowParse['tech_link'] = $TechnoLink;
                $TechnoList .= parsetemplate($TechRowTPL, $RowParse);
            }
        }
    }
    $PageParse = $lang;
    $PageParse['noresearch'] = $NoResearchMessage;
    $PageParse['technolist'] = $TechnoList;
    $Page .= parsetemplate(gettemplate('buildings_research'), $PageParse);
    display($Page, $lang['Research']);
}
Example #12
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
    $Allowed['3'] = array(12, 14, 15, 21, 34, 41, 42, 43);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        // On passe une commande
        $bThisIsCheated = false;
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        $Element = $_GET['building'];
        $ListID = $_GET['listid'];
        if (isset($Element)) {
            if (!strchr($Element, " ")) {
                if (!strchr($Element, ",")) {
                    if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                        $bDoItNow = true;
                    } else {
                        $bThisIsCheated = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    // Interrompre le premier batiment de la queue
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    // Supprimer un element de la queue (mais pas le premier)
                    // $RemID -> element de la liste a supprimer
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    // Insere un element dans la queue
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    break;
                case 'destroy':
                    // Detruit un batiment deja construit sur la planete !
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                    break;
                default:
                    break;
            }
            // switch
        } elseif ($bThisIsCheated == true) {
            ResetThisFuckingCheater($CurrentUser['id']);
        }
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // On enregistre ce que l'on a modifi&eacute; dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi&eacute; dans users
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Sp&eacute;cial Laboratoire
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Variable qui contient le parametre
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                    // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("buildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
 public function ShowResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
 {
     global $lang, $resource, $reslist, $phpEx, $dpath, $db, $displays, $_GET;
     include_once $svn_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $svn_root . 'includes/functions/GetElementPrice.' . $phpEx;
     $displays->assignContent("buildings/buildings_research");
     $NoResearchMessage = "";
     $bContinue = true;
     if ($CurrentPlanet[$resource[31]] == 0) {
         $displays->message($lang['bd_lab_required'], '', '', true);
     }
     if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) {
         $displays->assign('noresearch', $lang['bd_building_lab']);
         $bContinue = false;
     }
     if (isset($_GET['cmd']) && $bContinue) {
         $TheCommand = $_GET['cmd'];
         $Techno = intval($_GET['tech']);
         if (isset($Techno)) {
             if (!strstr($Techno, ",") && !strchr($Techno, " ") && !strchr($Techno, "+") && !strchr($Techno, "*") && !strchr($Techno, "~") && !strchr($Techno, "=") && !strchr($Techno, ";") && !strchr($Techno, "'") && !strchr($Techno, "#") && !strchr($Techno, "-") && !strchr($Techno, "_") && !strchr($Techno, "[") && !strchr($Techno, "]") && !strchr($Techno, ".") && !strchr($Techno, ":")) {
                 if (in_array($Techno, $reslist['tech'])) {
                     if (is_array($ThePlanet)) {
                         $WorkingPlanet = $ThePlanet;
                     } else {
                         $WorkingPlanet = $CurrentPlanet;
                     }
                     switch ($TheCommand) {
                         case 'cancel':
                             if ($ThePlanet['b_tech_id'] == $Techno) {
                                 $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                                 $WorkingPlanet['metal'] += $costs['metal'];
                                 $WorkingPlanet['crystal'] += $costs['crystal'];
                                 $WorkingPlanet['deuterium'] += $costs['deuterium'];
                                 $WorkingPlanet['b_tech_id'] = 0;
                                 $WorkingPlanet["b_tech"] = 0;
                                 $CurrentUser['b_tech_planet'] = 0;
                                 $UpdateData = true;
                                 $InResearch = false;
                             }
                             break;
                         case 'search':
                             if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) {
                                 $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                                 $WorkingPlanet['metal'] -= $costs['metal'];
                                 $WorkingPlanet['crystal'] -= $costs['crystal'];
                                 $WorkingPlanet['deuterium'] -= $costs['deuterium'];
                                 $WorkingPlanet["b_tech_id"] = $Techno;
                                 $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno);
                                 $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"];
                                 $UpdateData = true;
                                 $InResearch = true;
                             }
                             break;
                     }
                     if ($UpdateData == true) {
                         $QryUpdatePlanet = "UPDATE {{table}} SET ";
                         $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
                         $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
                         $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', ";
                         $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', ";
                         $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "' ";
                         $QryUpdatePlanet .= "WHERE ";
                         $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';";
                         $db->query($QryUpdatePlanet, 'planets');
                         $QryUpdateUser = "******";
                         $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' ";
                         $QryUpdateUser .= "WHERE ";
                         $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
                         $db->query($QryUpdateUser, 'users');
                     }
                     $CurrentPlanet = $WorkingPlanet;
                     if (is_array($ThePlanet)) {
                         $ThePlanet = $WorkingPlanet;
                     } else {
                         $CurrentPlanet = $WorkingPlanet;
                         if ($TheCommand == 'search') {
                             $ThePlanet = $CurrentPlanet;
                         }
                     }
                 }
             } else {
                 die(header("location:game.php?page=buildings&mode=research"));
             }
         } else {
             $bContinue = false;
         }
     }
     $siguiente = 1;
     foreach ($reslist['tech'] as $Tech) {
         if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
             $displays->newblock("research");
             $RowParse['tech_id'] = $Tech;
             $building_level = $CurrentUser[$resource[$Tech]];
             if ($Tech == 106) {
                 $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")";
                 $RowParse['tech_level'] .= $CurrentUser['rpg_espion'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_espion'] * 5 . $lang['bd_spy'] . "</font></strong>";
             } elseif ($Tech == 108) {
                 $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")";
                 $RowParse['tech_level'] .= $CurrentUser['rpg_commandant'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_commandant'] * 3 . $lang['bd_commander'] . "</font></strong>";
             } else {
                 $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . " )";
             }
             $RowParse['tech_name'] = $lang['tech'][$Tech];
             $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech];
             $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech);
             $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech);
             $RowParse['search_time'] = ShowBuildTime($SearchTime);
             $RowParse['tech_restp'] = "Restantes " . $this->GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true);
             $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech);
             if (!$InResearch) {
                 $LevelToDo = 1 + $CurrentUser[$resource[$Tech]];
                 if ($CanBeDone) {
                     if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) {
                         if ($LevelToDo == 1) {
                             $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>";
                         } else {
                             $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>";
                         }
                     } else {
                         $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Tech . "\">";
                         if ($LevelToDo == 1) {
                             $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "</font>";
                         } else {
                             $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>";
                         }
                         $TechnoLink .= "</a>";
                     }
                 } else {
                     if ($LevelToDo == 1) {
                         $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>";
                     } else {
                         $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>";
                     }
                 }
             } else {
                 if ($ThePlanet["b_tech_id"] == $Tech) {
                     $displays->newblock("script");
                     if ($ThePlanet['id'] != $CurrentPlanet['id']) {
                         $bloc['tech_time'] = $ThePlanet["b_tech"] - time();
                         $bloc['tech_name'] = "de<br>" . $ThePlanet["name"];
                         $bloc['tech_home'] = $ThePlanet["id"];
                         $bloc['tech_id'] = $ThePlanet["b_tech_id"];
                     } else {
                         $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time();
                         $bloc['tech_name'] = "";
                         $bloc['tech_home'] = $CurrentPlanet["id"];
                         $bloc['tech_id'] = $CurrentPlanet["b_tech_id"];
                     }
                     foreach ($bloc as $name => $trans) {
                         $displays->assign($name, $trans);
                     }
                 } else {
                     $TechnoLink = "<center>-</center>";
                 }
             }
             $displays->gotoBlock("research");
             $RowParse['tech_link'] = $TechnoLink;
             if ($siguiente % 3 == 0) {
                 $RowParse['cerrar'] = "</tr><tr>";
             }
             $siguiente++;
             foreach ($RowParse as $name => $trans) {
                 $displays->assign($name, $trans);
             }
             unset($RowParse, $TechnoLink);
         }
     }
     $displays->display("Investigación");
 }
Example #14
0
 protected function AddBuildingToQueue(&$CurrentPlanet, $CurrentUser, $Element, $AddMode = true)
 {
     global $resource;
     $CurrentQueue = $CurrentPlanet['b_building_id'];
     $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
     if ($CurrentQueue != 0) {
         $QueueArray = explode(";", $CurrentQueue);
         $ActualCount = count($QueueArray);
     } else {
         $QueueArray = "";
         $ActualCount = 0;
     }
     if ($AddMode == true) {
         $BuildMode = 'build';
     } else {
         $BuildMode = 'destroy';
     }
     if ($ActualCount < MAX_BUILDING_QUEUE_SIZE) {
         $QueueID = $ActualCount + 1;
     } else {
         $QueueID = false;
     }
     if ($QueueID != false) {
         if ($QueueID > 1) {
             $InArray = 0;
             for ($QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++) {
                 $QueueSubArray = explode(",", $QueueArray[$QueueElement]);
                 if ($QueueSubArray[0] == $Element) {
                     $InArray++;
                 }
             }
         } else {
             $InArray = 0;
         }
         if ($InArray != 0) {
             $ActualLevel = $CurrentPlanet[$resource[$Element]];
             if ($AddMode == true) {
                 $BuildLevel = $ActualLevel + 1 + $InArray;
                 $CurrentPlanet[$resource[$Element]] += $InArray;
                 $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 $CurrentPlanet[$resource[$Element]] -= $InArray;
             } else {
                 $BuildLevel = $ActualLevel - 1 - $InArray;
                 $CurrentPlanet[$resource[$Element]] -= $InArray;
                 $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
                 $CurrentPlanet[$resource[$Element]] += $InArray;
             }
         } else {
             $ActualLevel = $CurrentPlanet[$resource[$Element]];
             if ($AddMode == true) {
                 $BuildLevel = $ActualLevel + 1;
                 $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
             } else {
                 $BuildLevel = $ActualLevel - 1;
                 $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
             }
         }
         if ($QueueID == 1) {
             $BuildEndTime = time() + $BuildTime;
         } else {
             $PrevBuild = explode(",", $QueueArray[$ActualCount - 1]);
             $BuildEndTime = $PrevBuild[3] + $BuildTime;
         }
         $QueueArray[$ActualCount] = $Element . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $BuildMode;
         $NewQueue = implode(";", $QueueArray);
         $CurrentPlanet['b_building_id'] = $NewQueue;
     }
 }
Example #15
0
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $dpath, $_POST;
    if (isset($_POST['fmenge'])) {
        // Wenn man auf "Bauen" klickt
        // Raketen
        $Missiles[502] = $CurrentPlanet[$resource[502]];
        $Missiles[503] = $CurrentPlanet[$resource[503]];
        $SiloSize = $CurrentPlanet[$resource[44]];
        $MaxMissiles = $SiloSize * 10;
        $BuildQueue = $CurrentPlanet['b_hangar_id'];
        $BuildArray = explode(";", $BuildQueue);
        for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
            $ElmentArray = explode(",", $BuildArray[$QElement]);
            if ($ElmentArray[502] != 0) {
                $Missiles[502] += $ElmentArray[502];
            } elseif ($ElmentArray[503] != 0) {
                $Missiles[503] += $ElmentArray[503];
            }
        }
        foreach ($_POST['fmenge'] as $Element => $Count) {
            $Element = intval($Element);
            $Count = intval($Count);
            if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                $Count = MAX_FLEET_OR_DEFS_PER_ROW;
            }
            if ($Count != 0) {
                //Die Kuppeln können nur einmal gebaut werden.
                $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
                $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE;
                $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE;
                if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) {
                    $Count = 1;
                }
                if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) {
                    $Count = 1;
                }
                //Prüfen, ob man die nötige Technologie für den Bau hat
                if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    //Festlegen, wieviele Elemente maximal gebaut werden können
                    $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                    //Prüfen, ob in den Silos noch Platz für Raketen ist
                    if ($Element == 502 || $Element == 503) {
                        $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                        $MissilesSpace = $MaxMissiles - $ActuMissiles;
                        if ($Element == 502) {
                            if ($Count > $MissilesSpace) {
                                $Count = $MissilesSpace;
                            }
                        } else {
                            if ($Count > floor($MissilesSpace / 2)) {
                                $Count = floor($MissilesSpace / 2);
                            }
                        }
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                        $Missiles[$Element] += $Count;
                    } else {
                        // Hat man micht genug Ress, wird die Anzahl der Schiffe entsprechend angepasst
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                    }
                    $Ressource = GetElementRessources($Element, $Count);
                    $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                    if ($Count >= 1) {
                        $CurrentPlanet['metal'] -= $Ressource['metal'];
                        $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                        $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                        $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
                    }
                }
            }
        }
    }
    //Wenn man keine Raumschiffswerft hat
    if ($CurrentPlanet[$resource[21]] == 0) {
        //Kann man acuh nichts bauen^^
        message($lang['need_hangar'], $lang['tech'][21]);
        //Und bekommt ne Fehlermeldung
    }
    // Beginn der eigentlichen Bauseite ( Also das, was der User nachher sieht )
    $TabIndex = 0;
    $PageTable = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if ($Element > 400 && $Element <= 599) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                // Wenn man bauen kann...
                $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false);
                $BuildOneElementTimeWithoutTechs = GetBuildingTimeWithoutTechs($CurrentUser, $CurrentPlanet, $Element);
                //ursprüngliche Bauzeit ermitteln
                $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                //benötigte Bauzeit ermitteln
                // aktuell verfügbar
                $baubar = GetMaxConstructibleShips($CurrentPlanet, $Element);
                $ElementCount = $CurrentPlanet[$resource[$Element]];
                $ElementNbre = $ElementCount == 0 ? "({$lang['builtable']}{$baubar})" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . " {$lang['builtable']} {$baubar})";
                $PageTable .= "\n<tr>";
                $PageTable .= "\r\n\t<th class=\"l\" rowspan=\"2\" width=\"120\">\r\n\t\t<a href=\"?action=internalInformations&amp;gid=" . $Element . "\"><img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top alt=" . $Element . ".gif width=120 height=120></a>\r\n\t</th>\r\n    <td class=\"c\">\r\n    \t<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n    \t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width=\"15\"><img src=\"images/transparent.gif\" alt=\"transparent\" width=\"0\" height=\"21\"></td>\r\n\t\t\t\t\t<td><a href=\"?action=internalInformations&amp;gid=" . $Element . "\">" . $ElementName . "</a> " . $ElementNbre . "</td>\r\n\t\t\t\t\t<td width=\"100\">&nbsp;</td>\r\n    \t\t\t</tr>\r\n    \t\t</tbody>\r\n\t\t</table>\r\n    </td>\r\n</tr>\r\n<tr>\r\n    <td colspan=\"1\">\r\n    \t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n    \t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"rechtsohneborder\" width=\"10\"><img src=\"images/transparent.gif\" alt=\"transparent\" width=\"0\" height=\"100\"></td>\r\n\t\t\t\t\t<td class=\"linksundrechtsohneborder\" width=\"80%\">" . $lang['res']['descriptions'][$Element] . "<br>&nbsp;<br>";
                $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false);
                $PageTable .= "\r\n\t\t\t\t\t<br><br>\r\n        \t\t\t<td class=\"linksohneborder\" width=\"100\">";
                if ($CanBuildOne) {
                    if ($Element == 407 && $CurrentPlanet[$resource[407]] >= "1" || $Element == 407 && $CurrentPlanet['b_hangar_id'] == "407,1;" || $Element == 408 && $CurrentPlanet[$resource[408]] >= "1" || $Element == 408 && $CurrentPlanet['b_hangar_id'] == "408,1;") {
                        $PageTable .= "<p align=\"center\"><br>&nbsp;<br><font color=\"orange\">" . $lang['only_one'] . "</font></p>";
                    } else {
                        $TabIndex++;
                        $PageTable .= "<p align=\"center\"><br>&nbsp;<br><a href=\"javascript:setL(" . $Element . ");\"><img src=\"images/back.gif\" width=\"17\" style=\"vertical-align:bottom\" border=\"0\" height=\"15\" alt=\"back\"></a><input name=fmenge[" . $Element . "] size=\"5\" maxlength=\"5\" style=\"text-align: center;\" value=\"0\" onClick=\"if(this.value=='0') this.value='';\" onBlur=\"if(this.value=='') this.value='0';\" type=\"text\" tabindex=\"" . $TabIndex . "\"><a href=\"javascript:setN(" . $Element . ");\"><img src=\"images/forward.gif\" width=\"17\" style=\"vertical-align:bottom\" border=\"0\" height=\"15\" alt=\"forward\"></a><br>&nbsp;<br><a href=\"javascript:setMax(" . $Element . "," . $baubar . ")\">max</a></p>";
                        $PageTable .= "</th>";
                    }
                } else {
                    $PageTable .= "</th>";
                }
                $PageTable .= "\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t</tbody>\r\n\t\t</table>\r\n    </td>\r\n</tr>\r\n<tr>\r\n    <td colspan=\"2\">\r\n    \r\n        <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n        <tbody><tr>\r\n       \r\n             <td class=\"b\">\r\n                <table width=\"100%\" align=\"center\" cellpadding=\"2\" cellspacing=\"0\">\r\n                <tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<a class=\"b\">" . $lang['NeededRess'] . "</a><br><br>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td colspan=\"2\">\r\n\t\t\t\t\t\t<a class=\"b\">" . $lang['BuildingTime'] . "</a><br>\r\n\t\t\t\t\t\t<br>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\t\t\r\n\t\t\t\t\t<td width=\"68%\" rowspan=\"3\">";
                $PageTable .= GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $PageTable .= "</td>\r\n                    <td width=\"20%\">" . $lang['ConstructionTimeWithoutTechs'] . "</td>\r\n                    <td width=\"12%\" align=\"right\">";
                $PageTable .= ShowBuildTimeWithoutTechs($BuildOneElementTimeWithoutTechs);
                $PageTable .= "</td>\r\n                </tr>\r\n                <tr>\r\n                    <td>\r\n                        " . $lang['TechBonus'] . ":\r\n                    </td>\r\n                                \r\n                    <td align=\"right\">";
                $PageTable .= ShowTechBonus($BuildOneElementTimeWithoutTechs - $BuildOneElementTime);
                $PageTable .= "</td>\r\n                </tr>\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n                    <td>&nbsp;</td>          \r\n                    <td align=\"right\">&nbsp;</td>\r\n                </tr>\r\n\t\t\t\t\r\n                 <tr>\r\n                    <td colspan=\"2\" height=\"5\"></td>          \r\n                </tr>\r\n                <tr>\r\n\t\t\t\t\t<td>&nbsp;</td>\r\n                    <td>" . $lang['ConstructionTime'] . "</td>\r\n                    <td align=\"right\">";
                $PageTable .= ShowBuildTime($BuildOneElementTime);
                $PageTable .= "</td>\r\n                </tr>\r\n                </tbody></table>\r\n            </td>\r\n        </tr>\r\n        </tbody></table><br>";
                // Fin de ligne (les 3 cases sont construites !!
                $PageTable .= "</tr>";
            }
        }
    }
    if ($CurrentPlanet['b_hangar_id'] != '') {
        $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet);
    }
    $parse = $lang;
    // La page se trouve dans $PageTable;
    $parse['buildlist'] = $PageTable;
    // Et la liste de constructions en cours dans $BuildQueue;
    $parse['buildinglist'] = $BuildQueue;
    // fragmento de template
    $page .= parsetemplate(gettemplate('buildings_defense'), $parse);
    display($page, $lang['Defense']);
}
Example #16
0
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $planetrow, $lang, $pricelist, $resource, $phpEx, $dpath, $_POST;
    if (isset($_GET[action])) {
        switch ($_GET[action]) {
            case "cancelqueue":
                $ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']);
                foreach ($ElementQueue as $ElementLine => $Element) {
                    if ($Element != '') {
                        $Element = explode(',', $Element);
                        $ResourcesToUpd[metal] += floor($pricelist[$Element[0]][metal] * $Element[1]);
                        $ResourcesToUpd[crystal] += floor($pricelist[$Element[0]][crystal] * $Element[1]);
                        $ResourcesToUpd[deuterium] += floor($pricelist[$Element[0]][deuterium] * $Element[1]);
                        $ResourcesToUpd[tachyon] += floor($pricelist[$Element[0]][tachyon] * $Element[1]);
                    }
                }
                $SetRes = "UPDATE {{table}} SET ";
                $SetRes .= "`metal` = metal + '" . $ResourcesToUpd[metal] . "', ";
                $SetRes .= "`crystal` = crystal + '" . $ResourcesToUpd[crystal] . "', ";
                $SetRes .= "`deuterium` = deuterium + '" . $ResourcesToUpd[deuterium] . "', ";
                $SetRes .= "`tachyon` = tachyon + '" . $ResourcesToUpd[tachyon] . "', ";
                $SetRes .= "`b_hangar` = '', ";
                $SetRes .= "`b_hangar_id` = ''";
                $SetRes .= " WHERE `id` = '" . $CurrentPlanet['id'] . "'";
                doquery($SetRes, 'planets');
                header("location: " . $_SERVER['PHP_SELF'] . "?mode=" . $_GET[mode]);
                exit;
                break;
        }
    }
    if (isset($_POST['fmenge'])) {
        $Missiles[502] = $CurrentPlanet[$resource[502]];
        $Missiles[503] = $CurrentPlanet[$resource[503]];
        $SiloSize = $CurrentPlanet[$resource[44]];
        $MaxMissiles = $SiloSize * 10;
        $BuildQueue = $CurrentPlanet['b_hangar_id'];
        $BuildArray = explode(";", $BuildQueue);
        for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
            $ElmentArray = explode(",", $BuildArray[$QElement]);
            if ($ElmentArray[502] != 0) {
                $Missiles[502] += $ElmentArray[502];
            } elseif ($ElmentArray[503] != 0) {
                $Missiles[503] += $ElmentArray[503];
            }
        }
        foreach ($_POST['fmenge'] as $Element => $Count) {
            $Element = intval($Element);
            $Count = intval($Count);
            if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                $Count = MAX_FLEET_OR_DEFS_PER_ROW;
            }
            if ($Count != 0) {
                $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
                $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false;
                if ($Element == 407 || $Element == 408) {
                    if ($InQueue === false && !$IsBuild) {
                        $Count = 1;
                    }
                }
                if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                    if ($Element == 502 || $Element == 503) {
                        $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                        $MissilesSpace = $MaxMissiles - $ActuMissiles;
                        if ($Element == 502) {
                            if ($Count > $MissilesSpace) {
                                $Count = $MissilesSpace;
                            }
                        } else {
                            if ($Count > floor($MissilesSpace / 2)) {
                                $Count = floor($MissilesSpace / 2);
                            }
                        }
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                        $Missiles[$Element] += $Count;
                    } else {
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                    }
                    $Ressource = GetElementRessources($Element, $Count);
                    $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                    if ($Count >= 1) {
                        $CurrentPlanet['metal'] -= $Ressource['metal'];
                        $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                        $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                        $CurrentPlanet['tachyon'] -= $Ressource['tachyon'];
                        $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
                    }
                }
            }
        }
    }
    if ($CurrentPlanet[$resource[21]] == 0) {
        message($lang['need_hangar'], $lang['tech'][21]);
    }
    $TabIndex = 0;
    $PageTable = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if ($Element > 400 && $Element <= 599) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false);
                $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $ElementCount = $CurrentPlanet[$resource[$Element]];
                $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")";
                $PageTable .= "\n<tr>";
                $PageTable .= "<th class=k>";
                $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">";
                $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>";
                $PageTable .= "</th>";
                $PageTable .= "<td class=k>";
                $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>";
                $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>";
                $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false);
                $PageTable .= ShowBuildTime($BuildOneElementTime);
                $PageTable .= "</td>";
                $PageTable .= "<th class=k>";
                if ($CanBuildOne) {
                    $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
                    $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false;
                    $BuildIt = true;
                    if ($Element == 407 || $Element == 408) {
                        $BuildIt = false;
                        if ($InQueue === false && !$IsBuild) {
                            $BuildIt = true;
                        }
                    }
                    if (!$BuildIt) {
                        $PageTable .= "<font color=\"red\">" . $lang['only_one'] . "</font>";
                    } else {
                        $TabIndex++;
                        $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=7 maxlength=7 value=0 tabindex=" . $TabIndex . ">";
                        $PageTable .= "</th>";
                    }
                } else {
                    $PageTable .= "</th>";
                }
                $PageTable .= "</tr>";
            }
        }
    }
    if ($CurrentPlanet['b_hangar_id'] != '') {
        $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet);
    }
    $parse = $lang;
    $parse['buildlist'] = $PageTable;
    $parse['buildinglist'] = $BuildQueue;
    $page .= parsetemplate(gettemplate('buildings_defense'), $parse);
    display($page, $lang['Defense']);
}
Example #17
0
/**
 * This file is part of XNova:Legacies
 *
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
 * @see http://www.xnova-ng.org/
 *
 * Copyright (c) 2009-2010, XNova Support Team <http://www.xnova-ng.org>
 * All rights reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *                                --> NOTICE <--
 *  This file is part of the core development branch, changing its contents will
 * make you unable to use the automatic updates manager. Please refer to the
 * documentation for further information about customizing XNova.
 *
 */
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $dpath, $_POST;
    if (isset($_POST['fmenge'])) {
        // On vient de Cliquer ' Construire '
        // Et y a une liste de doléances
        // Ici, on sait precisement ce qu'on aimerait bien construire ...
        // Gestion de la place disponible dans les silos !
        $Missiles[502] = $CurrentPlanet[$resource[502]];
        $Missiles[503] = $CurrentPlanet[$resource[503]];
        $SiloSize = $CurrentPlanet[$resource[44]];
        $MaxMissiles = $SiloSize * 10;
        // On prend les missiles deja dans la queue de fabrication aussi (ca aide)
        $BuildQueue = $CurrentPlanet['b_hangar_id'];
        $BuildArray = explode(";", $BuildQueue);
        for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
            $ElmentArray = explode(",", $BuildArray[$QElement]);
            if ($ElmentArray[502] != 0) {
                $Missiles[502] += $ElmentArray[502];
            } elseif ($ElmentArray[503] != 0) {
                $Missiles[503] += $ElmentArray[503];
            }
        }
        foreach ($_POST['fmenge'] as $Element => $Count) {
            // Construction d'Element recuperés sur la page de Flotte ...
            // ATTENTION ! La file d'attente Flotte est Commune a celle des Defenses
            // Dans fmenge, on devrait trouver un tableau des elements constructibles etdu nombre d'elements souhaités
            $Element = intval($Element);
            $Count = intval($Count);
            if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                $Count = MAX_FLEET_OR_DEFS_PER_ROW;
            }
            if ($Count != 0) {
                // Cas particulier (Petit Bouclier et Grand Bouclier
                // ne peuvent exister qu'une seule et unique fois
                $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
                $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false;
                if ($Element == 407 || $Element == 408) {
                    if ($InQueue === false && !$IsBuild) {
                        $Count = 1;
                    }
                }
                // On verifie si on a les technologies necessaires a la construction de l'element
                if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    // On verifie combien on sait faire de cet element au max
                    $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                    // Testons si on a de la place pour ces nouveaux missiles !
                    if ($Element == 502 || $Element == 503) {
                        // Cas particulier des missiles
                        $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                        $MissilesSpace = $MaxMissiles - $ActuMissiles;
                        if ($Element == 502) {
                            if ($Count > $MissilesSpace) {
                                $Count = $MissilesSpace;
                            }
                        } else {
                            if ($Count > floor($MissilesSpace / 2)) {
                                $Count = floor($MissilesSpace / 2);
                            }
                        }
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                        $Missiles[$Element] += $Count;
                    } else {
                        // Si pas assez de ressources, on ajuste le nombre d'elements
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                    }
                    $Ressource = GetElementRessources($Element, $Count);
                    $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                    if ($Count >= 1) {
                        $CurrentPlanet['metal'] -= $Ressource['metal'];
                        $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                        $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                        $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
                    }
                }
            }
        }
    }
    // -------------------------------------------------------------------------------------------------------
    // S'il n'y a pas de Chantier ...
    if ($CurrentPlanet[$resource[21]] == 0) {
        // Veuillez avoir l'obligeance de construire le Chantier Spacial !!
        message($lang['need_hangar'], $lang['tech'][21]);
    }
    // -------------------------------------------------------------------------------------------------------
    // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ...
    $TabIndex = 0;
    $PageTable = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if ($Element > 400 && $Element <= 599) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                // Disponible à la construction
                // On regarde si on peut en acheter au moins 1
                $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false);
                // On regarde combien de temps il faut pour construire l'element
                $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                // Disponibilité actuelle
                $ElementCount = $CurrentPlanet[$resource[$Element]];
                $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")";
                // Construction des 3 cases de la ligne d'un element dans la page d'achat !
                // Début de ligne
                $PageTable .= "\n<tr>";
                // Imagette + Link vers la page d'info
                $PageTable .= "<th class=l>";
                $PageTable .= "<a href=infos." . PHPEXT . "?gid=" . $Element . ">";
                $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>";
                $PageTable .= "</th>";
                // Description
                $PageTable .= "<td class=l>";
                $PageTable .= "<a href=infos." . PHPEXT . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>";
                $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>";
                // On affiche le 'prix' avec eventuellement ce qui manque en ressource
                $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false);
                // On affiche le temps de construction (c'est toujours tellement plus joli)
                $PageTable .= ShowBuildTime($BuildOneElementTime);
                $PageTable .= "</td>";
                // Case nombre d'elements a construire
                $PageTable .= "<th class=k>";
                // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie
                if ($CanBuildOne) {
                    if ($Element == Legacies_Empire::ID_DEFENSE_SMALL_SHIELD_DOME || $Element == Legacies_Empire::ID_DEFENSE_LARGE_SHIELD_DOME) {
                        $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
                        $IsBuild = $CurrentPlanet[$resource[$Element]] >= 1 ? true : false;
                        $BuildIt = $InQueue === false && !$IsBuild ? true : false;
                    } else {
                        $BuildIt = true;
                    }
                    if (!$BuildIt) {
                        $PageTable .= "<font color=\"red\">" . $lang['only_one'] . "</font>";
                    } else {
                        $TabIndex++;
                        $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=5 maxlength=5 value=0 tabindex=" . $TabIndex . ">";
                        $PageTable .= "</th>";
                    }
                } else {
                    $PageTable .= $lang['no_enought_res'] . "</th>";
                }
                // Fin de ligne (les 3 cases sont construites !!
                $PageTable .= "</tr>";
            }
        }
    }
    if ($CurrentPlanet['b_hangar_id'] != '') {
        $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet);
    }
    $parse = $lang;
    // La page se trouve dans $PageTable;
    $parse['buildlist'] = $PageTable;
    // Et la liste de constructions en cours dans $BuildQueue;
    $parse['buildinglist'] = $BuildQueue;
    // fragmento de template
    $page .= parsetemplate(gettemplate('buildings_defense'), $parse);
    display($page, $lang['Defense']);
}
Example #18
0
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $phpEx, $dpath, $_POST;
    if (isset($_POST['fmenge'])) {
        // On vient de Cliquer ' Construire '
        // Et y a une liste de dol&eacute;ances
        $AddedInQueue = false;
        // Ici, on sait precisement ce qu'on aimerait bien construire ...
        foreach ($_POST['fmenge'] as $Element => $Count) {
            // Construction d'Element recuperés sur la page de Flotte ...
            // ATTENTION ! La file d'attente Flotte est Commune a celle des Defenses
            // Dans fmenge, on devrait trouver un tableau des elements constructibles et du nombre d'elements souhaités
            $Element = floatval($Element);
            $Count = floatval($Count);
            if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                $Count = MAX_FLEET_OR_DEFS_PER_ROW;
            }
            if ($Count != 0) {
                // On verifie si on a les technologies necessaires a la construction de l'element
                if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    // On verifie combien on sait faire de cet element au max
                    $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                    // Si pas assez de ressources, on ajuste le nombre d'elements
                    if ($Count > $MaxElements) {
                        $Count = $MaxElements;
                    }
                    $Ressource = GetElementRessources($Element, $Count);
                    $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                    if ($Count >= 1) {
                        if ($BuildTime > 0) {
                            $CurrentPlanet['metal'] -= $Ressource['metal'];
                            $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                            $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                            if ($Element == 214) {
                                $requete = doquery("SELECT rpg_destructeur FROM {{table}} WHERE id = " . $CurrentUser['id'] . ";", 'users', true);
                                if ($requete['rpg_destructeur'] == 1) {
                                    $Count = 2 * $Count;
                                }
                            }
                            $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
                        } else {
                            $CurrentPlanet['metal'] -= $Ressource['metal'];
                            $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                            $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                            if ($Element == 214) {
                                $requete = doquery("SELECT rpg_destructeur FROM {{table}} WHERE id = " . $CurrentUser['id'] . ";", 'users', true);
                                if ($requete['rpg_destructeur'] == 1) {
                                    $Count = 2 * $Count;
                                }
                            }
                            $NewFleetNumber = $CurrentPlanet[$resource[$Element]] + $Count;
                            $QryUpdatefleet = "UPDATE {{table}} SET ";
                            $QryUpdatefleet .= "`{$resource[$Element]}` = '" . $NewFleetNumber . "' ";
                            $QryUpdatefleet .= "WHERE ";
                            $QryUpdatefleet .= "`id` = '" . $CurrentPlanet['id'] . "'";
                            doquery($QryUpdatefleet, 'planets');
                        }
                    }
                }
            }
        }
    }
    // -------------------------------------------------------------------------------------------------------
    // S'il n'y a pas de Chantier ...
    if ($CurrentPlanet[$resource[21]] == 0) {
        // Veuillez avoir l'obligeance de construire le Chantier Spacial !!
        message($lang['need_hangar'], $lang['tech'][21]);
    }
    // -------------------------------------------------------------------------------------------------------
    // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ...
    $TabIndex = 0;
    foreach ($lang['tech'] as $Element => $ElementName) {
        if ($Element > 201 && $Element <= 399) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                // Disponible à la construction
                // On regarde si on peut en acheter au moins 1
                $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false);
                // On regarde combien de temps il faut pour construire l'element
                $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                // Disponibilité actuelle
                $ElementCount = $CurrentPlanet[$resource[$Element]];
                $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")";
                // Construction des 3 cases de la ligne d'un element dans la page d'achat !
                // Début de ligne
                $PageTable .= "\n<tr>";
                // Imagette + Link vers la page d'info
                $PageTable .= "<th class=l>";
                $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">";
                $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>";
                $PageTable .= "</th>";
                // Description
                $PageTable .= "<td class=l>";
                $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>";
                $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>";
                // On affiche le 'prix' avec eventuellement ce qui manque en ressource
                $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false);
                // On affiche le temps de construction (c'est toujours tellement plus joli)
                $PageTable .= ShowBuildTime($BuildOneElementTime);
                $PageTable .= "</td>";
                // Case nombre d'elements a construire
                $PageTable .= "<th class=k>";
                // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie
                if ($CanBuildOne) {
                    $TabIndex++;
                    $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=12 maxlength=12 value=0 tabindex=" . $TabIndex . ">";
                    $maxElement = GetMaxConstructibleElements($Element, $CurrentPlanet);
                    if ($maxElement > MAX_FLEET_OR_DEFS_PER_ROW) {
                        $maxElement = MAX_FLEET_OR_DEFS_PER_ROW;
                    }
                    $PageTable .= "<br><a href='javascript:' onclick=\"document.getElementsByName('fmenge[" . $Element . "]')[0].value = '{$maxElement}';\">(Max : {$maxElement})</a>";
                }
                $PageTable .= "</th>";
                // Fin de ligne (les 3 cases sont construites !!
                $PageTable .= "</tr>";
            }
        }
    }
    if ($CurrentPlanet['b_hangar_id'] != '') {
        $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet);
    }
    $parse = $lang;
    // La page se trouve dans $PageTable;
    $parse['buildlist'] = $PageTable;
    // Et la liste de constructions en cours dans $BuildQueue;
    $parse['buildinglist'] = $BuildQueue;
    $page .= parsetemplate(gettemplate('buildings_fleet'), $parse);
    display($page, $lang['Fleet']);
}
 public function ShowResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
 {
     global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
     include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
     $PageParse = $lang;
     $NoResearchMessage = "";
     $bContinue = true;
     if ($CurrentPlanet[$resource[31]] == 0) {
         message($lang['bd_lab_required'], '', '', true);
     }
     if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) {
         $NoResearchMessage = $lang['bd_building_lab'];
         $bContinue = false;
     }
     if (isset($_GET['cmd'])) {
         $TheCommand = $_GET['cmd'];
         $Techno = intval($_GET['tech']);
         if (isset($Techno)) {
             if (!strstr($Techno, ",") && !strchr($Techno, " ") && !strchr($Techno, "+") && !strchr($Techno, "*") && !strchr($Techno, "~") && !strchr($Techno, "=") && !strchr($Techno, ";") && !strchr($Techno, "'") && !strchr($Techno, "#") && !strchr($Techno, "-") && !strchr($Techno, "_") && !strchr($Techno, "[") && !strchr($Techno, "]") && !strchr($Techno, ".") && !strchr($Techno, ":")) {
                 if (in_array($Techno, $reslist['tech'])) {
                     if (is_array($ThePlanet)) {
                         $WorkingPlanet = $ThePlanet;
                     } else {
                         $WorkingPlanet = $CurrentPlanet;
                     }
                     switch ($TheCommand) {
                         case 'cancel':
                             if ($ThePlanet['b_tech_id'] == $Techno) {
                                 $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                                 $WorkingPlanet['metal'] += $costs['metal'];
                                 $WorkingPlanet['crystal'] += $costs['crystal'];
                                 $WorkingPlanet['deuterium'] += $costs['deuterium'];
                                 $WorkingPlanet['darkmatter'] += $costs['darkmatter'];
                                 $WorkingPlanet['b_tech_id'] = 0;
                                 $WorkingPlanet["b_tech"] = 0;
                                 $CurrentUser['b_tech_planet'] = 0;
                                 $UpdateData = true;
                                 $InResearch = false;
                             }
                             break;
                         case 'search':
                             if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) {
                                 $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                                 $WorkingPlanet['metal'] -= $costs['metal'];
                                 $WorkingPlanet['crystal'] -= $costs['crystal'];
                                 $WorkingPlanet['deuterium'] -= $costs['deuterium'];
                                 $WorkingPlanet['darkmatter'] -= $costs['darkmatter'];
                                 $WorkingPlanet["b_tech_id"] = $Techno;
                                 $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno);
                                 $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"];
                                 $UpdateData = true;
                                 $InResearch = true;
                             }
                             break;
                     }
                     if ($UpdateData == true) {
                         $QryUpdatePlanet = "UPDATE {{table}} SET ";
                         $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
                         $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
                         $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', ";
                         $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', ";
                         $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "', ";
                         $QryUpdatePlanet .= "`darkmatter` = '" . $WorkingPlanet['darkmatter'] . "' ";
                         $QryUpdatePlanet .= "WHERE ";
                         $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';";
                         doquery($QryUpdatePlanet, 'planets');
                         $QryUpdateUser = "******";
                         $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' ";
                         $QryUpdateUser .= "WHERE ";
                         $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
                         doquery($QryUpdateUser, 'users');
                     }
                     $CurrentPlanet = $WorkingPlanet;
                     if (is_array($ThePlanet)) {
                         $ThePlanet = $WorkingPlanet;
                     } else {
                         $CurrentPlanet = $WorkingPlanet;
                         if ($TheCommand == 'search') {
                             $ThePlanet = $CurrentPlanet;
                         }
                     }
                 }
             } else {
                 die(header("location:game.php?page=buildings&mode=research"));
             }
         } else {
             $bContinue = false;
         }
         header("Location: game.php?page=buildings&mode=research");
     }
     $siguiente = 1;
     $BuildingPage = "";
     $zaehler = 1;
     $TechRowTPL = gettemplate('buildings/buildings_research_row');
     $TechScrTPL = gettemplate('buildings/buildings_research_script');
     foreach ($lang['tech'] as $Tech => $TechName) {
         if ($Tech > 105 && $Tech <= 199) {
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
                 $RowParse['dpath'] = $dpath;
                 $RowParse['tech_id'] = $Tech;
                 $building_level = $CurrentUser[$resource[$Tech]];
                 if ($Tech == 106) {
                     $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")";
                     $RowParse['tech_level'] .= $CurrentUser['rpg_espion'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_espion'] * ESPION . $lang['bd_spy'] . "</font></strong>";
                 } elseif ($Tech == 108) {
                     $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")";
                     $RowParse['tech_level'] .= $CurrentUser['rpg_commandant'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_commandant'] * COMMANDANT . $lang['bd_commander'] . "</font></strong>";
                 } else {
                     $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . " )";
                 }
                 $RowParse['tech_name'] = $TechName;
                 $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech];
                 $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech);
                 $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech);
                 $RowParse['search_time'] = ShowBuildTime($SearchTime);
                 $RowParse['tech_restp'] = "Restantes " . $this->GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true);
                 $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech);
                 if ($siguiente == 1) {
                     $parse['abrirtr'] = "<tr>";
                 }
                 if (!$InResearch) {
                     $LevelToDo = 1 + $CurrentUser[$resource[$Tech]];
                     if ($CanBeDone) {
                         if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) {
                             if ($LevelToDo == 1) {
                                 $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>";
                             } else {
                                 $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>";
                             }
                         } else {
                             $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Tech . "\">";
                             if ($LevelToDo == 1) {
                                 $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "</font>";
                             } else {
                                 $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>";
                             }
                             $TechnoLink .= "</a>";
                         }
                     } else {
                         if ($LevelToDo == 1) {
                             $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>";
                         } else {
                             $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>";
                         }
                     }
                 } else {
                     if ($ThePlanet["b_tech_id"] == $Tech) {
                         $bloc = $lang;
                         if ($ThePlanet['id'] != $CurrentPlanet['id']) {
                             $bloc['tech_time'] = $ThePlanet["b_tech"] - time();
                             $bloc['tech_name'] = "de<br>" . $ThePlanet["name"];
                             $bloc['tech_home'] = $ThePlanet["id"];
                             $bloc['tech_id'] = $ThePlanet["b_tech_id"];
                         } else {
                             $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time();
                             $bloc['tech_name'] = "";
                             $bloc['tech_home'] = $CurrentPlanet["id"];
                             $bloc['tech_id'] = $CurrentPlanet["b_tech_id"];
                         }
                         $TechnoLink = parsetemplate($TechScrTPL, $bloc);
                     } else {
                         $TechnoLink = "<center>-</center>";
                     }
                 }
                 if ($siguiente == 3) {
                     $parse['cerrartr'] = "</tr>";
                     $siguiente = 1;
                 } else {
                     $siguiente++;
                 }
                 $TechRowTPL = gettemplate('buildings/buildings_research_row');
                 $RowParse['tech_link'] = $TechnoLink;
                 $TechnoList .= parsetemplate($TechRowTPL, $RowParse);
             }
         }
     }
     $PageParse['noresearch'] = $NoResearchMessage;
     $PageParse['technolist'] = $TechnoList;
     $Page .= parsetemplate(gettemplate('buildings/buildings_research'), $PageParse);
     display($Page);
 }
function AddBuildingToQueue(&$CurrentPlanet, $CurrentUser, $Element, $AddMode = true)
{
    global $lang, $resource;
    $CurrentQueue = $CurrentPlanet['b_building_id'];
    if ($CurrentQueue != 0) {
        $QueueArray = explode(";", $CurrentQueue);
        $ActualCount = count($QueueArray);
    } else {
        $QueueArray = "";
        $ActualCount = 0;
    }
    if ($AddMode == true) {
        $BuildMode = 'build';
    } else {
        $BuildMode = 'destroy';
    }
    if ($ActualCount < MAX_BUILDING_QUEUE_SIZE) {
        $QueueID = $ActualCount + 1;
    } else {
        $QueueID = false;
    }
    if ($QueueID != false) {
        // Must check if the item you want to integrate is already in the table!
        if ($QueueID > 1) {
            $InArray = 0;
            for ($QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++) {
                $QueueSubArray = explode(",", $QueueArray[$QueueElement]);
                if ($QueueSubArray[0] == $Element) {
                    $InArray++;
                }
            }
        } else {
            $InArray = 0;
        }
        if ($InArray != 0) {
            $ActualLevel = $CurrentPlanet[$resource[$Element]];
            if ($AddMode == true) {
                $BuildLevel = $ActualLevel + 1 + $InArray;
                $CurrentPlanet[$resource[$Element]] += $InArray;
                $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $CurrentPlanet[$resource[$Element]] -= $InArray;
            } else {
                $BuildLevel = $ActualLevel - 1 + $InArray;
                $CurrentPlanet[$resource[$Element]] -= $InArray;
                $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
                $CurrentPlanet[$resource[$Element]] += $InArray;
            }
        } else {
            $ActualLevel = $CurrentPlanet[$resource[$Element]];
            if ($AddMode == true) {
                $BuildLevel = $ActualLevel + 1;
                $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
            } else {
                $BuildLevel = $ActualLevel - 1;
                $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
            }
        }
        if ($QueueID == 1) {
            $BuildEndTime = time() + $BuildTime;
        } else {
            $PrevBuild = explode(",", $QueueArray[$ActualCount - 1]);
            $BuildEndTime = $PrevBuild[3] + $BuildTime;
        }
        $QueueArray[$ActualCount] = $Element . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $BuildMode;
        $NewQueue = implode(";", $QueueArray);
        $CurrentPlanet['b_building_id'] = $NewQueue;
    }
    return $QueueID;
}
Example #21
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 *
 * fix by vomi, zeus (team xorbit) for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
    $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
    // Boucle d'interpretation des eventuelles commandes
    if ($CurrentUser['urlaubs_modus'] == 0) {
        if (isset($_GET['cmd'])) {
            // On passe une commande
            $bDoItNow = false;
            $TheCommand = $_GET['cmd'];
            $Gebaude = false;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $_GET['building'])) {
                $Gebaude = IsElementBuyable($CurrentUser, $CurrentPlanet, $_GET['building'], true, false);
            }
            //Gebäude-Cheat-Fix Wolle1989
            //ändern für andere Bannzeiten in Sekunden
            $bannzeit = 60;
            // so lassen
            $time = time();
            $bantime = $time + $bannzeit;
            $Gebaude = false;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $_GET['building'])) {
                $Gebaude = IsElementBuyable($CurrentUser, $CurrentPlanet, $_GET['building'], true, false);
            }
            $Element = $_GET['building'];
            if (!$Gebaude) {
                doquery("UPDATE {{table}} SET bana='1', banaday='{$bantime}' WHERE id='{$CurrentUser['id']}'", "users");
                doquery("INSERT INTO {{table}} SET\r\n\t\t\t\t`who` = '{$CurrentUser['username']}',\r\n\t\t\t\t`theme`= 'Cheatversuch',\r\n\t\t\t\t`who2` = '{$CurrentUser['id']}',\r\n\t\t\t\t`time` = '{$time}',\r\n\t\t\t\t`longer` = '{$bantime}',\r\n\t\t\t\t`author` = 'SYSTEM: B',\r\n\t\t\t\t`email` = 'n'", 'banned');
                message($lang['CHEATATTEMPT'], $lang['CHEATATTEMPT_TITLE']);
                die;
            }
            $ListID = $_GET['listid'];
            if (isset($Element)) {
                if (!strchr($Element, ",")) {
                    if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                        $bDoItNow = true;
                    }
                }
            } elseif (isset($ListID)) {
                $bDoItNow = true;
            }
            //Hier wird geprüft ob ein ; in die URL(GET)Geschrieben wurde
            foreach ($_GET as $check_url) {
                if (eregi(";", $check_url)) {
                    die($lang['ANTICHEAT_MESSAGE']);
                }
            }
            //Hier wird gescheckt ob ein user das zeichen ; in einen INPUT schreibt
            foreach ($_POST as $check_pos) {
                if (eregi(";", $check_post, $check_url)) {
                    die($lang['ANTICHEAT_MESSAGE']);
                }
            }
            if ($bDoItNow == true) {
                switch ($TheCommand) {
                    case 'cancel':
                        // Interrompre le premier batiment de la queue
                        CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                        break;
                    case 'remove':
                        // Supprimer un element de la queue (mais pas le premier)
                        // $RemID -> element de la liste a supprimer
                        RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                        break;
                    case 'insert':
                        // Insere un element dans la queue
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                        break;
                    case 'destroy':
                        // Detruit un batiment deja construit sur la planete !
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                        break;
                    default:
                        break;
                }
                // switch
            }
        }
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // On enregistre ce que l'on a modifi� dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                // show energy on BuildingPage
                $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"];
                $BuildTemp = $CurrentPlanet['temp_max'];
                $CurrentBuildtLvl = $BuildingLevel;
                $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
                $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                $ActualNeed = floor($Prod[4]);
                $BuildLevel++;
                $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                $EnergyNeed = colorNumber(pretty_number(floor($Prod[4] - $ActualNeed)));
                if ($Element >= 1 && $Element <= 3) {
                    $parse['build_need_diff'] = "(" . "<font color=#FF0000>" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                } elseif ($Element == 4 || $Element == 12) {
                    $parse['build_need_diff'] = "(" . "<font color=#00FF00>+" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                }
                // end of 'show energy on BuildingPage'
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Special Laboratoire
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Variable qui contient le parametre
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                    // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        if ($HaveRessources == true) {
                            $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        } else {
                            $parse['click'] = "<font color=#FF0000>" . $lang['InBuildQueue'] . "</font>";
                        }
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("buildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
 public function ShowBuildingsPage(&$CurrentPlanet, $CurrentUser)
 {
     global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
     include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
     include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
     CheckPlanetUsedFields($CurrentPlanet);
     $parse = $lang;
     $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44);
     $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
     if (isset($_GET['cmd'])) {
         $bDoItNow = false;
         $TheCommand = $_GET['cmd'];
         $Element = $_GET['building'];
         $ListID = $_GET['listid'];
         if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
             unset($Element);
         }
         if (isset($Element)) {
             if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
                 if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                     $bDoItNow = true;
                 }
             } else {
                 header("location:game.php?page=buildings");
             }
         } elseif (isset($ListID)) {
             $bDoItNow = true;
         }
         if ($bDoItNow == true) {
             switch ($TheCommand) {
                 case 'cancel':
                     $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                     break;
                 case 'remove':
                     $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                     break;
                 case 'insert':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                     break;
                 case 'destroy':
                     $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                     break;
             }
         }
     }
     SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
     $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser);
     $this->BuildingSavePlanetRecord($CurrentPlanet);
     if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
         $CanBuildElement = true;
     } else {
         $CanBuildElement = false;
     }
     $BuildingPage = "";
     $zaehler = 1;
     $siguiente = 1;
     foreach ($lang['tech'] as $BuildID => $ElementName) {
         if (in_array($BuildID, $Allowed[$CurrentPlanet['planet_type']])) {
             $parse = $lang;
             $parse['dpath'] = $dpath;
             $parse['name'] = $lang['info'][$BuildID]['name'];
             $parse['image'] = $BuildID;
             $parse['description'] = $lang['info'][$BuildID]['description'];
             $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true);
             $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2;
             $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID;
             $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]];
             $parse['nfo_metal'] = $lang['Metal'];
             $parse['nfo_crysta'] = $lang['Crystal'];
             $parse['nfo_deuter'] = $lang['Deuterium'];
             $parse['metal'] = pretty_number($NeededRessources['metal']);
             $parse['crystal'] = pretty_number($NeededRessources['crystal']);
             $parse['deuterium'] = pretty_number($NeededRessources['deuterium']);
             $parse['destroytime'] = pretty_time($DestroyTime);
             $infodiv .= parsetemplate(gettemplate('buildings/buildings_info_row'), $parse);
         }
     }
     foreach ($lang['tech'] as $Element => $ElementName) {
         if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
             $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
             if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                 $RoomIsOk = true;
             } else {
                 $RoomIsOk = false;
             }
             if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                 $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                 $parse = array();
                 $parse = $lang;
                 $parse['dpath'] = $dpath;
                 if ($siguiente == 1) {
                     $parse['abrirtr'] = "<tr>";
                 }
                 $parse['i'] = $Element;
                 $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                 $parse['nivel'] = $BuildingLevel == 0 ? " (" . $lang['bd_lvl'] . " 0)" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
                 $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"];
                 $BuildTemp = $CurrentPlanet['temp_max'];
                 $CurrentBuildtLvl = $BuildingLevel;
                 $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1;
                 $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05);
                 $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                 if ($Element != 12) {
                     $ActualNeed = floor($Prod[4]);
                 } else {
                     $ActualNeed = floor($Prod[3]);
                 }
                 $BuildLevel++;
                 $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05);
                 $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                 if ($Element != 12) {
                     $EnergyNeed = pretty_number(abs(floor($Prod[4] - $ActualNeed)));
                 } else {
                     $EnergyNeed = pretty_number(abs(floor($Prod[3] - $ActualNeed)));
                 }
                 if ($Element >= 1 && $Element <= 3) {
                     $parse['build_need_diff'] = "Next Level:<br>Verbraucht <font color=#FF0000>" . $EnergyNeed . "</font> " . $lang['Energy'] . " mehr";
                     $BuildLevel = 0;
                 } elseif ($Element == 4 || $Element == 12) {
                     $parse['build_need_diff'] = "Next Level:<br>Produziert <font color=#00FF00>" . $EnergyNeed . "</font> mehr " . $lang['Energy'];
                     $BuildLevel = 0;
                 } elseif ($Element == 43 && $BuildingLevel != 0) {
                     $parse['build_need_diff'] = "<a href=\"javascript:f('game.php?page=infos&gid=43','');\">Springen</a>";
                     $BuildLevel = 0;
                 }
                 if ($BuildingLevel != 0) {
                     $parse['cancel'] = "<a href=\"javascript:infodiv('" . $Element . "-cancel');javascript:animatedcollapse.toggle('" . $Element . "-cancel')\">Abrei&szlig;en</a>";
                 }
                 $parse['n'] = $ElementName;
                 $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                 $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                 $parse['time'] = ShowBuildTime($ElementBuildTime);
                 $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, true);
                 $parse['click'] = '';
                 $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                 if ($RoomIsOk && $CanBuildElement) {
                     if ($Queue['lenght'] == 0) {
                         if ($NextBuildLevel == 1) {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                             }
                         } else {
                             if ($HaveRessources == true) {
                                 $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>";
                             } else {
                                 $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                             }
                         }
                     } else {
                         $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>";
                     }
                 } elseif ($RoomIsOk && !$CanBuildElement) {
                     if ($NextBuildLevel == 1) {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>";
                     } else {
                         $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>";
                     }
                 } else {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>";
                 }
                 if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if ($Element == 21 && $CurrentPlanet["b_hangar"] != 0) {
                     $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>";
                 }
                 if ($siguiente == 3) {
                     $parse['cerrartr'] = "</tr>";
                     $siguiente = 1;
                 } else {
                     $siguiente++;
                 }
                 $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse);
             }
         }
     }
     if ($Queue['lenght'] > 0) {
         include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
         $parse['BuildListScript'] = InsertBuildListScript("buildings");
         $parse['BuildList'] = $Queue['buildlist'];
     } else {
         $parse['BuildListScript'] = "";
         $parse['BuildList'] = "";
     }
     $parse['BuildingsList'] = $BuildingPage;
     $parse['infodiv'] = $infodiv;
     display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse));
 }
Example #23
0
 public function __construct($CurrentUser, $CurrentPlanet, $BuildID)
 {
     global $dpath, $lang, $resource, $pricelist, $CombatCaps, $phpEx, $xgp_root;
     $GateTPL = '';
     $DestroyTPL = '';
     $TableHeadTPL = '';
     $parse = $lang;
     $parse['dpath'] = $dpath;
     $parse['name'] = $lang['info'][$BuildID]['name'];
     $parse['image'] = $BuildID;
     $parse['description'] = $lang['info'][$BuildID]['description'];
     if ($BuildID >= 1 && $BuildID <= 3) {
         $PageTPL = gettemplate('infos/info_buildings_table');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
         $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_p_hour}</td><td class=\"c\">{in_difference}</td><td class=\"c\">{in_used_energy}</td><td class=\"c\">{in_difference}</td></tr>";
         $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>";
     } elseif ($BuildID == 4) {
         $PageTPL = gettemplate('infos/info_buildings_table');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
         $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_energy}</td><td class=\"c\">{in_difference}</td></tr>";
         $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>";
     } elseif ($BuildID == 12) {
         $PageTPL = gettemplate('infos/info_buildings_table');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
         $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_energy}</td><td class=\"c\">{in_difference}</td><td class=\"c\">{in_used_deuter}</td><td class=\"c\">{in_difference}</td></tr>";
         $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>";
     } elseif ($BuildID >= 14 && $BuildID <= 32) {
         $PageTPL = gettemplate('infos/info_buildings_general');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
     } elseif ($BuildID == 33) {
         $PageTPL = gettemplate('infos/info_buildings_general');
     } elseif ($BuildID == 34) {
         $PageTPL = gettemplate('infos/info_buildings_general');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
     } elseif ($BuildID == 44) {
         $PageTPL = gettemplate('infos/info_buildings_general');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
     } elseif ($BuildID == 41) {
         $PageTPL = gettemplate('infos/info_buildings_general');
     } elseif ($BuildID == 42) {
         $PageTPL = gettemplate('infos/info_buildings_table');
         $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_range}</td></tr>";
         $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>";
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
     } elseif ($BuildID == 43) {
         $PageTPL = gettemplate('infos/info_buildings_general');
         $GateTPL = gettemplate('infos/info_gate_table');
         $DestroyTPL = gettemplate('infos/info_buildings_destroy');
         if ($_POST) {
             message($this->DoFleetJump($CurrentUser, $CurrentPlanet), "game.php?page=infos&gid=43", 2);
         }
     } elseif ($BuildID >= 106 && $BuildID <= 199) {
         $PageTPL = gettemplate('infos/info_buildings_general');
     } elseif ($BuildID >= 202 && $BuildID <= 224) {
         $PageTPL = gettemplate('infos/info_buildings_fleet');
         $parse['element_typ'] = $lang['tech'][200];
         $parse['rf_info_to'] = $this->ShowRapidFireTo($BuildID);
         $parse['rf_info_fr'] = $this->ShowRapidFireFrom($BuildID);
         $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
         $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
         $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
         $parse['capacity_pt'] = pretty_number($pricelist[$BuildID]['capacity']);
         $parse['base_speed'] = pretty_number($pricelist[$BuildID]['speed']);
         $parse['base_conso'] = pretty_number($pricelist[$BuildID]['consumption']);
         if ($BuildID == 202) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>";
             $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['consumption2']) . ")</font>";
         } elseif ($BuildID == 211) {
             $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>";
         }
     } elseif ($BuildID >= 401 && $BuildID <= 411) {
         $PageTPL = gettemplate('infos/info_buildings_defense');
         $parse['element_typ'] = $lang['tech'][400];
         $parse['rf_info_to'] = $this->ShowRapidFireTo($BuildID);
         $parse['rf_info_fr'] = $this->ShowRapidFireFrom($BuildID);
         $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
         $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
         $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
     } elseif ($BuildID >= 502 && $BuildID <= 503) {
         $PageTPL = gettemplate('infos/info_buildings_defense');
         $parse['element_typ'] = $lang['tech'][400];
         $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
         $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
         $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
     } elseif ($BuildID >= 601 && $BuildID <= 615) {
         $PageTPL = gettemplate('infos/info_officiers_general');
     }
     if ($TableHeadTPL != '') {
         $parse['table_head'] = parsetemplate($TableHeadTPL, $lang);
         $parse['table_data'] = $this->ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL);
     }
     $page = parsetemplate($PageTPL, $parse);
     if ($GateTPL != '') {
         if ($CurrentPlanet[$resource[$BuildID]] > 0) {
             $RestString = $this->GetNextJumpWaitTime($CurrentPlanet);
             $parse['gate_start_link'] = BuildPlanetAdressLink($CurrentPlanet);
             if ($RestString['value'] != 0) {
                 include $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
                 $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true);
                 $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>";
                 $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false);
             } else {
                 $parse['gate_time_script'] = "";
                 $parse['gate_wait_time'] = "";
                 $parse['gate_script_go'] = "";
             }
             $parse['gate_dest_moons'] = $this->BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet);
             $parse['gate_fleet_rows'] = $this->BuildFleetListRows($CurrentPlanet);
             $page .= parsetemplate($GateTPL, $parse);
         }
     }
     if ($DestroyTPL != '') {
         if ($CurrentPlanet[$resource[$BuildID]] > 0) {
             $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true);
             $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2;
             $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID;
             $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]];
             $parse['nfo_metal'] = $lang['Metal'];
             $parse['nfo_crysta'] = $lang['Crystal'];
             $parse['nfo_deuter'] = $lang['Deuterium'];
             $parse['metal'] = pretty_number($NeededRessources['metal']);
             $parse['crystal'] = pretty_number($NeededRessources['crystal']);
             $parse['deuterium'] = pretty_number($NeededRessources['deuterium']);
             $parse['destroytime'] = pretty_time($DestroyTime);
             $page .= parsetemplate($DestroyTPL, $parse);
         }
     }
     return display($page);
 }
 public function DefensesBuildingPage()
 {
     global $USER, $PLANET, $LNG, $resource, $dpath, $reslist;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php';
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.php';
     $template = new template();
     if ($PLANET[$resource[21]] == 0) {
         $template->message($LNG['bd_shipyard_required']);
         exit;
     }
     $fmenge = $_POST['fmenge'];
     $cancel = request_var('auftr', range(0, MAX_FLEET_OR_DEFS_IN_BUILD - 1));
     $action = request_var('action', '');
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     $NotBuilding = true;
     if (!empty($PLANET['b_building_id'])) {
         $CurrentQueue = $PLANET['b_building_id'];
         $QueueArray = explode(";", $CurrentQueue);
         for ($i = 0; $i < count($QueueArray); $i++) {
             $ListIDArray = explode(",", $QueueArray[$i]);
             if ($ListIDArray[0] == 21 || $ListIDArray[0] == 15) {
                 $NotBuilding = false;
                 break;
             }
         }
     }
     if (isset($fmenge) && $NotBuilding == true && $USER['urlaubs_modus'] == 0) {
         $ebuild = explode(";", $PLANET['b_hangar_id']);
         if (count($ebuild) - 1 >= MAX_FLEET_OR_DEFS_IN_BUILD) {
             $template->message(sprintf($LNG['bd_max_builds'], MAX_FLEET_OR_DEFS_IN_BUILD), "?page=buildings&mode=fleet", 3);
             exit;
         }
         $Missiles[502] = $PLANET[$resource[502]];
         $Missiles[503] = $PLANET[$resource[503]];
         $SiloSize = $PLANET[$resource[44]];
         $MaxMissiles = $SiloSize * 10;
         $BuildQueue = $PLANET['b_hangar_id'];
         $BuildArray = explode(";", $BuildQueue);
         for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
             $ElmentArray = explode(",", $BuildArray[$QElement]);
             if (isset($Missiles[$ElmentArray[0]])) {
                 $Missiles[$ElmentArray[0]] += $ElmentArray[1];
             }
         }
         foreach ($fmenge as $Element => $Count) {
             if (empty($Count) || !in_array($Element, $reslist['defense'])) {
                 continue;
             }
             $Count = is_numeric($Count) ? $Count : 0;
             $Count = max(min($Count, MAX_FLEET_OR_DEFS_PER_ROW), 0);
             $MaxElements = $this->GetMaxConstructibleElements($Element);
             if (empty($Element) || empty($Count) || empty($MaxElements) || !IsTechnologieAccessible($USER, $PLANET, $Element)) {
                 continue;
             }
             if ($Element == 502 || $Element == 503) {
                 $ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
                 $MissilesSpace = $MaxMissiles - $ActuMissiles;
                 $Count = $Element == 502 ? min($Count, $MissilesSpace) : min($Count, floor($MissilesSpace / 2));
                 $Count = min($Count, $MaxElements);
                 $Missiles[$Element] += $Count;
             } elseif (in_array($Element, $reslist['one'])) {
                 $Count = $PLANET[$resource[$Element]] == 0 && strpos($PLANET['b_hangar_id'], $Element . ',') === false ? 1 : 0;
             } else {
                 $Count = min($Count, $MaxElements);
             }
             if ($Count < 1) {
                 continue;
             }
             $Ressource = $this->GetElementRessources($Element, $Count);
             $PLANET['metal'] -= $Ressource['metal'];
             $PLANET['crystal'] -= $Ressource['crystal'];
             $PLANET['deuterium'] -= $Ressource['deuterium'];
             $PLANET['norio'] -= $Ressource['norio'];
             $USER['darkmatter'] -= $Ressource['darkmatter'];
             $PLANET['b_hangar_id'] .= $Element . ',' . floattostring($Count) . ';';
         }
     }
     if ($action == "delete" && is_array($cancel) && $USER['urlaubs_modus'] == 0) {
         $this->CancelAuftr($cancel);
     }
     $PlanetRess->SavePlanetToDB();
     foreach ($reslist['defense'] as $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $DefenseList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element, false), 'restprice' => $this->GetRestPrice($Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'IsAvailable' => IsElementBuyable($USER, $PLANET, $Element, false), 'GetMaxAmount' => floattostring($this->GetMaxConstructibleElements($Element)), 'Available' => pretty_number($PLANET[$resource[$Element]]), 'AlreadyBuild' => in_array($Element, $reslist['one']) && (strpos($PLANET['b_hangar_id'], $Element . ",") !== false || $PLANET[$resource[$Element]] != 0) ? true : false);
     }
     $Buildlist = array();
     if (!empty($PLANET['b_hangar_id'])) {
         $ElementQueue = explode(';', $PLANET['b_hangar_id']);
         $Shipyard = array();
         $QueueTime = 0;
         foreach ($ElementQueue as $ElementLine => $Element) {
             if (empty($Element)) {
                 continue;
             }
             $Element = explode(',', $Element);
             $ElementTime = GetBuildingTime($USER, $PLANET, $Element[0]);
             $QueueTime += $ElementTime * $Element[1];
             $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime);
         }
         $template->loadscript('bcmath.js');
         $template->loadscript('shipyard.js');
         $template->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)));
     }
     $template->assign_vars(array('DefenseList' => $DefenseList, 'NotBuilding' => $NotBuilding, 'bd_available' => $LNG['bd_available'], 'bd_remaining' => $LNG['bd_remaining'], 'fgf_time' => $LNG['fgf_time'], 'bd_build_ships' => $LNG['bd_build_ships'], 'bd_building_shipyard' => $LNG['bd_building_shipyard'], 'bd_protection_shield_only_one' => $LNG['bd_protection_shield_only_one'], 'bd_cancel_warning' => $LNG['bd_cancel_warning'], 'bd_cancel_send' => $LNG['bd_cancel_send'], 'bd_operating' => $LNG['bd_operating'], 'bd_actual_production' => $LNG['bd_actual_production'], 'BuildList' => json_encode($Buildlist), 'maxlength' => strlen(MAX_FLEET_OR_DEFS_PER_ROW)));
     $template->show("shipyard_defense.tpl");
 }
Example #25
0
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $phpEx, $dpath, $_POST;
    if ($CurrentUser['urlaubs_modus'] == 0) {
        if (isset($_POST['fmenge'])) {
            // Es wurde 'Bauen' geklickt
            // Und hat auch eine Liste von [?]
            $AddedInQueue = false;
            // Gut, hier weiss man was und wieviel gebaut werden soll.
            foreach ($_POST['fmenge'] as $Element => $Count) {
                // Bau der Flotte auf der Flottenseite
                // ACHTUNG ! Die Warteschlange der Flotte und Verteidigung werden zusammen verarbeitet.
                // In fmenge, sollte man eine Tabelle der Elemente Baugrundstücke und der Anzahl der Elemente haben
                $Element = intval($Element);
                $Count = intval($Count);
                if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
                    $Count = MAX_FLEET_OR_DEFS_PER_ROW;
                }
                if ($Count != 0) {
                    // Verified, wenn man die notwendige Technologie hat für den Bau des aktuellen Elements
                    if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                        // Verified, hole maximal mögliche Anzahl
                        $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                        // Wenn nicht genügend Ressourcen vorhanden sind, wird eine Anpassung der Anzahl der Elemente vorgenommen
                        if ($Count > $MaxElements) {
                            $Count = $MaxElements;
                        }
                        $Ressource = GetElementRessources($Element, $Count);
                        $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                        if ($Count >= 1) {
                            $CurrentPlanet['metal'] -= $Ressource['metal'];
                            $CurrentPlanet['crystal'] -= $Ressource['crystal'];
                            $CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
                            $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
                        }
                    }
                }
            }
        }
    }
    // -------------------------------------------------------------------------------------------------------
    // Wenn nix gebaut wird / werden kann
    if ($CurrentPlanet[$resource[21]] == 0) {
        // Veuillez avoir l'obligeance de construire le Chantier Spacial !!
        message($lang['need_hangar'], $lang['tech'][21]);
    }
    // -------------------------------------------------------------------------------------------------------
    // Bau der Seite der Baustelle (denn wenn ich hier ... ist, dass ich alles, was Sie brauchen, um ...
    $TabIndex = 0;
    foreach ($lang['tech'] as $Element => $ElementName) {
        if ($Element > 201 && $Element <= 399) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                // Disponible à la construction
                // On regarde si on peut en acheter au moins 1
                $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false);
                // On regarde combien de temps il faut pour construire l'element
                $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                // Disponibilité actuelle
                $ElementCount = $CurrentPlanet[$resource[$Element]];
                $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")";
                // Construction des 3 cases de la ligne d'un element dans la page d'achat !
                // Début de ligne
                $PageTable .= "\n<tr>";
                // Imagette + Link vers la page d'info
                $PageTable .= "<th class=l>";
                $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">";
                $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>";
                $PageTable .= "</th>";
                // Description
                $PageTable .= "<td class=l>";
                $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>";
                $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>";
                // On affiche le 'prix' avec eventuellement ce qui manque en ressource
                $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false);
                // On affiche le temps de construction (c'est toujours tellement plus joli)
                $PageTable .= ShowBuildTime($BuildOneElementTime);
                $PageTable .= "</td>";
                // Case nombre d'elements a construire
                $PageTable .= "<th class=k>";
                // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie
                if ($CanBuildOne) {
                    $TabIndex++;
                    $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=5 maxlength=8 value=0 tabindex=" . $TabIndex . ">";
                }
                $PageTable .= "</th>";
                // Fin de ligne (les 3 cases sont construites !!
                $PageTable .= "</tr>";
            }
        }
    }
    if ($CurrentPlanet['b_hangar_id'] != '') {
        $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet);
    }
    $parse = $lang;
    // La page se trouve dans $PageTable;
    $parse['buildlist'] = $PageTable;
    // Et la liste de constructions en cours dans $BuildQueue;
    $parse['buildinglist'] = $BuildQueue;
    $page .= parsetemplate(gettemplate('buildings_fleet'), $parse);
    display($page, $lang['Fleet']);
}
 public function __construct()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist, $OfficerInfo;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php';
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.php';
     $template = new template();
     if ($PLANET[$resource[31]] == 0) {
         $template->message($LNG['bd_lab_required']);
         exit;
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false;
     $TheCommand = request_var('cmd', '');
     $Element = request_var('tech', 0);
     $ListID = request_var('listid', 0);
     $PlanetRess = new ResourceUpdate();
     $PLANET[$resource[31] . '_inter'] = $PlanetRess->CheckAndGetLabLevel($USER, $PLANET);
     $PlanetRess->CalcResource();
     if (!empty($Element) && $bContinue && $USER['urlaubs_modus'] == 0 && ($USER[$resource[$Element]] < $pricelist[$Element]['max'] && IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['tech'])) || $TheCommand == "cancel" || $TheCommand == "remove") {
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue($PlanetRess);
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID, $PlanetRess);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
     }
     $PlanetRess->SavePlanetToDB();
     $ScriptInfo = array();
     $TechQueue = $this->ShowTechQueue();
     foreach ($reslist['tech'] as $ID => $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $CanBeDone = IsElementBuyable($USER, $PLANET, $Element);
         if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) {
             $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>";
         } elseif (MAX_RESEACH_QUEUE_SIZE > 1) {
             $LevelToDo = 1 + $USER[$resource[$Element]];
             $TechnoLink = $CanBeDone && $bContinue ? "<a href=\"game.php?page=buildings&amp;mode=research&amp;cmd=insert&amp;tech=" . $Element . "\"><font color=\"#00FF00\">" . ($USER['b_tech_id'] != 0 ? $LNG['bd_add_to_list'] : $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo)) . "</font></a>" : "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>";
             if ($USER['b_tech_id'] != 0) {
                 $template->loadscript('researchlist.js');
                 $template->execscript('ReBuildView();Techlist();');
                 $ScriptInfo = array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $TechQueue);
             }
         } else {
             if ($USER['b_tech_id'] == 0) {
                 $LevelToDo = 1 + $USER[$resource[$Element]];
                 $TechnoLink = $CanBeDone && $bContinue ? "<a href=\"game.php?page=buildings&amp;mode=research&amp;cmd=insert&amp;tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>" : "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>";
             } else {
                 if ($USER['b_tech_id'] == $Element) {
                     $template->loadscript('research.js');
                     if ($USER['b_tech_planet'] == $PLANET['id']) {
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     } else {
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $TechQueue['planet'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     }
                     $TechnoLink = '<div id="research"></div>';
                 } else {
                     $TechnoLink = '<center>-</center>';
                 }
             }
         }
         $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * $OfficerInfo[610]['info'] . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * $OfficerInfo[611]['info'] . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink, 'oldlink' => MAX_RESEACH_QUEUE_SIZE == 1, 'queue' => $TechQueue);
     }
     $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time']));
     $template->show('buildings_research.tpl');
 }
Example #27
0
function ShowBuildingInfoPage($CurrentUser, $CurrentPlanet, $BuildID)
{
    global $dpath, $lang, $resource, $pricelist, $CombatCaps;
    includeLang('infos');
    $GateTPL = '';
    $DestroyTPL = '';
    $TableHeadTPL = '';
    $parse = $lang;
    // Données de base
    $parse['dpath'] = $dpath;
    $parse['name'] = $lang['info'][$BuildID]['name'];
    $parse['image'] = $BuildID;
    $parse['description'] = $lang['info'][$BuildID]['description'];
    if ($BuildID >= 1 && $BuildID <= 3) {
        // Cas des mines
        $PageTPL = gettemplate('info_buildings_table');
        $DestroyTPL = gettemplate('info_buildings_destroy');
        $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_p_hour}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_energy}</td><td class=\"c\">{nfo_difference}</td></tr>";
        $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>";
    } elseif ($BuildID == 4) {
        // Centrale Solaire
        $PageTPL = gettemplate('info_buildings_table');
        $DestroyTPL = gettemplate('info_buildings_destroy');
        $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td></tr>";
        $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>";
    } elseif ($BuildID == 12) {
        // Centrale Fusion
        $PageTPL = gettemplate('info_buildings_table');
        $DestroyTPL = gettemplate('info_buildings_destroy');
        $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_prod_energy}</td><td class=\"c\">{nfo_difference}</td><td class=\"c\">{nfo_used_deuter}</td><td class=\"c\">{nfo_difference}</td></tr>";
        $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>";
    } elseif ($BuildID >= 14 && $BuildID <= 32) {
        // Batiments Generaux
        $PageTPL = gettemplate('info_buildings_general');
        $DestroyTPL = gettemplate('info_buildings_destroy');
    } elseif ($BuildID == 33) {
        // Batiments Terraformer
        $PageTPL = gettemplate('info_buildings_general');
    } elseif ($BuildID == 34) {
        // Dépot d'alliance
        $PageTPL = gettemplate('info_buildings_general');
        $DestroyTPL = gettemplate('info_buildings_destroy');
    } elseif ($BuildID == 44) {
        // Silo de missiles
        $PageTPL = gettemplate('info_buildings_general');
        $DestroyTPL = gettemplate('info_buildings_destroy');
    } elseif ($BuildID == 41) {
        // Batiments lunaires
        $PageTPL = gettemplate('info_buildings_general');
    } elseif ($BuildID == 42) {
        // Phalange
        $PageTPL = gettemplate('info_buildings_table');
        $TableHeadTPL = "<tr><td class=\"c\">{nfo_level}</td><td class=\"c\">{nfo_range}</td></tr>";
        $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>";
        $DestroyTPL = gettemplate('info_buildings_destroy');
    } elseif ($BuildID == 43) {
        // Porte de Saut
        $PageTPL = gettemplate('info_buildings_general');
        $GateTPL = gettemplate('gate_fleet_table');
        $DestroyTPL = gettemplate('info_buildings_destroy');
    } elseif ($BuildID >= 106 && $BuildID <= 199) {
        // Laboratoire
        $PageTPL = gettemplate('info_buildings_general');
    } elseif ($BuildID >= 202 && $BuildID <= 215) {
        // Flotte
        $PageTPL = gettemplate('info_buildings_fleet');
        $parse['element_typ'] = $lang['tech'][200];
        $parse['rf_info_to'] = ShowRapidFireTo($BuildID);
        // Rapid Fire vers
        $parse['rf_info_fr'] = ShowRapidFireFrom($BuildID);
        // Rapid Fire de
        $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
        // Points de Structure
        $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
        // Points de Bouclier
        $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
        // Points d'Attaque
        $parse['capacity_pt'] = pretty_number($pricelist[$BuildID]['capacity']);
        // Capacitée de fret
        $parse['base_speed'] = pretty_number($pricelist[$BuildID]['speed']);
        // Vitesse de base
        $parse['base_conso'] = pretty_number($pricelist[$BuildID]['consumption']);
        // Consommation de base
        if ($BuildID == 202) {
            $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>";
            // Vitesse rééquipée
            $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['consumption2']) . ")</font>";
            // Consommation apres rééquipement
        } elseif ($BuildID == 211) {
            $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>";
            // Vitesse rééquipée
        }
    } elseif ($BuildID >= 401 && $BuildID <= 408) {
        // Defenses
        $PageTPL = gettemplate('info_buildings_defense');
        $parse['element_typ'] = $lang['tech'][400];
        $parse['rf_info_to'] = ShowRapidFireTo($BuildID);
        // Rapid Fire vers
        $parse['rf_info_fr'] = ShowRapidFireFrom($BuildID);
        // Rapid Fire de
        $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
        // Points de Structure
        $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
        // Points de Bouclier
        $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
        // Points d'Attaque
    } elseif ($BuildID >= 502 && $BuildID <= 503) {
        // Misilles
        $PageTPL = gettemplate('info_buildings_defense');
        $parse['element_typ'] = $lang['tech'][400];
        $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
        // Points de Structure
        $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
        // Points de Bouclier
        $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
        // Points d'Attaque
    } elseif ($BuildID >= 601 && $BuildID <= 615) {
        // Officiers
        $PageTPL = gettemplate('info_officiers_general');
    }
    // ---- Tableau d'evolution
    if ($TableHeadTPL != '') {
        $parse['table_head'] = parsetemplate($TableHeadTPL, $lang);
        $parse['table_data'] = ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL);
    }
    // La page principale
    $page = parsetemplate($PageTPL, $parse);
    if ($GateTPL != '') {
        if ($CurrentPlanet[$resource[$BuildID]] > 0) {
            $RestString = GetNextJumpWaitTime($CurrentPlanet);
            $parse['gate_start_link'] = BuildPlanetAdressLink($CurrentPlanet);
            if ($RestString['value'] != 0) {
                $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true);
                $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>";
                $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false);
            } else {
                $parse['gate_time_script'] = "";
                $parse['gate_wait_time'] = "";
                $parse['gate_script_go'] = "";
            }
            $parse['gate_dest_moons'] = BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet);
            $parse['gate_fleet_rows'] = BuildFleetListRows($CurrentPlanet);
            $page .= parsetemplate($GateTPL, $parse);
        }
    }
    if ($DestroyTPL != '') {
        if ($CurrentPlanet[$resource[$BuildID]] > 0) {
            // ---- Destruction
            $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true);
            $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2;
            $parse['destroyurl'] = "buildings.php?cmd=destroy&building=" . $BuildID;
            // Non balisé les balises sont dans le tpl
            $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]];
            // Niveau du batiment a detruire
            $parse['nfo_metal'] = $lang['Metal'];
            $parse['nfo_crysta'] = $lang['Crystal'];
            $parse['nfo_deuter'] = $lang['Deuterium'];
            $parse['metal'] = pretty_number($NeededRessources['metal']);
            // Cout en metal de la destruction
            $parse['crystal'] = pretty_number($NeededRessources['crystal']);
            // Cout en cristal de la destruction
            $parse['deuterium'] = pretty_number($NeededRessources['deuterium']);
            // Cout en deuterium de la destruction
            $parse['destroytime'] = pretty_time($DestroyTime);
            // Durée de la destruction
            // L'insert de destruction
            $page .= parsetemplate($DestroyTPL, $parse);
        }
    }
    return $page;
}
 public function __construct()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.' . PHP_EXT;
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.' . PHP_EXT;
     $template = new template();
     $template->page_header();
     $template->page_topnav();
     $template->page_leftmenu();
     $template->page_planetmenu();
     $template->page_footer();
     if ($PLANET[$resource[31]] == 0) {
         $template->message($LNG['bd_lab_required']);
         exit;
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false;
     $PLANET[$resource[31] . '_inter'] = $this->CheckAndGetLabLevel($USER, $PLANET);
     $TheCommand = request_var('cmd', '');
     $Element = request_var('tech', 0);
     $PlanetRess = new ResourceUpdate();
     if ($USER['urlaubs_modus'] == 0 && !empty($TheCommand) && $bContinue) {
         switch ($TheCommand) {
             case 'cancel':
                 if (empty($USER['b_tech'])) {
                     break;
                 }
                 $costs = GetBuildingPrice($USER, $PLANET, $USER['b_tech_id']);
                 if ($PLANET['id'] == $USER['b_tech_planet']) {
                     $PLANET['metal'] += $costs['metal'];
                     $PLANET['crystal'] += $costs['crystal'];
                     $PLANET['deuterium'] += $costs['deuterium'];
                 } else {
                     $db->query("UPDATE " . PLANETS . " SET `metal` = `metal` + '" . $costs['metal'] . "', `crystal` = `crystal` + '" . $costs['crystal'] . "', `deuterium` = `deuterium` + '" . $costs['deuterium'] . "' WHERE `id` = '" . $USER['b_tech_planet'] . "';");
                 }
                 $USER['darkmatter'] += $costs['darkmatter'];
                 $USER['b_tech_id'] = 0;
                 $USER['b_tech'] = 0;
                 $USER['b_tech_planet'] = 0;
                 break;
             case 'search':
                 if (!empty($USER['b_tech']) || empty($Element) || !in_array($Element, $reslist['tech']) || $USER[$resource[$Element]] >= $pricelist[$Element]['max'] || !IsTechnologieAccessible($USER, $PLANET, $Element) || !IsElementBuyable($USER, $PLANET, $Element)) {
                     break;
                 }
                 $costs = GetBuildingPrice($USER, $PLANET, $Element);
                 $PLANET['metal'] -= $costs['metal'];
                 $PLANET['crystal'] -= $costs['crystal'];
                 $PLANET['deuterium'] -= $costs['deuterium'];
                 $USER['darkmatter'] -= $costs['darkmatter'];
                 $USER['b_tech_id'] = $Element;
                 $USER['b_tech'] = TIMESTAMP + GetBuildingTime($USER, $PLANET, $Element);
                 $USER['b_tech_planet'] = $PLANET['id'];
                 break;
         }
     }
     $PlanetRess->CalcResource();
     $PlanetRess->SavePlanetToDB();
     $ScriptInfo = array();
     foreach ($reslist['tech'] as $ID => $Element) {
         if (IsTechnologieAccessible($USER, $PLANET, $Element)) {
             $CanBeDone = IsElementBuyable($USER, $PLANET, $Element);
             if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) {
                 $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>";
             } elseif ($USER['b_tech_id'] == 0) {
                 $LevelToDo = 1 + $USER[$resource[$Element]];
                 if ($CanBeDone && $this->CheckLabSettingsInQueue($PLANET)) {
                     $TechnoLink = "<a href=\"game.php?page=buildings&amp;mode=research&amp;cmd=search&amp;tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>";
                 } else {
                     $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>";
                 }
             } else {
                 if ($USER['b_tech_id'] == $Element) {
                     if ($USER['b_tech_planet'] == $PLANET['id']) {
                         $template->loadscript('research.js');
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     } else {
                         $THEPLANET = $db->uniquequery("SELECT `name` FROM " . PLANETS . " WHERE `id` = '" . $USER['b_tech_planet'] . "';");
                         $template->loadscript('research.js');
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $THEPLANET['name'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     }
                     $TechnoLink = '<div id="research"></div>';
                 } else {
                     $TechnoLink = '<center>-</center>';
                 }
             }
             $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * ESPION . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * COMMANDANT . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink);
         }
     }
     $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time']));
     $template->show('buildings_research.tpl');
 }
Example #29
0
function ShowOverviewPage($CurrentUser, $CurrentPlanet)
{
    global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user, $resource;
    include_once $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx;
    include_once $xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx;
    $FlyingFleetsTable = new FlyingFleetsTable();
    $lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentPlanet['id_owner'] . "' AND `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type`='3'", 'planets', true);
    if (empty($lunarow)) {
        unset($lunarow);
    }
    CheckPlanetUsedFields($lunarow);
    $parse = $lang;
    $parse['planet_id'] = $CurrentPlanet['id'];
    $parse['planet_name'] = $CurrentPlanet['name'];
    $parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    $parse['galaxy_system'] = $CurrentPlanet['system'];
    $parse['galaxy_planet'] = $CurrentPlanet['planet'];
    $parse['dpath'] = $dpath;
    $parse['avatar'] = $user['avatar'];
    $online_users = doquery("SELECT COUNT(DISTINCT(id)) as `onlinenow` FROM {{table}} WHERE `onlinetime` > '" . (time() - 15 * 60) . "';", 'users', true);
    $parse['online_users'] = $online_users['onlinenow'];
    $QueryStat = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `stat_type` = '1'", "statpoints", true);
    $parse['puntos_defensa'] = pretty_number($QueryStat['defs_count']);
    $parse['puntos_edificios'] = pretty_number($QueryStat['build_points']);
    $parse['puntos_naves'] = pretty_number($QueryStat['fleet_count']);
    $parse['puntos_investigaciones'] = pretty_number($QueryStat['tech_count']);
    $StatRecord = doquery("SELECT `total_rank`,`total_points`,`defs_rank`,`build_rank`,`fleet_rank`,`tech_rank` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
    $parse['top_defensa'] = $StatRecord['defs_rank'];
    $parse['top_edificios'] = $StatRecord['build_rank'];
    $parse['top_naves'] = $StatRecord['fleet_rank'];
    $parse['top_investigaciones'] = $StatRecord['tech_rank'];
    $parse['top_total'] = $StatRecord['total_rank'];
    $parse['ally_name'] = $ally_name;
    $parse['ally_tag'] = $ally_tag;
    if ($Level > 0) {
        $parse['admin_link'] = "<tr><td><div align=\"center\"><a href=\"javascript:top.location.href='adm/index.php'\"> <font color=\"lime\">" . $lang['lm_administration'] . "</font></a></div></td></tr>";
    } else {
        $parse['admin_link'] = "";
    }
    switch ($_GET['mode']) {
        case 'renameplanet':
            if ($_POST['action'] == $lang['ov_planet_rename_action']) {
                $newname = mysql_escape_string(strip_tags(trim($_POST['newname'])));
                if (preg_match("/[^A-z0-9_\\- ]/", $newname) == 1) {
                    message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet", 2);
                }
                if ($newname != "") {
                    doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . $CurrentUser['current_planet'] . "' LIMIT 1;", "planets");
                }
            } elseif ($_POST['action'] == $lang['ov_abandon_planet']) {
                return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
            } elseif ($_POST['kolonieloeschen'] == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet']) {
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_owner = '{$user['id']}' AND fleet_start_galaxy='{$CurrentPlanet['galaxy']}' AND fleet_start_system='{$CurrentPlanet['system']}' AND fleet_start_planet='{$CurrentPlanet['planet']}'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $harabeyeri = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                $filokontrol = doquery("SELECT * FROM {{table}} WHERE fleet_target_owner = '{$user['id']}' AND fleet_end_galaxy='{$CurrentPlanet['galaxy']}' AND fleet_end_system='{$CurrentPlanet['system']}' AND fleet_end_planet='{$CurrentPlanet['planet']}'", 'fleets');
                while ($satir = mysql_fetch_array($filokontrol)) {
                    $kendifilo = $satir['fleet_owner'];
                    $digerfilo = $satir['fleet_target_owner'];
                    $gezoay = $satir['fleet_end_type'];
                    $mess = $satir['fleet_mess'];
                }
                if ($kendifilo > 0) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } elseif ($digerfilo > 0 && $mess < 1 && $gezoay != 2) {
                    message($lang['ov_abandon_planet_not_possible'], 'game.php?page=overview&mode=renameplanet');
                } else {
                    if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet']) {
                        doquery("UPDATE {{table}} SET `destruyed` = '" . (time() + 86400) . "' WHERE `id` = '" . mysql_real_escape_string($CurrentUser['current_planet']) . "' LIMIT 1;", 'planets');
                        doquery("UPDATE {{table}} SET `current_planet` = `id_planet` WHERE `id` = '" . mysql_real_escape_string($CurrentUser['id']) . "' LIMIT 1", "users");
                        doquery("DELETE FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = 3;", 'planets');
                        message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
                    } elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"]) {
                        message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
                    } else {
                        message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
                    }
                }
            }
            return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
            break;
        default:
            if ($StatRecord['total_points'] >= 0 && $StatRecord['total_points'] < 100000) {
                $parse['rankgame'] = "Soldado";
                $parse['rankimg'] = "rank1.gif";
            } elseif ($StatRecord['total_points'] >= 100000 && $StatRecord['total_points'] < 250000) {
                $parse['rankgame'] = "Cabo Cazador";
                $parse['rankimg'] = "rank2.gif";
            } elseif ($StatRecord['total_points'] >= 250000 && $StatRecord['total_points'] < 500000) {
                $parse['rankgame'] = "Sargento Cazador";
                $parse['rankimg'] = "rank3.gif";
            } elseif ($StatRecord['total_points'] >= 500000 && $StatRecord['total_points'] < 1000000) {
                $parse['rankgame'] = "Teniente de Crucero";
                $parse['rankimg'] = "rank4.gif";
            } elseif ($StatRecord['total_points'] >= 1000000 && $StatRecord['total_points'] < 2500000) {
                $parse['rankgame'] = "Capitán Destructor";
                $parse['rankimg'] = "rank5.gif";
            } elseif ($StatRecord['total_points'] >= 2500000 && $StatRecord['total_points'] < 5000000) {
                $parse['rankgame'] = "Almirante Acorazado";
                $parse['rankimg'] = "rank6.gif";
            } elseif ($StatRecord['total_points'] >= 5000000 && $StatRecord['total_points'] < 10000000) {
                $parse['rankgame'] = "General Estrella";
                $parse['rankimg'] = "rank7.gif";
            } elseif ($StatRecord['total_points'] >= 10000000 && $StatRecord['total_points'] < 25000000) {
                $parse['rankgame'] = "General Supernova";
                $parse['rankimg'] = "rank8.gif";
            } elseif ($StatRecord['total_points'] >= 25000000 && $StatRecord['total_points'] < 50000000) {
                $parse['rankgame'] = "General de Flota";
                $parse['rankimg'] = "rank9.gif";
            } elseif ($StatRecord['total_points'] >= 50000000 && $StatRecord['total_points'] < 100000000) {
                $parse['rankgame'] = "General Interestelar";
                $parse['rankimg'] = "rank10.gif";
            } elseif ($StatRecord['total_points'] >= 100000000 && $StatRecord['total_points'] < 500000000) {
                $parse['rankgame'] = "Cónsul General";
                $parse['rankimg'] = "rank11.gif";
            } elseif ($StatRecord['total_points'] >= 500000000) {
                $parse['rankgame'] = "Emperador";
                $parse['rankimg'] = "rank12.gif";
            }
            if ($CurrentPlanet['planet'] >= 1 && $CurrentPlanet['planet'] < 4) {
                $parse['type_of_planet'] = "Desertico";
            } elseif ($CurrentPlanet['planet'] >= 4 && $CurrentPlanet['planet'] < 7) {
                $parse['type_of_planet'] = "Jungla";
            } elseif ($CurrentPlanet['planet'] >= 7 && $CurrentPlanet['planet'] < 10) {
                $parse['type_of_planet'] = "Gaseoso";
            } elseif ($CurrentPlanet['planet'] >= 10 && $CurrentPlanet['planet'] < 13) {
                $parse['type_of_planet'] = "Acuatico";
            } elseif ($CurrentPlanet['planet'] >= 13) {
                $parse['type_of_planet'] = "Congelado";
            }
            $CONSULTA = doquery("SELECT metal,crystal,darkmatter FROM {{table}} WHERE galaxy = '" . $CurrentPlanet['galaxy'] . "' AND system = '" . $CurrentPlanet['system'] . "' AND planet = '" . $CurrentPlanet['planet'] . "'", "galaxy", true);
            $parse['metal_debris'] = pretty_number($CONSULTA['metal']);
            $parse['crystal_debris'] = pretty_number($CONSULTA['crystal']);
            $parse['darkmatter_debris'] = pretty_number($CONSULTA['darkmatter']);
            if ($CurrentPlanet['recycler'] != 0 && ($CONSULTA['metal'] != 0 || $CONSULTA['crystal'] != 0 || $CONSULTA['darkmatter'] != 0)) {
                $parse['get_link'] = " (<a href=\"game.php?page=galaxy&mode=8&g=" . $CurrentPlanet['galaxy'] . "&s=" . $CurrentPlanet['system'] . "&p=" . $CurrentPlanet['planet'] . "&t=2\">asdasd</a>)";
            } else {
                $parse['get_link'] = '';
            }
            if ($CurrentUser['new_message'] != 0) {
                $Have_new_message .= "<tr>";
                if ($CurrentUser['new_message'] == 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>" . $lang['ov_have_new_message'] . "</a></th>";
                } elseif ($CurrentUser['new_message'] > 1) {
                    $Have_new_message .= "<th colspan=4><a href=game.{$phpEx}?page=messages>";
                    $Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
                    $Have_new_message .= "</a></th>";
                }
                $Have_new_message .= "</tr>";
            }
            $OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 0;
            while ($FleetRow = mysql_fetch_array($OwnFleets)) {
                $Record++;
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $id = $FleetRow['fleet_id'];
                $EndTime = $FleetRow['fleet_end_time'];
                /////// // ### LUCKY , CODES ARE BELOW
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                //////
                $Label = "fs";
                if ($StartTime > time()) {
                    $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, true, $Label, $Record);
                }
                if ($FleetRow['fleet_mission'] != 4 && $FleetRow['fleet_mission'] != 10) {
                    $Label = "ft";
                    if ($StayTime > time()) {
                        $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, true, $Label, $Record);
                    }
                    $Label = "fe";
                    if ($EndTime > time()) {
                        $fpage[$EndTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 2, true, $Label, $Record);
                    }
                }
            }
            mysql_free_result($OwnFleets);
            //iss ye katilan filo////////////////////////////////////
            // ### LUCKY , CODES ARE BELOW
            $dostfilo = doquery("SELECT * FROM {{table}} WHERE `fleet_end_galaxy` = '" . $hedefgalaksi . "' AND `fleet_end_system` = '" . $hedefsistem . "' AND `fleet_end_planet` = '" . $hedefgezegen . "' AND `fleet_group` = '" . $filogrubu . "';", 'fleets');
            $Record1 = 0;
            while ($FleetRow = mysql_fetch_array($dostfilo)) {
                $StartTime = $FleetRow['fleet_start_time'];
                $StayTime = $FleetRow['fleet_end_stay'];
                $id = $FleetRow['fleet_id'];
                $EndTime = $FleetRow['fleet_end_time'];
                ///////
                $hedefgalaksi = $FleetRow['fleet_end_galaxy'];
                $hedefsistem = $FleetRow['fleet_end_system'];
                $hedefgezegen = $FleetRow['fleet_end_planet'];
                $mess = $FleetRow['fleet_mess'];
                $filogrubu = $FleetRow['fleet_group'];
                $id = $FleetRow['fleet_id'];
                ///////
                if ($FleetRow['fleet_mission'] == 2 && $FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    $Record1++;
                    // if (($FleetRow['fleet_mission'] == 2) ){
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record1);
                    }
                    // }
                }
                ///""
                if ($FleetRow['fleet_mission'] == 1 && $FleetRow['fleet_owner'] != $CurrentUser['id'] && $filogrubu > 0) {
                    $Record++;
                    if ($mess > 0) {
                        $StartTime = "";
                    } else {
                        $StartTime = $FleetRow['fleet_start_time'];
                    }
                    if ($StartTime > time()) {
                        $Label = "ofs";
                        $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                    }
                }
            }
            mysql_free_result($dostfilo);
            //
            //////////////////////////////////////////////////
            $OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
            $Record = 2000;
            while ($FleetRow = mysql_fetch_array($OtherFleets)) {
                if ($FleetRow['fleet_owner'] != $CurrentUser['id']) {
                    if ($FleetRow['fleet_mission'] != 8) {
                        $Record++;
                        $StartTime = $FleetRow['fleet_start_time'];
                        $StayTime = $FleetRow['fleet_end_stay'];
                        if ($StartTime > time()) {
                            $Label = "ofs";
                            $fpage[$StartTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 0, false, $Label, $Record);
                        }
                        if ($FleetRow['fleet_mission'] == 5) {
                            $Label = "oft";
                            if ($StayTime > time()) {
                                $fpage[$StayTime . $id] = $FlyingFleetsTable->BuildFleetEventTable($FleetRow, 1, false, $Label, $Record);
                            }
                        }
                    }
                }
            }
            mysql_free_result($OtherFleets);
            $planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='{$CurrentUser['id']}' AND `destruyed` = 0", "planets");
            $Colone = 1;
            $AllPlanets = "<tr>";
            while ($CurrentUserPlanet = mysql_fetch_array($planets_query)) {
                if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3) {
                    $Coloneshow++;
                    $AllPlanets .= "<th width='80'>" . $CurrentUserPlanet['name'] . "<br>";
                    $AllPlanets .= "<a href=\"game.php?page=overview&cp=" . $CurrentUserPlanet['id'] . "&re=0\" title=\"" . $CurrentUserPlanet['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $CurrentUserPlanet['image'] . ".gif\" height=\"50\" width=\"50\"></a><br>";
                    $AllPlanets .= "<center>";
                    if ($CurrentUserPlanet['b_building'] != 0) {
                        UpdatePlanetBatimentQueueList($CurrentUserPlanet, $CurrentUser);
                        if ($CurrentUserPlanet['b_building'] != 0) {
                            $BuildQueue = $CurrentUserPlanet['b_building_id'];
                            $QueueArray = explode(";", $BuildQueue);
                            $CurrentBuild = explode(",", $QueueArray[0]);
                            $BuildElement = $CurrentBuild[0];
                            $BuildLevel = $CurrentBuild[1];
                            $BuildRestTime = pretty_time($CurrentBuild[3] - time());
                            $AllPlanets .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
                            $AllPlanets .= "<br><font color=\"#7f7f7f\">(" . $BuildRestTime . ")</font>";
                        } else {
                            CheckPlanetUsedFields($CurrentUserPlanet);
                            $AllPlanets .= $lang['ov_free'];
                        }
                    } else {
                        $AllPlanets .= $lang['ov_free'];
                    }
                    $AllPlanets .= "</center></th>";
                    if ($Colone <= 5) {
                        $Colone++;
                    } else {
                        $AllPlanets .= "</tr><tr>";
                        $Colone = 1;
                    }
                }
            }
            mysql_free_result($planets_query);
            $AllPlanets .= "</tr>";
            if ($game_config['OverviewNewsFrame'] == '1') {
                $parse['NewsFrame'] = "<tr>" . $lang['ov_news_title'] . "<th colspan=\"4\">" . stripslashes($game_config['OverviewNewsText']) . "</th></tr>";
            }
            if ($lunarow['id'] != 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3) {
                if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] != 0) {
                    $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '3'", 'planets', true);
                    $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $moon['image'] . ".png\" height=\"90\" width=\"90\"></a>";
                    $parse['moon'] = $moon['name'] . "";
                } else {
                    $parse['moon_img'] = "";
                    $parse['moon'] = "";
                }
            } elseif ($CurrentPlanet['planet_type'] == 3) {
                $moon = doquery("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '1'", 'planets', true);
                $parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/small/s_" . $moon['image'] . ".gif\" height=\"120\" width=\"120\"></a>";
                $parse['moon'] = $moon['name'] . "";
            } else {
                $parse['moon_img'] = "";
                $parse['moon'] = "";
            }
            $parse['planet_diameter'] = pretty_number($CurrentPlanet['diameter']);
            $parse['planet_field_current'] = $CurrentPlanet['field_current'];
            $parse['planet_field_max'] = CalculateMaxPlanetFields($CurrentPlanet);
            $parse['planet_temp_min'] = $CurrentPlanet['temp_min'];
            $parse['planet_temp_max'] = $CurrentPlanet['temp_max'];
            $StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
            $parse['user_username'] = $CurrentUser['username'];
            if (count($fpage) > 0) {
                ksort($fpage);
                foreach ($fpage as $time => $content) {
                    $flotten .= $content . "\n";
                }
            }
            // **** INICIA MOD {MOSTRAR TECNOLOGIA EN PROCESO EN VISTA GENERAL} ****
            if ($CurrentPlanet['b_building'] != 0) {
                include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                if ($CurrentPlanet['b_building'] != 0) {
                    $BuildQueue = explode(";", $CurrentPlanet['b_building_id']);
                    $CurrBuild = explode(",", $BuildQueue[0]);
                    $RestTime = $CurrentPlanet['b_building'] - time();
                    $PlanetID = $CurrentPlanet['id'];
                    $Build = InsertBuildListScript("buildings");
                    $Build .= "<table>";
                    $Build .= " <tr>";
                    $Build .= " <td colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</td>";
                    $Build .= " </tr>";
                    $Build .= " <tr>";
                    $Build .= " <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"></td>";
                    $Build .= " <td>" . $lang['pr_subiendo'] . " <span style=\"color:#FF8C00;\">Nivel " . $CurrBuild[1] . "</span><br />";
                    $Build .= " " . $lang['pr_duracion'] . ":<div id=\"blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                    $Build .= " </td>";
                    $Build .= " </tr>";
                    $Build .= "</Table>";
                    $Build .= "\n<script language=\"JavaScript\">";
                    $Build .= "\n pp = \"" . $RestTime . "\";\n";
                    $Build .= "\n pk = \"" . 1 . "\";\n";
                    $Build .= "\n pm = \"cancel\";\n";
                    $Build .= "\n pl = \"" . $PlanetID . "\";\n";
                    $Build .= "\n t();\n";
                    $Build .= "\n</script>\n";
                    $parse['building'] = $Build;
                } else {
                    $parse['building'] = $lang['ov_free'];
                }
            } else {
                $parse['building'] = $lang['ov_free'];
            }
            $PlanetaQueInv = doquery("SELECT id, name, b_tech, b_tech_id FROM `{{table}}` WHERE `id_owner` = '" . $CurrentUser['id'] . "' AND `b_tech` != '0';", 'planets', true);
            if ($PlanetaQueInv['b_tech'] != 0) {
                include $xgp_root . 'includes/functions/InsertTechListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $NvlActual = $CurrentUser[$resource[$PlanetaQueInv['b_tech_id']]] + 1;
                $RestTime = $PlanetaQueInv['b_tech'] - time();
                $PlanetID = $PlanetaQueInv['id'];
                $NomPlaneta = "";
                if ($PlanetaQueInv['name'] != $CurrentPlanet['name']) {
                    $NomPlaneta = " de " . $PlanetaQueInv['name'];
                }
                $Tech = InsertTechListScript("buildings", $NomPlaneta);
                $Tech .= "<table>";
                $Tech .= " <tr>";
                $Tech .= " <td colspan=\"2\">" . $lang['tech'][$PlanetaQueInv['b_tech_id']] . "</td>";
                $Tech .= " </tr>";
                $Tech .= " <tr>";
                $Tech .= " <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $PlanetaQueInv['b_tech_id'] . ".gif\" width=\"40\" height=\"40\"></td>";
                $Tech .= " <td>" . $lang['pr_investigando'] . " <span style=\"color:#FF8C00;\">Nivel " . $NvlActual . "</span><br />";
                $Tech .= " " . $lang['pr_duracion'] . ":<div id=\"tec_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Tech .= " </td>";
                $Tech .= " </tr>";
                $Tech .= "</Table>";
                $Tech .= "\n<script language=\"JavaScript\">";
                $Tech .= "\n tec_pp = \"" . $RestTime . "\";\n";
                $Tech .= "\n tec_pk = \"" . 1 . "\";\n";
                $Tech .= "\n tec_pm = \"cancel\";\n";
                $Tech .= "\n tec_pl = \"" . $PlanetaQueInv['b_tech_id'] . "\";\n";
                $Tech .= "\n tec_t();\n";
                $Tech .= "\n</script>\n";
                $parse['tech_en_proceso'] .= $Tech;
            } else {
                $parse['tech_en_proceso'] = $lang['ov_tfree'];
            }
            if ($CurrentPlanet['b_hangar'] != 0) {
                include $xgp_root . 'includes/functions/InsertHangarListScript.' . $phpEx;
                UpdatePlanetBatimentQueueList($planetrow, $user);
                $BuildQueue = explode(";", $CurrentPlanet['b_hangar_id']);
                $CurrBuild = explode(",", $BuildQueue[0]);
                $RealTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $CurrBuild[0]);
                $QueueTime = $RealTime * $CurrBuild[1];
                $RestTime = $QueueTime - $CurrentPlanet['b_hangar'];
                $PlanetID = $CurrentPlanet['id'];
                $Hangar = InsertHangarListScript("overview");
                $Hangar .= "<table>";
                $Hangar .= " <tr>";
                $Hangar .= " <td colspan=\"2\">" . $lang['tech'][$CurrBuild[0]] . "</td>";
                $Hangar .= " </tr>";
                $Hangar .= " <tr>";
                $Hangar .= " <td align=\"center\" valign=\"middle\"><img src=\"" . $dpath . "gebaeude/" . $CurrBuild[0] . ".gif\" width=\"40\" height=\"40\"><br />";
                $Hangar .= " </td>";
                $Hangar .= " <td>" . $lang['pr_tiempo_prod'] . "<br />";
                $Hangar .= " <div id=\"han_blc\" class=\"z\" style=\"color:yellow;\">" . pretty_time($RestTime) . "</div>";
                $Hangar .= " </td>";
                $Hangar .= " </tr>";
                $Hangar .= "</Table>";
                $Hangar .= "\n<script language=\"JavaScript\">";
                $Hangar .= "\n han_pp = \"" . $RestTime . "\";\n";
                $Hangar .= "\n han_pk = \"" . 1 . "\";\n";
                $Hangar .= "\n han_pm = \"cancel\";\n";
                $Hangar .= "\n han_pl = \"" . $PlanetID . "\";\n";
                $Hangar .= "\n han_t();\n";
                $Hangar .= "\n</script>\n";
                $parse['hangar_en_proceso'] .= $Hangar;
            } else {
                $parse['hangar_en_proceso'] = $lang['ov_hree'];
            }
            $parse['overview_produccion'] = parsetemplate(gettemplate('overview/overview_produccion'), $parse);
            // **** FIN MOD {MOSTRAR TECNOLOGIA EN PROCESO EN VISTA GENERAL} ****
            $parse['fleet_list'] = $flotten;
            $parse['Have_new_message'] = $Have_new_message;
            $parse['planet_image'] = $CurrentPlanet['image'];
            $parse['anothers_planets'] = $AllPlanets;
            $parse["dpath"] = $dpath;
            if ($game_config['stat'] == 0) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } elseif ($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level']) {
                $parse['user_rank'] = pretty_number($StatRecord['total_points']) . " (" . $lang['ov_place'] . " <a href=\"game.php?page=statistics&range=" . $StatRecord['total_rank'] . "\">" . $StatRecord['total_rank'] . "</a> " . $lang['ov_of'] . " " . $game_config['users_amount'] . ")";
            } else {
                $parse['user_rank'] = "-";
            }
            setlocale(LC_ALL, 'es_ES');
            $parse['date_time'] = date("D M j H:i:s", time());
            if ($Level > 0) {
                $parse['admin_link'] = "<tr><td><div align=\"center\"><a href=\"javascript:top.location.href='adm/index.php'\"> <font color=\"lime\">" . $lang['lm_administration'] . "</font></a></div></td></tr>";
            } else {
                $parse['admin_link'] = "";
            }
            if ($user["new_message"] != 0) {
                $color = "color=\"red\"";
            } else {
                $color = "color=\"white\"";
            }
            $parse["new_message"] = ' (<font size="1px" ' . $color . ' > ' . $user["new_message"] . ' </font>)';
            return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
            break;
    }
}
 public function __construct()
 {
     global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php';
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.php';
     $TheCommand = request_var('cmd', '');
     $Element = request_var('building', 0);
     $ListID = request_var('listid', 0);
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     if (!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']])) || $TheCommand == "cancel" || $TheCommand == "remove") {
         if ($Element == 31 && $USER["b_tech_planet"] != 0 || ($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) {
             $TheCommand = '';
         }
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue($PlanetRess);
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID, $PlanetRess);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
     }
     $PlanetRess->SavePlanetToDB();
     $Queue = $this->ShowBuildingQueue();
     $template = new template();
     $CanBuildElement = count($Queue) < MAX_BUILDING_QUEUE_SIZE ? true : false;
     $BuildingPage = "";
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET["field_current"] < $CurrentMaxFields - count($Queue) ? true : false;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     foreach ($reslist['allow'][$PLANET['planet_type']] as $ID => $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, false);
         if (in_array($Element, $reslist['prod'])) {
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1);
             $BuildLevel += 1;
             $Prod = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1);
             $EnergyNeed = $Prod - $Need;
         } else {
             unset($EnergyNeed);
         }
         $parse['click'] = '';
         $NextBuildLevel = $PLANET[$resource[$Element]] + 1;
         if ($RoomIsOk && $CanBuildElement) {
             $parse['click'] = $HaveRessources == true ? "<a href=\"game.php?page=buildings&amp;cmd=insert&amp;building=" . $Element . "\"><span style=\"color:#00FF00\">" . ($PLANET['b_building'] != 0 ? $LNG['bd_add_to_list'] : ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)) . "</span></a>" : "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>";
         } elseif ($RoomIsOk && !$CanBuildElement) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>";
         } else {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_no_more_fields'] . "</span>";
         }
         if (($Element == 6 || $Element == 31) && $USER['b_tech'] > TIMESTAMP) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>";
         } elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>";
         }
         $BuildInfoList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'level' => $PLANET[$resource[$Element]], 'destroyress' => array_map('pretty_number', GetBuildingPrice($USER, $PLANET, $Element, true, true)), 'destroytime' => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)), 'price' => GetElementPrice($USER, $PLANET, $Element, true), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'EnergyNeed' => isset($EnergyNeed) ? sprintf($EnergyNeed < 0 ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'], pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "", 'BuildLink' => $parse['click'], 'restprice' => $this->GetRestPrice($Element));
     }
     if ($PLANET['b_building'] != 0) {
         $template->execscript('ReBuildView();Buildlist();');
         $template->loadscript('buildlist.js');
         $template->assign_vars(array('data' => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue))));
     }
     $template->assign_vars(array('BuildInfoList' => $BuildInfoList, 'bd_lvl' => $LNG['bd_lvl'], 'bd_next_level' => $LNG['bd_next_level'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'bd_dismantle' => $LNG['bd_dismantle'], 'fgf_time' => $LNG['fgf_time'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_jump_gate_action' => $LNG['bd_jump_gate_action'], 'bd_price_for_destroy' => $LNG['bd_price_for_destroy'], 'bd_destroy_time' => $LNG['bd_destroy_time']));
     $template->show("buildings_overview.tpl");
 }