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


PHP GetBuildingPrice函数代码示例

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


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

示例1: GetBuildingTime

function GetBuildingTime($user, $planet, $Element, $destroy = false)
{
    global $pricelist, $resource, $reslist, $game_config;
    //Get the cost
    $cost = GetBuildingPrice($user, $planet, $Element, true, $destroy, false);
    $cost = $cost['metal'] + $cost['crystal'];
    if (in_array($Element, $reslist['build'])) {
        // For buildings
        $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['14']] + 1)) * pow(0.5, $planet[$resource['15']]);
        $time = floor($time * 60 * 60);
        //Else if its a research
    } elseif (in_array($Element, $reslist['tech'])) {
        // For research
        //Intergalactic Research Network
        $lablevel = $planet[$resource['31']];
        //If we have IRN
        if ($user[$resource[123]] > 0) {
            $empire = doquery("SELECT `" . $resource['31'] . "` FROM {{table}} WHERE `id_owner` ='" . $user['id'] . "' AND `id` <>'" . $user['current_planet'] . "' ORDER BY `" . $resource['31'] . "` DESC LIMIT 0 , " . $user[$resource[123]] . " ;", 'planets');
            //Loop through colonies
            while ($colonie = mysql_fetch_array($empire)) {
                //Add there lab level to combined lab level
                $lablevel += $colonie[$resource['31']];
            }
        }
        //IRN
        $time = $cost / $game_config['game_speed'] / (($lablevel + 1) * 2);
        $time = floor($time * 60 * 60);
    } elseif (in_array($Element, $reslist['defense']) || in_array($Element, $reslist['fleet'])) {
        // For shipyard / defense
        $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['21']] + 1)) * pow(1 / 2, $planet[$resource['15']]);
        $time = floor($time * 60 * 60);
    }
    return $time;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:34,代码来源:GetBuildingTime.php

示例2: CancelBuildingFromQueue

/**
 * Cancel a building from the queue and give the resource to the player
 *
 * @param array $currentPlanet @see $planetrow
 * @param array $currentUser @see $user
 * @return bool True if the cancel the cancel is correct
 */
