当前位置: 首页>>代码示例>>PHP>>正文


PHP GetElementPrice函数代码示例

本文整理汇总了PHP中GetElementPrice函数的典型用法代码示例。如果您正苦于以下问题:PHP GetElementPrice函数的具体用法?PHP GetElementPrice怎么用?PHP GetElementPrice使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetElementPrice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DefensesBuildingPage

 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) {
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:class.ShowBuildFleetPage.php

示例2: FleetBuildingPage

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']);
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:FleetBuildingPage.php

示例3: BuildingPage


//.........这里部分代码省略.........
    } 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 {
开发者ID:sonicmaster,项目名称:RPG,代码行数:67,代码来源:BuildingPage.php

示例4: __construct

 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) {
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:class.ShowInfosPage.php

示例5: ShowResearchPage

 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 = "UPDATE {{table}} SET ";
                         $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 {
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:class.ShowResearchPage.php

示例6: __construct

 public function __construct()
 {
     global $ProdGrid, $LNG, $resource, $reslist, $CONF, $db, $PLANET, $USER;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php';
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.php';
     $TheCommand = request_var('cmd', '');
     $Element = request_var('building', 0);
     $ListID = request_var('listid', 0);
     $PlanetRess = new ResourceUpdate();
     $PlanetRess->CalcResource();
     if (!empty($Element) && $USER['urlaubs_modus'] == 0 && (IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['allow'][$PLANET['planet_type']])) || $TheCommand == "cancel" || $TheCommand == "remove") {
         if ($Element == 31 && $USER["b_tech_planet"] != 0 || ($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) {
             $TheCommand = '';
         }
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue($PlanetRess);
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID, $PlanetRess);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
     }
     $PlanetRess->SavePlanetToDB();
     $Queue = $this->ShowBuildingQueue();
     $template = new template();
     $CanBuildElement = count($Queue) < MAX_BUILDING_QUEUE_SIZE ? true : false;
     $BuildingPage = "";
     $CurrentMaxFields = CalculateMaxPlanetFields($PLANET);
     $RoomIsOk = $PLANET["field_current"] < $CurrentMaxFields - count($Queue) ? true : false;
     $BuildEnergy = $USER[$resource[113]];
     $BuildLevelFactor = 10;
     $BuildTemp = $PLANET['temp_max'];
     foreach ($reslist['allow'][$PLANET['planet_type']] as $ID => $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, false);
         if (in_array($Element, $reslist['prod'])) {
             $BuildLevel = $PLANET[$resource[$Element]];
             $Need = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1);
             $BuildLevel += 1;
             $Prod = floor(eval($ProdGrid[$Element]['formule']['energy']) * $CONF['resource_multiplier']) * (1 + ($this->TIME - $this->USER[$resource[704]] <= 0) ? 1 + $ExtraDM[704]['add'] : 1);
             $EnergyNeed = $Prod - $Need;
         } else {
             unset($EnergyNeed);
         }
         $parse['click'] = '';
         $NextBuildLevel = $PLANET[$resource[$Element]] + 1;
         if ($RoomIsOk && $CanBuildElement) {
             $parse['click'] = $HaveRessources == true ? "<a href=\"game.php?page=buildings&amp;cmd=insert&amp;building=" . $Element . "\"><span style=\"color:#00FF00\">" . ($PLANET['b_building'] != 0 ? $LNG['bd_add_to_list'] : ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel)) . "</span></a>" : "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>";
         } elseif ($RoomIsOk && !$CanBuildElement) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . ($NextBuildLevel == 1 ? $LNG['bd_build'] : $LNG['bd_build_next_level'] . $NextBuildLevel) . "</span>";
         } else {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_no_more_fields'] . "</span>";
         }
         if (($Element == 6 || $Element == 31) && $USER['b_tech'] > TIMESTAMP) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>";
         } elseif (($Element == 15 || $Element == 21) && !empty($PLANET['b_hangar_id'])) {
             $parse['click'] = "<span style=\"color:#FF0000\">" . $LNG['bd_working'] . "</span>";
         }
         $BuildInfoList[] = array('id' => $Element, 'name' => $LNG['tech'][$Element], 'descriptions' => $LNG['res']['descriptions'][$Element], 'level' => $PLANET[$resource[$Element]], 'destroyress' => array_map('pretty_number', GetBuildingPrice($USER, $PLANET, $Element, true, true)), 'destroytime' => pretty_time(GetBuildingTime($USER, $PLANET, $Element, true)), 'price' => GetElementPrice($USER, $PLANET, $Element, true), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'EnergyNeed' => isset($EnergyNeed) ? sprintf($EnergyNeed < 0 ? $LNG['bd_need_engine'] : $LNG['bd_more_engine'], pretty_number(abs($EnergyNeed)), $LNG['Energy']) : "", 'BuildLink' => $parse['click'], 'restprice' => $this->GetRestPrice($Element));
     }
     if ($PLANET['b_building'] != 0) {
         $template->execscript('ReBuildView();Buildlist();');
         $template->loadscript('buildlist.js');
         $template->assign_vars(array('data' => json_encode(array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $Queue))));
     }
     $template->assign_vars(array('BuildInfoList' => $BuildInfoList, 'bd_lvl' => $LNG['bd_lvl'], 'bd_next_level' => $LNG['bd_next_level'], 'Metal' => $LNG['Metal'], 'Crystal' => $LNG['Crystal'], 'Deuterium' => $LNG['Deuterium'], 'Norio' => $LNG['Norio'], 'Darkmatter' => $LNG['Darkmatter'], 'bd_dismantle' => $LNG['bd_dismantle'], 'fgf_time' => $LNG['fgf_time'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_jump_gate_action' => $LNG['bd_jump_gate_action'], 'bd_price_for_destroy' => $LNG['bd_price_for_destroy'], 'bd_destroy_time' => $LNG['bd_destroy_time']));
     $template->show("buildings_overview.tpl");
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:77,代码来源:class.ShowBuildingsPage.php

示例7: DefensesBuildingPage


//.........这里部分代码省略.........
                            }
                        }
                        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']);
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:DefensesBuildingPage.php

示例8: DefensesBuildingPage

 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;
         }
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:class.ShowShipyardPage.php

