Ejemplo n.º 1
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']);
}
Ejemplo n.º 2
0
/**
 * BuildingPage.php
 *
 * @version 1.0
 * @copyright 2009 by MadnessRed for XNova Redesigned
 */
function BuildingPage($a = 0, $b = 0)
{
    global $lang, $resource, $reslist, $pricelist, $dpath, $game_config, $_GET, $user, $planetrow;
    CheckPlanetUsedFields($planetrow);
    if (!$_GET['page']) {
        return false;
        die;
    }
    // Tables des batiments possibles par type de planete
    if ($_GET['page'] == 'station') {
        $Allowed[1] = array(14, 15, 21, 31, 33, 34, 44);
        $Allowed[3] = array(14, 21, 34, 41, 42, 43);
    } elseif ($_GET['page'] == 'resources') {
        $Allowed[1] = array(1, 2, 3, 4, 12, 212, 22, 23, 24);
        $Allowed[3] = array(212, 22, 23, 24);
    } else {
        die("Hacking attempt");
    }
    //Right, lets see what he has an generate him an image.
    $imgnum = '';
    if ($planetrow[$resource[1]] > 0) {
        $imgnum .= "_1";
    }
    if ($planetrow[$resource[2]] > 0) {
        $imgnum .= "_2";
    }
    if ($planetrow[$resource[3]] > 0) {
        $imgnum .= "_3";
    }
    if ($planetrow[$resource[4]] > 0) {
        $imgnum .= "_4";
    }
    // 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[$planetrow['planet_type']])) {
                        $bDoItNow = true;
                    } else {
                        //$bThisIsCheated = true;
                        $bDoItNow = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    //Remove last queue item
                    RemoveFromQueue();
                    break;
                case 'remove':
                    //Remove a specific queue item
                    RemoveFromQueue($ListID);
                    break;
                case 'insert':
                    //Insert into the queue a build
                    $fields_rem = $planetrow['field_max'] - $planetrow['field_current'] + $planetrow[$resource[33]] * 5;
                    if ($fields_rem >= 0) {
                        AddToQueue($Element, 1);
                    } else {
                        echo $fields_rem . " < 0";
                        die("Hacking Attempt!");
                    }
                    break;
                case 'destroy':
                    //Add a deconstrction to the queue
                    AddToQueue($Element, -1);
                    break;
            }
            // switch
        } elseif ($bThisIsCheated == true) {
            //ResetThisFuckingCheater ( $user['id'] );
        }
        //If they want axah_section
        if ($_GET['axah_box']) {
            $q = ShowQueue(false);
            makeAXAH($q['buildlist']);
            die;
        }
    }
    $Queue = ShowQueue(true);
    // On enregistre ce que l'on a modifi� dans planet !
    BuildingSavePlanetRecord($planetrow);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($user);
    $max_qs = MAX_BUILDING_QUEUE_SIZE;
    if ($max_qs > 0) {
        //fine :)
    } else {
        $max_qs = 10;
    }
    if ($Queue['length'] < $max_qs) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    if ($_GET['page'] == 'station') {
        if ($planetrow['planet_type'] == 3) {
            $SubTemplate = gettemplate('buildings/station-moon_buttonz');
        } else {
            $SubTemplate = gettemplate('buildings/station_buttonz');
        }
    } elseif ($_GET['page'] == 'resources') {
        $SubTemplate = gettemplate('buildings/resources_buttonz');
    } else {
        die("Hacking attempt");
    }
    $parse = array();
    $infopg = array();
    foreach ($lang['names'] as $Element => $ElementName) {
        if (!$planetrow['planet_type']) {
            die("no planet type");
        }
        if (in_array($Element, $Allowed[$planetrow['planet_type']]) || $_GET['page'] == 'station') {
            if (@in_array($Element, $Allowed[$planetrow['planet_type']])) {
                if (!IsTechnologieAccessible($user, $planetrow, $Element)) {
                    $parse['state_' . $Element] = "off";
                    $parse['mes_' . $Element] = "Requirements are not met";
                    $parse['canbuild_' . $Element] = "";
                } elseif (!IsElementBuyable($user, $planetrow, $Element, true, false) && $Queue['length'] == 0) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Not enough resources!";
                    $parse['canbuild_' . $Element] = "";
                } elseif (!$CanBuildElement) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Queue is full!";
                    $parse['canbuild_' . $Element] = "";
                } else {
                    $parse['state_' . $Element] = "on";
                    $parse['mes_' . $Element] = "";
                    $parse['canbuild_' . $Element] = "\n\t\t\t\t\t\t<a class=\"fastBuild tips\" href=\"#\" onclick=\"loadpage('./?page=" . $_GET['page'] . "&cmd=insert&building={$Element}&id={$Element}',document.title,document.body.id);\">\n\t\t\t\t\t\t\t<img src=\"" . GAME_SKIN . "/img/layout/sofort_bauen.gif\" height=\"14\" width=\"22\">\n\t\t\t\t\t\t</a>";
                }
            } else {
                $parse['state_' . $Element] = "off";
                $parse['mes_' . $Element] = "Not availble";
                $parse['canbuild_' . $Element] = "";
            }
            $parse['name_' . $Element] = $ElementName;
            $parse['count_' . $Element] = $planetrow[$resource[$Element]];
        }
    }
    //Countdowns
    if ($planetrow['b_building'] > 0) {
        $BuildQueue = explode(";", $planetrow['b_building_id']);
        $CurrBuild = explode(",", $BuildQueue[0]);
        $parse['countdown_' . $CurrBuild[0]] = "\n\t\t\t\t\t\t\t\t\t<div class=\"construction\">\n\n\t\t\t\t\t\t\t\t\t\t<div class=\"pusher\" style=\"height: 80px; margin-bottom: -80px;\">\n\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"time\" id=\"resource\">" . parsecountdown($planetrow['b_building']) . "</span>\n\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t</div>\n";
    }
    $BuildingPage = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['names'][$Element];
    // Faut il afficher la liste de construction ??
    if ($Queue['length'] > 0) {
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildList'] = "";
    }
    $de_planettype = PlanetType($planetrow['image']);
    $parse['type'] = $de_planettype['type'];
    if ($_GET['page'] == 'station') {
        $parse['bg'] = HEADER_CACHE . "station/" . $parse['type'] . ".png";
    } elseif ($_GET['page'] == 'resources') {
        if (url_exists(HEADER_CACHE . "resources/" . $parse['type'] . $imgnum . ".png")) {
            $parse['bg'] = HEADER_CACHE . "resources/" . $parse['type'] . $imgnum . ".png";
        } else {
            $parse['bg'] = HEADER_CACHE . "resources/default.png";
        }
    } else {
        die("Hacking attempt");
    }
    $parse['hideres'] = "display:none;";
    $parse['hidenorm'] = "";
    $parse['planetname'] = $planetrow['name'];
    if (!$Element) {
        if ($_GET['mode'] == "resources") {
            $parse['hideres'] = "";
            $parse['hidenorm'] = "display:none;";
        }
    } else {
        if (!is_array($Allowed[$planetrow['planet_type']])) {
            $message = $user['username'] . " (" . intval($user['id']) . ") does not have a propper planet_type, so \$Allowed[\$planetrow['planet_type']] was not an array, causing the error which is most likely directly below this.";
            trigger_error($message, E_USER_NOTICE);
        }
        if (in_array($Element, $Allowed[$planetrow['planet_type']])) {
            //Something else
            $HaveRessources = IsElementBuyable($user, $planetrow, $Element, true, false);
            $parse['i'] = $Element;
            $parse['dpath'] = $dpath;
            $BuildingLevel = $planetrow[$resource[$Element]];
            $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
            $parse['n'] = $ElementName;
            $parse['descriptions'] = $lang['res']['descriptions'][$Element];
            $ElementBuildTime = BuildingTime($Element, $BuildingLevel + 1, $planetrow);
            $parse['time'] = ShowBuildTime($ElementBuildTime);
            $parse['price'] = GetElementPrice($user, $planetrow, $Element);
            $parse['rest_price'] = GetRestPrice($user, $planetrow, $Element);
            $parse['click'] = '';
            $NextBuildLevel = $planetrow[$resource[$Element]] + 1;
            $CurrentMaxFields = CalculateMaxPlanetFields($planetrow);
            if ($planetrow["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if ($Element == 31) {
                // Sp�cial Laboratoire
                if ($user["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 (IsTechnologieAccessible($user, $planetrow, $Element)) {
                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=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                                $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            } else {
                                $parse['click'] = "<font color=#FF0000>4" . $lang['BuildFirstLevel'] . "</font>";
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                                $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                        $infopg['build_text'] = $lang['InBuildQueue'];
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>2" . $lang['BuildFirstLevel'] . "</font>";
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $parse['click'] = "<font color=#FF0000>1" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                    $infopg['build_text'] = $lang['NoMoreSpace'];
                }
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = "Improve";
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = "In queue";
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $planetrow[$resource[$Element]];
            if ($planetrow[$resource[$Element]] < 1) {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=destroy&id=" . $Element . "&building=" . $Element;
            $infopg['title'] = "Tear down";
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['sdesc'][$Element];
            $infopg['skin'] = $user['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            if ($infopg['cost_m'] > $planetrow['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $planetrow['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $planetrow['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
            if ($_GET['axah_section'] == '1') {
                makeAXAH($parse['info']);
                die;
            }
        }
    }
    $parse['planet_field_current'] = $planetrow["field_current"];
    $parse['planet_field_max'] = $planetrow['field_max'] + $planetrow[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $planetrow['field_current'];
    $parse['buttonz'] = $BuildingPage;
    $parse['BuildingsList'] = $BuildingPage;
    if ($_GET['page'] == 'station') {
        $page = parsetemplate(gettemplate('buildings/station'), $parse);
        $title = $lang['Facilities'];
    } elseif ($_GET['page'] == 'resources') {
        //Resources screen
        $parse['resources_section'] = BuildRessourcePage($user, $planetrow, $parse['hideres']);
        $page = parsetemplate(gettemplate('buildings/resources'), $parse);
        $title = $lang['Resources'];
    } else {
        die("Hacking attempt");
    }
    if ($_GET['axah']) {
        makeAXAH($page);
    } else {
        displaypage($page, $title);
    }
}
Ejemplo n.º 3
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']);
}
Ejemplo n.º 4
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']);
}
Ejemplo n.º 5
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function ProductionBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $pricelist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Tables des batiments possibles par type de planete
    $Allowed['1'] = array(1, 2, 3, 4, 12, 212, 22, 23, 24);
    $Allowed['3'] = array(212, 22, 23, 24);
    //Right, lets see what he has an generate him an image.
    $imgnum = '';
    if ($CurrentPlanet[$resource[1]] > 0) {
        $imgnum .= "_1";
    }
    if ($CurrentPlanet[$resource[2]] > 0) {
        $imgnum .= "_2";
    }
    if ($CurrentPlanet[$resource[3]] > 0) {
        $imgnum .= "_3";
    }
    if ($CurrentPlanet[$resource[4]] > 0) {
        $imgnum .= "_4";
    }
    // 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;
                        $bDoItNow = 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
                    $fields_rem = $CurrentPlanet['field_max'] - $CurrentPlanet['field_current'] + $CurrentPlanet[$resource[33]] * 5;
                    if ($fields_rem >= 0) {
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    } else {
                        echo $fields_rem . " < 0";
                        die("Hacking Attempt!");
                    }
                    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� dans planet !
    BuildingSavePlanetRecord($CurrentPlanet);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($CurrentUser);
    $max_qs = MAX_BUILDING_QUEUE_SIZE;
    if ($max_qs > 0) {
        //fine :)
    } else {
        $max_qs = 10;
    }
    if ($Queue['lenght'] < $max_qs) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_res_buttonz');
    $parse = array();
    $infopg = array();
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[1])) {
            if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
                if (!IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    $parse['state_' . $Element] = "off";
                    $parse['mes_' . $Element] = "Requirements are not met";
                } elseif (!IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false)) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Not enough resources!";
                } else {
                    $parse['state_' . $Element] = "on";
                    $parse['mes_' . $Element] = "";
                }
            } else {
                $parse['state_' . $Element] = "off";
                $parse['mes_' . $Element] = "Not availble";
            }
            $parse['name_' . $Element] = $ElementName;
            $parse['count_' . $Element] = $CurrentPlanet[$resource[$Element]];
        }
    }
    $BuildingPage = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['tech'][$Element];
    // Faut il afficher la liste de construction ??
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = '';
        //$parse['BuildListScript']  = InsertBuildListScript ( "buildings" );
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $de_planettype = PlanetType($CurrentPlanet['image']);
    $parse['type'] = $de_planettype['type'];
    $parse['bg'] = GAME_SKIN . "/img/header/resources/" . $parse['type'] . $imgnum . ".png";
    $parse['hideres'] = "display:none;";
    $parse['hidenorm'] = "";
    if (!$Element) {
        $parse['bg'] = GAME_SKIN . "/img/header/resources/" . $parse['type'] . $imgnum . ".png";
        if ($_GET['mode'] == "resources") {
            $parse['hideres'] = "";
            $parse['hidenorm'] = "display:none;";
            $parse['resources_section'] = BuildRessourcePage($CurrentUser, $CurrentPlanet);
        }
    } else {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            //Something else
            $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
            $parse['i'] = $Element;
            $parse['dpath'] = $dpath;
            $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'] = '';
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if ($Element == 31) {
                // Sp�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 (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                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=\"./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                                $infopg['build_link'] = "./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            } else {
                                $parse['click'] = "<font color=#FF0000>4" . $lang['BuildFirstLevel'] . "</font>";
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                                $infopg['build_link'] = "./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        $infopg['build_link'] = "./?page=resources&cmd=insert&building=" . $Element . "&id=" . $Element;
                        $infopg['build_text'] = $lang['InBuildQueue'];
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>2" . $lang['BuildFirstLevel'] . "</font>";
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $parse['click'] = "<font color=#FF0000>1" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                    $infopg['build_text'] = $lang['NoMoreSpace'];
                }
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //$parse['bg'] = GAME_SKIN."/img/header/resources/ice.png";
            $parse['gebaeude_inf'] = "<br /><blockquote style=\"margin-left: 15px; margin-right: 15px; filter:alpha(opacity=75); -moz-opacity:.75; opacity:.75; background-color: #000000;\">\r\n\t\t\t<div style=\"margin-left: 10px; margin-right: 10px;\">\r\n\t\t\t<table width=\"100%\"><tr>\r\n\t\t\t\t<td width=\"130\"><img src=\"" . $dpath . "/gebaeude/" . $parse['i'] . ".gif\" width=\"120\" border=\"0\" alt=\"" . $parse['n'] . "\" /></td>\r\n\t\t\t\t<td style=\"margin-left: 10px;\">\r\n\t\t\t\t<div style=\"text-align: center;\"><!--<a href=\"infos.php?gid=" . $parse['i'] . "\">-->" . $parse['n'] . "<!--</a>--></div>" . "<div style=\"text-align: left;\">" . $parse['nivel'] . "<br />" . $parse['descriptions'] . "<br /><br />" . $parse['price'] . $parse['time'] . $parse['rest_price'] . "<br /></div>" . "<div style=\"text-align: right;\">" . $parse['click'] . "</div>\r\n\t\t\t\t</td>\r\n\t\t\t</tr></table>\r\n\t\t\t</div>\r\n\t\t\t</blockquote>";
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = "Improve";
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = "In queue";
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $CurrentPlanet[$resource[$Element]];
            if ($CurrentPlanet[$resource[$Element]] < 1) {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=destroy&building=" . $Element;
            $infopg['title'] = "Tear down";
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['res']['descriptions'][$Element];
            $infopg['skin'] = $CurrentUser['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $CurrentPlanet[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $CurrentPlanet[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $CurrentPlanet[$resource[$Element]]));
            if ($infopg['cost_m'] > $CurrentPlanet['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $CurrentPlanet['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $CurrentPlanet['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
        }
    }
    $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['buttonz'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings/resources'), $parse);
    displaypage($page, $lang['Builds']);
}
Ejemplo n.º 6
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']);
}
Ejemplo n.º 7
0
function ResearchBuildingPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
{
    global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    $NoResearchMessage = "";
    $bContinue = true;
    if ($CurrentPlanet[$resource[31]] == 0) {
        message($lang['no_laboratory'], $lang['Research']);
    }
    if (!CheckLabSettingsInQueue($CurrentPlanet)) {
        $NoResearchMessage = $lang['labo_on_update'];
        $bContinue = false;
    }
    if (isset($_GET['cmd'])) {
        $TheCommand = $_GET['cmd'];
        $Techno = intval($_GET['tech']);
        if (is_numeric($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) {
                            $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Techno, true, $ForDestroy);
                            $CurrentPlanet['metal'] += $Needed['metal'];
                            $CurrentPlanet['crystal'] += $Needed['crystal'];
                            $CurrentPlanet['deuterium'] += $Needed['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 = "******";
                    $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);
                if (!$InResearch) {
                    $LevelToDo = 1 + $CurrentUser[$resource[$Tech]];
                    if ($CanBeDone) {
                        if (!CheckLabSettingsInQueue($CurrentPlanet)) {
                            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 {
                    if ($ThePlanet["b_tech_id"] == $Tech) {
                        $bloc = $lang;
                        if ($ThePlanet['id'] != $CurrentPlanet['id']) {
                            $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 {
                            $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>";
                    }
                }
                $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']);
}
Ejemplo n.º 8
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $user;
    CheckPlanetUsedFields($CurrentPlanet);
    PlanetResourceUpdate($CurrentUser, $CurrentPlanet, time());
    // Was gebaut werden darf in Abhängikeit zum gewählten Volk.
    switch ($user['volk']) {
        case "A":
            $Allowed['1'] = array(1, 2, 3, 11, 12, 14, 15, 21, 22, 23, 24, 25, 26, 27, 31, 33, 34, 44);
            $Allowed['3'] = array(4, 12, 14, 15, 21, 25, 26, 34, 41, 42, 43);
            break;
        case "B":
            $Allowed['1'] = array(1, 2, 3, 11, 12, 14, 15, 21, 22, 23, 24, 25, 26, 31, 33, 34, 44, 45);
            $Allowed['3'] = array(4, 12, 14, 15, 21, 25, 26, 34, 41, 42, 43);
            break;
        case "C":
            $Allowed['1'] = array(1, 2, 3, 11, 12, 14, 15, 21, 22, 23, 24, 25, 26, 31, 33, 34, 44, 46);
            $Allowed['3'] = array(4, 12, 14, 15, 21, 25, 26, 34, 41, 42, 43, 46);
            break;
    }
    //Werte auf null setzen
    $bThisIsCheated = 0;
    $bDoItNow = 0;
    $TheCommand = 0;
    $Element = 0;
    $ListID = 0;
    // 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 (!strchr($Element, ";")) {
                        if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                            $bDoItNow = true;
                        } else {
                            $bThisIsCheated = true;
                        }
                    } else {
                        $bThisIsCheated = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            $Element = abs($Element);
            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']);
        }
        sleep(1);
        // es wird 1 sekunde geschlafen
    }
    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 = "";
    $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['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;
                // show energy on BuildingPage
                //================================
                $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[11] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                if ($Element != 12) {
                    $ActualNeed = floor($Prod[11]);
                } 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[11] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05);
                if ($Element != 12) {
                    $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID]));
                    $bloc['build_prod_diff'] = colorNumber(pretty_number(floor($Prod[$BuildID] - $ActualProd)));
                    $bloc['build_need'] = colorNumber(pretty_number(floor($Prod[11])));
                    $EnergyNeed = colorNumber(pretty_number(floor($Prod[11] - $ActualNeed)));
                } else {
                    $bloc['build_prod'] = pretty_number(floor($Prod[11]));
                    $bloc['build_prod_diff'] = colorNumber(pretty_number(floor($Prod[11] - $ActualProd)));
                    $bloc['build_need'] = colorNumber(pretty_number(floor($Prod[3])));
                    $EnergyNeed = colorNumber(pretty_number(floor($Prod[3] - $ActualNeed)));
                }
                if ($Element >= 1 && $Element <= 4) {
                    $parse['build_need_diff'] = "(" . "<font color=#FF0000>" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                } elseif ($Element == 11 || $Element == 12) {
                    $parse['build_need_diff'] = "(" . "<font color=#00FF00>+" . $EnergyNeed . " " . $lang['Energy'] . "</font>" . ")";
                    $BuildLevel = 0;
                }
                //================================
                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 ($Element == 15) {
                    // Spezialgebäude Nanitenfabrik
                    if ($CurrentPlanet['robot_factory'] <= 9) {
                        // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                        $parse['click'] = "<font color=#FF0000>" . $lang['no Nani'] . "</font>";
                    }
                }
                if ($Element == 45) {
                    // Spezialgebäude Mondtransformer
                    if ($CurrentPlanet['mondtransformer'] == 1) {
                        // Es darf nur ein Mondtransformer pro Planet gebaut werden
                        $parse['click'] = "<font color=#FF0000>" . $lang['only_one_mondtransformer'] . "</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>";
                }
                if ($zaehler % 3 == 0) {
                    $parse['trclose'] = '</tr>';
                    $zaehler++;
                } else {
                    $parse['trclose'] = '';
                    $zaehler++;
                }
                $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'];
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
Ejemplo n.º 9
0
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    $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 (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;
            }
        }
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    BuildingSavePlanetRecord($CurrentPlanet);
    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) {
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                } 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;
    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']);
}
Ejemplo n.º 10
0
/**
 * BatimentBuildingPage.php
 *
 * @version 1.1
 * @copyright 2008 by Chlorel for XNova
 */
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $reslist, $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'])) {
        // On passe une commande
        $bThisIsCheated = false;
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        if (isset($_GET['building'])) {
            //Wenn Variable gefüllt ist
            $Element = intval($_GET['building']);
            // Muss ne Zahl sein
            if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
                $bDoItNow = true;
                // Ist true wenns vorhanden ist und eine Zahl aus der Whitelist des jeweiligen Typs enthält.
            } else {
                $bThisIsCheated = true;
            }
        }
        if (isset($_GET['listid'])) {
            //Wenn Variable gefüllt ist...
            $ListID = intval($_GET['listid']);
            // Das hier muss ne Zahl sein
            $bDoItNow = true;
            // Und ist auch true wenn $ListID vorhanden ist
        }
        if ($bDoItNow == true) {
            // Wenn True dann mach hier weiter
            switch ($TheCommand) {
                case 'cancel':
                    // Bricht den aktuell laufenden Auftrag ab
                    CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
                    break;
                case 'remove':
                    // Entfernt ein wartendes Element aus der Bauschleife
                    RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
                    break;
                case 'insert':
                    // Fügt ein Element zur Bauschleife hinzu
                    if ($Element == 31) {
                        if ($CurrentUser["b_tech_planet"] == 0 || $game_config['BuildLabWhileRun'] == 1) {
                            AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                        }
                    } else {
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
                    }
                    break;
                case 'destroy':
                    // Baut ein Gebäude eine Stufe ab
                    if ($Element == 31) {
                        if ($CurrentUser["b_tech_planet"] == 0 || $game_config['BuildLabWhileRun'] == 1) {
                            AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                        }
                    } else {
                        AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
                    }
                    break;
                default:
                    break;
            }
        }
        header('Location: ?action=internalBuildings');
        //Nach nem Klick Weiterleitung auf die Bauseite um Doppelklicke zu vermeiden
    }
    SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    $Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    // Änderungen in den Planeten Rekorden übernehmen
    BuildingSavePlanetRecord($CurrentPlanet);
    // Änderungen in den Userrekorden übernehmen
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        //Solange noch Platz in der Bauischleife ist...
        $CanBuildElement = true;
        // ...kann man bauen
    } 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);
                $ElementBuildTimeWithoutTechs = GetBuildingTimeWithoutTechs($CurrentUser, $CurrentPlanet, $Element);
                //Bauzeiten parsen
                $parse['timewithouttechs'] = ShowBuildTimeWithoutTechs($ElementBuildTimeWithoutTechs);
                $parse['technobonus'] = ShowBuildTime($ElementBuildTimeWithoutTechs - $ElementBuildTime);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                //Sprachvariablen für die Bauzeit laden
                $parse['BuildingTime'] = $lang['BuildingTime'];
                $parse['NeededRess'] = $lang['NeededRess'];
                $parse['ConstructionTimeWithoutTechs'] = $lang['ConstructionTimeWithoutTechs'];
                $parse['TechBonus'] = $lang['TechBonus'];
                $parse['ConstructionTime'] = $lang['ConstructionTime'];
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Sonderstatus fürs FOrschungslabor
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Config Einstellung die das Forschen während des Ausbaus erlaubt
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;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=\"?action=internalBuildings&amp;cmd=insert&amp;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=\"?action=internalBuildings&amp;cmd=insert&amp;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;
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("?action=internalBuildings");
        $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']);
}
Ejemplo n.º 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 ($CurrentUser['urlaubs_modus'] == 0) {
        if (isset($_GET['cmd'])) {
            $TheCommand = $_GET['cmd'];
            $Techno = ltrim($_GET['tech'], 0);
            //########Auto Ban Funktion v.1########
            //######Author = The_Revenge/Xire######
            //################BEGIN################
            if (preg_match('/\\D/', $Techno, $match)) {
                $user = doquery("SELECT * FROM {{table}} WHERE `id` ='{$CurrentUser['id']}';", "users");
                while ($usern = mysql_fetch_array($user)) {
                    $username = $usern['username'];
                    doquery("UPDATE {{table}} SET bana='1', banaday='{$bantime}' WHERE id='{$CurrentUser['id']}'", "users");
                    doquery("INSERT INTO {{table}} SET\r\n\t\t\t\t\t`who` = '{$username}',\r\n\t\t\t\t\t`theme`= '" . $lang['CHEATATTEMPT_TITLE'] . "',\r\n\t\t\t\t\t`who2` = '{$usern['id']}',\r\n\t\t\t\t\t`time` = '{$time}',\r\n\t\t\t\t\t`longer` = '{$bantime}',\r\n\t\t\t\t\t`author` = 'SYSTEM: R',\r\n\t\t\t\t\t`email` = 'n'", 'banned');
                }
                message($lang['CHEATATTEMPT'], $lang['CHEATATTEMPT_TITLE']);
                die;
            }
            //########Auto Ban Funktion v.1########
            //######Author = The_Revenge/Xire######
            //#################END#################
            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) {
                                $nedeed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Techno);
                                $CurrentPlanet['metal'] = $CurrentPlanet['metal'] + $nedeed['metal'];
                                $CurrentPlanet['crystal'] = $CurrentPlanet['crystal'] + $nedeed['crystal'];
                                $CurrentPlanet['deuterium'] = $CurrentPlanet['deuterium'] + $nedeed['deuterium'];
                                $WorkingPlanet['b_tech_id'] = 0;
                                $WorkingPlanet["b_tech"] = 0;
                                $CurrentUser['b_tech_planet'] = $WorkingPlanet["id"];
                                $UpdateData = 1;
                                $InResearch = false;
                            }
                            break;
                        case 'search':
                            if (!strchr($Techno, " ")) {
                                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 = 1;
                                    $InResearch = true;
                                }
                            }
                            break;
                    }
                    if ($UpdateData == 1) {
                        $QryUpdatePlanet = "UPDATE {{table}} SET ";
                        $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
                        $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
                        $QryUpdatePlanet .= "`metal` = '" . $CurrentPlanet['metal'] . "', ";
                        $QryUpdatePlanet .= "`crystal` = '" . $CurrentPlanet['crystal'] . "', ";
                        $QryUpdatePlanet .= "`deuterium` = '" . $CurrentPlanet['deuterium'] . "' ";
                        $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='#' onclick=\"document.location.replace('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"];
                            $TechnoLink = "<center>Wir zur Zeit auf Planet<br>" . $ThePlanet["name"] . " geforscht.</center>";
                        } 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']);
}
Ejemplo n.º 12
0
function ResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
{
    global $lang, $resource, $reslist, $pricelist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        $TheCommand = $_GET['cmd'];
        $Techno = idstring($_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) && !$InResearch) {
                            $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 = "******";
                    $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;
        }
    }
    $TechScrTPL = gettemplate('buildings_research_script');
    $SubTemplate = gettemplate('buildings/research_buttonz');
    $parse = array();
    $infopg = array();
    foreach ($lang['names'] as $Tech => $TechName) {
        if ($Tech > 105 && $Tech <= 199) {
            if (!IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
                $parse['state_' . $Tech] = "off";
                $parse['mes_' . $Tech] = "Requirements are not met";
            } elseif (!IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech)) {
                $parse['state_' . $Tech] = "disabled";
                $parse['mes_' . $Tech] = "Not enough resources!";
            } else {
                $parse['state_' . $Tech] = "on";
                $parse['mes_' . $Tech] = "";
            }
        } else {
            $parse['state_' . $Tech] = "off";
            $parse['mes_' . $Tech] = "Not availble";
        }
        $parse['name_' . $Tech] = $TechName;
        $parse['count_' . $Tech] = $CurrentUser[$resource[$Tech]];
    }
    //Anything currently building?
    if ($CurrentUser['b_tech_planet']) {
        $WorkingPlanet = doquery("SELECT `id`,`name`,`b_tech_id`,`b_tech` FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true);
        //Whats currently building
        $curbuild = $WorkingPlanet['b_tech_id'];
        $parse['countdown_' . $curbuild] = "\r\n\t\t\t\t\t\t\t\t\t\t<div class=\"pusher\" id=\"b_research" . $curbuild . "\" style=\"height:80px;margin-bottom:-80px;\">\n\r\n\t\t\t\t\t\t\t\t\t\t\t<a><span class=\"time\" id=\"test\" name=\"zeit\">" . parsecountdown($WorkingPlanet['b_tech']) . "</span></a>\n\r\n\t\t\t\t\t\t\t\t\t\t</div>\n";
    } else {
        $curbuild = 0;
    }
    $Buttonz = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['names'][$Element];
    $de_planettype = PlanetType($CurrentPlanet['image']);
    $parse['type'] = $de_planettype['type'];
    if ($Element) {
        if (in_array($Element, $reslist['tech'])) {
            /*
            $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);
            */
            $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element);
            $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'] = '';
            $buildlink = "./?page=research&cmd=search&id=" . $Element . "&tech=" . $Element;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                if ($NextBuildLevel == 1) {
                    if ($HaveRessources == true) {
                        $infopg['build_link'] = $buildlink;
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    }
                } else {
                    if ($HaveRessources == true) {
                        $infopg['build_link'] = $buildlink;
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    } else {
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                }
            } elseif ($InResearch) {
                $parse['click'] = "<font color=#FF0000>" . $lang['InResearch'] . "</font>";
                $infopg['build_text'] = $lang['InResearch'];
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = $lang['Improve'];
            } elseif ($InResearch) {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = $lang['InResearch'];
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $CurrentUser[$resource[$Element]];
            //Current research
            if ($curbuild == $Element) {
                $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=cancel&id=" . $Element . "&tech=" . $Element;
                if ($WorkingPlanet['id'] == $CurrentPlanet['id']) {
                    $infopg['title'] = "Cancel";
                } else {
                    //$infopg['title'] = "Cancel on ".$WorkingPlanet['name'];
                    $infopg['title'] = "Cancel";
                }
            } else {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['sdesc'][$Element];
            $infopg['skin'] = $CurrentUser['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            if ($infopg['cost_m'] > $CurrentPlanet['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $CurrentPlanet['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $CurrentPlanet['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
            if ($_GET['axah_section'] == '1') {
                makeAXAH($parse['info']);
                die;
            }
        }
    }
    $parse['buttonz'] = $Buttonz;
    $parse['planetname'] = $CurrentPlanet['name'];
    $page .= parsetemplate(gettemplate('buildings/research'), $parse);
    if ($_GET['axah']) {
        makeAXAH($page);
    } else {
        displaypage($page, $lang['Research']);
    }
}
Ejemplo n.º 13
0
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource, $dpath, $_POST;
    if (isset($_POST['fmenge'])) {
        //fmenge muss zum Bauen gefüllt sein
        $AddedInQueue = false;
        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) {
                if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                    //prüfen, ob die nötigen Techs vohanden sind
                    $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
                    //maximal baubare Schiffe herausfinden
                    if ($Count > $MaxElements) {
                        //wenn nicht genügend ress vorhanden sind
                        $Count = $MaxElements;
                        //wird die Anzahl der Schiffe entsprechend angepasst
                    }
                    $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 . ";";
                    }
                }
            }
        }
    }
    if ($CurrentPlanet[$resource[21]] == 0) {
        // Wenn es keine Raumschiffwerft auf dem Plani gibt...
        message($lang['need_hangar'], $lang['tech'][21]);
        //Dann gib nen Fehler aus
    }
    $TabIndex = 0;
    foreach ($lang['tech'] as $Element => $ElementName) {
        if ($Element > 201 && $Element <= 399) {
            //ID des Elements muss zwischen diesen beiden Werten liegen
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                //Wenn verfügbar
                $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>\n";
                $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\t\t\r\n\t\t\t\t\t<a href=\"javascript:void(0);\" onmouseover=\"return overlib('";
                //$PageTable .= ShowTechs ($user, $planetrow, $Element);
                $PageTable .= "', BGCOLOR, 'red', FGCOLOR, '#000000', TEXTCOLOR, 'white', WIDTH, '120');\" onmouseout=\"return nd();\">" . $lang['TechnicalData'] . "</a>\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n        \t\t\t<td class=\"linksohneborder\" width=\"100\">\r\n        \t\t\t<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>\r\n                \t</p>\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>";
                $PageTable .= "</tr>";
            }
        }
    }
    if ($CurrentPlanet['b_hangar_id'] != '') {
        $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet);
    }
    $parse = $lang;
    //die HTML Seite lieht nun in $PageTable
    $parse['buildlist'] = $PageTable;
    // Und die Liste der noch laufenden Elemente liegt in $BuildQueue;
    $parse['buildinglist'] = $BuildQueue;
    $page .= parsetemplate(gettemplate('buildings_fleet'), $parse);
    display($page, $lang['Fleet']);
}