function CancelBuildingFromQueue(&$currentPlanet, &$currentUser)
{
    if ($currentPlanet['b_building_id'] == 0) {
        return false;
    }
    $currentQueue = explode(';', $currentPlanet['b_building_id']);
    $firstElement = explode(',', $currentQueue[0]);
    array_shift($currentQueue);
    $queueSize = count($currentQueue);
    $forDestroy = $firstElement[4] == 'destroy' ? true : false;
    $elementPrice = GetBuildingPrice($currentUser, $currentPlanet, $firstElement[0], true, $forDestroy);
    $currentPlanet['metal'] += $elementPrice['metal'];
    $currentPlanet['crystal'] += $elementPrice['crystal'];
    $currentPlanet['deuterium'] += $elementPrice['deuterium'];
    if ($queueSize > 0) {
        $buildEndTime = time();
        $newQueue = array();
        for ($i = 0; $i < $queueSize; $i++) {
            $elementArray = explode(',', $currentQueue[$i]);
            if ($firstElement[0] == $elementArray[0]) {
                $elementArray[1]--;
                $elementArray[2] = GetBuildingTimeLevel($currentUser, $currentPlanet, $elementArray[0], $elementArray[1]);
            }
            $buildEndTime += $elementArray[2];
            $elementArray[3] = $buildEndTime;
            $newQueue[$i] = implode(',', $elementArray);
        }
    }
    $currentPlanet['b_building_id'] = $queueSize > 0 ? implode(';', $newQueue) : 0;
    $currentPlanet['b_building'] = $queueSize > 0 ? $buildEndTime : 0;
    return true;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:39,代码来源:CancelBuildingFromQueue.php

示例3: CancelBuildingFromQueue

 private function CancelBuildingFromQueue(&$CurrentPlanet, &$CurrentUser)
 {
     $CurrentQueue = $CurrentPlanet['b_building_id'];
     if ($CurrentQueue != 0) {
         $QueueArray = explode(";", $CurrentQueue);
         $ActualCount = count($QueueArray);
         $CanceledIDArray = explode(",", $QueueArray[0]);
         $Element = $CanceledIDArray[0];
         $BuildMode = $CanceledIDArray[4];
         if ($ActualCount > 1) {
             array_shift($QueueArray);
             $NewCount = count($QueueArray);
             $BuildEndTime = time();
             $PreElementArray = $CanceledIDArray;
             for ($ID = 0; $ID < $NewCount; $ID++) {
                 $ListIDArray = explode(",", $QueueArray[$ID]);
                 $temp = $ListIDArray;
                 if ($ListIDArray[0] == $Element) {
                     $ListIDArray = $PreElementArray;
                 }
                 $PreElementArray = $temp;
                 $BuildEndTime += $ListIDArray[2];
                 $ListIDArray[3] = $BuildEndTime;
                 $QueueArray[$ID] = implode(",", $ListIDArray);
             }
             unset($temp);
             $NewQueue = implode(";", $QueueArray);
             $ReturnValue = true;
             $BuildEndTime = '0';
         } else {
             $NewQueue = '0';
             $ReturnValue = false;
             $BuildEndTime = '0';
         }
         if ($BuildMode == 'destroy') {
             $ForDestroy = true;
         } else {
             $ForDestroy = false;
         }
         if ($Element != false) {
             $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy);
             $CurrentPlanet['metal'] += $Needed['metal'];
             $CurrentPlanet['crystal'] += $Needed['crystal'];
             $CurrentPlanet['deuterium'] += $Needed['deuterium'];
             $CurrentPlanet['tritium'] += $Needed['tritium'];
         }
     } else {
         $NewQueue = '0';
         $BuildEndTime = '0';
         $ReturnValue = false;
     }
     $CurrentPlanet['b_building_id'] = $NewQueue;
     $CurrentPlanet['b_building'] = $BuildEndTime;
     return $ReturnValue;
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:55,代码来源:class.ShowBuildingsPage.php

示例4: CancelBuildingFromQueue

/**
 * CancelBuildingFromQueue
 *
 * @version 1
 * @copyright 2008 by Chlorel for XNova
 */
function CancelBuildingFromQueue(&$CurrentPlanet, &$CurrentUser)
{
    $CurrentQueue = $CurrentPlanet['b_building_id'];
    if ($CurrentQueue != 0) {
        // Creation du tableau de la liste de construction
        $QueueArray = explode(";", $CurrentQueue);
        // Comptage du nombre d'elements dans la liste
        $ActualCount = count($QueueArray);
        // Stockage de l'element a 'interrompre'
        $CanceledIDArray = explode(",", $QueueArray[0]);
        $Element = $CanceledIDArray[0];
        $BuildMode = $CanceledIDArray[4];
        // pour savoir si on construit ou detruit
        if ($ActualCount > 1) {
            array_shift($QueueArray);
            $NewCount = count($QueueArray);
            // Mise a jour de l'heure de fin de construction theorique du batiment
            $BuildEndTime = time();
            for ($ID = 0; $ID < $NewCount; $ID++) {
                $ListIDArray = explode(",", $QueueArray[$ID]);
                $BuildEndTime += $ListIDArray[2];
                $ListIDArray[3] = $BuildEndTime;
                $QueueArray[$ID] = implode(",", $ListIDArray);
            }
            $NewQueue = implode(";", $QueueArray);
            $ReturnValue = true;
            $BuildEndTime = '0';
        } else {
            $NewQueue = '0';
            $ReturnValue = false;
            $BuildEndTime = '0';
        }
        // Ici on va rembourser les ressources engagées ...
        // Deja le mode (car quand on detruit ca ne coute que la moitié du prix de construction classique
        if ($BuildMode == 'destroy') {
            $ForDestroy = true;
        } else {
            $ForDestroy = false;
        }
        if ($Element != false) {
            $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy);
            $CurrentPlanet['metal'] += $Needed['metal'];
            $CurrentPlanet['crystal'] += $Needed['crystal'];
            $CurrentPlanet['deuterium'] += $Needed['deuterium'];
        }
    } else {
        $NewQueue = '0';
        $BuildEndTime = '0';
        $ReturnValue = false;
    }
    $CurrentPlanet['b_building_id'] = $NewQueue;
    $CurrentPlanet['b_building'] = $BuildEndTime;
    return $ReturnValue;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:60,代码来源:CancelBuildingFromQueue.php

示例5: HandleElementBuildingQueue

/**
 * HandleElementBuildingQueue.php
 *
 * @version 2
 * @copyright 2009 By MadnessRed for XNova Redesigned
 */
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet)
{
    global $resource;
    //Right, lets make a new shipyard queue management.
    //So some stuff in shipyard?
    //echo $CurrentPlanet['b_hangar_id'];
    //Lets stop it complaining, we should define $cost as an array here
    $cost = array();
    if (strlen($CurrentPlanet['b_hangar_id']) > 0) {
        //Whats be built, so far nothing,
        $built = array();
        $cost = 0;
        //Lets explode the queue into an array
        $queue = explode(';', $CurrentPlanet['b_hangar_id']);
        //Son't stop yet, we haven't started
        $stop = false;
        //Make an array
        $built = array();
        //Clear the queue to add to it later.
        $CurrentPlanet['b_hangar_id'] = '';
        //When was hanger last updated?
        $ProductionTime = $CurrentPlanet['b_hangar_lastupdate'];
        //Check a time was set
        if ($ProductionTime == 0) {
            $ProductionTime = time();
        }
        //So how long since the update?
        $ProductionTime = time() - $ProductionTime;
        //echo "Last update: ".$CurrentPlanet['b_hangar_lastupdate']."<br />Time since then: ".$ProductionTime."<br />";
        //Incase any script tries to check again before we get to write to database
        $CurrentPlanet['b_hangar_lastupdate'] = time();
        //Add left overs from last attempt
        $ProductionTime += $CurrentPlanet['b_hangar'];
        //echo "Leftover time: ".$CurrentPlanet['b_hangar']."<br />";
        //now, keeping the queue in that order.
        foreach ($queue as $todo) {
            //If its a blank entry, move on.
            if ($todo == '') {
                continue;
            }
            //Should we stop?
            if (!$stop) {
                //Explodew the queue
                $q = explode(',', $todo);
                //Add the build time to the temp array
                $q[2] = GetBuildingTime($CurrentUser, $CurrentPlanet, $q[0]);
                //echo "Build time: ".$q[2].'<br />Ammount: '.$q[1].'<br />Time to build in: '.$ProductionTime;
                //Now is there time to build all of these?
                if ($q[2] * $q[1] <= $ProductionTime) {
                    $ProductionTime -= $q[2] * $q[1];
                    $built[$q[0]] += $q[1];
                    $CurrentPlanet[$resource[$q[0]]] += $q[1];
                    //$ncost = GetBuildingPrice(array(),$CurrentPlanet,$q[0],false,false,true);
                    $ncost = GetBuildingPrice(array(), $CurrentPlanet, $q[0], false);
                    if (!is_array($ncost)) {
                        trigger_error("\$ncost returned from GetBuildingPrice was not the expected array. The following was returned.<br />" . nl2br(print_r($ncost, true)) . "<br />The arguments were:<br />GetBuildingPrice(array()," . $CurrentPlanet . "," . $q[0] . ",false,false,true);");
                    }
                    //foreach($ncost as $key => $val){ $cost[$key] += ($val * $q[1]); }
                    foreach ($ncost as $val) {
                        $cost += $val * $q[1];
                    }
                } elseif ($q[2] <= $ProductionTime) {
                    $canbuild = floor($ProductionTime / $q[2]);
                    $ProductionTime -= $q[2] * $canbuild;
                    $built[$q[0]] += $canbuild;
                    $CurrentPlanet[$resource[$q[0]]] += $canbuild;
                    //$ncost = GetBuildingPrice(array(),$CurrentPlanet,$q[0],false,false,true);
                    $ncost = GetBuildingPrice(array(), $CurrentPlanet, $q[0], false);
                    if (!is_array($ncost)) {
                        trigger_error("\$ncost returned from GetBuildingPrice was not the expected array. The following was returned.<br />" . nl2br(print_r($ncost, true)) . "<br />The arguments were:<br />GetBuildingPrice(array()," . $CurrentPlanet . "," . $q[0] . ",false,false,true);");
                    }
                    //foreach($ncost as $key => $val){ $cost[$key] += ($val * $canbuild); }
                    foreach ($ncost as $val) {
                        $cost += $val * $canbuild;
                    }
                    //And lets upt the rest back into the queue
                    $CurrentPlanet['b_hangar_id'] .= $q[0] . "," . ($q[1] - $canbuild) . ";";
                    //And stop doing stuff.
                    $stop = true;
                } else {
                    $CurrentPlanet['b_hangar_id'] .= $todo . ";";
                    $stop = true;
                }
            } else {
                $CurrentPlanet['b_hangar_id'] .= $todo . ";";
            }
        }
        //And how much time is left over?
        $CurrentPlanet['b_hangar'] = $ProductionTime;
        //Add what he build to the stats
        AddPoints($cost, false, $CurrentUser['id']);
    } else {
        $built = array();
        $CurrentPlanet['b_hangar'] = 0;
//.........这里部分代码省略.........
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:HandleElementBuildingQueue.php

示例6: ShowBuildingInfoPage


//.........这里部分代码省略.........
        $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
        // Points de Structure
        $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
        // Points de Bouclier
        $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
        // Points d'Attaque
        $parse['capacity_pt'] = pretty_number($pricelist[$BuildID]['capacity']);
        // Capacitée de fret
        $parse['base_speed'] = pretty_number($pricelist[$BuildID]['speed']);
        // Vitesse de base
        $parse['base_conso'] = pretty_number($pricelist[$BuildID]['consumption']);
        // Consommation de base
        if ($BuildID == 202) {
            $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>";
            // Vitesse rééquipée
            $parse['upd_conso'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['consumption2']) . ")</font>";
            // Consommation apres rééquipement
        } elseif ($BuildID == 211) {
            $parse['upd_speed'] = "<font color=\"yellow\">(" . pretty_number($pricelist[$BuildID]['speed2']) . ")</font>";
            // Vitesse rééquipée
        }
    } elseif ($BuildID >= 401 && $BuildID <= 408) {
        // Defenses
        $PageTPL = gettemplate('info_buildings_defense');
        $parse['element_typ'] = $lang['tech'][400];
        $parse['rf_info_to'] = ShowRapidFireTo($BuildID);
        // Rapid Fire vers
        $parse['rf_info_fr'] = ShowRapidFireFrom($BuildID);
        // Rapid Fire de
        $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
        // Points de Structure
        $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
        // Points de Bouclier
        $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
        // Points d'Attaque
    } elseif ($BuildID >= 502 && $BuildID <= 503) {
        // Misilles
        $PageTPL = gettemplate('info_buildings_defense');
        $parse['element_typ'] = $lang['tech'][400];
        $parse['hull_pt'] = pretty_number($pricelist[$BuildID]['metal'] + $pricelist[$BuildID]['crystal']);
        // Points de Structure
        $parse['shield_pt'] = pretty_number($CombatCaps[$BuildID]['shield']);
        // Points de Bouclier
        $parse['attack_pt'] = pretty_number($CombatCaps[$BuildID]['attack']);
        // Points d'Attaque
    } elseif ($BuildID >= 601 && $BuildID <= 615) {
        // Officiers
        $PageTPL = gettemplate('info_officiers_general');
    }
    // ---- Tableau d'evolution
    if ($TableHeadTPL != '') {
        $parse['table_head'] = parsetemplate($TableHeadTPL, $lang);
        $parse['table_data'] = ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $TableTPL);
    }
    // La page principale
    $page = parsetemplate($PageTPL, $parse);
    if ($GateTPL != '') {
        if ($CurrentPlanet[$resource[$BuildID]] > 0) {
            $RestString = GetNextJumpWaitTime($CurrentPlanet);
            $parse['gate_start_link'] = BuildPlanetAdressLink($CurrentPlanet);
            if ($RestString['value'] != 0) {
                $parse['gate_time_script'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], true);
                $parse['gate_wait_time'] = "<div id=\"bxx" . "Gate" . "1" . "\"></div>";
                $parse['gate_script_go'] = InsertJavaScriptChronoApplet("Gate", "1", $RestString['value'], false);
            } else {
                $parse['gate_time_script'] = "";
                $parse['gate_wait_time'] = "";
                $parse['gate_script_go'] = "";
            }
            $parse['gate_dest_moons'] = BuildJumpableMoonCombo($CurrentUser, $CurrentPlanet);
            $parse['gate_fleet_rows'] = BuildFleetListRows($CurrentPlanet);
            $page .= parsetemplate($GateTPL, $parse);
        }
    }
    if ($DestroyTPL != '') {
        if ($CurrentPlanet[$resource[$BuildID]] > 0) {
            // ---- Destruction
            $NeededRessources = GetBuildingPrice($CurrentUser, $CurrentPlanet, $BuildID, true, true);
            $DestroyTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $BuildID) / 2;
            $parse['destroyurl'] = "buildings.php?cmd=destroy&building=" . $BuildID;
            // Non balisé les balises sont dans le tpl
            $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]];
            // Niveau du batiment a detruire
            $parse['nfo_metal'] = $lang['Metal'];
            $parse['nfo_crysta'] = $lang['Crystal'];
            $parse['nfo_deuter'] = $lang['Deuterium'];
            $parse['metal'] = pretty_number($NeededRessources['metal']);
            // Cout en metal de la destruction
            $parse['crystal'] = pretty_number($NeededRessources['crystal']);
            // Cout en cristal de la destruction
            $parse['deuterium'] = pretty_number($NeededRessources['deuterium']);
            // Cout en deuterium de la destruction
            $parse['destroytime'] = pretty_time($DestroyTime);
            // Durée de la destruction
            // L'insert de destruction
            $page .= parsetemplate($DestroyTPL, $parse);
        }
    }
    return $page;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:101,代码来源:infos.php

