本文整理汇总了PHP中Game::getResearch方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::getResearch方法的具体用法?PHP Game::getResearch怎么用?PHP Game::getResearch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::getResearch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Main method of sending fleet via Ajax.
*
* @return Bengine_Game_Controller_Ajax_Fleet
*/
protected function init()
{
Core::getLanguage()->load("Galaxy");
$events = Game::getEH()->getOwnFleetEvents();
if ($events !== false && Game::getResearch(14) + 1 <= count($events)) {
Core::getLanguage()->load("mission");
$this->display($this->format(Core::getLanguage()->getItem("NO_FREE_FLEET_SLOTS")));
}
$this->setIsAjax();
Hook::event("AjaxSendFleet", array($this));
return parent::init();
}
示例2: parseFormula
/**
* Executes a formula.
*
* @param string $formula Formular to execute
* @param integer $basic First number to replace
* @param integer $level Second number to replace
*
* @return integer Result
*/
function parseFormula($formula, $basic, $level)
{
Hook::event("ParseFormula", array(&$formula, &$basic, &$level));
$formula = Str::replace("{level}", $level, $formula);
$formula = Str::replace("{basic}", $basic, $formula);
$formula = Str::replace("{temp}", Game::getPlanet()->getData("temperature"), $formula);
$formula = preg_replace_callback("#\\{tech\\=([0-9]+)\\}#i", function ($matches) {
return Game::getResearch($matches[1]);
}, $formula);
$formula = preg_replace_callback("#\\{building\\=([0-9]+)\\}#i", function ($matches) {
return Game::getPlanet()->getBuilding($matches[1]);
}, $formula);
$result = 0;
eval("\$result = " . $formula . ";");
return (int) $result;
}
示例3: sendFleet
/**
* This starts the missions and shows a quick overview of the flight.
*
* @param integer $mode
* @param integer $metal
* @param integer $silicon
* @param integer $hydrogen
* @param integer $holdingTime
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Mission
*/
protected function sendFleet($mode, $metal, $silicon, $hydrogen, $holdingTime)
{
$this->noAction = true;
$fleetEvents = Game::getEH()->getOwnFleetEvents();
if ($fleetEvents && Game::getResearch(14) + 1 <= count(Game::getEH()->getOwnFleetEvents())) {
throw new Recipe_Exception_Generic("Too many fleets on missions.");
}
$result = Core::getQuery()->select("temp_fleet", "data", "", Core::getDB()->quoteInto("planetid = ?", Core::getUser()->get("curplanet")));
if ($row = $result->fetchRow()) {
$result->closeCursor();
$temp = unserialize($row["data"]);
if (!in_array($mode, $temp["amissions"])) {
Logger::dieMessage("UNKNOWN_MISSION");
}
$data["ships"] = $temp["ships"];
$data["galaxy"] = $temp["galaxy"];
$data["system"] = $temp["system"];
$data["position"] = $temp["position"];
$data["sgalaxy"] = Game::getPlanet()->getData("galaxy");
$data["ssystem"] = Game::getPlanet()->getData("system");
$data["sposition"] = Game::getPlanet()->getData("position");
$data["maxspeed"] = $temp["maxspeed"];
$distance = Game::getDistance($data["galaxy"], $data["system"], $data["position"]);
$data["consumption"] = Game::getFlyConsumption($temp["consumption"], $distance, $temp["speed"]);
if (Game::getPlanet()->getData("hydrogen") - $data["consumption"] < 0) {
Logger::dieMessage("NOT_ENOUGH_FUEL");
}
if ($temp["capacity"] < $data["consumption"]) {
Logger::dieMessage("NOT_ENOUGH_CAPACITY");
}
$data["metal"] = (int) abs($metal);
$data["silicon"] = (int) abs($silicon);
$data["hydrogen"] = (int) abs($hydrogen);
if ($data["metal"] > Game::getPlanet()->getData("metal")) {
$data["metal"] = _pos(Game::getPlanet()->getData("metal"));
}
if ($data["silicon"] > Game::getPlanet()->getData("silicon")) {
$data["silicon"] = _pos(Game::getPlanet()->getData("silicon"));
}
if ($data["hydrogen"] > Game::getPlanet()->getData("hydrogen") - $data["consumption"]) {
$data["hydrogen"] = _pos(Game::getPlanet()->getData("hydrogen") - $data["consumption"]);
}
if ($mode == 13) {
$data["duration"] = _pos($holdingTime);
if ($data["duration"] > 24) {
$data["duration"] = 24;
}
$data["duration"] *= 3600;
}
$capa = $temp["capacity"] - $data["consumption"] - $data["metal"] - $data["silicon"] - $data["hydrogen"];
// Reduce used capacity automatically
if ($capa < 0) {
if ($capa + $data["hydrogen"] > 0) {
$data["hydrogen"] -= abs($capa);
} else {
$capa += $data["hydrogen"];
$data["hydrogen"] = 0;
if ($capa + $data["silicon"] > 0 && $capa < 0) {
$data["silicon"] -= abs($capa);
} else {
if ($capa < 0) {
$capa += $data["silicon"];
$data["silicon"] = 0;
if ($capa + $data["metal"] && $capa < 0) {
$data["metal"] -= abs($capa);
} else {
if ($capa < 0) {
$data["metal"] = 0;
}
}
}
}
}
}
$data["capacity"] = $temp["capacity"] - $data["consumption"] - $data["metal"] - $data["silicon"] - $data["hydrogen"];
if ($data["capacity"] < 0) {
Logger::dieMessage("NOT_ENOUGH_CAPACITY");
}
// If mission is recycling, get just the capacity of the recyclers.
if ($mode == 9 && $data["capacity"] > 0) {
$_result = Core::getQuery()->select("ship_datasheet", "capicity", "", "unitid = '37'");
// It is __capacity__ and not capicity
$_row = $_result->fetchRow();
$_result->closeCursor();
$recCapa = $_row["capicity"] * $temp["ships"][37]["quantity"];
if ($data["capacity"] >= $recCapa) {
$data["capacity"] = $recCapa;
}
}
//.........这里部分代码省略.........
示例4: upgradeAction
/**
* Check for sufficient resources and start research upgrade.
*
* @param integer $id Building id to upgrade
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Research
*/
protected function upgradeAction($id)
{
// Check events
if ($this->event != false || Core::getUser()->get("umode")) {
$this->redirect("game/" . SID . "/Research");
}
// Check for requirements
if (!Game::canBuild($id) || !Game::getPlanet()->getBuilding("RESEARCH_LAB")) {
throw new Recipe_Exception_Generic("You do not fulfil the requirements to research this.");
}
// Check if research labor is not in progress
if (!Game::getEH()->canReasearch()) {
throw new Recipe_Exception_Generic("Research labor in progress.");
}
/* @var Bengine_Game_Model_Construction $construction */
$construction = Game::getModel("game/construction");
$construction->load($id);
if (!$construction->getId()) {
throw new Recipe_Exception_Generic("Unkown research :(");
}
if ($construction->get("mode") != self::RESEARCH_CONSTRUCTION_TYPE) {
throw new Recipe_Exception_Generic("Research not allowed.");
}
if (Game::getPlanet()->getData("ismoon") && !$construction->get("allow_on_moon")) {
throw new Recipe_Exception_Generic("Research not allowed.");
}
Hook::event("UpgradeResearchFirst", array($construction));
// Get required resources
$level = Game::getResearch($id);
if ($level > 0) {
$level = $level + 1;
} else {
$level = 1;
}
$this->setRequieredResources($level, $construction);
// Check resources
if ($this->checkResources()) {
$data["metal"] = $this->requiredMetal;
$data["silicon"] = $this->requiredSilicon;
$data["hydrogen"] = $this->requiredHydrogen;
$data["energy"] = $this->requiredEnergy;
$time = getBuildTime($data["metal"], $data["silicon"], self::RESEARCH_CONSTRUCTION_TYPE);
$data["level"] = $level;
$data["buildingid"] = $id;
$data["buildingname"] = $construction->get("name");
Hook::event("UpgradeResearchLast", array($construction, &$data, &$time));
Game::getEH()->addEvent(3, $time + TIME, Core::getUser()->get("curplanet"), Core::getUser()->get("userid"), null, $data);
$this->redirect("game/" . SID . "/Research");
} else {
Logger::dieMessage("INSUFFICIENT_RESOURCES");
}
return $this;
}
示例5: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Techtree
*/
protected function indexAction()
{
$reqs = Game::getAllRequirements();
$cons = array();
$research = array();
$ships = array();
$def = array();
$moon = array();
$result = Core::getQuery()->select("construction", array("buildingid", "mode", "name"), "ORDER BY display_order ASC, buildingid ASC");
foreach ($result->fetchAll() as $row) {
Hook::event("LoadTechtree", array(&$row));
$bid = $row["buildingid"];
$requirements = "";
if (!isset($reqs[$bid])) {
$reqs[$bid] = array();
}
foreach ($reqs[$bid] as $r) {
$buffer = Core::getLanguage()->getItem($r["name"]) . " (" . Core::getLanguage()->getItem("LEVEL") . " " . $r["level"] . ")</span><br />";
$rLevel = 0;
if ($r["mode"] == 1 || $r["mode"] == 5) {
$rLevel = Game::getPlanet()->getBuilding($r["needs"]);
} else {
if ($r["mode"] == 2) {
$rLevel = Game::getResearch($r["needs"]);
}
}
if ($rLevel >= $r["level"]) {
$requirements .= "<span class=\"true\">" . $buffer;
} else {
$requirements .= "<span class=\"false\">" . $buffer;
}
}
$name = Core::getLanguage()->getItem($row["name"]);
switch ($row["mode"]) {
case 1:
$cons[$bid]["name"] = Link::get("game/" . SID . "/Constructions/Info/" . $row["buildingid"], $name);
$cons[$bid]["requirements"] = $requirements;
break;
case 2:
$research[$bid]["name"] = Link::get("game/" . SID . "/Constructions/Info/" . $row["buildingid"], $name);
$research[$bid]["requirements"] = $requirements;
break;
case 3:
$ships[$bid]["name"] = Link::get("game/" . SID . "/Unit/Info/" . $row["buildingid"], $name);
$ships[$bid]["requirements"] = $requirements;
break;
case 4:
$def[$bid]["name"] = Link::get("game/" . SID . "/Unit/Info/" . $row["buildingid"], $name);
$def[$bid]["requirements"] = $requirements;
break;
case 5:
$moon[$bid]["name"] = Link::get("game/" . SID . "/Constructions/Info/" . $row["buildingid"], $name);
$moon[$bid]["requirements"] = $requirements;
break;
}
}
$result->closeCursor();
Hook::event("ShowLoadedTechtree", array(&$cons, &$research, &$ships, &$def, &$moon, &$moon));
Core::getTPL()->addLoop("construction", $cons);
Core::getTPL()->addLoop("research", $research);
Core::getTPL()->addLoop("shipyard", $ships);
Core::getTPL()->addLoop("defense", $def);
Core::getTPL()->addLoop("moon", $moon);
return $this;
}