public function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $phpEx, $dpath, $_POST, $svn_root, $reslist, $displays; if ($CurrentPlanet[$resource[21]] == 0) { $displays->message($lang['bd_shipyard_required'], '', '', true); } include_once $svn_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $svn_root . 'includes/functions/GetElementPrice.' . $phpEx; $displays->assignContent("buildings/buildings_defense"); if (isset($_POST['fmenge'])) { $Missiles[502] = $CurrentPlanet[$resource[502]]; $Missiles[503] = $CurrentPlanet[$resource[503]]; $SiloSize = $CurrentPlanet[$resource[44]]; $MaxMissiles = $SiloSize * 10; $BuildQueue = $CurrentPlanet['b_hangar_id']; $BuildArray = explode(";", $BuildQueue); for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if ($ElmentArray[0] == 502) { $Missiles[502] += $ElmentArray[1]; } elseif ($ElmentArray[0] == 503) { $Missiles[503] += $ElmentArray[1]; } } foreach ($_POST['fmenge'] as $Element => $Count) { $Element = intval($Element); $Count = intval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE; $IsBuildpp = $CurrentPlanet[$resource[409]] >= 1 ? TRUE : FALSE; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $Count = 1; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $Count = 1; } if ($Element == 409 && !$IsBuildpp && $InQueue === FALSE) { $Count = 1; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $MaxElements = $this->GetMaxConstructibleElements($Element, $CurrentPlanet); if ($Element == 502 || $Element == 503) { $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; if ($Element == 502) { if ($Count > $MissilesSpace) { $Count = $MissilesSpace; } } else { if ($Count > floor($MissilesSpace / 2)) { $Count = floor($MissilesSpace / 2); } } if ($Count > $MaxElements) { $Count = $MaxElements; } $Missiles[$Element] += $Count; } else { if ($Count > $MaxElements) { $Count = $MaxElements; } } $Ressource = $this->GetElementRessources($Element, $Count); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } //$CurrentPlanet['b_hangar_id']=substr($CurrentPlanet['b_hangar_id'], 0, -1); header("location: ?page=buildings&mode=defense"); } $NotBuilding = true; if ($CurrentPlanet['b_building_id'] != '') { $CurrentQueue = explode(";", $CurrentPlanet['b_building_id']); foreach ($CurrentQueue as $a) { if ($i < 1) { $QueueArray = explode(",", $a); if ($QueueArray[0] == 21 || $QueueArray[0] == 15) { $NotCan = TRUE; } } $i++; } if ($NotCan) { $parse[message] = "<font color=\"red\">" . $lang['bd_building_shipyard'] . "</font>"; $NotBuilding = false; } } $TabIndex = 0; $fila = 1; foreach ($reslist['defense'] as $Element) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $displays->newblock("buildlist"); $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['bd_available'] . pretty_number($ElementCount) . ")"; $parserow["i"] = $Element; $parserow["dpath"] = $dpath; $parserow["count"] = $ElementNbre; $parserow["name"] = $lang['tech'][$Element]; $parserow["descripcion"] = $lang['res']['descriptions'][$Element]; $parserow["price"] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); $parserow["time"] = ShowBuildTime($BuildOneElementTime); if ($CanBuildOne) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE; $IsBuildpp = $CurrentPlanet[$resource[409]] >= 1 ? TRUE : FALSE; $BuildIt = TRUE; if ($Element == 407 || $Element == 408 || $Element == 409) { $BuildIt = false; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 409 && !$IsBuildpp && $InQueue === FALSE) { $BuildIt = TRUE; } } if (!$BuildIt) { $parserow["click"] = "<font color=\"red\">" . $lang['bd_protection_shield_only_one'] . "</font>"; } elseif ($NotBuilding) { $TabIndex++; $maxElement = $this->GetMaxConstructibleElements($Element, $CurrentPlanet); $parserow["click"] = "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=9 maxlength=9 value=0 tabindex=" . $TabIndex . ">\r\n\t\t\t\t\t\t\t\t<a href='javascript:' onclick=\"document.getElementsByName('fmenge[" . $Element . "]')[0].value = '{$maxElement}';\">Máx.</a>"; } } if ($fila % 3 == 0) { $parserow['cerrartr'] = "</tr><tr>"; } $fila++; foreach ($parserow as $key => $value) { $displays->assign($key, $value); } //$buildefense.=parsetemplate(gettemplate('buildings/buildings_defense_row'), $parserow); unset($parserow); } } if ($CurrentPlanet['b_hangar_id'] != '') { $this->ElementBuildListBox($CurrentUser, $CurrentPlanet); } $displays->gotoBlock("_ROOT"); if ($NotBuilding) { $parse['build_defenses'] = "<tr><td class=\"c\" colspan=\"3\" align=\"center\"><input type=\"submit\" value=\"" . $lang['bd_build_ships'] . "\"></td></tr>"; } foreach ($parse as $key => $value) { $displays->assign($key, $value); } $displays->display(); }
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $phpEx, $dpath, $_POST; if ($CurrentUser['urlaubs_modus'] == 0) { if (isset($_POST['fmenge'])) { // Es wurde 'Bauen' geklickt // Und hat auch eine Liste von [?] $AddedInQueue = false; // Gut, hier weiss man was und wieviel gebaut werden soll. foreach ($_POST['fmenge'] as $Element => $Count) { // Bau der Flotte auf der Flottenseite // ACHTUNG ! Die Warteschlange der Flotte und Verteidigung werden zusammen verarbeitet. // In fmenge, sollte man eine Tabelle der Elemente Baugrundstücke und der Anzahl der Elemente haben $Element = intval($Element); $Count = intval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { // Verified, wenn man die notwendige Technologie hat für den Bau des aktuellen Elements if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // Verified, hole maximal mögliche Anzahl $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); // Wenn nicht genügend Ressourcen vorhanden sind, wird eine Anpassung der Anzahl der Elemente vorgenommen if ($Count > $MaxElements) { $Count = $MaxElements; } $Ressource = GetElementRessources($Element, $Count); $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } } } // ------------------------------------------------------------------------------------------------------- // Wenn nix gebaut wird / werden kann if ($CurrentPlanet[$resource[21]] == 0) { // Veuillez avoir l'obligeance de construire le Chantier Spacial !! message($lang['need_hangar'], $lang['tech'][21]); } // ------------------------------------------------------------------------------------------------------- // Bau der Seite der Baustelle (denn wenn ich hier ... ist, dass ich alles, was Sie brauchen, um ... $TabIndex = 0; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 201 && $Element <= 399) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // Disponible à la construction // On regarde si on peut en acheter au moins 1 $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); // On regarde combien de temps il faut pour construire l'element $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); // Disponibilité actuelle $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")"; // Construction des 3 cases de la ligne d'un element dans la page d'achat ! // Début de ligne $PageTable .= "\n<tr>"; // Imagette + Link vers la page d'info $PageTable .= "<th class=l>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; // Description $PageTable .= "<td class=l>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; // On affiche le 'prix' avec eventuellement ce qui manque en ressource $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); // On affiche le temps de construction (c'est toujours tellement plus joli) $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; // Case nombre d'elements a construire $PageTable .= "<th class=k>"; // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie if ($CanBuildOne) { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=5 maxlength=8 value=0 tabindex=" . $TabIndex . ">"; } $PageTable .= "</th>"; // Fin de ligne (les 3 cases sont construites !! $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse = $lang; // La page se trouve dans $PageTable; $parse['buildlist'] = $PageTable; // Et la liste de constructions en cours dans $BuildQueue; $parse['buildinglist'] = $BuildQueue; $page .= parsetemplate(gettemplate('buildings_fleet'), $parse); display($page, $lang['Fleet']); }
/** * 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); } }
public function __construct($CurrentUser, $CurrentPlanet, $BuildID) { global $dpath, $lang, $resource, $pricelist, $reslist, $CombatCaps, $phpEx, $xgp_root; $GateTPL = ''; $DestroyTPL = ''; $TableHeadTPL = ''; $parse = $lang; $parse['dpath'] = $dpath; $parse['name'] = $lang['info'][$BuildID]['name']; $parse['image'] = $BuildID; $parse['description'] = $lang['info'][$BuildID]['description']; if (in_array($BuildID, $reslist['fleet']) or in_array($BuildID, $reslist['defense'])) { $parse['description'] .= "<br><br>" . GetElementPrice($CurrentUser, $CurrentPlanet, $BuildID, false); } elseif (!in_array($BuildID, $reslist['officier'])) { $parse['description'] .= "<br><br>" . GetElementPrice($CurrentUser, $CurrentPlanet, $BuildID, true); } if ($BuildID >= 1 && $BuildID <= 3 || $BuildID == 5) { $PageTPL = gettemplate('infos/info_buildings_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_p_hour}</td><td class=\"c\">{in_difference}</td><td class=\"c\">{in_used_energy}</td><td class=\"c\">{in_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID == 4) { $PageTPL = gettemplate('infos/info_buildings_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_energy}</td><td class=\"c\">{in_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th></tr>"; } elseif ($BuildID == 12) { $PageTPL = gettemplate('infos/info_buildings_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_prod_energy}</td><td class=\"c\">{in_difference}</td><td class=\"c\">{in_used_deuter}</td><td class=\"c\">{in_difference}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_prod} {build_gain}</th><th>{build_prod_diff}</th><th>{build_need}</th><th>{build_need_diff}</th></tr>"; } elseif ($BuildID >= 14 && $BuildID <= 32) { $PageTPL = gettemplate('infos/info_buildings_general'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 33) { $PageTPL = gettemplate('infos/info_buildings_general'); } elseif ($BuildID == 34) { $PageTPL = gettemplate('infos/info_buildings_general'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 44) { $PageTPL = gettemplate('infos/info_buildings_general'); $PageTPL .= $this->BuildDeleteMissilesForm($CurrentPlanet); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 41) { $PageTPL = gettemplate('infos/info_buildings_general'); } elseif ($BuildID == 42) { $PageTPL = gettemplate('infos/info_buildings_table'); $TableHeadTPL = "<tr><td class=\"c\">{in_level}</td><td class=\"c\">{in_range}</td></tr>"; $TableTPL = "<tr><th>{build_lvl}</th><th>{build_range}</th></tr>"; $DestroyTPL = gettemplate('infos/info_buildings_destroy'); } elseif ($BuildID == 43) { $PageTPL = gettemplate('infos/info_buildings_general'); $GateTPL = gettemplate('infos/info_gate_table'); $DestroyTPL = gettemplate('infos/info_buildings_destroy'); if ($_POST) { message($this->DoFleetJump($CurrentUser, $CurrentPlanet), "game.php?page=infos&gid=43", 2); } } elseif ($BuildID >= 106 && $BuildID <= 199) { $PageTPL = gettemplate('infos/info_buildings_general'); } elseif ($BuildID >= 202 && $BuildID <= 300) { $PageTPL = gettemplate('infos/info_buildings_fleet'); $parse['element_typ'] = $lang['tech'][200]; $parse['rf_info_to'] = $this->ShowRapidFireTo($BuildID); $parse['rf_info_fr'] = $this->ShowRapidFireFrom($BuildID); $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); $parse['capacity_pt'] = pretty_number($pricelist[$BuildID]['capacity']); $parse['base_speed'] = pretty_number($pricelist[$BuildID]['speed']); $parse['base_conso'] = pretty_number($pricelist[$BuildID]['consumption']); if ($BuildID == 202) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>"; $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['consumption2']) . ")</font>"; } elseif ($BuildID == 211) { $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>"; } } elseif ($BuildID >= 401 && $BuildID <= 500) { $PageTPL = gettemplate('infos/info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['rf_info_to'] = $this->ShowRapidFireTo($BuildID); $parse['rf_info_fr'] = $this->ShowRapidFireFrom($BuildID); $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); } elseif ($BuildID >= 502 && $BuildID <= 503) { $PageTPL = gettemplate('infos/info_buildings_defense'); $parse['element_typ'] = $lang['tech'][400]; $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']); $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']); $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']); } elseif ($BuildID >= 601 && $BuildID <= 700) { $PageTPL = gettemplate('infos/info_officiers_general'); } if ($TableHeadTPL != '') { $parse['table_head'] = parsetemplate($TableHeadTPL, $lang); $parse['table_data'] = $this->ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL); } $page = parsetemplate($PageTPL, $parse); if ($GateTPL != '') { if ($CurrentPlanet[$resource[$BuildID]] > 0) { $RestString = $this->GetNextJumpWaitTime($CurrentPlanet); $parse['gate_start_link'] = BuildPlanetAdressLink($CurrentPlanet); if ($RestString['value'] != 0) { include $xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx; $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true); $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>"; $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false); } else { $parse['gate_time_script'] = ""; $parse['gate_wait_time'] = ""; $parse['gate_script_go'] = ""; } $parse['gate_dest_moons'] = $this->BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet); $parse['gate_fleet_rows'] = $this->BuildFleetListRows($CurrentPlanet); $page .= parsetemplate($GateTPL, $parse); } } if ($DestroyTPL != '') { if ($CurrentPlanet[$resource[$BuildID]] > 0) { $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2; $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID; $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]]; $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; $parse['nfo_deuter'] = $lang['Deuterium']; $parse['nfo_tritium'] = $lang['Tritium']; $parse['metal'] = pretty_number($NeededRessources['metal']); $parse['crystal'] = pretty_number($NeededRessources['crystal']); $parse['deuterium'] = pretty_number($NeededRessources['deuterium']); $parse['tritium'] = pretty_number($NeededRessources['tritium']); $parse['destroytime'] = pretty_time($DestroyTime); $page .= parsetemplate($DestroyTPL, $parse); } } return display($page); }
public function ShowResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $db, $displays, $_GET; include_once $svn_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $svn_root . 'includes/functions/GetElementPrice.' . $phpEx; $displays->assignContent("buildings/buildings_research"); $NoResearchMessage = ""; $bContinue = true; if ($CurrentPlanet[$resource[31]] == 0) { $displays->message($lang['bd_lab_required'], '', '', true); } if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { $displays->assign('noresearch', $lang['bd_building_lab']); $bContinue = false; } if (isset($_GET['cmd']) && $bContinue) { $TheCommand = $_GET['cmd']; $Techno = intval($_GET['tech']); if (isset($Techno)) { if (!strstr($Techno, ",") && !strchr($Techno, " ") && !strchr($Techno, "+") && !strchr($Techno, "*") && !strchr($Techno, "~") && !strchr($Techno, "=") && !strchr($Techno, ";") && !strchr($Techno, "'") && !strchr($Techno, "#") && !strchr($Techno, "-") && !strchr($Techno, "_") && !strchr($Techno, "[") && !strchr($Techno, "]") && !strchr($Techno, ".") && !strchr($Techno, ":")) { if (in_array($Techno, $reslist['tech'])) { if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] += $costs['metal']; $WorkingPlanet['crystal'] += $costs['crystal']; $WorkingPlanet['deuterium'] += $costs['deuterium']; $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = 0; $UpdateData = true; $InResearch = false; } break; case 'search': if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = true; $InResearch = true; } break; } if ($UpdateData == true) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; $db->query($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; $db->query($QryUpdateUser, 'users'); } $CurrentPlanet = $WorkingPlanet; if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { die(header("location:game.php?page=buildings&mode=research")); } } else { $bContinue = false; } } $siguiente = 1; foreach ($reslist['tech'] as $Tech) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $displays->newblock("research"); $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; if ($Tech == 106) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_espion'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_espion'] * 5 . $lang['bd_spy'] . "</font></strong>"; } elseif ($Tech == 108) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_commandant'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_commandant'] * 3 . $lang['bd_commander'] . "</font></strong>"; } else { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . " )"; } $RowParse['tech_name'] = $lang['tech'][$Tech]; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = "Restantes " . $this->GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Tech . "\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } } else { if ($ThePlanet["b_tech_id"] == $Tech) { $displays->newblock("script"); if ($ThePlanet['id'] != $CurrentPlanet['id']) { $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = "de<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; } else { $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; } foreach ($bloc as $name => $trans) { $displays->assign($name, $trans); } } else { $TechnoLink = "<center>-</center>"; } } $displays->gotoBlock("research"); $RowParse['tech_link'] = $TechnoLink; if ($siguiente % 3 == 0) { $RowParse['cerrar'] = "</tr><tr>"; } $siguiente++; foreach ($RowParse as $name => $trans) { $displays->assign($name, $trans); } unset($RowParse, $TechnoLink); } } $displays->display("Investigación"); }
public function __construct() { global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php'; include_once ROOT_PATH . 'includes/functions/GetElementPrice.php'; $TheCommand = request_var('cmd', ''); $Element = request_var('building', 0); $ListID = request_var('listid', 0); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); if (!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']])) || $TheCommand == "cancel" || $TheCommand == "remove") { if ($Element == 31 && $USER["b_tech_planet"] != 0 || ($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) { $TheCommand = ''; } switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($PlanetRess); break; case 'remove': $this->RemoveBuildingFromQueue($ListID, $PlanetRess); break; case 'insert': $this->AddBuildingToQueue($Element, true); break; case 'destroy': $this->AddBuildingToQueue($Element, false); break; } } $PlanetRess->SavePlanetToDB(); $Queue = $this->ShowBuildingQueue(); $template = new template(); $CanBuildElement = count($Queue) < MAX_BUILDING_QUEUE_SIZE ? true : false; $BuildingPage = ""; $CurrentMaxFields = CalculateMaxPlanetFields($PLANET); $RoomIsOk = $PLANET["field_current"] < $CurrentMaxFields - count($Queue) ? true : false; $BuildEnergy = $USER[$resource[113]]; $BuildLevelFactor = 10; $BuildTemp = $PLANET['temp_max']; foreach ($reslist['allow'][$PLANET['planet_type']] as $ID => $Element) { if (!IsTechnologieAccessible($USER, $PLANET, $Element)) { continue; } $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, false); if (in_array($Element, $reslist['prod'])) { $BuildLevel = $PLANET[$resource[$Element]]; $Need = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1); $BuildLevel += 1; $Prod = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1); $EnergyNeed = $Prod - $Need; } else { unset($EnergyNeed); } $parse['click'] = ''; $NextBuildLevel = $PLANET[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { $parse['click'] = $HaveRessources == true ? "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><span style=\"color:#00FF00\">" . ($PLANET['b_building'] != 0 ? $LNG['bd_add_to_list'] : ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)) . "</span></a>" : "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>"; } elseif ($RoomIsOk && !$CanBuildElement) { $parse['click'] = "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>"; } else { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_no_more_fields'] . "</span>"; } if (($Element == 6 || $Element == 31) && $USER['b_tech'] > TIMESTAMP) { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>"; } elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) { $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>"; } $BuildInfoList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'level' => $PLANET[$resource[$Element]], 'destroyress' => array_map('pretty_number', GetBuildingPrice($USER, $PLANET, $Element, true, true)), 'destroytime' => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)), 'price' => GetElementPrice($USER, $PLANET, $Element, true), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'EnergyNeed' => isset($EnergyNeed) ? sprintf($EnergyNeed < 0 ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'], pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "", 'BuildLink' => $parse['click'], 'restprice' => $this->GetRestPrice($Element)); } if ($PLANET['b_building'] != 0) { $template->execscript('ReBuildView();Buildlist();'); $template->loadscript('buildlist.js'); $template->assign_vars(array('data' => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue)))); } $template->assign_vars(array('BuildInfoList' => $BuildInfoList, 'bd_lvl' => $LNG['bd_lvl'], 'bd_next_level' => $LNG['bd_next_level'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'bd_dismantle' => $LNG['bd_dismantle'], 'fgf_time' => $LNG['fgf_time'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_jump_gate_action' => $LNG['bd_jump_gate_action'], 'bd_price_for_destroy' => $LNG['bd_price_for_destroy'], 'bd_destroy_time' => $LNG['bd_destroy_time'])); $template->show("buildings_overview.tpl"); }
/** * This file is part of XNova:Legacies * * @license http://www.gnu.org/licenses/gpl-3.0.txt * @see http://www.xnova-ng.org/ * * Copyright (c) 2009-2010, XNova Support Team <http://www.xnova-ng.org> * All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * --> NOTICE <-- * This file is part of the core development branch, changing its contents will * make you unable to use the automatic updates manager. Please refer to the * documentation for further information about customizing XNova. * */ function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $dpath, $_POST; if (isset($_POST['fmenge'])) { // On vient de Cliquer ' Construire ' // Et y a une liste de doléances // Ici, on sait precisement ce qu'on aimerait bien construire ... // Gestion de la place disponible dans les silos ! $Missiles[502] = $CurrentPlanet[$resource[502]]; $Missiles[503] = $CurrentPlanet[$resource[503]]; $SiloSize = $CurrentPlanet[$resource[44]]; $MaxMissiles = $SiloSize * 10; // On prend les missiles deja dans la queue de fabrication aussi (ca aide) $BuildQueue = $CurrentPlanet['b_hangar_id']; $BuildArray = explode(";", $BuildQueue); for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if ($ElmentArray[502] != 0) { $Missiles[502] += $ElmentArray[502]; } elseif ($ElmentArray[503] != 0) { $Missiles[503] += $ElmentArray[503]; } } foreach ($_POST['fmenge'] as $Element => $Count) { // Construction d'Element recuperés sur la page de Flotte ... // ATTENTION ! La file d'attente Flotte est Commune a celle des Defenses // Dans fmenge, on devrait trouver un tableau des elements constructibles etdu nombre d'elements souhaités $Element = intval($Element); $Count = intval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { // Cas particulier (Petit Bouclier et Grand Bouclier // ne peuvent exister qu'une seule et unique fois $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false; if ($Element == 407 || $Element == 408) { if ($InQueue === false && !$IsBuild) { $Count = 1; } } // On verifie si on a les technologies necessaires a la construction de l'element if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // On verifie combien on sait faire de cet element au max $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); // Testons si on a de la place pour ces nouveaux missiles ! if ($Element == 502 || $Element == 503) { // Cas particulier des missiles $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; if ($Element == 502) { if ($Count > $MissilesSpace) { $Count = $MissilesSpace; } } else { if ($Count > floor($MissilesSpace / 2)) { $Count = floor($MissilesSpace / 2); } } if ($Count > $MaxElements) { $Count = $MaxElements; } $Missiles[$Element] += $Count; } else { // Si pas assez de ressources, on ajuste le nombre d'elements if ($Count > $MaxElements) { $Count = $MaxElements; } } $Ressource = GetElementRessources($Element, $Count); $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } } // ------------------------------------------------------------------------------------------------------- // S'il n'y a pas de Chantier ... if ($CurrentPlanet[$resource[21]] == 0) { // Veuillez avoir l'obligeance de construire le Chantier Spacial !! message($lang['need_hangar'], $lang['tech'][21]); } // ------------------------------------------------------------------------------------------------------- // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ... $TabIndex = 0; $PageTable = ""; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 400 && $Element <= 599) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // Disponible à la construction // On regarde si on peut en acheter au moins 1 $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); // On regarde combien de temps il faut pour construire l'element $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); // Disponibilité actuelle $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")"; // Construction des 3 cases de la ligne d'un element dans la page d'achat ! // Début de ligne $PageTable .= "\n<tr>"; // Imagette + Link vers la page d'info $PageTable .= "<th class=l>"; $PageTable .= "<a href=infos." . PHPEXT . "?gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; // Description $PageTable .= "<td class=l>"; $PageTable .= "<a href=infos." . PHPEXT . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; // On affiche le 'prix' avec eventuellement ce qui manque en ressource $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); // On affiche le temps de construction (c'est toujours tellement plus joli) $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; // Case nombre d'elements a construire $PageTable .= "<th class=k>"; // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie if ($CanBuildOne) { if ($Element == Legacies_Empire::ID_DEFENSE_SMALL_SHIELD_DOME || $Element == Legacies_Empire::ID_DEFENSE_LARGE_SHIELD_DOME) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuild = $CurrentPlanet[$resource[$Element]] >= 1 ? true : false; $BuildIt = $InQueue === false && !$IsBuild ? true : false; } else { $BuildIt = true; } if (!$BuildIt) { $PageTable .= "<font color=\"red\">" . $lang['only_one'] . "</font>"; } else { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=5 maxlength=5 value=0 tabindex=" . $TabIndex . ">"; $PageTable .= "</th>"; } } else { $PageTable .= $lang['no_enought_res'] . "</th>"; } // Fin de ligne (les 3 cases sont construites !! $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse = $lang; // La page se trouve dans $PageTable; $parse['buildlist'] = $PageTable; // Et la liste de constructions en cours dans $BuildQueue; $parse['buildinglist'] = $BuildQueue; // fragmento de template $page .= parsetemplate(gettemplate('buildings_defense'), $parse); display($page, $lang['Defense']); }
public function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $phpEx, $dpath, $_POST, $xgp_root; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; $parse = $lang; if (isset($_POST['fmenge'])) { $Missiles[502] = $CurrentPlanet[$resource[502]]; $Missiles[503] = $CurrentPlanet[$resource[503]]; $SiloSize = $CurrentPlanet[$resource[44]]; $MaxMissiles = $SiloSize * 10; $BuildQueue = $CurrentPlanet['b_hangar_id']; $BuildArray = explode(";", $BuildQueue); for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if ($ElmentArray[0] == 502) { $Missiles[502] += $ElmentArray[1]; } elseif ($ElmentArray[0] == 503) { $Missiles[503] += $ElmentArray[1]; } } foreach ($_POST['fmenge'] as $Element => $Count) { $Element = intval($Element); $Count = intval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE; $IsBuildpp = $CurrentPlanet[$resource[409]] >= 1 ? TRUE : FALSE; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $Count = 1; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $Count = 1; } if ($Element == 409 && !$IsBuildpp && $InQueue === FALSE) { $Count = 1; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $MaxElements = $this->GetMaxConstructibleElements($Element, $CurrentPlanet); if ($Element == 502 || $Element == 503) { $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; if ($Element == 502) { if ($Count > $MissilesSpace) { $Count = $MissilesSpace; } } else { if ($Count > floor($MissilesSpace / 2)) { $Count = floor($MissilesSpace / 2); } } if ($Count > $MaxElements) { $Count = $MaxElements; } $Missiles[$Element] += $Count; } else { if ($Count > $MaxElements) { $Count = $MaxElements; } } $Ressource = $this->GetElementRessources($Element, $Count); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } header("Location: game.php?page=buildings&mode=defense"); } if ($CurrentPlanet[$resource[21]] == 0) { message($lang['bd_shipyard_required'], '', '', true); } $NotBuilding = true; if ($CurrentPlanet['b_building_id'] != 0) { $CurrentQueue = $CurrentPlanet['b_building_id']; if (strpos($CurrentQueue, ";")) { // FIX BY LUCKY - IF THE SHIPYARD IS IN QUEUE THE USER CANT RESEARCH ANYTHING... $QueueArray = explode(";", $CurrentQueue); for ($i = 0; $i < MAX_BUILDING_QUEUE_SIZE; $i++) { $ListIDArray = explode(",", $QueueArray[$i]); $Element = $ListIDArray[0]; if ($Element == 21 or $Element == 14 or $Element == 15) { break; } } // END - FIX } else { $CurrentBuilding = $CurrentQueue; } if ($CurrentBuilding == 21 or $CurrentBuilding == 14 or $CurrentBuilding == 15 or ($Element == 21 or $Element == 14 or $Element == 15)) { $parse[message] = "<font color=\"red\">" . $lang['bd_building_shipyard'] . "</font>"; $NotBuilding = false; } } $TabIndex = 0; $PageTable = ""; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 400 && $Element <= 599) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['bd_available'] . pretty_number($ElementCount) . ")"; $PageTable .= "\n<tr>"; $PageTable .= "<th class=l>"; $PageTable .= "<a href=game." . $phpEx . "?page=infos&gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; $PageTable .= "<td class=l>"; $PageTable .= "<a href=game." . $phpEx . "?page=infos&gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; $PageTable .= "<th class=k>"; if ($CanBuildOne) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE; $IsBuildpp = $CurrentPlanet[$resource[409]] >= 1 ? TRUE : FALSE; $BuildIt = TRUE; if ($Element == 407 || $Element == 408 || $Element == 409) { $BuildIt = false; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 409 && !$IsBuildpp && $InQueue === FALSE) { $BuildIt = TRUE; } } if (!$BuildIt) { $PageTable .= "<font color=\"red\">" . $lang['bd_protection_shield_only_one'] . "</font>"; } elseif ($NotBuilding) { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=6 maxlength=6 value=0 tabindex=" . $TabIndex . ">"; $PageTable .= "</th>"; } if ($NotBuilding) { $parse[build_defenses] = "<tr><td class=\"c\" colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"" . $lang['bd_build_defenses'] . "\"></td></tr>"; } } else { $PageTable .= "</th>"; } $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= $this->ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse['buildlist'] = $PageTable; $parse['buildinglist'] = $BuildQueue; display(parsetemplate(gettemplate('buildings/buildings_defense'), $parse)); }
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']); }
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']); }
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser) { global $planetrow, $lang, $pricelist, $resource, $phpEx, $dpath, $_POST; if (isset($_GET[action])) { switch ($_GET[action]) { case "cancelqueue": $ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']); foreach ($ElementQueue as $ElementLine => $Element) { if ($Element != '') { $Element = explode(',', $Element); $ResourcesToUpd[metal] += floor($pricelist[$Element[0]][metal] * $Element[1]); $ResourcesToUpd[crystal] += floor($pricelist[$Element[0]][crystal] * $Element[1]); $ResourcesToUpd[deuterium] += floor($pricelist[$Element[0]][deuterium] * $Element[1]); $ResourcesToUpd[tachyon] += floor($pricelist[$Element[0]][tachyon] * $Element[1]); } } $SetRes = "UPDATE {{table}} SET "; $SetRes .= "`metal` = metal + '" . $ResourcesToUpd[metal] . "', "; $SetRes .= "`crystal` = crystal + '" . $ResourcesToUpd[crystal] . "', "; $SetRes .= "`deuterium` = deuterium + '" . $ResourcesToUpd[deuterium] . "', "; $SetRes .= "`tachyon` = tachyon + '" . $ResourcesToUpd[tachyon] . "', "; $SetRes .= "`b_hangar` = '', "; $SetRes .= "`b_hangar_id` = ''"; $SetRes .= " WHERE `id` = '" . $CurrentPlanet['id'] . "'"; doquery($SetRes, 'planets'); header("location: " . $_SERVER['PHP_SELF'] . "?mode=" . $_GET[mode]); exit; break; } } if (isset($_POST['fmenge'])) { $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)) { $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); if ($Count > $MaxElements) { $Count = $MaxElements; } $Ressource = GetElementRessources($Element, $Count); $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['tachyon'] -= $Ressource['tachyon']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } } if ($CurrentPlanet[$resource[21]] == 0) { message($lang['need_hangar'], $lang['tech'][21]); } $TabIndex = 0; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 201 && $Element <= 399) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")"; $PageTable .= "\n<tr>"; $PageTable .= "<th class=k>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; $PageTable .= "<td class=k>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; $PageTable .= "<th class=k>"; if ($CanBuildOne) { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=7 maxlength=7 value=0 tabindex=" . $TabIndex . ">"; } $PageTable .= "</th>"; $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse = $lang; $parse['buildlist'] = $PageTable; $parse['buildinglist'] = $BuildQueue; $page .= parsetemplate(gettemplate('buildings_fleet'), $parse); display($page, $lang['Fleet']); }
/** * 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&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=\"?action=internalBuildings&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=\"?action=internalBuildings&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("?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']); }
public function ShowBuildingsPage(&$CurrentPlanet, $CurrentUser) { global $ProdGrid, $lang, $resource, $reslist, $phpEx, $db, $svn_root, $displays; include_once $svn_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $svn_root . 'includes/functions/GetElementPrice.' . $phpEx; $displays->assignContent('buildings/buildings_building'); CheckPlanetUsedFields($CurrentPlanet); $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44, 45); $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43); if (isset($_GET['cmd'])) { $bDoItNow = false; $TheCommand = $_GET['cmd']; $Element = $_GET['building']; $ListID = $_GET['listid']; if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { unset($Element); } if (isset($Element)) { if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) { if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { $bDoItNow = true; } } else { header("location:game.php?page=buildings"); } } elseif (isset($ListID)) { $bDoItNow = true; } if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) { $bDoItNow = false; } if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) { $bDoItNow = false; } if ($bDoItNow == true) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser); break; case 'remove': $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID); break; case 'insert': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true); break; case 'destroy': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false); break; } header("location:game.php?page=buildings"); } } SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser); $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); $this->BuildingSavePlanetRecord($CurrentPlanet); if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) { $CanBuildElement = true; } else { $CanBuildElement = false; } $siguiente = 1; foreach ($reslist['build'] as $Element) { 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)) { $displays->newblock('build'); $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false); $parse['i'] = $Element; $BuildingLevel = $CurrentPlanet[$resource[$Element]]; $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")"; $parse['n'] = $lang['tech'][$Element]; $parse['descriptionss'] = $lang['res']['descriptions'][$Element]; $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $parse['time'] = ShowBuildTime($ElementBuildTime); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element); $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { if ($Queue['lenght'] == 0) { if ($NextBuildLevel == 1) { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } } else { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } } else { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>"; } } elseif ($RoomIsOk && !$CanBuildElement) { if ($NextBuildLevel == 1) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>"; } if ($siguiente % 3 == 0) { $parse['cerrar'] = "</tr><tr>"; } $siguiente++; if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } foreach ($parse as $name => $trans) { $displays->assign($name, $trans); } unset($parse); } } } if ($Queue['lenght'] > 0) { include $svn_root . 'includes/functions/InsertBuildListScript.' . $phpEx; $parse['BuildListScript'] = InsertBuildListScript("buildings"); $parse['BuildList'] = $Queue['buildlist']; $parse['ScriptList'] = $Queue['scriptlist']; } else { $parse['BuildListScript'] = ""; $parse['BuildList'] = ""; } $displays->gotoBlock("_ROOT"); $displays->assign("planet_field_current", $CurrentPlanet['field_current']); $displays->assign("planet_field_max", CalculateMaxPlanetFields($CurrentPlanet)); $displays->assign("BuildListScript", $parse['BuildListScript']); $displays->assign("BuildList", $Queue['buildlist']); $displays->assign("ScriptList", $Queue['scriptlist']); $displays->assign("time_time", time() * 1000); $displays->display('Construcciones'); }
public function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $phpEx, $dpath, $_POST, $xgp_root; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; $parse = $lang; //---Inicio cancelar cola de defensas---// if ($_GET['cancel'] == 'queue') { // Comprobacion de cola if ($CurrentPlanet['b_hangar_id'] == 0 or $CurrentPlanet['b_hangar_id'] == '') { message('Error<br>No hay ningun elemento en la cola', 'game.php?page=buildings&mode=defense', 3); } // Reconstruir $Queue = $CurrentPlanet['b_hangar_id']; $DO = explode(";", $Queue); $QueueCountColocation = 1; if (count($DO) > 1) { $QueueCountColocation = 2; } $COUNTD = count($DO) - $QueueCountColocation; // Devolver recursos $CASE = explode(",", $DO[$COUNTD]); $Ressource = $this->GetElementRessources($CASE[0], $CASE[1]); $Ressource['metal'] = $Ressource['metal'] / 100 * 75; $Ressource['crystal'] = $Ressource['crystal'] / 100 * 75; $Ressource['deuterium'] = $Ressource['deuterium'] / 100 * 75; $Ressource['darkmatter'] = $Ressource['darkmatter'] / 100 * 75; $CurrentPlanet['metal'] += $Ressource['metal']; $CurrentPlanet['crystal'] += $Ressource['crystal']; $CurrentPlanet['deuterium'] += $Ressource['deuterium']; $CurrentPlanet['darkmatter'] += $Ressource['darkmatter']; // POP Manual if (count($DO) > 1) { $LAST = $COUNTD; // Reconstruccion foreach ($DO as $ID => $CAD) { if ($ID != $LAST) { $NDO[$ID] = $CAD; } } // Grabar nuevos datos $REC = implode(";", $NDO); doquery("UPDATE {{table}} SET b_hangar_id = '" . $REC . "', metal = metal + " . $Ressource['metal'] . ", crystal = crystal + " . $Ressource['crystal'] . ", deuterium = deuterium + " . $Ressource['deuterium'] . ", darkmatter = darkmatter + " . $Ressource['darkmatter'] . " WHERE id = '" . $CurrentPlanet["id"] . "'", "planets"); } else { doquery("UPDATE {{table}} SET b_hangar = '', b_hangar_plus = '', b_hangar_id = '', metal = metal + " . $Ressource['metal'] . ", crystal = crystal + " . $Ressource['crystal'] . ", deuterium = deuterium + " . $Ressource['deuterium'] . ", darkmatter = darkmatter + " . $Ressource['darkmatter'] . " WHERE id = '" . $CurrentPlanet["id"] . "'", "planets"); } message('¡Cancelado!<br><a href=game.php?page=buildings&mode=fleet>Regresar</a>', 'game.php?page=buildings&mode=fleet', 3); } //---Fin cancelar cola de defensas---// if (isset($_POST['fmenge'])) { $Missiles[502] = $CurrentPlanet[$resource[502]]; $Missiles[503] = $CurrentPlanet[$resource[503]]; $SiloSize = $CurrentPlanet[$resource[44]]; $MaxMissiles = $SiloSize * 10; $BuildQueue = $CurrentPlanet['b_hangar_id']; $BuildArray = explode(";", $BuildQueue); for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if ($ElmentArray[0] == 502) { $Missiles[502] += $ElmentArray[1]; } elseif ($ElmentArray[0] == 503) { $Missiles[503] += $ElmentArray[1]; } } foreach ($_POST['fmenge'] as $Element => $Count) { $Element = floatval($Element); $Count = floatval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE; $IsBuildpp = $CurrentPlanet[$resource[409]] >= 1 ? TRUE : FALSE; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $Count = 1; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $Count = 1; } if ($Element == 409 && !$IsBuildpp && $InQueue === FALSE) { $Count = 1; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $MaxElements = $this->GetMaxConstructibleElements($Element, $CurrentPlanet); if ($Element == 502 || $Element == 503) { $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; if ($Element == 502) { if ($Count > $MissilesSpace) { $Count = $MissilesSpace; } } else { if ($Count > floor($MissilesSpace / 2)) { $Count = floor($MissilesSpace / 2); } } if ($Count > $MaxElements) { $Count = $MaxElements; } $Missiles[$Element] += $Count; } else { if ($Count > $MaxElements) { $Count = $MaxElements; } } $Ressource = $this->GetElementRessources($Element, $Count); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['darkmatter'] -= $Ressource['darkmatter']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } header("Location: game.php?page=buildings&mode=defense"); } if ($CurrentPlanet[$resource[21]] == 0) { message($lang['bd_shipyard_required'], '', '', true); } $NotBuilding = true; if ($CurrentPlanet['b_building_id'] != 0) { $CurrentQueue = $CurrentPlanet['b_building_id']; if (strpos($CurrentQueue, ";")) { // FIX BY LUCKY - IF THE SHIPYARD IS IN QUEUE THE USER CANT RESEARCH ANYTHING... $QueueArray = explode(";", $CurrentQueue); for ($i = 0; $i < MAX_BUILDING_QUEUE_SIZE; $i++) { $ListIDArray = explode(",", $QueueArray[$i]); $Element = $ListIDArray[0]; if ($Element == 21 or $Element == 14 or $Element == 15) { break; } } // END - FIX } else { $CurrentBuilding = $CurrentQueue; } if ($CurrentBuilding == 21 or $CurrentBuilding == 14 or $CurrentBuilding == 15 or ($Element == 21 or $Element == 14 or $Element == 15)) { $parse[message] = "<font color=\"red\">" . $lang['bd_building_shipyard'] . "</font>"; $NotBuilding = false; } } $TabIndex = 0; $PageTable = ""; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 400 && $Element <= 599) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['bd_available'] . pretty_number($ElementCount) . ")"; $PageTable .= "\n<tr>"; $PageTable .= "<th class=l>"; $PageTable .= "<a href=game." . $phpEx . "?page=infos&gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; $PageTable .= "<td class=l>"; $PageTable .= "<a href=game." . $phpEx . "?page=infos&gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; $PageTable .= "<th class=k>"; if ($CanBuildOne) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE; $IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE; $IsBuildpp = $CurrentPlanet[$resource[409]] >= 1 ? TRUE : FALSE; $BuildIt = TRUE; if ($Element == 407 || $Element == 408 || $Element == 409) { $BuildIt = false; if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) { $BuildIt = TRUE; } if ($Element == 409 && !$IsBuildpp && $InQueue === FALSE) { $BuildIt = TRUE; } } if (!$BuildIt) { $PageTable .= "<font color=\"red\">" . $lang['bd_protection_shield_only_one'] . "</font>"; } elseif ($NotBuilding) { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=18 maxlength=18 value=0 tabindex=" . $TabIndex . ">"; $maxElement = $this->GetMaxConstructibleElements($Element, $CurrentPlanet); $PageTable .= "<br><th><a href='javascript:' onclick=\"document.getElementsByName('fmenge[" . $Element . "]')[0].value = '{$maxElement}';\">Max.</a></th>"; $PageTable .= "</th>"; } if ($NotBuilding) { $parse[build_defenses] = "<tr><td class=\"c\" colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"" . $lang['bd_build_defenses'] . "\"></td></tr>"; } } else { $PageTable .= "</th>"; } $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= $this->ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse['buildlist'] = $PageTable; $parse['buildinglist'] = $BuildQueue; display(parsetemplate(gettemplate('buildings/buildings_defense'), $parse)); }
public function __construct() { global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist, $OfficerInfo; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php'; include_once ROOT_PATH . 'includes/functions/GetElementPrice.php'; $template = new template(); if ($PLANET[$resource[31]] == 0) { $template->message($LNG['bd_lab_required']); exit; } $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false; $TheCommand = request_var('cmd', ''); $Element = request_var('tech', 0); $ListID = request_var('listid', 0); $PlanetRess = new ResourceUpdate(); $PLANET[$resource[31] . '_inter'] = $PlanetRess->CheckAndGetLabLevel($USER, $PLANET); $PlanetRess->CalcResource(); if (!empty($Element) && $bContinue && $USER['urlaubs_modus'] == 0 && ($USER[$resource[$Element]] < $pricelist[$Element]['max'] && IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['tech'])) || $TheCommand == "cancel" || $TheCommand == "remove") { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($PlanetRess); break; case 'remove': $this->RemoveBuildingFromQueue($ListID, $PlanetRess); break; case 'insert': $this->AddBuildingToQueue($Element, true); break; case 'destroy': $this->AddBuildingToQueue($Element, false); break; } } $PlanetRess->SavePlanetToDB(); $ScriptInfo = array(); $TechQueue = $this->ShowTechQueue(); foreach ($reslist['tech'] as $ID => $Element) { if (!IsTechnologieAccessible($USER, $PLANET, $Element)) { continue; } $CanBeDone = IsElementBuyable($USER, $PLANET, $Element); if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) { $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>"; } elseif (MAX_RESEACH_QUEUE_SIZE > 1) { $LevelToDo = 1 + $USER[$resource[$Element]]; $TechnoLink = $CanBeDone && $bContinue ? "<a href=\"game.php?page=buildings&mode=research&cmd=insert&tech=" . $Element . "\"><font color=\"#00FF00\">" . ($USER['b_tech_id'] != 0 ? $LNG['bd_add_to_list'] : $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo)) . "</font></a>" : "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>"; if ($USER['b_tech_id'] != 0) { $template->loadscript('researchlist.js'); $template->execscript('ReBuildView();Techlist();'); $ScriptInfo = array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $TechQueue); } } else { if ($USER['b_tech_id'] == 0) { $LevelToDo = 1 + $USER[$resource[$Element]]; $TechnoLink = $CanBeDone && $bContinue ? "<a href=\"game.php?page=buildings&mode=research&cmd=insert&tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>" : "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>"; } else { if ($USER['b_tech_id'] == $Element) { $template->loadscript('research.js'); if ($USER['b_tech_planet'] == $PLANET['id']) { $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']); } else { $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $TechQueue['planet'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']); } $TechnoLink = '<div id="research"></div>'; } else { $TechnoLink = '<center>-</center>'; } } } $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * $OfficerInfo[610]['info'] . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * $OfficerInfo[611]['info'] . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink, 'oldlink' => MAX_RESEACH_QUEUE_SIZE == 1, 'queue' => $TechQueue); } $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time'])); $template->show('buildings_research.tpl'); }
/** * 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é 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 = ""; $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é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']); }
public function __construct() { global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.' . PHP_EXT; include_once ROOT_PATH . 'includes/functions/GetElementPrice.' . PHP_EXT; $template = new template(); $template->page_header(); $template->page_topnav(); $template->page_leftmenu(); $template->page_planetmenu(); $template->page_footer(); if ($PLANET[$resource[31]] == 0) { $template->message($LNG['bd_lab_required']); exit; } $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false; $PLANET[$resource[31] . '_inter'] = $this->CheckAndGetLabLevel($USER, $PLANET); $TheCommand = request_var('cmd', ''); $Element = request_var('tech', 0); $PlanetRess = new ResourceUpdate(); if ($USER['urlaubs_modus'] == 0 && !empty($TheCommand) && $bContinue) { switch ($TheCommand) { case 'cancel': if (empty($USER['b_tech'])) { break; } $costs = GetBuildingPrice($USER, $PLANET, $USER['b_tech_id']); if ($PLANET['id'] == $USER['b_tech_planet']) { $PLANET['metal'] += $costs['metal']; $PLANET['crystal'] += $costs['crystal']; $PLANET['deuterium'] += $costs['deuterium']; } else { $db->query("UPDATE " . PLANETS . " SET `metal` = `metal` + '" . $costs['metal'] . "', `crystal` = `crystal` + '" . $costs['crystal'] . "', `deuterium` = `deuterium` + '" . $costs['deuterium'] . "' WHERE `id` = '" . $USER['b_tech_planet'] . "';"); } $USER['darkmatter'] += $costs['darkmatter']; $USER['b_tech_id'] = 0; $USER['b_tech'] = 0; $USER['b_tech_planet'] = 0; break; case 'search': if (!empty($USER['b_tech']) || empty($Element) || !in_array($Element, $reslist['tech']) || $USER[$resource[$Element]] >= $pricelist[$Element]['max'] || !IsTechnologieAccessible($USER, $PLANET, $Element) || !IsElementBuyable($USER, $PLANET, $Element)) { break; } $costs = GetBuildingPrice($USER, $PLANET, $Element); $PLANET['metal'] -= $costs['metal']; $PLANET['crystal'] -= $costs['crystal']; $PLANET['deuterium'] -= $costs['deuterium']; $USER['darkmatter'] -= $costs['darkmatter']; $USER['b_tech_id'] = $Element; $USER['b_tech'] = TIMESTAMP + GetBuildingTime($USER, $PLANET, $Element); $USER['b_tech_planet'] = $PLANET['id']; break; } } $PlanetRess->CalcResource(); $PlanetRess->SavePlanetToDB(); $ScriptInfo = array(); foreach ($reslist['tech'] as $ID => $Element) { if (IsTechnologieAccessible($USER, $PLANET, $Element)) { $CanBeDone = IsElementBuyable($USER, $PLANET, $Element); if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) { $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>"; } elseif ($USER['b_tech_id'] == 0) { $LevelToDo = 1 + $USER[$resource[$Element]]; if ($CanBeDone && $this->CheckLabSettingsInQueue($PLANET)) { $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>"; } else { $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>"; } } else { if ($USER['b_tech_id'] == $Element) { if ($USER['b_tech_planet'] == $PLANET['id']) { $template->loadscript('research.js'); $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']); } else { $THEPLANET = $db->uniquequery("SELECT `name` FROM " . PLANETS . " WHERE `id` = '" . $USER['b_tech_planet'] . "';"); $template->loadscript('research.js'); $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $THEPLANET['name'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']); } $TechnoLink = '<div id="research"></div>'; } else { $TechnoLink = '<center>-</center>'; } } $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * ESPION . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * COMMANDANT . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink); } } $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time'])); $template->show('buildings_research.tpl'); }
/** * 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']); }
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser) { global $planetrow, $lang, $pricelist, $resource, $phpEx, $dpath, $_POST; if (isset($_GET[action])) { switch ($_GET[action]) { case "cancelqueue": $ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']); foreach ($ElementQueue as $ElementLine => $Element) { if ($Element != '') { $Element = explode(',', $Element); $ResourcesToUpd[metal] += floor($pricelist[$Element[0]][metal] * $Element[1]); $ResourcesToUpd[crystal] += floor($pricelist[$Element[0]][crystal] * $Element[1]); $ResourcesToUpd[deuterium] += floor($pricelist[$Element[0]][deuterium] * $Element[1]); $ResourcesToUpd[tachyon] += floor($pricelist[$Element[0]][tachyon] * $Element[1]); } } $SetRes = "UPDATE {{table}} SET "; $SetRes .= "`metal` = metal + '" . $ResourcesToUpd[metal] . "', "; $SetRes .= "`crystal` = crystal + '" . $ResourcesToUpd[crystal] . "', "; $SetRes .= "`deuterium` = deuterium + '" . $ResourcesToUpd[deuterium] . "', "; $SetRes .= "`tachyon` = tachyon + '" . $ResourcesToUpd[tachyon] . "', "; $SetRes .= "`b_hangar` = '', "; $SetRes .= "`b_hangar_id` = ''"; $SetRes .= " WHERE `id` = '" . $CurrentPlanet['id'] . "'"; doquery($SetRes, 'planets'); header("location: " . $_SERVER['PHP_SELF'] . "?mode=" . $_GET[mode]); exit; break; } } if (isset($_POST['fmenge'])) { $Missiles[502] = $CurrentPlanet[$resource[502]]; $Missiles[503] = $CurrentPlanet[$resource[503]]; $SiloSize = $CurrentPlanet[$resource[44]]; $MaxMissiles = $SiloSize * 10; $BuildQueue = $CurrentPlanet['b_hangar_id']; $BuildArray = explode(";", $BuildQueue); for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if ($ElmentArray[502] != 0) { $Missiles[502] += $ElmentArray[502]; } elseif ($ElmentArray[503] != 0) { $Missiles[503] += $ElmentArray[503]; } } foreach ($_POST['fmenge'] as $Element => $Count) { $Element = intval($Element); $Count = intval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false; if ($Element == 407 || $Element == 408) { if ($InQueue === false && !$IsBuild) { $Count = 1; } } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); if ($Element == 502 || $Element == 503) { $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; if ($Element == 502) { if ($Count > $MissilesSpace) { $Count = $MissilesSpace; } } else { if ($Count > floor($MissilesSpace / 2)) { $Count = floor($MissilesSpace / 2); } } if ($Count > $MaxElements) { $Count = $MaxElements; } $Missiles[$Element] += $Count; } else { if ($Count > $MaxElements) { $Count = $MaxElements; } } $Ressource = GetElementRessources($Element, $Count); $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); if ($Count >= 1) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $CurrentPlanet['tachyon'] -= $Ressource['tachyon']; $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } } } } } if ($CurrentPlanet[$resource[21]] == 0) { message($lang['need_hangar'], $lang['tech'][21]); } $TabIndex = 0; $PageTable = ""; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 400 && $Element <= 599) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")"; $PageTable .= "\n<tr>"; $PageTable .= "<th class=k>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; $PageTable .= "<td class=k>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; $PageTable .= "<th class=k>"; if ($CanBuildOne) { $InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ","); $IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false; $BuildIt = true; if ($Element == 407 || $Element == 408) { $BuildIt = false; if ($InQueue === false && !$IsBuild) { $BuildIt = true; } } if (!$BuildIt) { $PageTable .= "<font color=\"red\">" . $lang['only_one'] . "</font>"; } else { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=7 maxlength=7 value=0 tabindex=" . $TabIndex . ">"; $PageTable .= "</th>"; } } else { $PageTable .= "</th>"; } $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse = $lang; $parse['buildlist'] = $PageTable; $parse['buildinglist'] = $BuildQueue; $page .= parsetemplate(gettemplate('buildings_defense'), $parse); display($page, $lang['Defense']); }
/** * This file is part of XNova:Legacies * * @license http://www.gnu.org/licenses/gpl-3.0.txt * @see http://www.xnova-ng.org/ * * Copyright (c) 2009-2010, XNova Support Team <http://www.xnova-ng.org> * All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * --> NOTICE <-- * This file is part of the core development branch, changing its contents will * make you unable to use the automatic updates manager. Please refer to the * documentation for further information about customizing XNova. * */ function FleetBuildingPage(&$CurrentPlanet, $CurrentUser) { global $pricelist, $lang, $resource, $dpath, $reslist; if (isset($_POST['fmenge'])) { // On vient de Cliquer ' Construire ' // Ici, on sait precisement ce qu'on aimerait bien construire ... foreach ($_POST['fmenge'] as $Element => $Count) { // Construction d'Element recuper�s sur la page de Flotte ... // ATTENTION ! La file d'attente Flotte est Commune a celle des Defenses // Dans fmenge, on devrait trouver un tableau des elements constructibles et du nombre d'elements souhait�s $Element = (int) $Element; $Count = (int) $Count; $Count = $Count > MAX_FLEET_OR_DEFS_PER_ROW ? MAX_FLEET_OR_DEFS_PER_ROW : $Count; if (!in_array($Element, $reslist[Legacies_Empire::TYPE_SHIP]) || $Count < 1 || !IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { continue; } // On verifie combien on sait faire de cet element au max $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); // Si pas assez de ressources, on ajuste le nombre d'elements $Count = $Count > $MaxElements ? $MaxElements : $Count; $Ressource = GetElementRessources($Element, $Count); $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); //Correctif en attendant mieux. if ($CurrentPlanet['b_hangar_id'] == '') { $CurrentPlanet['b_hangar'] = 0; } if ($BuildTime > 0) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; if ($Element == 214 && $CurrentUser['rpg_destructeur'] == 1) { $Count = $Count * 2; //On multiplie les EDLM par 2 } $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } else { $res = doquery("SELECT " . $resource[$Element] . " FROM {{table}} WHERE id = '" . $CurrentPlanet['id'] . "' ;", 'planets'); $NombreVaisseauxActuel = mysql_result($res, 0, $resource[$Element]); $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; $NewFleetNumber = $CurrentPlanet[$resource[$Element]] + $Count; if ($Element == 214 && $CurrentUser['rpg_destructeur'] == 1) { $Count = $Count * 2; //On multiplie les EDLM par 2 } $QryUpdatefleet = "UPDATE {{table}} SET "; $QryUpdatefleet .= "`{$resource[$Element]}` = '" . $NombreVaisseauxActuel . "' + '" . $Count . "' "; $QryUpdatefleet .= "WHERE "; $QryUpdatefleet .= "`id` = '" . $CurrentPlanet['id'] . "'"; doquery($QryUpdatefleet, 'planets'); } } } // ------------------------------------------------------------------------------------------------------- // S'il n'y a pas de Chantier ... if ($CurrentPlanet[$resource[21]] == 0) { // Veuillez avoir l'obligeance de construire le Chantier Spacial !! message($lang['need_hangar'], $lang['tech'][21]); } // ------------------------------------------------------------------------------------------------------- // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ... $TabIndex = 0; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 201 && $Element <= 399) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // Disponible à la construction // On regarde si on peut en acheter au moins 1 $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); // On regarde combien de temps il faut pour construire l'element $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); // Disponibilité actuelle $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")"; // Construction des 3 cases de la ligne d'un element dans la page d'achat ! // Début de ligne $PageTable .= "\n<tr>"; // Imagette + Link vers la page d'info $PageTable .= "<th class=l>"; $PageTable .= "<a href=infos." . PHPEXT . "?gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; // Description $PageTable .= "<td class=l>"; $PageTable .= "<a href=infos." . PHPEXT . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; // On affiche le 'prix' avec eventuellement ce qui manque en ressource $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); // On affiche le temps de construction (c'est toujours tellement plus joli) $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; // Case nombre d'elements a construire $PageTable .= "<th class=k>"; // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie if ($CanBuildOne) { $TabIndex++; $PageTable .= "<input type=text id=fmenge[" . $Element . "] name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' value=0 tabindex=" . $TabIndex . ">"; $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); if ($MaxElements > MAX_FLEET_OR_DEFS_PER_ROW) { $MaxElements = MAX_FLEET_OR_DEFS_PER_ROW; } $PageTable .= '<BR><BR><A ONCLICK="document.getElementById(\'fmenge[' . $Element . ']\').value=\'' . intval($MaxElements) . '\';" STYLE="cursor:pointer;">Nombre max (' . intval($MaxElements) . ')</A></th>'; } else { $PageTable .= $lang['no_enought_res'] . '</th>'; } $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); if ($MaxElements > MAX_FLEET_OR_DEFS_PER_ROW) { $MaxElements = MAX_FLEET_OR_DEFS_PER_ROW; } // Fin de ligne (les 3 cases sont construites !! $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse = $lang; // La page se trouve dans $PageTable; $parse['buildlist'] = $PageTable; // Et la liste de constructions en cours dans $BuildQueue; $parse['buildinglist'] = $BuildQueue; $page .= parsetemplate(gettemplate('buildings_fleet'), $parse); display($page, $lang['Fleet']); }
public function ShowResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet) { global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; $PageParse = $lang; $NoResearchMessage = ""; $bContinue = true; if ($CurrentPlanet[$resource[31]] == 0) { message($lang['bd_lab_required'], '', '', true); } if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { $NoResearchMessage = $lang['bd_building_lab']; $bContinue = false; } if (isset($_GET['cmd'])) { $TheCommand = $_GET['cmd']; $Techno = intval($_GET['tech']); if (isset($Techno)) { if (!strstr($Techno, ",") && !strchr($Techno, " ") && !strchr($Techno, "+") && !strchr($Techno, "*") && !strchr($Techno, "~") && !strchr($Techno, "=") && !strchr($Techno, ";") && !strchr($Techno, "'") && !strchr($Techno, "#") && !strchr($Techno, "-") && !strchr($Techno, "_") && !strchr($Techno, "[") && !strchr($Techno, "]") && !strchr($Techno, ".") && !strchr($Techno, ":")) { if (in_array($Techno, $reslist['tech'])) { if (is_array($ThePlanet)) { $WorkingPlanet = $ThePlanet; } else { $WorkingPlanet = $CurrentPlanet; } switch ($TheCommand) { case 'cancel': if ($ThePlanet['b_tech_id'] == $Techno) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] += $costs['metal']; $WorkingPlanet['crystal'] += $costs['crystal']; $WorkingPlanet['deuterium'] += $costs['deuterium']; $WorkingPlanet['darkmatter'] += $costs['darkmatter']; $WorkingPlanet['b_tech_id'] = 0; $WorkingPlanet["b_tech"] = 0; $CurrentUser['b_tech_planet'] = 0; $UpdateData = true; $InResearch = false; } break; case 'search': if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) { $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno); $WorkingPlanet['metal'] -= $costs['metal']; $WorkingPlanet['crystal'] -= $costs['crystal']; $WorkingPlanet['deuterium'] -= $costs['deuterium']; $WorkingPlanet['darkmatter'] -= $costs['darkmatter']; $WorkingPlanet["b_tech_id"] = $Techno; $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno); $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"]; $UpdateData = true; $InResearch = true; } break; } if ($UpdateData == true) { $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', "; $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', "; $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', "; $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', "; $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "', "; $QryUpdatePlanet .= "`darkmatter` = '" . $WorkingPlanet['darkmatter'] . "' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';"; doquery($QryUpdatePlanet, 'planets'); $QryUpdateUser = "******"; $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' "; $QryUpdateUser .= "WHERE "; $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';"; doquery($QryUpdateUser, 'users'); } $CurrentPlanet = $WorkingPlanet; if (is_array($ThePlanet)) { $ThePlanet = $WorkingPlanet; } else { $CurrentPlanet = $WorkingPlanet; if ($TheCommand == 'search') { $ThePlanet = $CurrentPlanet; } } } } else { die(header("location:game.php?page=buildings&mode=research")); } } else { $bContinue = false; } header("Location: game.php?page=buildings&mode=research"); } $siguiente = 1; $BuildingPage = ""; $zaehler = 1; $TechRowTPL = gettemplate('buildings/buildings_research_row'); $TechScrTPL = gettemplate('buildings/buildings_research_script'); foreach ($lang['tech'] as $Tech => $TechName) { if ($Tech > 105 && $Tech <= 199) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) { $RowParse['dpath'] = $dpath; $RowParse['tech_id'] = $Tech; $building_level = $CurrentUser[$resource[$Tech]]; if ($Tech == 106) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_espion'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_espion'] * ESPION . $lang['bd_spy'] . "</font></strong>"; } elseif ($Tech == 108) { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . ")"; $RowParse['tech_level'] .= $CurrentUser['rpg_commandant'] == 0 ? "" : "<strong><font color=\"lime\"> +" . $CurrentUser['rpg_commandant'] * COMMANDANT . $lang['bd_commander'] . "</font></strong>"; } else { $RowParse['tech_level'] = $building_level == 0 ? "" : "(" . $lang['bd_lvl'] . " " . $building_level . " )"; } $RowParse['tech_name'] = $TechName; $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech]; $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech); $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech); $RowParse['search_time'] = ShowBuildTime($SearchTime); $RowParse['tech_restp'] = "Restantes " . $this->GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true); $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech); if ($siguiente == 1) { $parse['abrirtr'] = "<tr>"; } if (!$InResearch) { $LevelToDo = 1 + $CurrentUser[$resource[$Tech]]; if ($CanBeDone) { if (!$this->CheckLabSettingsInQueue($CurrentPlanet)) { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } else { $TechnoLink = "<a href=\"game.php?page=buildings&mode=research&cmd=search&tech=" . $Tech . "\">"; if ($LevelToDo == 1) { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink .= "<font color=#00FF00>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } $TechnoLink .= "</a>"; } } else { if ($LevelToDo == 1) { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "</font>"; } else { $TechnoLink = "<font color=#FF0000>" . $lang['bd_research'] . "<br>" . $lang['bd_lvl'] . " " . $LevelToDo . "</font>"; } } } else { if ($ThePlanet["b_tech_id"] == $Tech) { $bloc = $lang; if ($ThePlanet['id'] != $CurrentPlanet['id']) { $bloc['tech_time'] = $ThePlanet["b_tech"] - time(); $bloc['tech_name'] = "de<br>" . $ThePlanet["name"]; $bloc['tech_home'] = $ThePlanet["id"]; $bloc['tech_id'] = $ThePlanet["b_tech_id"]; } else { $bloc['tech_time'] = $CurrentPlanet["b_tech"] - time(); $bloc['tech_name'] = ""; $bloc['tech_home'] = $CurrentPlanet["id"]; $bloc['tech_id'] = $CurrentPlanet["b_tech_id"]; } $TechnoLink = parsetemplate($TechScrTPL, $bloc); } else { $TechnoLink = "<center>-</center>"; } } if ($siguiente == 3) { $parse['cerrartr'] = "</tr>"; $siguiente = 1; } else { $siguiente++; } $TechRowTPL = gettemplate('buildings/buildings_research_row'); $RowParse['tech_link'] = $TechnoLink; $TechnoList .= parsetemplate($TechRowTPL, $RowParse); } } } $PageParse['noresearch'] = $NoResearchMessage; $PageParse['technolist'] = $TechnoList; $Page .= parsetemplate(gettemplate('buildings/buildings_research'), $PageParse); display($Page); }
function 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&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&gid=" . $Element . "\">" . $ElementName . "</a> " . $ElementNbre . "</td>\r\n\t\t\t\t\t<td width=\"100\"> </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> <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> <br><font color=\"orange\">" . $lang['only_one'] . "</font></p>"; } else { $TabIndex++; $PageTable .= "<p align=\"center\"><br> <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> <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> </td> \r\n <td align=\"right\"> </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> </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']); }
/** * 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']); }
function FleetBuildingPage(&$CurrentPlanet, $CurrentUser) { global $lang, $resource, $phpEx, $dpath, $_POST; if (isset($_POST['fmenge'])) { // On vient de Cliquer ' Construire ' // Et y a une liste de doléances $AddedInQueue = false; // Ici, on sait precisement ce qu'on aimerait bien construire ... foreach ($_POST['fmenge'] as $Element => $Count) { // Construction d'Element recuperés sur la page de Flotte ... // ATTENTION ! La file d'attente Flotte est Commune a celle des Defenses // Dans fmenge, on devrait trouver un tableau des elements constructibles et du nombre d'elements souhaités $Element = floatval($Element); $Count = floatval($Count); if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) { $Count = MAX_FLEET_OR_DEFS_PER_ROW; } if ($Count != 0) { // On verifie si on a les technologies necessaires a la construction de l'element if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // On verifie combien on sait faire de cet element au max $MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet); // Si pas assez de ressources, on ajuste le nombre d'elements if ($Count > $MaxElements) { $Count = $MaxElements; } $Ressource = GetElementRessources($Element, $Count); $BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); if ($Count >= 1) { if ($BuildTime > 0) { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; if ($Element == 214) { $requete = doquery("SELECT rpg_destructeur FROM {{table}} WHERE id = " . $CurrentUser['id'] . ";", 'users', true); if ($requete['rpg_destructeur'] == 1) { $Count = 2 * $Count; } } $CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";"; } else { $CurrentPlanet['metal'] -= $Ressource['metal']; $CurrentPlanet['crystal'] -= $Ressource['crystal']; $CurrentPlanet['deuterium'] -= $Ressource['deuterium']; if ($Element == 214) { $requete = doquery("SELECT rpg_destructeur FROM {{table}} WHERE id = " . $CurrentUser['id'] . ";", 'users', true); if ($requete['rpg_destructeur'] == 1) { $Count = 2 * $Count; } } $NewFleetNumber = $CurrentPlanet[$resource[$Element]] + $Count; $QryUpdatefleet = "UPDATE {{table}} SET "; $QryUpdatefleet .= "`{$resource[$Element]}` = '" . $NewFleetNumber . "' "; $QryUpdatefleet .= "WHERE "; $QryUpdatefleet .= "`id` = '" . $CurrentPlanet['id'] . "'"; doquery($QryUpdatefleet, 'planets'); } } } } } } // ------------------------------------------------------------------------------------------------------- // S'il n'y a pas de Chantier ... if ($CurrentPlanet[$resource[21]] == 0) { // Veuillez avoir l'obligeance de construire le Chantier Spacial !! message($lang['need_hangar'], $lang['tech'][21]); } // ------------------------------------------------------------------------------------------------------- // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ... $TabIndex = 0; foreach ($lang['tech'] as $Element => $ElementName) { if ($Element > 201 && $Element <= 399) { if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { // Disponible à la construction // On regarde si on peut en acheter au moins 1 $CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false); // On regarde combien de temps il faut pour construire l'element $BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); // Disponibilité actuelle $ElementCount = $CurrentPlanet[$resource[$Element]]; $ElementNbre = $ElementCount == 0 ? "" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . ")"; // Construction des 3 cases de la ligne d'un element dans la page d'achat ! // Début de ligne $PageTable .= "\n<tr>"; // Imagette + Link vers la page d'info $PageTable .= "<th class=l>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">"; $PageTable .= "<img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top width=120 height=120></a>"; $PageTable .= "</th>"; // Description $PageTable .= "<td class=l>"; $PageTable .= "<a href=infos." . $phpEx . "?gid=" . $Element . ">" . $ElementName . "</a> " . $ElementNbre . "<br>"; $PageTable .= "" . $lang['res']['descriptions'][$Element] . "<br>"; // On affiche le 'prix' avec eventuellement ce qui manque en ressource $PageTable .= GetElementPrice($CurrentUser, $CurrentPlanet, $Element, false); // On affiche le temps de construction (c'est toujours tellement plus joli) $PageTable .= ShowBuildTime($BuildOneElementTime); $PageTable .= "</td>"; // Case nombre d'elements a construire $PageTable .= "<th class=k>"; // Si ... Et Seulement si je peux construire je mets la p'tite zone de saisie if ($CanBuildOne) { $TabIndex++; $PageTable .= "<input type=text name=fmenge[" . $Element . "] alt='" . $lang['tech'][$Element] . "' size=12 maxlength=12 value=0 tabindex=" . $TabIndex . ">"; $maxElement = GetMaxConstructibleElements($Element, $CurrentPlanet); if ($maxElement > MAX_FLEET_OR_DEFS_PER_ROW) { $maxElement = MAX_FLEET_OR_DEFS_PER_ROW; } $PageTable .= "<br><a href='javascript:' onclick=\"document.getElementsByName('fmenge[" . $Element . "]')[0].value = '{$maxElement}';\">(Max : {$maxElement})</a>"; } $PageTable .= "</th>"; // Fin de ligne (les 3 cases sont construites !! $PageTable .= "</tr>"; } } } if ($CurrentPlanet['b_hangar_id'] != '') { $BuildQueue .= ElementBuildListBox($CurrentUser, $CurrentPlanet); } $parse = $lang; // La page se trouve dans $PageTable; $parse['buildlist'] = $PageTable; // Et la liste de constructions en cours dans $BuildQueue; $parse['buildinglist'] = $BuildQueue; $page .= parsetemplate(gettemplate('buildings_fleet'), $parse); display($page, $lang['Fleet']); }
/** * 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é dans planet ! BuildingSavePlanetRecord($CurrentPlanet); // On enregistre ce que l'on a eventuellement modifié dans users BuildingSaveUserRecord($CurrentUser); if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) { $CanBuildElement = true; } else { $CanBuildElement = false; } $SubTemplate = gettemplate('buildings_builds_row'); $BuildingPage = ""; foreach ($lang['tech'] as $Element => $ElementName) { if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) { $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet); if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) { $RoomIsOk = true; } else { $RoomIsOk = false; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false); $parse = array(); $parse['dpath'] = $dpath; $parse['i'] = $Element; $BuildingLevel = $CurrentPlanet[$resource[$Element]]; $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")"; $parse['n'] = $ElementName; $parse['descriptions'] = $lang['res']['descriptions'][$Element]; $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $parse['time'] = ShowBuildTime($ElementBuildTime); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element); $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element); $parse['click'] = ''; $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1; if ($Element == 31) { // 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 ($parse['click'] != '') { // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !! } elseif ($RoomIsOk && $CanBuildElement) { if ($Queue['lenght'] == 0) { if ($NextBuildLevel == 1) { if ($HaveRessources == true) { $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>"; } } else { if ($HaveRessources == true) { $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>"; } } } else { $parse['click'] = "<a href=\"?cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>"; } } elseif ($RoomIsOk && !$CanBuildElement) { if ($NextBuildLevel == 1) { $parse['click'] = "<font color=#FF0000>" . $lang['BuildFirstLevel'] . "</font>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>"; } } else { $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>"; } $BuildingPage .= parsetemplate($SubTemplate, $parse); } } } $parse = $lang; // Faut il afficher la liste de construction ?? if ($Queue['lenght'] > 0) { $parse['BuildListScript'] = InsertBuildListScript("buildings"); $parse['BuildList'] = $Queue['buildlist']; } else { $parse['BuildListScript'] = ""; $parse['BuildList'] = ""; } $parse['planet_field_current'] = $CurrentPlanet["field_current"]; $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5; $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current']; $parse['BuildingsList'] = $BuildingPage; $page .= parsetemplate(gettemplate('buildings_builds'), $parse); display($page, $lang['Builds']); }
public function ShowBuildingsPage(&$CurrentPlanet, $CurrentUser) { global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; CheckPlanetUsedFields($CurrentPlanet); $parse = $lang; $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44); $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43); if (isset($_GET['cmd'])) { $bDoItNow = false; $TheCommand = $_GET['cmd']; $Element = $_GET['building']; $ListID = $_GET['listid']; if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { unset($Element); } if (isset($Element)) { if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) { if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { $bDoItNow = true; } } else { header("location:game.php?page=buildings"); } } elseif (isset($ListID)) { $bDoItNow = true; } if ($bDoItNow == true) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser); break; case 'remove': $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID); break; case 'insert': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true); break; case 'destroy': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false); break; } } } SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser); $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); $this->BuildingSavePlanetRecord($CurrentPlanet); if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) { $CanBuildElement = true; } else { $CanBuildElement = false; } $BuildingPage = ""; $zaehler = 1; $siguiente = 1; foreach ($lang['tech'] as $BuildID => $ElementName) { if (in_array($BuildID, $Allowed[$CurrentPlanet['planet_type']])) { $parse = $lang; $parse['dpath'] = $dpath; $parse['name'] = $lang['info'][$BuildID]['name']; $parse['image'] = $BuildID; $parse['description'] = $lang['info'][$BuildID]['description']; $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2; $parse['destroyurl'] = "game.php?page=buildings&cmd=destroy&building=" . $BuildID; $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]]; $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; $parse['nfo_deuter'] = $lang['Deuterium']; $parse['metal'] = pretty_number($NeededRessources['metal']); $parse['crystal'] = pretty_number($NeededRessources['crystal']); $parse['deuterium'] = pretty_number($NeededRessources['deuterium']); $parse['destroytime'] = pretty_time($DestroyTime); $infodiv .= parsetemplate(gettemplate('buildings/buildings_info_row'), $parse); } } foreach ($lang['tech'] as $Element => $ElementName) { if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) { $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet); if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) { $RoomIsOk = true; } else { $RoomIsOk = false; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false); $parse = array(); $parse = $lang; $parse['dpath'] = $dpath; if ($siguiente == 1) { $parse['abrirtr'] = "<tr>"; } $parse['i'] = $Element; $BuildingLevel = $CurrentPlanet[$resource[$Element]]; $parse['nivel'] = $BuildingLevel == 0 ? " (" . $lang['bd_lvl'] . " 0)" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")"; $BuildLevelFactor = $CurrentPlanet[$resource[$Element] . "_porcent"]; $BuildTemp = $CurrentPlanet['temp_max']; $CurrentBuildtLvl = $BuildingLevel; $BuildLevel = $CurrentBuildtLvl > 0 ? $CurrentBuildtLvl : 1; $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05); $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05); if ($Element != 12) { $ActualNeed = floor($Prod[4]); } else { $ActualNeed = floor($Prod[3]); } $BuildLevel++; $Prod[3] = floor(eval($ProdGrid[$Element]['formule']['deuterium']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_geologue'] * 0.05); $Prod[4] = floor(eval($ProdGrid[$Element]['formule']['energy']) * $game_config['resource_multiplier']) * (1 + $CurrentUser['rpg_ingenieur'] * 0.05); if ($Element != 12) { $EnergyNeed = pretty_number(abs(floor($Prod[4] - $ActualNeed))); } else { $EnergyNeed = pretty_number(abs(floor($Prod[3] - $ActualNeed))); } if ($Element >= 1 && $Element <= 3) { $parse['build_need_diff'] = "Next Level:<br>Verbraucht <font color=#FF0000>" . $EnergyNeed . "</font> " . $lang['Energy'] . " mehr"; $BuildLevel = 0; } elseif ($Element == 4 || $Element == 12) { $parse['build_need_diff'] = "Next Level:<br>Produziert <font color=#00FF00>" . $EnergyNeed . "</font> mehr " . $lang['Energy']; $BuildLevel = 0; } elseif ($Element == 43 && $BuildingLevel != 0) { $parse['build_need_diff'] = "<a href=\"javascript:f('game.php?page=infos&gid=43','');\">Springen</a>"; $BuildLevel = 0; } if ($BuildingLevel != 0) { $parse['cancel'] = "<a href=\"javascript:infodiv('" . $Element . "-cancel');javascript:animatedcollapse.toggle('" . $Element . "-cancel')\">Abreißen</a>"; } $parse['n'] = $ElementName; $parse['descriptions'] = $lang['res']['descriptions'][$Element]; $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $parse['time'] = ShowBuildTime($ElementBuildTime); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, true); $parse['click'] = ''; $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { if ($Queue['lenght'] == 0) { if ($NextBuildLevel == 1) { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } } else { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } } else { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>"; } } elseif ($RoomIsOk && !$CanBuildElement) { if ($NextBuildLevel == 1) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>"; } if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } if ($Element == 21 && $CurrentPlanet["b_hangar"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } if ($siguiente == 3) { $parse['cerrartr'] = "</tr>"; $siguiente = 1; } else { $siguiente++; } $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse); } } } if ($Queue['lenght'] > 0) { include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx; $parse['BuildListScript'] = InsertBuildListScript("buildings"); $parse['BuildList'] = $Queue['buildlist']; } else { $parse['BuildListScript'] = ""; $parse['BuildList'] = ""; } $parse['BuildingsList'] = $BuildingPage; $parse['infodiv'] = $infodiv; display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse)); }
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']); }
public function DefensesBuildingPage() { global $USER, $PLANET, $LNG, $resource, $dpath, $reslist; include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php'; include_once ROOT_PATH . 'includes/functions/GetElementPrice.php'; $template = new template(); if ($PLANET[$resource[21]] == 0) { $template->message($LNG['bd_shipyard_required']); exit; } $fmenge = $_POST['fmenge']; $cancel = request_var('auftr', range(0, MAX_FLEET_OR_DEFS_IN_BUILD - 1)); $action = request_var('action', ''); $PlanetRess = new ResourceUpdate(); $PlanetRess->CalcResource(); $NotBuilding = true; if (!empty($PLANET['b_building_id'])) { $CurrentQueue = $PLANET['b_building_id']; $QueueArray = explode(";", $CurrentQueue); for ($i = 0; $i < count($QueueArray); $i++) { $ListIDArray = explode(",", $QueueArray[$i]); if ($ListIDArray[0] == 21 || $ListIDArray[0] == 15) { $NotBuilding = false; break; } } } if (isset($fmenge) && $NotBuilding == true && $USER['urlaubs_modus'] == 0) { $ebuild = explode(";", $PLANET['b_hangar_id']); if (count($ebuild) - 1 >= MAX_FLEET_OR_DEFS_IN_BUILD) { $template->message(sprintf($LNG['bd_max_builds'], MAX_FLEET_OR_DEFS_IN_BUILD), "?page=buildings&mode=fleet", 3); exit; } $Missiles[502] = $PLANET[$resource[502]]; $Missiles[503] = $PLANET[$resource[503]]; $SiloSize = $PLANET[$resource[44]]; $MaxMissiles = $SiloSize * 10; $BuildQueue = $PLANET['b_hangar_id']; $BuildArray = explode(";", $BuildQueue); for ($QElement = 0; $QElement < count($BuildArray); $QElement++) { $ElmentArray = explode(",", $BuildArray[$QElement]); if (isset($Missiles[$ElmentArray[0]])) { $Missiles[$ElmentArray[0]] += $ElmentArray[1]; } } foreach ($fmenge as $Element => $Count) { if (empty($Count) || !in_array($Element, $reslist['defense'])) { continue; } $Count = is_numeric($Count) ? $Count : 0; $Count = max(min($Count, MAX_FLEET_OR_DEFS_PER_ROW), 0); $MaxElements = $this->GetMaxConstructibleElements($Element); if (empty($Element) || empty($Count) || empty($MaxElements) || !IsTechnologieAccessible($USER, $PLANET, $Element)) { continue; } if ($Element == 502 || $Element == 503) { $ActuMissiles = $Missiles[502] + 2 * $Missiles[503]; $MissilesSpace = $MaxMissiles - $ActuMissiles; $Count = $Element == 502 ? min($Count, $MissilesSpace) : min($Count, floor($MissilesSpace / 2)); $Count = min($Count, $MaxElements); $Missiles[$Element] += $Count; } elseif (in_array($Element, $reslist['one'])) { $Count = $PLANET[$resource[$Element]] == 0 && strpos($PLANET['b_hangar_id'], $Element . ',') === false ? 1 : 0; } else { $Count = min($Count, $MaxElements); } if ($Count < 1) { continue; } $Ressource = $this->GetElementRessources($Element, $Count); $PLANET['metal'] -= $Ressource['metal']; $PLANET['crystal'] -= $Ressource['crystal']; $PLANET['deuterium'] -= $Ressource['deuterium']; $PLANET['norio'] -= $Ressource['norio']; $USER['darkmatter'] -= $Ressource['darkmatter']; $PLANET['b_hangar_id'] .= $Element . ',' . floattostring($Count) . ';'; } } if ($action == "delete" && is_array($cancel) && $USER['urlaubs_modus'] == 0) { $this->CancelAuftr($cancel); } $PlanetRess->SavePlanetToDB(); foreach ($reslist['defense'] as $Element) { if (!IsTechnologieAccessible($USER, $PLANET, $Element)) { continue; } $DefenseList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element, false), 'restprice' => $this->GetRestPrice($Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'IsAvailable' => IsElementBuyable($USER, $PLANET, $Element, false), 'GetMaxAmount' => floattostring($this->GetMaxConstructibleElements($Element)), 'Available' => pretty_number($PLANET[$resource[$Element]]), 'AlreadyBuild' => in_array($Element, $reslist['one']) && (strpos($PLANET['b_hangar_id'], $Element . ",") !== false || $PLANET[$resource[$Element]] != 0) ? true : false); } $Buildlist = array(); if (!empty($PLANET['b_hangar_id'])) { $ElementQueue = explode(';', $PLANET['b_hangar_id']); $Shipyard = array(); $QueueTime = 0; foreach ($ElementQueue as $ElementLine => $Element) { if (empty($Element)) { continue; } $Element = explode(',', $Element); $ElementTime = GetBuildingTime($USER, $PLANET, $Element[0]); $QueueTime += $ElementTime * $Element[1]; $Shipyard[] = array($LNG['tech'][$Element[0]], $Element[1], $ElementTime); } $template->loadscript('bcmath.js'); $template->loadscript('shipyard.js'); $template->execscript('ShipyardInit();'); $Buildlist = array('Queue' => $Shipyard, 'b_hangar_id_plus' => $PLANET['b_hangar'], 'pretty_time_b_hangar' => pretty_time(max($QueueTime - $PLANET['b_hangar'], 0))); } $template->assign_vars(array('DefenseList' => $DefenseList, 'NotBuilding' => $NotBuilding, 'bd_available' => $LNG['bd_available'], 'bd_remaining' => $LNG['bd_remaining'], 'fgf_time' => $LNG['fgf_time'], 'bd_build_ships' => $LNG['bd_build_ships'], 'bd_building_shipyard' => $LNG['bd_building_shipyard'], 'bd_protection_shield_only_one' => $LNG['bd_protection_shield_only_one'], 'bd_cancel_warning' => $LNG['bd_cancel_warning'], 'bd_cancel_send' => $LNG['bd_cancel_send'], 'bd_operating' => $LNG['bd_operating'], 'bd_actual_production' => $LNG['bd_actual_production'], 'BuildList' => json_encode($Buildlist), 'maxlength' => strlen(MAX_FLEET_OR_DEFS_PER_ROW))); $template->show("shipyard_defense.tpl"); }
public function __construct(&$CurrentPlanet, $CurrentUser) { global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root; include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx; include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx; include_once $xgp_root . 'includes/functions/CheckPlanetUsedFields.' . $phpEx; CheckPlanetUsedFields($CurrentPlanet); $parse = $lang; $Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44); $Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43); if (isset($_GET['cmd'])) { $bDoItNow = false; $TheCommand = $_GET['cmd']; $Element = $_GET['building']; $ListID = $_GET['listid']; if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { unset($Element); } if (isset($Element)) { if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) { if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) { $bDoItNow = true; } } else { header("location:game.php?page=buildings"); } } elseif (isset($ListID)) { $bDoItNow = true; } if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) { $bDoItNow = false; } if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) { $bDoItNow = false; } if ($bDoItNow == true) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser); break; case 'remove': $this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID); break; case 'insert': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true); break; case 'destroy': $this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false); break; } } if ($_GET['r'] == 'overview') { header('location:game.php?page=overview'); } else { header("Location: game.php?page=buildings&mode=buildings"); } } SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser); // $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); // OLD CODE // START FIX BY JSTAR $Sprice = array(); $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser, $Sprice); // END FIX BY JSTAR $this->BuildingSavePlanetRecord($CurrentPlanet); if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) { $CanBuildElement = true; } else { $CanBuildElement = false; } $BuildingPage = ""; $zaehler = 1; foreach ($lang['tech'] as $Element => $ElementName) { if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) { $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet); if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) { $RoomIsOk = true; } else { $RoomIsOk = false; } if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) { $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false); $parse = array(); $parse = $lang; $parse['dpath'] = $dpath; $parse['i'] = $Element; $BuildingLevel = $CurrentPlanet[$resource[$Element]]; $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")"; $parse['n'] = $ElementName; $parse['descriptions'] = $lang['res']['descriptions'][$Element]; /* OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- // $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element); $parse['time'] = ShowBuildTime($ElementBuildTime); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element); OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- // */ // START FIX BY JSTAR $really_lvl = isset($Sprice[$Element]) ? $Sprice[$Element] : $BuildingLevel; $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element, $really_lvl); $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, $really_lvl); $parse['time'] = ShowBuildTime($ElementBuildTime); // END FIX BY JSTAR $parse['click'] = ''; $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1; if ($RoomIsOk && $CanBuildElement) { if ($Queue['lenght'] == 0) { if ($NextBuildLevel == 1) { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build'] . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } } else { if ($HaveRessources == true) { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font></a>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } } else { $parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=" . $Element . "\"><font color=#00FF00>" . $lang['bd_add_to_list'] . "</font></a>"; } } elseif ($RoomIsOk && !$CanBuildElement) { if ($NextBuildLevel == 1) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build'] . "</font>"; } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_build_next_level'] . $NextBuildLevel . "</font>"; } } else { $parse['click'] = "<font color=#FF0000>" . $lang['bd_no_more_fields'] . "</font>"; } if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) { $parse['click'] = "<font color=#FF0000>" . $lang['bd_working'] . "</font>"; } $BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse); } } } if ($Queue['lenght'] > 0) { include $xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx; $parse['BuildListScript'] = InsertBuildListScript("buildings"); $parse['BuildList'] = $Queue['buildlist']; } else { $parse['BuildListScript'] = ""; $parse['BuildList'] = ""; } $parse['BuildingsList'] = $BuildingPage; display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse)); }
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']); }