示例7: SetNextQueueElementOnTop

function SetNextQueueElementOnTop(&$CurrentPlanet, $CurrentUser)
{
    global $lang, $resource;
    if ($CurrentPlanet['b_building'] == 0) {
        $CurrentQueue = $CurrentPlanet['b_building_id'];
        if ($CurrentQueue != 0) {
            $QueueArray = explode(";", $CurrentQueue);
            $Loop = true;
            while ($Loop == true) {
                $ListIDArray = explode(",", $QueueArray[0]);
                $Element = $ListIDArray[0];
                $Level = $ListIDArray[1];
                $BuildTime = $ListIDArray[2];
                $BuildEndTime = $ListIDArray[3];
                $BuildMode = $ListIDArray[4];
                $HaveNoMoreLevel = false;
                if ($BuildMode == 'destroy') {
                    $ForDestroy = true;
                } else {
                    $ForDestroy = false;
                }
                $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy);
                if ($ForDestroy) {
                    if ($CurrentPlanet[$resource[$Element]] == 0) {
                        $HaveRessources = false;
                        $HaveNoMoreLevel = true;
                    }
                }
                if ($HaveRessources == true) {
                    $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy);
                    $CurrentPlanet['metal'] -= $Needed['metal'];
                    $CurrentPlanet['crystal'] -= $Needed['crystal'];
                    $CurrentPlanet['deuterium'] -= $Needed['deuterium'];
                    $CurrentPlanet['tritium'] -= $Needed['tritium'];
                    $CurrentTime = time();
                    $BuildEndTime = $BuildEndTime;
                    $NewQueue = implode(";", $QueueArray);
                    if ($NewQueue == "") {
                        $NewQueue = '0';
                    }
                    $Loop = false;
                } else {
                    $ElementName = $lang['tech'][$Element];
                    if ($HaveNoMoreLevel == true) {
                        $Message = sprintf($lang['sys_nomore_level'], $ElementName);
                    } else {
                        $Needed = GetBuildingPrice($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy);
                        $Message = sprintf($lang['sys_notenough_money'], $ElementName, pretty_number($CurrentPlanet['metal']), $lang['Metal'], pretty_number($CurrentPlanet['crystal']), $lang['Crystal'], pretty_number($CurrentPlanet['deuterium']), $lang['Deuterium'], pretty_number($CurrentPlanet['tritium']), $lang['Tritium'], pretty_number($Needed['metal']), $lang['Metal'], pretty_number($Needed['crystal']), $lang['Crystal'], pretty_number($Needed['deuterium']), $lang['Deuterium'], pretty_number($Needed['tritium']), $lang['Tritium']);
                    }
                    SendSimpleMessage($CurrentUser['id'], '', '', 99, $lang['sys_buildlist'], $lang['sys_buildlist_fail'], $Message);
                    array_shift($QueueArray);
                    $ActualCount = count($QueueArray);
                    if ($ActualCount == 0) {
                        $BuildEndTime = '0';
                        $NewQueue = '0';
                        $Loop = false;
                    }
                }
            }
        } else {
            $BuildEndTime = '0';
            $NewQueue = '0';
        }
        $CurrentPlanet['b_building'] = $BuildEndTime;
        $CurrentPlanet['b_building_id'] = $NewQueue;
        $QryUpdatePlanet = "UPDATE {{table}} SET ";
        $QryUpdatePlanet .= "`metal` = '" . $CurrentPlanet['metal'] . "' , ";
        $QryUpdatePlanet .= "`crystal` = '" . $CurrentPlanet['crystal'] . "' , ";
        $QryUpdatePlanet .= "`deuterium` = '" . $CurrentPlanet['deuterium'] . "' , ";
        $QryUpdatePlanet .= "`tritium` \t= '" . $CurrentPlanet['tritium'] . "' , ";
        $QryUpdatePlanet .= "`b_building` = '" . $CurrentPlanet['b_building'] . "' , ";
        $QryUpdatePlanet .= "`b_building_id` = '" . $CurrentPlanet['b_building_id'] . "' ";
        $QryUpdatePlanet .= "WHERE ";
        $QryUpdatePlanet .= "`id` = '" . $CurrentPlanet['id'] . "';";
        doquery($QryUpdatePlanet, 'planets');
    }
    return;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:78,代码来源:SetNextQueueElementOnTop.php

