/**
 * 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, 21, 22, 23, 24, 34, 41, 42, 43);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        check_urlaubmodus();
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        $Element = $_GET['building'];
        $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;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    // È¡Ïû
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    // ²ð³ý
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    // ½¨Á¢
                    AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    break;
                case 'destroy':
                    // ´Ý»Ù
                    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 . ")";
                $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) {
                    // Spcial 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'] = "<button onClick=\"this.disabled=true;location.href='?cmd=insert&building=" . $Element . "'\">" . $lang['BuildFirstLevel'] . "";
                            } else {
                                $parse['click'] = "<button style='color:red'>" . $lang['BuildFirstLevel'] . "</button>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<button onClick=\"this.disabled=true;location.href='?cmd=insert&building=" . $Element . "'\">" . $lang['BuildNextLevel'] . "<br>" . $lang['level'] . $NextBuildLevel . "</button>";
                            } else {
                                $parse['click'] = "<button style='color:red'>" . $lang['BuildNextLevel'] . "<br>" . $NextBuildLevel . "</button>";
                            }
                        }
                    } else {
                        $parse['click'] = "<button onClick=\"this.disabled=true;location.href='?cmd=insert&building=" . $Element . "'\">" . $lang['InBuildQueue'] . "</button>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<button style='color:red'>" . $lang['BuildFirstLevel'] . "</button>";
                    } else {
                        $parse['click'] = "<button style='color:red'>" . $lang['BuildNextLevel'] . "<br>" . $NextBuildLevel . "</button>";
                    }
                } else {
                    $parse['click'] = "<button style='color:red'>" . $lang['NoMoreSpace'] . "</button>";
                }
                $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']);
}
Exemple #2
0
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $phpEx, $dpath, $_POST;
    if (isset($_POST['fmenge'])) {
        check_urlaubmodus();
        // On vient de Cliquer ' Construire '
        // Et y a une liste de dolances
        $AddedInQueue = false;
        // Ici, on sait precisement ce qu'on aimerait bien construire ...
        foreach ($_POST['fmenge'] as $Element => $Count) {
            // Construction d'Element recupers 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 souhaits
            $Element = intval($Element);
            $Count = intval($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) {
                        $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 .= '<tr al><td class="c">外观</td><td class="c">描述</td><td class="c">数量</td></tr>';
    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>";
                // 图片和详细资料链接
                $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>";
                // 描述
                $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>";
                // 数量
                $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=6 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']);
}
Exemple #3
0
<?php

/**
 * floten1.php
 *
 * @version 1.0
 * @copyright 2008 by Chlorel for XNova
 */
define('INSIDE', true);
define('INSTALL', false);
$ugamela_root_path = './';
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
check_urlaubmodus();
includeLang('fleet');
$speed = array(10 => 100, 9 => 90, 8 => 80, 7 => 70, 6 => 60, 5 => 50, 4 => 40, 3 => 30, 2 => 20, 1 => 10);
$g = $_POST['galaxy'];
$s = $_POST['system'];
$p = $_POST['planet'];
$t = $_POST['planet_type'];
if (!$g) {
    $g = $planetrow['galaxy'];
}
if (!$s) {
    $s = $planetrow['system'];
}
if (!$p) {
    $p = $planetrow['planet'];
}
if (!$t) {
    $t = $planetrow['planet_type'];
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'])) {
        check_urlaubmodus();
        $TheCommand = $_GET['cmd'];
        $Techno = $_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['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'] . "';";
                    doquery($QryUpdatePlanet, 'planets');
                    $QryUpdateUser = "UPDATE {{table}} SET ";
                    $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 = "<button disabled>" . $lang['Rechercher'] . "</button>";
                            } else {
                                $TechnoLink = "<button disabled>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</button>";
                            }
                        } else {
                            //可以建造
                            //$TechnoLink  = "<a href=\"buildings.php?mode=research&cmd=search&tech=".$Tech."\">";
                            $TechnoLink = "<button onClick=\"this.disabled=true;location.href='buildings.php?mode=research&cmd=search&tech=" . $Tech . "';\">";
                            if ($LevelToDo == 1) {
                                $TechnoLink .= "" . $lang['Rechercher'] . "</button>";
                            } else {
                                $TechnoLink .= "" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</button>";
                            }
                            $TechnoLink .= "</a>";
                        }
                    } else {
                        if ($LevelToDo == 1) {
                            //不能建造
                            $TechnoLink = "<button disabled style='color:red'>" . $lang['Rechercher'] . "</button>";
                        } else {
                            $TechnoLink = "<button  style='color:red'>" . $lang['Rechercher'] . "<br>" . $lang['level'] . " " . $LevelToDo . "</button>";
                        }
                    }
                } 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']);
}
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $phpEx, $dpath, $_POST;
    if (isset($_POST['fmenge'])) {
        check_urlaubmodus();
        // 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 = "";
    //+ edit by sbdx 13:48 2008-6-10
    $PageTable .= '<tr al><td class="c">外观</td><td class="c">描述</td><td class="c">数量</td></tr>';
    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." . $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) {
                    $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=5 maxlength=6 value=0 tabindex=" . $TabIndex . ">";
                        $PageTable .= "</th>";
                    }
                } else {
                    $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;
    // fragmento de template
    $page .= parsetemplate(gettemplate('buildings_defense'), $parse);
    display($page, $lang['Defense']);
}