public static function addResearchToQueue($Element, $AddMode = true) { global $PLANET, $USER, $resource, $CONF, $reslist, $pricelist; $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET); if (!in_array($Element, $reslist['tech']) || !BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element) || !BuildFunctions::CheckLabSettingsInQueue($PLANET)) { return; } $CurrentQueue = unserialize($USER['b_tech_queue']); if (!empty($CurrentQueue)) { $ActualCount = count($CurrentQueue); } else { $CurrentQueue = array(); $ActualCount = 0; } if (Config::get('max_elements_tech') != 0 && Config::get('max_elements_tech') <= $ActualCount) { return false; } $BuildLevel = $USER[$resource[$Element]] + 1; if ($ActualCount == 0) { if ($pricelist[$Element]['max'] < $BuildLevel) { return; } $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, !$AddMode); if (!BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources)) { return; } if (isset($costRessources[901])) { $PLANET[$resource[901]] -= $costRessources[901]; } if (isset($costRessources[902])) { $PLANET[$resource[902]] -= $costRessources[902]; } if (isset($costRessources[903])) { $PLANET[$resource[903]] -= $costRessources[903]; } if (isset($costRessources[921])) { $USER[$resource[921]] -= $costRessources[921]; } $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources); $BuildEndTime = TIMESTAMP + $elementTime; $USER['b_tech_queue'] = serialize(array(array($Element, $BuildLevel, $elementTime, $BuildEndTime, $PLANET['id']))); $USER['b_tech'] = $BuildEndTime; $USER['b_tech_id'] = $Element; $USER['b_tech_planet'] = $PLANET['id']; } else { $addLevel = 0; foreach ($CurrentQueue as $QueueSubArray) { if ($QueueSubArray[0] != $Element) { continue; } $addLevel++; } $BuildLevel += $addLevel; if ($pricelist[$Element]['max'] < $BuildLevel) { return; } $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, NULL, !$AddMode, $BuildLevel); $BuildEndTime = $CurrentQueue[$ActualCount - 1][3] + $elementTime; $CurrentQueue[] = array($Element, $BuildLevel, $elementTime, $BuildEndTime, $PLANET['id']); $USER['b_tech_queue'] = serialize($CurrentQueue); } }
public function show() { global $PLANET, $USER, $UNI, $LNG, $resource, $reslist, $CONF, $pricelist; if ($PLANET[$resource[31]] == 0) { $this->printMessage($LNG['bd_lab_required']); } $TheCommand = HTTP::_GP('cmd', ''); $Element = HTTP::_GP('tech', 0); $ListID = HTTP::_GP('listid', 0); $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET); if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) { switch ($TheCommand) { case 'insert': $this->AddBuildingToQueue($Element, true); break; } $this->redirectTo('game.php?page=dmtech'); } $bContinue = $this->CheckLabSettingsInQueue($PLANET); $queueData = $this->getQueueData(); $TechQueue = $queueData['queue']; $QueueCount = count($TechQueue); $ResearchList = array(); $Elements = array(106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 131, 132, 133); foreach ($Elements as $ID => $Element) { if (!BuildFunctions::isBusyToBuild($USER, $PLANET, $Element)) { continue; } $AllTech = array(); $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;"); if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) { while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) { $AllTech[] = $x; } } if (isset($queueData['quickinfo'][$Element])) { $levelToBuild = $queueData['quickinfo'][$Element]; } else { $levelToBuild = $USER[$resource[$Element]]; } $costRessources = max(1, ($pricelist[$Element]['cost']['901'] + $pricelist[$Element]['cost']['902'] * 2 + $pricelist[$Element]['cost']['903'] * 4) * pow($pricelist[$Element]['factor'], $USER[$resource[$Element]]) / 2500); $elementTime = 0; $ResearchList[$Element] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => pretty_number($costRessources), 'levelToBuild' => $levelToBuild, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element), 'AllTech' => $AllTech); } $premium_stage = 0; if ($USER['premium_reward_stage'] > 0 && $USER['premium_reward_days'] > TIMESTAMP) { $premium_stage = $USER['premium_reward_stage']; } $this->tplObj->assign_vars(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => Config::get('max_elements_tech') == 0 || Config::get('max_elements_tech') + $premium_stage == count($TechQueue), 'Queue' => $TechQueue)); $this->display('page.dmtech.default.tpl'); }
public function show() { global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $pricelist; $TheCommand = HTTP::_GP('cmd', ''); $Element = HTTP::_GP('tech', 0); $ListID = HTTP::_GP('listid', 0); $lvlup1 = HTTP::_GP('lvlup1', 0); $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET); if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue(); break; case 'remove': $this->RemoveBuildingFromQueue($ListID); break; case 'instant': $this->InstantBuildingFromQueue(); break; case 'insert': $this->AddBuildingToQueue($Element, $lvlup1, true); break; case 'destroy': $this->DoAddBuildingToQueue($Element, false); break; } $this->redirectTo('game.php?page=research'); } $bContinue = $this->CheckLabSettingsInQueue($PLANET); $queueData = $this->getQueueData(); $TechQueue = $queueData['queue']; $QueueCount = count($TechQueue); $ResearchList = array(); foreach ($reslist['tech'] as $ID => $Element) { $AllTech = array(); $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;"); if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) { while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) { $AllTech[] = $x; } } if (isset($queueData['quickinfo'][$Element])) { $levelToBuild = $queueData['quickinfo'][$Element]; } else { $levelToBuild = $USER[$resource[$Element]]; } $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild); $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources); $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources); $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources); $ResearchList[$Element] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'factor' => $pricelist[$Element]['factor'], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)); } $this->tplObj->loadscript('research.js'); $premium_stage = 0; if ($USER['premium_reward_stage'] > 0 && $USER['premium_reward_stage_days'] > TIMESTAMP) { $premium_stage = $USER['premium_reward_stage']; } $manual_step_5 = 1; if ($USER['training'] == 0 && $USER['training_step'] == 5 && $PLANET['laboratory'] < 3) { $manual_step_5 = 0; } $manual_step_5_1 = 1; if ($USER['training'] == 0 && $USER['training_step'] == 5 && $PLANET['laboratory'] >= 3) { $manual_step_5_1 = 0; } $manual_step_6 = 1; if ($USER['training'] == 0 && $USER['training_step'] == 6) { $manual_step_6 = 0; } $manual_step_6_1 = 1; $manual_step_7 = 1; if ($USER['training'] == 0 && $USER['training_step'] == 6 && $USER['spy_tech'] >= 3) { $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `training_step` = '8' WHERE `id` = " . $USER['id'] . ";"); $GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET `experience_peace` = `experience_peace` + '650' WHERE `id` = " . $USER['id'] . ";"); $manual_step_7 = 0; } $manual_step_9 = 1; if ($USER['training'] == 0 && $USER['training_step'] == 9) { $manual_step_9 = 0; } $manual_step_16 = 1; if ($USER['training'] == 0 && $USER['training_step'] == 16) { $manual_step_16 = 0; } $this->tplObj->assign_vars(array('manual_step_5_1' => $manual_step_5_1, 'manual_step_16' => $manual_step_16, 'manual_step_5' => $manual_step_5, 'manual_step_9' => $manual_step_9, 'manual_step_6' => $manual_step_6, 'dmavaible' => $USER['darkmatter'], 'modinstant' => $CONF['modinstant'], 'mod_research_cost' => $CONF['modinstantresearch'], 'modinstantresen' => $CONF['modinstantresen'], 'manual_step_7' => $manual_step_7, 'ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => Config::get('max_elements_tech') == 0 || Config::get('max_elements_tech') + $premium_stage == count($TechQueue), 'Queue' => $TechQueue)); $this->display('page.research.default.tpl'); }
public function show() { global $PLANET, $USER, $LNG, $resource, $reslist, $pricelist; if ($PLANET[$resource[31]] == 0) { $this->printMessage($LNG['bd_lab_required']); } $TheCommand = HTTP::_GP('cmd', ''); $elementId = HTTP::_GP('tech', 0); $ListID = HTTP::_GP('listid', 0); $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET); if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue(); break; case 'remove': $this->RemoveBuildingFromQueue($ListID); break; case 'insert': $this->AddBuildingToQueue($elementId, true); break; case 'destroy': $this->AddBuildingToQueue($elementId, false); break; } $this->redirectTo('game.php?page=research'); } $bContinue = $this->CheckLabSettingsInQueue($PLANET); $queueData = $this->getQueueData(); $TechQueue = $queueData['queue']; $QueueCount = count($TechQueue); $ResearchList = array(); foreach ($reslist['tech'] as $elementId) { if (!BuildFunctions::isTechnologieAccessible($USER, $PLANET, $elementId)) { continue; } if (isset($queueData['quickinfo'][$elementId])) { $levelToBuild = $queueData['quickinfo'][$elementId]; } else { $levelToBuild = $USER[$resource[$elementId]]; } $costResources = BuildFunctions::getElementPrice($USER, $PLANET, $elementId, false, $levelToBuild); $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $elementId, $costResources); $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $elementId, $costResources); $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $elementId, $costResources); $ResearchList[$elementId] = array('id' => $elementId, 'level' => $USER[$resource[$elementId]], 'maxLevel' => $pricelist[$elementId]['max'], 'costResources' => $costResources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild); } $this->assign(array('ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => Config::get()->max_elements_tech == 0 || Config::get()->max_elements_tech == count($TechQueue), 'Queue' => $TechQueue)); $this->display('page.research.default.tpl'); }
public function show() { global $PLANET, $USER, $LNG, $resource, $reslist, $CONF, $pricelist; $TheCommand = HTTP::_GP('cmd', ''); $Element = HTTP::_GP('tech', 0); $ListID = HTTP::_GP('listid', 0); $mode = HTTP::_GP('cmdd', 'physik'); $PLANET[$resource[31] . '_inter'] = ResourceUpdate::getNetworkLevel($USER, $PLANET); if (!empty($TheCommand) && $_SERVER['REQUEST_METHOD'] === 'POST' && $USER['urlaubs_modus'] == 0) { switch ($TheCommand) { case 'cancel': $this->CancelBuildingFromQueue(); break; case 'remove': $this->RemoveBuildingFromQueue($ListID); break; case 'insert': $this->AddBuildingToQueue($Element, true); break; case 'destroy': $this->AddBuildingToQueue($Element, false); break; } $this->redirectTo('game.php?page=research&cmdd=' . $mode . ''); } $bContinue = $this->CheckLabSettingsInQueue($PLANET); $queueData = $this->getQueueData(); $TechQueue = $queueData['queue']; $QueueCount = count($TechQueue); $ResearchList = array(); if ($mode == 'space') { $elementIDs = array(109, 110, 111, 115, 117, 118); } elseif ($mode == 'militar') { $elementIDs = array(145, 106, 146, 147, 148, 149); } else { $elementIDs = array(113, 140, 141, 142, 143, 144); } foreach ($elementIDs as $ID => $Element) { $AllTech = array(); $GetAll = $GLOBALS['DATABASE']->query("SELECT * FROM `uni1_vars_requriements` WHERE elementID = " . $Element . " ;"); if ($GLOBALS['DATABASE']->numRows($GetAll) > 0) { while ($x = $GLOBALS['DATABASE']->fetch_array($GetAll)) { $AllTech[] = $x; } } if (isset($queueData['quickinfo'][$Element])) { $levelToBuild = $queueData['quickinfo'][$Element]; } else { $levelToBuild = $USER[$resource[$Element]]; } $costRessources = BuildFunctions::getElementPrice($USER, $PLANET, $Element, false, $levelToBuild); $costOverflow = BuildFunctions::getRestPrice($USER, $PLANET, $Element, $costRessources); $elementTime = BuildFunctions::getBuildingTime($USER, $PLANET, $Element, $costRessources); $buyable = $QueueCount != 0 || BuildFunctions::isElementBuyable($USER, $PLANET, $Element, $costRessources); $ResearchList[$Element] = array('id' => $Element, 'level' => $USER[$resource[$Element]], 'maxLevel' => $pricelist[$Element]['max'], 'costRessources' => $costRessources, 'costOverflow' => $costOverflow, 'elementTime' => $elementTime, 'buyable' => $buyable, 'levelToBuild' => $levelToBuild, 'AllTech' => $AllTech, 'techacc' => BuildFunctions::isTechnologieAccessible($USER, $PLANET, $Element)); } if ($USER['b_tech_id'] != 0) { $this->tplObj->loadscript('research.js'); } $max_build = Config::get('max_elements_tech'); if ($USER['mode_chaine'] > TIMESTAMP) { $max_build += 2; } if ($mode == 'space') { $Tab = 'Space research'; } elseif ($mode == 'militar') { $Tab = 'Military research'; } else { $Tab = 'Theoretical Physics'; } $this->tplObj->assign_vars(array('Tab' => $Tab, 'ResearchList' => $ResearchList, 'IsLabinBuild' => !$bContinue, 'IsFullQueue' => $max_build == 0 || $max_build == count($TechQueue), 'Queue' => $TechQueue, 'mode' => $mode)); $this->display('page.research.default.tpl'); }