示例8: 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

示例9: GetBuildingTime

/**
 * GetBuildingTime.php
 * @Licence GNU (GPL)
 * @version 3.0
 * @copyright 2009
 * @Team Space Beginner
 *
 **/
function GetBuildingTime($user, $planet, $Element, $destroy = false)
{
    global $pricelist, $resource, $reslist, $game_config, $user;
    // Baukosten = Bauzeit
    $cost = GetBuildingPrice($user, $planet, $Element, true, $destroy, false);
    $cost = $cost['metal'] + $cost['crystal'];
    // Standart
    $bonusgeb = 60;
    // Gebaude
    $bonusfleet = 60;
    // Flotten
    $bonusforsch = 60;
    // Forschungen
    $bonusdeff = 60;
    // Verteidigung
    // Rasse Vorteile / Nachteile
    switch ($user['volk']) {
        case "A":
            $bonusgeb = 57;
            // + 5%
            $bonusfleet = 66;
            // -10%
            $bonusforsch = 57;
            // + 5%
            $bonusdeff = 60;
            break;
        case "B":
            $bonusgeb = 57;
            // + 5%
            $bonusfleet = 57;
            // + 5%
            $bonusforsch = 66;
            // -10%
            $bonusdeff = 60;
            break;
        case "C":
            $bonusgeb = 66;
            // -10%
            $bonusfleet = 57;
            // + 5%
            $bonusforsch = 57;
            // + 5%
            $bonusdeff = 60;
            break;
    }
    if (in_array($Element, $reslist['build'])) {
        // Gebäude + Rassen Bonus
        $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['14']] + 1)) * pow(0.5, $planet[$resource['15']]);
        $time = floor($time * 60 * $bonusgeb);
    } elseif (in_array($Element, $reslist['tech'])) {
        // Forschung + Rassen Bonus + Forschungsbeschleunigung
        $lablevel = $planet[$resource['31']];
        $technodrom = $planet[$resource['27']];
        if ($user[$resource[123]] > 0) {
            $empire = doquery("SELECT `" . $resource['31'] . "` FROM {{table}} WHERE `id_owner` ='" . $user['id'] . "' AND `id` <>'" . $user['current_planet'] . "' ORDER BY `" . $resource['31'] . "` DESC LIMIT 0 , " . $user[$resource[123]] . " ;", 'planets');
            while ($colonie = mysql_fetch_array($empire)) {
                $lablevel += $colonie[$resource['31']];
            }
        }
        $time = $cost / $game_config['game_speed'] / (($lablevel + 1) * 2) * pow(1 / 2, $planet[$resource['27']]);
        $time = floor($time * 60 * $bonusforsch);
    } elseif (in_array($Element, $reslist['defense'])) {
        // Verteidigung + Rassen Bonus
        $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['21']] + 1)) * pow(1 / 2, $planet[$resource['15']]);
        $time = floor($time * 60 * $bonusdeff);
    } elseif (in_array($Element, $reslist['fleet'])) {
        // Schiffe
        $time = $cost / $game_config['game_speed'] * (1 / ($planet[$resource['21']] + 1)) * pow(1 / 2, $planet[$resource['15']]);
        $time = floor($time * 60 * $bonusfleet);
    }
    return $time;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:80,代码来源:GetBuildingTime.php