示例9: ResearchBuildingPage

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 = "UPDATE {{table}} SET ";
                    $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' ";
                    $QryUpdateUser .= "WHERE ";
                    $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
                    doquery($QryUpdateUser, 'users');
                }
                if (is_array($ThePlanet)) {
                    $ThePlanet = $WorkingPlanet;
                } else {
                    $CurrentPlanet = $WorkingPlanet;
                    if ($TheCommand == 'search') {
                        $ThePlanet = $CurrentPlanet;
                    }
                }
            }
        } else {
            $bContinue = false;
        }
    }
    $TechRowTPL = gettemplate('buildings_research_row');
    $TechScrTPL = gettemplate('buildings_research_script');
    foreach ($lang['tech'] as $Tech => $TechName) {
        if ($Tech > 105 && $Tech <= 199) {
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
                $RowParse = $lang;
                $RowParse['dpath'] = $dpath;
                $RowParse['tech_id'] = $Tech;
                $building_level = $CurrentUser[$resource[$Tech]];
                $RowParse['tech_level'] = $building_level == 0 ? "" : "( " . $lang['level'] . " " . $building_level . " )";
                $RowParse['tech_name'] = $TechName;
                $RowParse['tech_descr'] = $lang['res']['descriptions'][$Tech];
                $RowParse['tech_price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech);
                $SearchTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech);
                $RowParse['search_time'] = ShowBuildTime($SearchTime);
                $RowParse['tech_restp'] = $lang['Rest_ress'] . " " . GetRestPrice($CurrentUser, $CurrentPlanet, $Tech, true);
                $CanBeDone = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech);
                if (!$InResearch) {
                    $LevelToDo = 1 + $CurrentUser[$resource[$Tech]];
                    if ($CanBeDone) {
                        if (!CheckLabSettingsInQueue($CurrentPlanet)) {
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:ResearchBuildingPage.php

示例10: BatimentBuildingPage

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>";
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:BatimentBuildingPage.php

示例11: FleetBuildingPage

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']);
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:98,代码来源:FleetBuildingPage.php

示例12: BatimentBuildingPage


//.........这里部分代码省略.........
    // Änderungen in den Planeten Rekorden übernehmen
    BuildingSavePlanetRecord($CurrentPlanet);
    // Änderungen in den Userrekorden übernehmen
    BuildingSaveUserRecord($CurrentUser);
    if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
        //Solange noch Platz in der Bauischleife ist...
        $CanBuildElement = true;
        // ...kann man bauen
    } else {
        $CanBuildElement = false;
    }
    $SubTemplate = gettemplate('buildings_builds_row');
    $BuildingPage = "";
    foreach ($lang['tech'] as $Element => $ElementName) {
        if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
            $CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
            if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
                $parse = array();
                $parse['dpath'] = $dpath;
                $parse['i'] = $Element;
                $BuildingLevel = $CurrentPlanet[$resource[$Element]];
                $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
                $parse['n'] = $ElementName;
                $parse['descriptions'] = $lang['res']['descriptions'][$Element];
                $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
                $ElementBuildTimeWithoutTechs = GetBuildingTimeWithoutTechs($CurrentUser, $CurrentPlanet, $Element);
                //Bauzeiten parsen
                $parse['timewithouttechs'] = ShowBuildTimeWithoutTechs($ElementBuildTimeWithoutTechs);
                $parse['technobonus'] = ShowBuildTime($ElementBuildTimeWithoutTechs - $ElementBuildTime);
                $parse['time'] = ShowBuildTime($ElementBuildTime);
                //Sprachvariablen für die Bauzeit laden
                $parse['BuildingTime'] = $lang['BuildingTime'];
                $parse['NeededRess'] = $lang['NeededRess'];
                $parse['ConstructionTimeWithoutTechs'] = $lang['ConstructionTimeWithoutTechs'];
                $parse['TechBonus'] = $lang['TechBonus'];
                $parse['ConstructionTime'] = $lang['ConstructionTime'];
                $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
                $parse['click'] = '';
                $NextBuildLevel = $CurrentPlanet[$resource[$Element]] + 1;
                if ($Element == 31) {
                    // Sonderstatus fürs FOrschungslabor
                    if ($CurrentUser["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                        // Config Einstellung die das Forschen während des Ausbaus erlaubt
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['in_working'] . "</font>";
                    }
                }
                if ($parse['click'] != '') {
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;building=" . $Element . "\"><font color=\"#00FF00\">" . $lang['BuildFirstLevel'] . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildFirstLevel'] . "</font>";
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;building=" . $Element . "\"><font color=\"#00FF00\">" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                            } else {
                                $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"?action=internalBuildings&amp;cmd=insert&amp;building=" . $Element . "\"><font color=\"#00FF00\">" . $lang['InBuildQueue'] . "</font></a>";
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildFirstLevel'] . "</font>";
                    } else {
                        $parse['click'] = "<font color=\"#FF0000\">" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                    }
                } else {
                    $parse['click'] = "<font color=\"#FF0000\">" . $lang['NoMoreSpace'] . "</font>";
                }
                $BuildingPage .= parsetemplate($SubTemplate, $parse);
            }
        }
    }
    $parse = $lang;
    if ($Queue['lenght'] > 0) {
        $parse['BuildListScript'] = InsertBuildListScript("?action=internalBuildings");
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildListScript'] = "";
        $parse['BuildList'] = "";
    }
    $parse['planet_field_current'] = $CurrentPlanet["field_current"];
    $parse['planet_field_max'] = $CurrentPlanet['field_max'] + $CurrentPlanet[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $CurrentPlanet['field_current'];
    $parse['BuildingsList'] = $BuildingPage;
    $page .= parsetemplate(gettemplate('buildings_builds'), $parse);
    display($page, $lang['Builds']);
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:BatimentBuildingPage.php

示例13: ShowBuildingsPage

 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) {
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:class.ShowBuildingsPage.php

示例14: DefensesBuildingPage

 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;
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:class.ShowShipyardPage.php

示例15: __construct

 public function __construct()
 {
     global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $db, $pricelist, $OfficerInfo;
     include_once ROOT_PATH . 'includes/functions/IsTechnologieAccessible.php';
     include_once ROOT_PATH . 'includes/functions/GetElementPrice.php';
     $template = new template();
     if ($PLANET[$resource[31]] == 0) {
         $template->message($LNG['bd_lab_required']);
         exit;
     }
     $bContinue = $this->CheckLabSettingsInQueue($PLANET) ? true : false;
     $TheCommand = request_var('cmd', '');
     $Element = request_var('tech', 0);
     $ListID = request_var('listid', 0);
     $PlanetRess = new ResourceUpdate();
     $PLANET[$resource[31] . '_inter'] = $PlanetRess->CheckAndGetLabLevel($USER, $PLANET);
     $PlanetRess->CalcResource();
     if (!empty($Element) && $bContinue && $USER['urlaubs_modus'] == 0 && ($USER[$resource[$Element]] < $pricelist[$Element]['max'] && IsTechnologieAccessible($USER, $PLANET, $Element) && in_array($Element, $reslist['tech'])) || $TheCommand == "cancel" || $TheCommand == "remove") {
         switch ($TheCommand) {
             case 'cancel':
                 $this->CancelBuildingFromQueue($PlanetRess);
                 break;
             case 'remove':
                 $this->RemoveBuildingFromQueue($ListID, $PlanetRess);
                 break;
             case 'insert':
                 $this->AddBuildingToQueue($Element, true);
                 break;
             case 'destroy':
                 $this->AddBuildingToQueue($Element, false);
                 break;
         }
     }
     $PlanetRess->SavePlanetToDB();
     $ScriptInfo = array();
     $TechQueue = $this->ShowTechQueue();
     foreach ($reslist['tech'] as $ID => $Element) {
         if (!IsTechnologieAccessible($USER, $PLANET, $Element)) {
             continue;
         }
         $CanBeDone = IsElementBuyable($USER, $PLANET, $Element);
         if (isset($pricelist[$Element]['max']) && $USER[$resource[$Element]] >= $pricelist[$Element]['max']) {
             $TechnoLink = "<font color=\"#FF0000\">" . $LNG['bd_maxlevel'] . "</font>";
         } elseif (MAX_RESEACH_QUEUE_SIZE > 1) {
             $LevelToDo = 1 + $USER[$resource[$Element]];
             $TechnoLink = $CanBeDone && $bContinue ? "<a href=\"game.php?page=buildings&amp;mode=research&amp;cmd=insert&amp;tech=" . $Element . "\"><font color=\"#00FF00\">" . ($USER['b_tech_id'] != 0 ? $LNG['bd_add_to_list'] : $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo)) . "</font></a>" : "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>";
             if ($USER['b_tech_id'] != 0) {
                 $template->loadscript('researchlist.js');
                 $template->execscript('ReBuildView();Techlist();');
                 $ScriptInfo = array('bd_cancel' => $LNG['bd_cancel'], 'bd_continue' => $LNG['bd_continue'], 'bd_finished' => $LNG['bd_finished'], 'build' => $TechQueue);
             }
         } else {
             if ($USER['b_tech_id'] == 0) {
                 $LevelToDo = 1 + $USER[$resource[$Element]];
                 $TechnoLink = $CanBeDone && $bContinue ? "<a href=\"game.php?page=buildings&amp;mode=research&amp;cmd=insert&amp;tech=" . $Element . "\"><font color=\"#00FF00\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font></a>" : "<font color=\"#FF0000\">" . $LNG['bd_research'] . ($LevelToDo == 1 ? "" : "<br>" . $LNG['bd_lvl'] . " " . $LevelToDo) . "</font>";
             } else {
                 if ($USER['b_tech_id'] == $Element) {
                     $template->loadscript('research.js');
                     if ($USER['b_tech_planet'] == $PLANET['id']) {
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => '', 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     } else {
                         $ScriptInfo = array('tech_time' => $USER['b_tech'], 'tech_name' => $LNG['bd_on'] . '<br>' . $TechQueue['planet'], 'tech_home' => $USER['b_tech_planet'], 'tech_id' => $USER['b_tech_id'], 'game_name' => $CONF['game_name'], 'tech_lang' => $LNG['tech'][$USER['b_tech_id']], 'bd_cancel' => $LNG['bd_cancel'], 'bd_ready' => $LNG['bd_ready'], 'bd_continue' => $LNG['bd_continue']);
                     }
                     $TechnoLink = '<div id="research"></div>';
                 } else {
                     $TechnoLink = '<center>-</center>';
                 }
             }
         }
         $ResearchList[] = array('id' => $Element, 'maxinfo' => isset($pricelist[$Element]['max']) && $pricelist[$Element]['max'] != 255 ? sprintf($LNG['bd_max_lvl'], $pricelist[$Element]['max']) : '', 'name' => $LNG['tech'][$Element], 'descr' => $LNG['res']['descriptions'][$Element], 'price' => GetElementPrice($USER, $PLANET, $Element), 'time' => pretty_time(GetBuildingTime($USER, $PLANET, $Element)), 'restprice' => $this->GetRestPrice($Element), 'elvl' => $Element == 106 ? $USER['rpg_espion'] * $OfficerInfo[610]['info'] . " (" . $LNG['tech'][610] . ")" : ($Element == 108 ? $USER['rpg_commandant'] * $OfficerInfo[611]['info'] . " (" . $LNG['tech'][611] . ")" : false), 'lvl' => $USER[$resource[$Element]], 'link' => $TechnoLink, 'oldlink' => MAX_RESEACH_QUEUE_SIZE == 1, 'queue' => $TechQueue);
     }
     $template->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'ScriptInfo' => json_encode($ScriptInfo), 'bd_building_lab' => $LNG['bd_building_lab'], 'bd_remaining' => $LNG['bd_remaining'], 'bd_lvl' => $LNG['bd_lvl'], 'fgf_time' => $LNG['fgf_time']));
     $template->show('buildings_research.tpl');
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:74,代码来源:class.ShowResearchPage.php


注:本文中的GetElementPrice函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。