本文整理汇总了PHP中GetBuildingTime函数的典型用法代码示例。如果您正苦于以下问题:PHP GetBuildingTime函数的具体用法?PHP GetBuildingTime怎么用?PHP GetBuildingTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetBuildingTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HandleElementBuildingQueue
/**
* This file is part of XNova:Legacies
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://www.xnova-ng.org/
*
* Copyright (c) 2009-Present, XNova Support Team <http://www.xnova-ng.org>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing XNova.
*
*/
function HandleElementBuildingQueue($currentUser, &$currentPlanet, $productionTime)
{
global $resource;
// Pendant qu'on y est, si on verifiait ce qui se passe dans la queue de construction du chantier ?
if ($currentPlanet['b_hangar_id']) {
$buildArray = array();
$currentPlanet['b_hangar'] += $productionTime;
$buildQueue = explode(';', $currentPlanet['b_hangar_id']);
$currentPlanet['b_hangar_id'] = '';
foreach ($buildQueue as $element) {
if (empty($element) || !($element = explode(',', $element)) || count($element) != 2) {
continue;
}
list($item, $count) = $element;
$buildTime = GetBuildingTime($currentUser, $currentPlanet, $item);
if ($currentPlanet['b_hangar'] >= $buildTime && $count > 0) {
$currentPlanet['b_hangar'] -= $buildTime * $count;
$buildArray[$element] += $count;
$currentPlanet[$resource[$element]] += $count;
$currentPlanet['b_hangar_id'] .= "{$element},{$Count};";
}
}
} else {
$buildArray = array();
$currentPlanet['b_hangar'] = 0;
}
return $buildArray;
}
示例2: ElementBuildListBox
function ElementBuildListBox($CurrentUser, $CurrentPlanet)
{
global $lang, $pricelist;
// Array del b_hangar_id
$ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']);
$NbrePerType = "";
$NamePerType = "";
$TimePerType = "";
foreach ($ElementQueue as $ElementLine => $Element) {
if ($Element != '') {
$Element = explode(',', $Element);
$ElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element[0]);
$QueueTime += $ElementTime * $Element[1];
$TimePerType .= "" . $ElementTime . ",";
$NamePerType .= "'" . html_entity_decode($lang['tech'][$Element[0]]) . "',";
$NbrePerType .= "" . $Element[1] . ",";
}
}
$parse = $lang;
$parse['a'] = $NbrePerType;
$parse['b'] = $NamePerType;
$parse['c'] = $TimePerType;
$parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
$parse['pretty_time_b_hangar'] = pretty_time($QueueTime - $CurrentPlanet['b_hangar']);
$text .= parsetemplate(gettemplate('buildings_script'), $parse);
return $text;
}
示例3: ElementBuildListQueue
function ElementBuildListQueue($CurrentUser, $CurrentPlanet)
{
global $lang, $pricelist;
$b_building_id = explode(';', $CurrentPlanet['b_building_queue']);
$a = $b = $c = "";
foreach ($b_hangar_id as $n => $array) {
if ($array != '') {
$array = explode(',', $array);
// calculamos el tiempo
$time = GetBuildingTime($user, $CurrentPlanet, $array[0]);
$totaltime += $time * $array[1];
$c .= "{$time},";
$b .= "'{$lang['tech'][$array[0]]}',";
$a .= "{$array[1]},";
}
}
$parse = $lang;
$parse['a'] = $a;
$parse['b'] = $b;
$parse['c'] = $c;
$parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
$parse['pretty_time_b_hangar'] = pretty_time($totaltime - $CurrentPlanet['b_hangar']);
$text .= parsetemplate(gettemplate('buildings_script'), $parse);
return $text;
}
示例4: HandleElementBuildingQueue
/**
* Check the hangar queue.
*
* @global array $resource @see vars.php
* @param array $currentUser Similar as $user
* @param array $currentPlanet Similar as $planetrow
* @param int $productionTime Pass time beetween now and the last update
* @return array Contain the builded element.
*/
function HandleElementBuildingQueue($currentUser, &$currentPlanet, $productionTime)
{
global $resource;
$buildArray = array();
if ($currentPlanet['b_hangar_id'] !== 0) {
$currentPlanet['b_hangar'] += $productionTime;
$buildQueue = explode(';', $currentPlanet['b_hangar_id']);
$currentPlanet['b_hangar_id'] = '';
foreach ($buildQueue as $element) {
if (empty($element) || !($element = explode(',', $element)) || count($element) != 2) {
continue;
}
list($item, $count) = $element;
$buildTime = GetBuildingTime($currentUser, $currentPlanet, $item);
if ($currentPlanet['b_hangar'] >= $buildTime && $count > 0) {
$buildedElements = floor($currentPlanet['b_hangar'] / $buildTime);
$buildedElements = $buildedElements > $count ? $count : $buildedElements;
if ($buildedElements < $count) {
$currentPlanet['b_hangar_id'] .= "{$item}," . ($count - $buildedElements) . ";";
}
$currentPlanet['b_hangar'] -= $buildTime * $buildedElements;
$buildArray[$item] += $buildedElements;
$currentPlanet[$resource[$item]] += $buildedElements;
} else {
$currentPlanet['b_hangar_id'] .= "{$item},{$count};";
}
}
} else {
$currentPlanet['b_hangar'] = 0;
}
return $buildArray;
}
示例5: eco_bld_handle_que
/**
* eco_bld_handle_que.php
* Handles building in hangar
*
* @oldname HandleElementBuildingQueue.php
* @package economic
* @version 2
*
* Revision History
* ================
* 2 - copyright (c) 2010 by Gorlum for http://supernova.ws
* [!] Full rewrite
* [%] Fixed stupid bug that allows to build several fast-build
* units utilizing build-time of slow-build units upper in que
* [~] Some optimizations and speedups
* [~] Complies with PCG1
*
* 1 - copyright 2008 By Chlorel for XNova
*/
function eco_bld_handle_que($user, &$planet, $production_time)
{
global $sn_data;
$quest_rewards = array();
if ($planet['b_hangar_id'] != 0) {
$hangar_time = $planet['b_hangar'] + $production_time;
$que = explode(';', $planet['b_hangar_id']);
$quest_list = qst_get_quests($user['id']);
$quest_triggers = qst_active_triggers($quest_list);
$built = array();
$new_hangar = '';
$skip_rest = false;
foreach ($que as $que_string) {
if ($que_string) {
$que_data = explode(',', $que_string);
$unit_id = $que_data[0];
$count = $que_data[1];
$build_time = GetBuildingTime($user, $planet, $unit_id);
if (!$skip_rest) {
$unit_db_name = $sn_data[$unit_id]['name'];
$planet_unit = $planet[$unit_db_name];
while ($hangar_time >= $build_time && $count > 0) {
$hangar_time -= $build_time;
$count--;
$built[$unit_id]++;
$planet_unit++;
}
$planet[$unit_db_name] = $planet_unit;
// TODO: Check mutiply condition quests
$quest_trigger_list = array_keys($quest_triggers, $unit_id);
foreach ($quest_trigger_list as $quest_id) {
if ($quest_list[$quest_id]['quest_unit_amount'] <= $planet[$unit_db_name] && $quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) {
$quest_rewards[$quest_id] = $quest_list[$quest_id]['quest_rewards'];
$quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE;
}
}
if ($count) {
$skip_rest = true;
}
}
if ($count > 0) {
$new_hangar .= "{$unit_id},{$count};";
}
}
}
if (!$new_hangar) {
$hangar_time = 0;
}
$planet['b_hangar'] = $hangar_time;
$planet['b_hangar_id'] = $new_hangar;
} else {
$built = '';
$planet['b_hangar'] = 0;
}
return array('built' => $built, 'rewards' => $quest_rewards);
}
示例6: HandleElementBuildingQueue
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime)
{
global $resource;
if ($CurrentPlanet['b_hangar_id'] != 0) {
$Builded = array();
$BuildArray = array();
$CurrentPlanet['b_hangar'] += $ProductionTime;
//$CurrentPlanet['b_hangar_id']=substr($CurrentPlanet['b_hangar_id'], 0, -1);
$BuildQueue = explode(';', $CurrentPlanet['b_hangar_id']);
foreach ($BuildQueue as $Node => $Array) {
if ($Array != '') {
$Item = explode(',', $Array);
$AcumTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Item[0]);
$BuildArray[$Node] = array($Item[0], $Item[1], $AcumTime);
}
}
$CurrentPlanet['b_hangar_id'] = '';
$UnFinished = false;
foreach ($BuildArray as $Node => $Item) {
$Element = $Item[0];
$Count = $Item[1];
$BuildTime = $Item[2];
$Builded[$Element] = 0;
if (!$UnFinished and $BuildTime > 0) {
$AllTime = $BuildTime * $Count;
if ($CurrentPlanet['b_hangar'] >= $BuildTime) {
$Done = min($Count, floor($CurrentPlanet['b_hangar'] / $BuildTime));
if ($Count > $Done) {
$CurrentPlanet['b_hangar'] -= $BuildTime * $Done;
$UnFinished = true;
$Count -= $Done;
} else {
$CurrentPlanet['b_hangar'] -= $AllTime;
$Count = 0;
}
$Builded[$Element] += $Done;
$CurrentPlanet[$resource[$Element]] += $Done;
} else {
$UnFinished = true;
}
} elseif (!$UnFinished) {
$Builded[$Element] += $Count;
$CurrentPlanet[$resource[$Element]] += $Count;
$Count = 0;
}
if ($Count != 0) {
$CurrentPlanet['b_hangar_id'] .= $Element . "," . $Count . ";";
}
}
} else {
$Builded = '';
$CurrentPlanet['b_hangar'] = 0;
}
return $Builded;
}
示例7: HandleElementBuildingQueue
/**
* HandleElementBuildingQueue.php
*
* @version 1
* @copyright 2008 By Chlorel for XNova
*/
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime)
{
global $resource;
// Pendant qu'on y est, si on verifiait ce qui se passe dans la queue de construction du chantier ?
if ($CurrentPlanet['b_hangar_id'] != 0) {
$Builded = array();
$CurrentPlanet['b_hangar'] += $ProductionTime;
$BuildQueue = explode(';', $CurrentPlanet['b_hangar_id']);
foreach ($BuildQueue as $Node => $Array) {
if ($Array != '') {
$Item = explode(',', $Array);
// On stocke sous forme Element, Nombre, Duree de fab
$BuildArray[$Node] = array($Item[0], $Item[1], GetBuildingTime($CurrentUser, $CurrentPlanet, $Item[0]));
}
}
$CurrentPlanet['b_hangar_id'] = '';
$UnFinished = false;
foreach ($BuildArray as $Node => $Item) {
if (!$UnFinished) {
$Element = $Item[0];
$Count = $Item[1];
$BuildTime = $Item[2];
while ($CurrentPlanet['b_hangar'] >= $BuildTime && !$UnFinished) {
if ($Count > 0) {
$CurrentPlanet['b_hangar'] -= $BuildTime;
$Builded[$Element]++;
$CurrentPlanet[$resource[$Element]]++;
$Count--;
if ($Count == 0) {
break;
}
} else {
$UnFinished = true;
break;
}
}
}
if ($Count != 0) {
$CurrentPlanet['b_hangar_id'] .= $Element . "," . $Count . ";";
}
}
} else {
$Builded = '';
$CurrentPlanet['b_hangar'] = 0;
}
return $Builded;
}
示例8: HandleElementBuildingQueue
function HandleElementBuildingQueue($CurrentUser, &$CurrentPlanet, $ProductionTime)
{
global $resource;
if ($CurrentPlanet['b_hangar_id'] != 0) {
$Builded = array();
$CurrentPlanet['b_hangar'] += $ProductionTime;
$BuildQueue = explode(';', $CurrentPlanet['b_hangar_id']);
foreach ($BuildQueue as $Node => $Array) {
if ($Array != '') {
$Item = explode(',', $Array);
$AcumTime += GetBuildingTime($CurrentUser, $CurrentPlanet, $Item[0]);
$BuildArray[$Node] = array($Item[0], $Item[1], $AcumTime);
}
}
$CurrentPlanet['b_hangar_id'] = '';
$UnFinished = false;
foreach ($BuildArray as $Node => $Item) {
if (!$UnFinished) {
$Element = $Item[0];
$Count = $Item[1];
$BuildTime = $Item[2];
while ($CurrentPlanet['b_hangar'] >= $BuildTime && !$UnFinished) {
if ($Count > 0) {
$CurrentPlanet['b_hangar'] -= $BuildTime;
$Builded[$Element]++;
$CurrentPlanet[$resource[$Element]]++;
$Count--;
if ($Count == 0) {
break;
}
} else {
$UnFinished = true;
break;
}
}
}
if ($Count != 0) {
$CurrentPlanet['b_hangar_id'] .= $Element . "," . $Count . ";";
}
}
} else {
$Builded = '';
$CurrentPlanet['b_hangar'] = 0;
}
return $Builded;
}
示例9: ElementBuildListQueue
/**
* ElementBuildListQueue.php
*
* @version 1.0
* @copyright 2008 By Chlorel for XNova
*/
function ElementBuildListQueue($CurrentUser, $CurrentPlanet)
{
// Jamais appelé pour le moment donc totalement modifiable !
/*
alter table `ogame`.`game_planets`
change `name` `name` varchar (255) NULL COLLATE latin1_general_ci,
change `b_building_id` `b_building_id` text NULL COLLATE latin1_general_ci,
change `b_tech_id` `b_tech_id` text NULL COLLATE latin1_general_ci,
change `b_hangar_id` `b_hangar_id` text NULL COLLATE latin1_general_ci,
change `image` `image` varchar (32) DEFAULT 'normaltempplanet01' NOT NULL COLLATE latin1_general_ci,
change `b_building_queue` `b_building_queue` text NULL COLLATE latin1_general_ci,
change `unbau` `unbau` varchar (100) NULL COLLATE latin1_general_ci;
*/
global $lang, $pricelist;
// Array del b_hangar_id
$b_building_id = explode(';', $CurrentPlanet['b_building_queue']);
$a = $b = $c = "";
foreach ($b_hangar_id as $n => $array) {
if ($array != '') {
$array = explode(',', $array);
// calculamos el tiempo
$time = GetBuildingTime($user, $CurrentPlanet, $array[0]);
$totaltime += $time * $array[1];
$c .= "{$time},";
$Replace = array('ä' => 'ae', 'ü' => 'ü', 'ö' => 'ö');
$Name = strtr($Replace, $lang['tech'][$array[0]]);
$b .= "'Test',";
$a .= "{$array[1]},";
}
}
$parse = $lang;
$parse['a'] = $a;
$parse['b'] = $b;
$parse['c'] = $c;
$parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
$parse['pretty_time_b_hangar'] = pretty_time($totaltime - $CurrentPlanet['b_hangar']);
// //$CurrentPlanet['last_update']
$text .= parsetemplate(gettemplate('buildings_script'), $parse);
#return $text;
}
示例10: __construct
public function __construct(&$CurrentPlanet, $CurrentUser)
{
global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
include_once $xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx;
include_once $xgp_root . 'includes/functions/GetElementPrice.' . $phpEx;
include_once $xgp_root . 'includes/functions/CheckPlanetUsedFields.' . $phpEx;
CheckPlanetUsedFields($CurrentPlanet);
$parse = $lang;
$Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
$Allowed['3'] = array(12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
if (isset($_GET['cmd'])) {
$bDoItNow = false;
$TheCommand = $_GET['cmd'];
$Element = $_GET['building'];
$ListID = $_GET['listid'];
if (!in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
unset($Element);
}
if (isset($Element)) {
if (!strchr($Element, ",") && !strchr($Element, " ") && !strchr($Element, "+") && !strchr($Element, "*") && !strchr($Element, "~") && !strchr($Element, "=") && !strchr($Element, ";") && !strchr($Element, "'") && !strchr($Element, "#") && !strchr($Element, "-") && !strchr($Element, "_") && !strchr($Element, "[") && !strchr($Element, "]") && !strchr($Element, ".") && !strchr($Element, ":")) {
if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
$bDoItNow = true;
}
} else {
header("location:game.php?page=buildings");
}
} elseif (isset($ListID)) {
$bDoItNow = true;
}
if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0) {
$bDoItNow = false;
}
if (($Element == 21 or $Element == 14 or $Element == 15) && $CurrentPlanet["b_hangar"] != 0) {
$bDoItNow = false;
}
if ($bDoItNow == true) {
switch ($TheCommand) {
case 'cancel':
$this->CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
break;
case 'remove':
$this->RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
break;
case 'insert':
$this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
break;
case 'destroy':
$this->AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
break;
}
}
if ($_GET['r'] == 'overview') {
header('location:game.php?page=overview');
} else {
header("Location: game.php?page=buildings&mode=buildings");
}
}
SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
// $Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser); // OLD CODE
// START FIX BY JSTAR
$Sprice = array();
$Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser, $Sprice);
// END FIX BY JSTAR
$this->BuildingSavePlanetRecord($CurrentPlanet);
if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
$CanBuildElement = true;
} else {
$CanBuildElement = false;
}
$BuildingPage = "";
$zaehler = 1;
foreach ($lang['tech'] as $Element => $ElementName) {
if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
$CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
$RoomIsOk = true;
} else {
$RoomIsOk = false;
}
if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
$HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
$parse = array();
$parse = $lang;
$parse['dpath'] = $dpath;
$parse['i'] = $Element;
$BuildingLevel = $CurrentPlanet[$resource[$Element]];
$parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['bd_lvl'] . " " . $BuildingLevel . ")";
$parse['n'] = $ElementName;
$parse['descriptions'] = $lang['res']['descriptions'][$Element];
/* OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- //
$ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
$parse['time'] = ShowBuildTime($ElementBuildTime);
$parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
OLD CODE ---------------------------------------------------- OLD CODE ------------------------------------- //
*/
// START FIX BY JSTAR
$really_lvl = isset($Sprice[$Element]) ? $Sprice[$Element] : $BuildingLevel;
$ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element, $really_lvl);
$parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element, true, $really_lvl);
$parse['time'] = ShowBuildTime($ElementBuildTime);
//.........这里部分代码省略.........
示例11: 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 (isset($_GET['cmd'])) {
$TheCommand = $_GET['cmd'];
$Techno = (int) $_GET['tech'];
if (is_numeric($Techno)) {
if (in_array($Techno, $reslist['tech'])) {
// Bon quand on arrive ici ... On sait deja qu'on a une technologie valide
if (is_array($ThePlanet)) {
$WorkingPlanet = $ThePlanet;
} else {
$WorkingPlanet = $CurrentPlanet;
}
switch ($TheCommand) {
case 'cancel':
if ($ThePlanet['b_tech_id'] == $Techno) {
$costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
$WorkingPlanet['metal'] += $costs['metal'];
$WorkingPlanet['crystal'] += $costs['crystal'];
$WorkingPlanet['deuterium'] += $costs['deuterium'];
$WorkingPlanet['appolonium'] += $costs['appolonium'];
if ($WorkingPlanet['id'] == $CurrentPlanet['id']) {
$CurrentPlanet['metal'] += $costs['metal'];
$CurrentPlanet['crystal'] += $costs['crystal'];
$CurrentPlanet['deuterium'] += $costs['deuterium'];
$CurrentPlanet['appolonium'] += $costs['appolonium'];
}
$WorkingPlanet['b_tech_id'] = 0;
$WorkingPlanet["b_tech"] = 0;
$CurrentUser['b_tech_planet'] = 0;
$UpdateData = true;
$InResearch = false;
}
break;
case 'search':
if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno)) {
$costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
$WorkingPlanet['metal'] -= $costs['metal'];
$WorkingPlanet['crystal'] -= $costs['crystal'];
$WorkingPlanet['deuterium'] -= $costs['deuterium'];
$WorkingPlanet['appolonium'] -= $costs['appolonium'];
$WorkingPlanet["b_tech_id"] = $Techno;
$WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno);
$CurrentUser["b_tech_planet"] = $WorkingPlanet["id"];
$UpdateData = true;
$InResearch = true;
}
break;
}
if ($UpdateData == true) {
$QryUpdatePlanet = "UPDATE {{table}} SET ";
$QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
$QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
$QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', ";
$QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', ";
$QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "', ";
$QryUpdatePlanet .= "`appolonium` = '" . $WorkingPlanet['appolonium'] . "' ";
$QryUpdatePlanet .= "WHERE ";
$QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';";
doquery($QryUpdatePlanet, 'planets');
$QryUpdateUser = "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;
//.........这里部分代码省略.........
示例12: BatimentBuildingPage
/**
* BatimentBuildingPage.php
*
* @version 1.1
* @copyright 2008 by Chlorel for XNova
*/
function BatimentBuildingPage(&$CurrentPlanet, $CurrentUser)
{
global $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET;
CheckPlanetUsedFields($CurrentPlanet);
// Tables des batiments possibles par type de planete
$Allowed['1'] = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44);
$Allowed['3'] = array(12, 14, 15, 21, 34, 41, 42, 43);
// Boucle d'interpretation des eventuelles commandes
if (isset($_GET['cmd'])) {
// On passe une commande
$bThisIsCheated = false;
$bDoItNow = false;
$TheCommand = $_GET['cmd'];
$Element = $_GET['building'];
$ListID = $_GET['listid'];
if (isset($Element)) {
if (!strchr($Element, " ")) {
if (!strchr($Element, ",")) {
if (in_array(trim($Element), $Allowed[$CurrentPlanet['planet_type']])) {
$bDoItNow = true;
} else {
$bThisIsCheated = true;
}
} else {
$bThisIsCheated = true;
}
} else {
$bThisIsCheated = true;
}
} elseif (isset($ListID)) {
$bDoItNow = true;
}
if ($bDoItNow == true) {
switch ($TheCommand) {
case 'cancel':
// Interrompre le premier batiment de la queue
CancelBuildingFromQueue($CurrentPlanet, $CurrentUser);
break;
case 'remove':
// Supprimer un element de la queue (mais pas le premier)
// $RemID -> element de la liste a supprimer
RemoveBuildingFromQueue($CurrentPlanet, $CurrentUser, $ListID);
break;
case 'insert':
// Insere un element dans la queue
AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, true);
break;
case 'destroy':
// Detruit un batiment deja construit sur la planete !
AddBuildingToQueue($CurrentPlanet, $CurrentUser, $Element, false);
break;
default:
break;
}
// switch
} elseif ($bThisIsCheated == true) {
ResetThisFuckingCheater($CurrentUser['id']);
}
}
SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
$Queue = ShowBuildingQueue($CurrentPlanet, $CurrentUser);
// On enregistre ce que l'on a modifié dans planet !
BuildingSavePlanetRecord($CurrentPlanet);
// On enregistre ce que l'on a eventuellement modifié dans users
BuildingSaveUserRecord($CurrentUser);
if ($Queue['lenght'] < MAX_BUILDING_QUEUE_SIZE) {
$CanBuildElement = true;
} else {
$CanBuildElement = false;
}
$SubTemplate = gettemplate('buildings_builds_row');
$BuildingPage = "";
foreach ($lang['tech'] as $Element => $ElementName) {
if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']])) {
$CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
if ($CurrentPlanet["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
$RoomIsOk = true;
} else {
$RoomIsOk = false;
}
if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
$HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, true, false);
$parse = array();
$parse['dpath'] = $dpath;
$parse['i'] = $Element;
$BuildingLevel = $CurrentPlanet[$resource[$Element]];
$parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
$parse['n'] = $ElementName;
$parse['descriptions'] = $lang['res']['descriptions'][$Element];
$ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
$parse['time'] = ShowBuildTime($ElementBuildTime);
$parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
$parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
$parse['click'] = '';
//.........这里部分代码省略.........
示例13: 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 {
//.........这里部分代码省略.........
示例14: AddBuildingToQueue
protected function AddBuildingToQueue(&$CurrentPlanet, $CurrentUser, $Element, $AddMode = true)
{
global $resource;
$CurrentQueue = $CurrentPlanet['b_building_id'];
$CurrentMaxFields = CalculateMaxPlanetFields($CurrentPlanet);
if ($CurrentQueue != 0) {
$QueueArray = explode(";", $CurrentQueue);
$ActualCount = count($QueueArray);
} else {
$QueueArray = "";
$ActualCount = 0;
}
if ($AddMode == true) {
$BuildMode = 'build';
} else {
$BuildMode = 'destroy';
}
if ($ActualCount < MAX_BUILDING_QUEUE_SIZE) {
$QueueID = $ActualCount + 1;
} else {
$QueueID = false;
}
if ($QueueID != false) {
if ($QueueID > 1) {
$InArray = 0;
for ($QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++) {
$QueueSubArray = explode(",", $QueueArray[$QueueElement]);
if ($QueueSubArray[0] == $Element) {
$InArray++;
}
}
} else {
$InArray = 0;
}
if ($InArray != 0) {
$ActualLevel = $CurrentPlanet[$resource[$Element]];
if ($AddMode == true) {
$BuildLevel = $ActualLevel + 1 + $InArray;
$CurrentPlanet[$resource[$Element]] += $InArray;
$BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
$CurrentPlanet[$resource[$Element]] -= $InArray;
} else {
$BuildLevel = $ActualLevel - 1 - $InArray;
$CurrentPlanet[$resource[$Element]] -= $InArray;
$BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
$CurrentPlanet[$resource[$Element]] += $InArray;
}
} else {
$ActualLevel = $CurrentPlanet[$resource[$Element]];
if ($AddMode == true) {
$BuildLevel = $ActualLevel + 1;
$BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
} else {
$BuildLevel = $ActualLevel - 1;
$BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
}
}
if ($QueueID == 1) {
$BuildEndTime = time() + $BuildTime;
} else {
$PrevBuild = explode(",", $QueueArray[$ActualCount - 1]);
$BuildEndTime = $PrevBuild[3] + $BuildTime;
}
$QueueArray[$ActualCount] = $Element . "," . $BuildLevel . "," . $BuildTime . "," . $BuildEndTime . "," . $BuildMode;
$NewQueue = implode(";", $QueueArray);
$CurrentPlanet['b_building_id'] = $NewQueue;
}
}
示例15: DefensesBuildingPage
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
global $lang, $resource, $dpath, $_POST;
if (isset($_POST['fmenge'])) {
// Wenn man auf "Bauen" klickt
// Raketen
$Missiles[502] = $CurrentPlanet[$resource[502]];
$Missiles[503] = $CurrentPlanet[$resource[503]];
$SiloSize = $CurrentPlanet[$resource[44]];
$MaxMissiles = $SiloSize * 10;
$BuildQueue = $CurrentPlanet['b_hangar_id'];
$BuildArray = explode(";", $BuildQueue);
for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
$ElmentArray = explode(",", $BuildArray[$QElement]);
if ($ElmentArray[502] != 0) {
$Missiles[502] += $ElmentArray[502];
} elseif ($ElmentArray[503] != 0) {
$Missiles[503] += $ElmentArray[503];
}
}
foreach ($_POST['fmenge'] as $Element => $Count) {
$Element = intval($Element);
$Count = intval($Count);
if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
$Count = MAX_FLEET_OR_DEFS_PER_ROW;
}
if ($Count != 0) {
//Die Kuppeln können nur einmal gebaut werden.
$InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
$IsBuildp = $CurrentPlanet[$resource[407]] >= 1 ? TRUE : FALSE;
$IsBuildg = $CurrentPlanet[$resource[408]] >= 1 ? TRUE : FALSE;
if ($Element == 407 && !$IsBuildp && $InQueue === FALSE) {
$Count = 1;
}
if ($Element == 408 && !$IsBuildg && $InQueue === FALSE) {
$Count = 1;
}
//Prüfen, ob man die nötige Technologie für den Bau hat
if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
//Festlegen, wieviele Elemente maximal gebaut werden können
$MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
//Prüfen, ob in den Silos noch Platz für Raketen ist
if ($Element == 502 || $Element == 503) {
$ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
$MissilesSpace = $MaxMissiles - $ActuMissiles;
if ($Element == 502) {
if ($Count > $MissilesSpace) {
$Count = $MissilesSpace;
}
} else {
if ($Count > floor($MissilesSpace / 2)) {
$Count = floor($MissilesSpace / 2);
}
}
if ($Count > $MaxElements) {
$Count = $MaxElements;
}
$Missiles[$Element] += $Count;
} else {
// Hat man micht genug Ress, wird die Anzahl der Schiffe entsprechend angepasst
if ($Count > $MaxElements) {
$Count = $MaxElements;
}
}
$Ressource = GetElementRessources($Element, $Count);
$BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
if ($Count >= 1) {
$CurrentPlanet['metal'] -= $Ressource['metal'];
$CurrentPlanet['crystal'] -= $Ressource['crystal'];
$CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
$CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
}
}
}
}
}
//Wenn man keine Raumschiffswerft hat
if ($CurrentPlanet[$resource[21]] == 0) {
//Kann man acuh nichts bauen^^
message($lang['need_hangar'], $lang['tech'][21]);
//Und bekommt ne Fehlermeldung
}
// Beginn der eigentlichen Bauseite ( Also das, was der User nachher sieht )
$TabIndex = 0;
$PageTable = "";
foreach ($lang['tech'] as $Element => $ElementName) {
if ($Element > 400 && $Element <= 599) {
if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
// Wenn man bauen kann...
$CanBuildOne = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element, false);
$BuildOneElementTimeWithoutTechs = GetBuildingTimeWithoutTechs($CurrentUser, $CurrentPlanet, $Element);
//ursprüngliche Bauzeit ermitteln
$BuildOneElementTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
//benötigte Bauzeit ermitteln
// aktuell verfügbar
$baubar = GetMaxConstructibleShips($CurrentPlanet, $Element);
$ElementCount = $CurrentPlanet[$resource[$Element]];
$ElementNbre = $ElementCount == 0 ? "({$lang['builtable']}{$baubar})" : " (" . $lang['dispo'] . ": " . pretty_number($ElementCount) . " {$lang['builtable']} {$baubar})";
$PageTable .= "\n<tr>";
$PageTable .= "\r\n\t<th class=\"l\" rowspan=\"2\" width=\"120\">\r\n\t\t<a href=\"?action=internalInformations&gid=" . $Element . "\"><img border=0 src=\"" . $dpath . "gebaeude/" . $Element . ".gif\" align=top alt=" . $Element . ".gif width=120 height=120></a>\r\n\t</th>\r\n <td class=\"c\">\r\n \t<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n \t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width=\"15\"><img src=\"images/transparent.gif\" alt=\"transparent\" width=\"0\" height=\"21\"></td>\r\n\t\t\t\t\t<td><a href=\"?action=internalInformations&gid=" . $Element . "\">" . $ElementName . "</a> " . $ElementNbre . "</td>\r\n\t\t\t\t\t<td width=\"100\"> </td>\r\n \t\t\t</tr>\r\n \t\t</tbody>\r\n\t\t</table>\r\n </td>\r\n</tr>\r\n<tr>\r\n <td colspan=\"1\">\r\n \t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n \t\t<tbody>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td class=\"rechtsohneborder\" width=\"10\"><img src=\"images/transparent.gif\" alt=\"transparent\" width=\"0\" height=\"100\"></td>\r\n\t\t\t\t\t<td class=\"linksundrechtsohneborder\" width=\"80%\">" . $lang['res']['descriptions'][$Element] . "<br> <br>";
//.........这里部分代码省略.........