示例10: ShowResearchPage

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

示例11: StartBuild

    function StartBuild($ACTUAL_TICK, $building, $planet)
    {
        global $MAX_BUILDING_LVL;
        $res = BUILD_ERR_DB;
        // Building queue full?
        $this->db->queryrow('SELECT installation_type FROM scheduler_instbuild WHERE planet_id=' . $planet['planet_id']);
        if ($this->db->num_rows() >= BUILDING_QUEUE_LEN) {
            return BUILD_ERR_QUEUE;
        }
        // Retrieve some BOT infos
        $sql = 'SELECT user_race, user_capital, pending_capital_choice FROM user WHERE user_id=' . $this->bot['user_id'];
        $userdata = $this->db->queryrow($sql);
        $race = $userdata['user_data'];
        // Planet selected is capital or not?
        $capital = $userdata['user_capital'] == $planet['planet_id'] ? 1 : 0;
        if ($userdata['pending_capital_choice']) {
            $capital = 0;
        }
        // Check if building hasn't reached max level
        if ($planet['building_' . ($building + 1)] == $MAX_BUILDING_LVL[$capital][$building]) {
            return BUILD_ERR_MAXLEVEL;
        }
        // Calculate resources needed for the building
        $resource_1 = GetBuildingPrice($building, 0, $planet, $race);
        $resource_2 = GetBuildingPrice($building, 1, $planet, $race);
        $resource_3 = GetBuildingPrice($building, 2, $planet, $race);
        // Check resources availability
        if ($planet['resource_1'] >= $resource_1 && $planet['resource_2'] >= $resource_2 && $planet['resource_3'] >= $resource_3) {
            // Calculate planet power consumption
            $buildings = $planet['building_1'] + $planet['building_2'] + $planet['building_3'] + $planet['building_4'] + $planet['building_10'] + $planet['building_6'] + $planet['building_7'] + $planet['building_8'] + $planet['building_9'] + $planet['building_11'] + $planet['building_12'] + $planet['building_13'];
            /* I think we don't need this check here...
            			if (($building==11 && $planet['building_1']<4) ||
            			($building==10 && $planet['building_1']<3) ||
            			($building==6 && $planet['building_1']<5) ||
            			($building==8 && $planet['building_1']<9) ||
            			($building==7 && $planet['building_7']<1) ||
            			($building==9 && ($planet['building_6']<5 ||$planet['building_7']<1)) ||
            			($building==12 && ($planet['building_6']<1 || $planet['building_7']<1)) )
            			{
            				return BUILD_ERR_REQUIRED;
            			}*/
            // If we are building a power plant, or there is energy still available
            if ($building == 4 || $buildings <= ($capital ? $planet['building_5'] * 11 + 14 : $planet['building_5'] * 15 + 3)) {
                // Remove resources needed from the planet
                $sql = 'UPDATE planets SET
				               resource_1=resource_1-' . $resource_1 . ',
				               resource_2=resource_2-' . $resource_2 . ',
				               resource_3=resource_3-' . $resource_3 . '
				        WHERE planet_id= ' . $planet['planet_id'];
                if (!$this->db->query($sql)) {
                    $this->sdl->log('<b>Error:</b> Cannot remove resources need for construction from planet #' . $planet['planet_id'] . '!', TICK_LOG_FILE_NPC);
                }
                // Check planet activity
                $sql = 'SELECT build_finish FROM scheduler_instbuild
				        WHERE planet_id=' . $planet['planet_id'] . '
				        ORDER BY build_finish DESC';
                $userquery = $this->db->queryrow($sql);
                if ($this->db->num_rows() > 0) {
                    $build_start = $userquery['build_finish'];
                    // BOT take a little bonus here: future level of the building is not
                    // considered, also for simplicity.
                    $build_finish = $build_start + GetBuildingTimeTicks($building, $planet, $race);
                } else {
                    $build_start = $ACTUAL_TICK;
                    $build_finish = $build_start + GetBuildingTimeTicks($building, $planet, $race);
                }
                $sql = 'INSERT INTO scheduler_instbuild (installation_type,planet_id,build_start,build_finish)
					    VALUES ("' . $building . '",
					            "' . $planet['planet_id'] . '",
					            "' . $build_start . '",
					            "' . $build_finish . '")';
                if (!$this->db->query($sql)) {
                    $this->sdl->log('<b>Error:</b> cannot add building <b>#' . $building . '</b> to the planet <b>#' . $planet['planet_id'] . '</b>', TICK_LOG_FILE_NPC);
                } else {
                    $this->sdl->log('Construction of <b>#' . $building . '</b> started on planet <b>#' . $planet['planet_id'] . '</b>', TICK_LOG_FILE_NPC);
                    $res = BUILD_SUCCESS;
                }
            } else {
                $this->sdl->log('Insufficient energy on planet <b>#' . $planet['planet_id'] . '</b> for building <b>#' . $building . '</b>', TICK_LOG_FILE_NPC);
                $res = BUILD_ERR_ENERGY;
            }
        } else {
            $this->sdl->log('Insufficient resources on planet <b>#' . $planet['planet_id'] . '</b> for building <b>#' . $building . '</b>', TICK_LOG_FILE_NPC);
            $res = BUILD_ERR_RESOURCES;
        }
        return $res;
    }
开发者ID:Caberhagen,项目名称:Scheduler,代码行数:87,代码来源:NPC_BOT.php

示例12: SetNextQueueElementOnTop

 public function SetNextQueueElementOnTop($USER, $PLANET, $TIME)
 {
     global $LNG, $resource, $db;
     if (empty($PLANET['b_building_id'])) {
         $PLANET['b_building'] = 0;
         $PLANET['b_building_id'] = '';
         return array($USER, $PLANET);
     }
     $QueueArray = explode(";", $PLANET['b_building_id']);
     $Loop = true;
     $BuildEndTime = $TIME;
     while ($Loop == true) {
         $ListIDArray = explode(",", $QueueArray[0]);
         $Element = $ListIDArray[0];
         $Level = $ListIDArray[1];
         $BuildTime = $ListIDArray[2];
         $BuildEndTime = $ListIDArray[3];
         $BuildMode = $ListIDArray[4];
         $ForDestroy = $BuildMode == 'destroy' ? true : false;
         $HaveNoMoreLevel = false;
         $HaveRessources = IsElementBuyable($USER, $PLANET, $Element, true, $ForDestroy);
         if ($ForDestroy && $PLANET[$resource[$Element]] == 0) {
             $HaveRessources = false;
             $HaveNoMoreLevel = true;
         }
         if ($HaveRessources == true) {
             $Needed = GetBuildingPrice($USER, $PLANET, $Element, true, $ForDestroy);
             $PLANET['metal'] -= $Needed['metal'];
             $PLANET['crystal'] -= $Needed['crystal'];
             $PLANET['deuterium'] -= $Needed['deuterium'];
             $USER['darkmatter'] -= $Needed['darkmatter'];
             $NewQueue = implode(";", $QueueArray);
             $Loop = false;
         } else {
             if ($USER['hof'] == 1) {
                 if ($HaveNoMoreLevel == true) {
                     $Message = sprintf($LNG['sys_nomore_level'], $LNG['tech'][$Element]);
                 } else {
                     $Needed = GetBuildingPrice($USER, $PLANET, $Element, true, $ForDestroy);
                     $Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['Metal'], pretty_number($PLANET['crystal']), $LNG['Crystal'], pretty_number($PLANET['deuterium']), $LNG['Deuterium'], pretty_number($Needed['metal']), $LNG['Metal'], pretty_number($Needed['crystal']), $LNG['Crystal'], pretty_number($Needed['deuterium']), $LNG['Deuterium']);
                 }
                 SendSimpleMessage($USER['id'], '', $BuildEndTime - $BuildTime, 99, $LNG['sys_buildlist'], $LNG['sys_buildlist_fail'], $Message);
             }
             array_shift($QueueArray);
             if (count($QueueArray) == 0) {
                 $BuildEndTime = 0;
                 $NewQueue = '';
                 $Loop = false;
             } else {
                 $BaseTime = $BuildEndTime - $BuildTime;
                 foreach ($QueueArray as $ID => $QueueInfo) {
                     $ListIDArray = explode(",", $QueueInfo);
                     $BaseTime += $ListIDArray[2];
                     $ListIDArray[3] = $BaseTime;
                     $QueueArray[$ID] = implode(",", $ListIDArray);
                 }
             }
         }
     }
     $PLANET['b_building'] = $BuildEndTime;
     $PLANET['b_building_id'] = $NewQueue;
     return array($USER, $PLANET);
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:63,代码来源:class.PlanetRessUpdate.php

示例13: HandleTechnologieBuild

function HandleTechnologieBuild(&$CurrentPlanet, &$CurrentUser)
{
    global $resource;
    if ($CurrentUser['b_tech_planet'] != 0) {
        // Y a une technologie en cours sur une de mes colonies
        if ($CurrentUser['b_tech_planet'] != $CurrentPlanet['id']) {
            // Et ce n'est pas sur celle ci !!
            $WorkingPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true);
        }
        if ($WorkingPlanet) {
            $ThePlanet = $WorkingPlanet;
        } else {
            $ThePlanet = $CurrentPlanet;
        }
        if ($ThePlanet['b_tech'] <= time() && $ThePlanet['b_tech_id'] != 0) {
            // La recherche en cours est terminée ...
            $CurrentUser[$resource[$ThePlanet['b_tech_id']]]++;
            // Mise a jour de la planete sur laquelle la technologie a été recherchée
            $QryUpdatePlanet = "UPDATE {{table}} SET ";
            $QryUpdatePlanet .= "`b_tech` = '0', ";
            $QryUpdatePlanet .= "`b_tech_id` = '0' ";
            $QryUpdatePlanet .= "WHERE ";
            $QryUpdatePlanet .= "`id` = '" . $ThePlanet['id'] . "';";
            doquery($QryUpdatePlanet, 'planets');
            // Mes a jour de la techno sur l'enregistrement Utilisateur
            // Et tant qu'a faire des stats points
            $QryUpdateUser = "UPDATE {{table}} SET ";
            $QryUpdateUser .= "`" . $resource[$ThePlanet['b_tech_id']] . "` = '" . $CurrentUser[$resource[$ThePlanet['b_tech_id']]] . "', ";
            $QryUpdateUser .= "`b_tech_planet` = '0' ";
            $QryUpdateUser .= "WHERE ";
            $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
            doquery($QryUpdateUser, 'users');
            $costs = GetBuildingPrice($CurrentUser, $ThePlanet, $ThePlanet['b_tech_id']);
            AddPoints($costs['metal'] + $costs['crystal'] + $costs['deuterium'], true, $CurrentUser['id']);
            //MadnessRed - Update stats
            $ThePlanet["b_tech_id"] = 0;
            if (isset($WorkingPlanet)) {
                $WorkingPlanet = $ThePlanet;
            } else {
                $CurrentPlanet = $ThePlanet;
            }
            $Result['WorkOn'] = "";
            $Result['OnWork'] = false;
        } elseif ($ThePlanet["b_tech_id"] == 0) {
            // Il n'y a rien a l'ouest ...
            // Pas de Technologie en cours devait y avoir un bug lors de la derniere connexion
            // On met l'enregistrement informant d'une techno en cours de recherche a jours
            doquery("UPDATE {{table}} SET `b_tech_planet` = '0'  WHERE `id` = '" . $CurrentUser['id'] . "';", 'users');
            $Result['WorkOn'] = "";
            $Result['OnWork'] = false;
        } else {
            // Bin on bosse toujours ici ... Alors ne nous derangez pas !!!
            $Result['WorkOn'] = $ThePlanet;
            $Result['OnWork'] = true;
        }
    } else {
        $Result['WorkOn'] = "";
        $Result['OnWork'] = false;
    }
    return $Result;
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:61,代码来源:HandleTechnologieBuild.php

示例14: Show_Main

function Show_Main()
{
    global $db;
    global $game;
    global $NUM_BUILDING, $BUILDING_DESCRIPTION, $BUILDING_NAME, $BUILDING_DATA, $MAX_BUILDING_LVL, $NEXT_TICK, $ACTUAL_TICK;
    $capital = $game->player['user_capital'] == $game->planet['planet_id'] ? 1 : 0;
    if ($game->player['pending_capital_choice']) {
        $capital = 0;
    }
    // Clickids:
    $game->register_click_id(11);
    // Retrieve construction queue for the planet ordered by time
    $sql = 'SELECT * FROM scheduler_instbuild
            WHERE planet_id="' . $game->planet['planet_id'] . '"
            ORDER by build_start ASC';
    $schedulerquery = $db->query($sql);
    if (($queued = $db->num_rows()) > 0) {
        // Timer ID
        $t = 3;
        while ($scheduler = $db->fetchrow($schedulerquery)) {
            // From now on the level of the building is currently developed at the final stage:
            $game->planet['building_' . ($scheduler['installation_type'] + 1)]++;
            $game->out('<table border=0 cellpadding=1 cellspacing=1 width=330 class="style_outer"><tr><td>
<table border=0 cellpadding=1 cellspacing=1 width=330 class="style_inner"><tr><td>
' . constant($game->sprache("TEXT11")) . ' <b>' . $BUILDING_NAME[$game->player['user_race']][$scheduler['installation_type']] . ' (' . constant($game->sprache("TEXT12")) . ' ' . $game->planet['building_' . ($scheduler['installation_type'] + 1)] . ')</b><br>
' . constant($game->sprache("TEXT13")) . '
<b id="timer' . $t . '" title="time1_' . ($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['build_finish'] - $ACTUAL_TICK)) . '_type1_1">&nbsp;</b><br>
<a href="' . parse_link_ex('a=building&a2=abort_build&id=' . $scheduler['installation_type'], LINK_CLICKID) . '"><b>' . constant($game->sprache("TEXT14")) . '</b></a>
</td></tr></table>
</td></tr></table><br>');
            // Prepare another timer
            $t++;
            $game->set_autorefresh($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['build_finish'] - $ACTUAL_TICK) + TICK_DURATION);
        }
    }
    // Calculate available energy power
    $avail = $game->planet['building_5'] * 11 + 14;
    if (!$capital) {
        $avail = $game->planet['building_5'] * 15 + 3;
    }
    // Calculate energy power consumption
    $used = $game->planet['building_1'] + $game->planet['building_2'] + $game->planet['building_3'] + $game->planet['building_4'] + $game->planet['building_10'] + $game->planet['building_6'] + $game->planet['building_7'] + $game->planet['building_8'] + $game->planet['building_9'] + $game->planet['building_11'] + $game->planet['building_12'] + $game->planet['building_13'];
    $game->out(constant($game->sprache("TEXT16")) . ' <b id="timer2" title="time1_' . $NEXT_TICK . '_type1_3">&nbsp;</b> ' . constant($game->sprache("TEXT17")) . '<br>' . constant($game->sprache("TEXT18")) . ' ' . $used . '/' . $avail . ' ' . constant($game->sprache("TEXT19")) . '<br><br>');
    $game->out('<span class="sub_caption">' . constant($game->sprache($queued ? "TEXT21" : "TEXT20")) . ' ' . HelpPopup('building_1') . ' :</span><br><br>');
    $game->out('<table border=0 cellpadding=2 cellspacing=2 width=90% class="style_outer">
<tr><td width=100%>
<table border=0 cellpadding=2 cellspacing=2 width=100% class="style_inner">
<tr>
    <td width=130><b>' . constant($game->sprache("TEXT29")) . '</b></td>
    <td width=155><b>' . constant($game->sprache("TEXT22")) . '</b></td>
    <td width=75><b>' . constant($game->sprache("TEXT23")) . '</b></td>
    <td width=130><b>' . constant($game->sprache("TEXT24")) . '</b></td>
</tr>');
    for ($tt = 0; $tt <= $NUM_BUILDING; $tt++) {
        if ($tt > 9) {
            $t = $tt - 1;
        } else {
            $t = $tt;
        }
        if ($tt == 9) {
            $t = 12;
        }
        if (areRequirementsMet($t)) {
            // Check if building has reached maximum level
            if ($game->planet['building_' . ($t + 1)] >= $MAX_BUILDING_LVL[$capital][$t]) {
                $met = $min = $lat = $build_time = 0;
                $build_text = constant($game->sprache("TEXT28"));
            } else {
                // Calculate required resources for next building level
                $met = GetBuildingPrice($t, 0);
                $min = GetBuildingPrice($t, 1);
                $lat = GetBuildingPrice($t, 2);
                $fut = GetFuturePts($t);
                // Calculate points gained for this building
                $points = round(pow($game->planet['building_' . ($t + 1)] + 1, 1.5) - pow($game->planet['building_' . ($t + 1)], 1.5));
                if ($game->planet['resource_1'] >= $met && $game->planet['resource_2'] >= $min && $game->planet['resource_3'] >= $lat && $game->planet['planet_available_points'] >= $fut) {
                    $build_text = '<a href="' . parse_link_ex('a=building&a2=start_build&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT25")) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span></a>';
                    if ($game->planet['building_' . ($t + 1)] > 0) {
                        $build_text = '<a href="' . parse_link_ex('a=building&a2=start_build&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT27")) . ' ' . ($game->planet['building_' . ($t + 1)] + 1) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span></a>';
                    }
                } else {
                    $build_text = '<span style="color: red">' . constant($game->sprache("TEXT25")) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span>';
                    if ($game->planet['building_' . ($t + 1)] > 0) {
                        $build_text = '<span style="color: red">' . constant($game->sprache("TEXT27")) . ' ' . ($game->planet['building_' . ($t + 1)] + 1) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span>';
                    }
                }
                // Calculate required construction time
                $build_time = GetBuildingTime($t);
            }
            $game->out('
<tr>
    <td><b><a href="javascript:void(0);" onmouseover="return overlib(\'' . $BUILDING_DESCRIPTION[$game->player['user_race']][$t] . '\', CAPTION, \'' . $BUILDING_NAME[$game->player['user_race']][$t] . '\', WIDTH, 400, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $BUILDING_NAME[$game->player['user_race']][$t] . '</b></td>
    <td><img src="' . $game->GFX_PATH . 'menu_metal_small.gif"> ' . $met . '&nbsp;&nbsp; <img src="' . $game->GFX_PATH . 'menu_mineral_small.gif">' . $min . '&nbsp;&nbsp; <img src="' . $game->GFX_PATH . 'menu_latinum_small.gif"> ' . $lat . '&nbsp; </td>
    <td>' . $build_time . '</td>
    <td>' . $build_text . '</td>
</tr>');
        }
    }
    $game->out('</table></td></tr></table>');
}
开发者ID:startrekfinalfrontier,项目名称:UI,代码行数:100,代码来源:building.php

示例15: ResearchBuildingPage

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


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