本文整理汇总了PHP中Game::getPlanet方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::getPlanet方法的具体用法?PHP Game::getPlanet怎么用?PHP Game::getPlanet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::getPlanet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _match
/**
* @return bool
*/
protected function _match()
{
if ($this->getUser()->get("hp") == Core::getUser()->get("curplanet")) {
return Game::getPlanet()->getData("planetname") != Core::getLang()->get("HOME_PLANET");
}
$planet = Game::getModel("game/planet")->load($this->getUser()->get("hp"));
return $planet->get("planetname") != Core::getLang()->get("HOME_PLANET");
}
示例2: _add
/**
* (non-PHPdoc)
* @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_add($event, $data)
*/
protected function _add(Bengine_Game_Model_Event $event, array $data)
{
$planet = Game::getPlanet();
$planet->setData("metal", $planet->getData("metal") - $data["metal"] * $data["quantity"]);
$planet->setData("silicon", $planet->getData("silicon") - $data["silicon"] * $data["quantity"]);
$planet->setData("hydrogen", $planet->getData("hydrogen") - $data["hydrogen"] * $data["quantity"]);
$spec = array("metal" => new Recipe_Database_Expr("metal - ?"), "silicon" => new Recipe_Database_Expr("silicon - ?"), "hydrogen" => new Recipe_Database_Expr("hydrogen - ?"));
$bind = array($data["metal"] * $data["quantity"], $data["silicon"] * $data["quantity"], $data["hydrogen"] * $data["quantity"], $event->get("planetid"));
$bind = array_map("intval", $bind);
Core::getQuery()->update("planet", $spec, "planetid = ?", $bind);
return $this;
}
示例3: hasResources
public function hasResources()
{
if ($this->get("basic_metal") > Game::getPlanet()->getData("metal")) {
return false;
}
if ($this->get("basic_silicon") > Game::getPlanet()->getData("silicon")) {
return false;
}
if ($this->get("basic_hydrogen") > Game::getPlanet()->getData("hydrogen")) {
return false;
}
$energy = Game::getPlanet()->getEnergy() < 0 ? 0 : Game::getPlanet()->getEnergy();
if ($this->get("basic_energy") > $energy) {
return false;
}
return true;
}
示例4: checkResources
/**
* Checks the resources.
*
* @return boolean True if resources suffice, fals if not
*/
protected function checkResources()
{
if ($this->requiredMetal > Game::getPlanet()->getData("metal")) {
return false;
}
if ($this->requiredSilicon > Game::getPlanet()->getData("silicon")) {
return false;
}
if ($this->requiredHydrogen > Game::getPlanet()->getData("hydrogen")) {
return false;
}
$energy = Game::getPlanet()->getEnergy() < 0 ? 0 : Game::getPlanet()->getEnergy();
if ($this->requiredEnergy > $energy) {
return false;
}
return true;
}
示例5: hasResources
/**
* Checks if the current planet has enough resources to build this.
*
* @return bool
*/
public function hasResources()
{
$required = $this->calculateRequiredResources();
if ($required["required_metal"] > Game::getPlanet()->getData("metal")) {
return false;
}
if ($required["required_silicon"] > Game::getPlanet()->getData("silicon")) {
return false;
}
if ($required["required_hydrogen"] > Game::getPlanet()->getData("hydrogen")) {
return false;
}
$energy = Game::getPlanet()->getEnergy() < 0 ? 0 : Game::getPlanet()->getEnergy();
if ($required["required_energy"] > $energy) {
return false;
}
return true;
}
示例6: validate
/**
* Checks for validation.
*
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_MonitorPlanet
*/
protected function validate()
{
if (!$this->planetData->getPlanetid() || $this->planetData->getIsmoon() || Core::getUser()->get("curplanet") == $this->planetData->getPlanetid()) {
throw new Recipe_Exception_Generic("The selected planet is unavailable.");
}
// Check range
if (Game::getPlanet()->getBuilding("STAR_SURVEILLANCE") <= 0) {
throw new Recipe_Exception_Generic("Range exceeded.");
}
$range = pow(Game::getPlanet()->getBuilding("STAR_SURVEILLANCE"), 2) - 1;
$diff = abs(Game::getPlanet()->getData("system") - $this->planetData->getSystem());
if ($this->planetData->getGalaxy() != Game::getPlanet()->getData("galaxy") || $range < $diff) {
throw new Recipe_Exception_Generic("Range exceeded.");
}
// Check consumption
Core::getLanguage()->load(array("Galaxy", "Main", "info"));
if (Game::getPlanet()->getData("hydrogen") < Core::getOptions()->get("STAR_SURVEILLANCE_CONSUMPTION")) {
Logger::dieMessage("DEFICIENT_CONSUMPTION");
}
return $this;
}
示例7: checkResourceForQuantity
/**
* Checks the resource against the given quantity and reduce it if needed.
*
* @param integer $qty Quantity
* @param Bengine_Game_Model_Unit $construction Ship data row
*
* @return integer
*/
protected function checkResourceForQuantity($qty, Bengine_Game_Model_Unit $construction)
{
$basicMetal = $construction->get("basic_metal");
$basicSilicon = $construction->get("basic_silicon");
$basicHydrogen = $construction->get("basic_hydrogen");
$basicEnergy = $construction->get("basic_energy");
$metal = _pos(Game::getPlanet()->getData("metal"));
$silicon = _pos(Game::getPlanet()->getData("silicon"));
$hydrogen = _pos(Game::getPlanet()->getData("hydrogen"));
$energy = _pos(Game::getPlanet()->getEnergy());
$requiredMetal = $basicMetal * $qty;
$requiredSilicon = $basicSilicon * $qty;
$requiredHydrogen = $basicHydrogen * $qty;
$requiredEnergy = $basicEnergy * $qty;
if ($requiredMetal > $metal || $requiredSilicon > $silicon || $requiredHydrogen > $hydrogen || $requiredEnergy > $energy) {
// Try to reduce quantity
$q = array();
$q[] = $basicMetal > 0 ? floor($metal / $basicMetal) : $qty;
$q[] = $basicSilicon > 0 ? floor($silicon / $basicSilicon) : $qty;
$q[] = $basicHydrogen > 0 ? floor($hydrogen / $basicHydrogen) : $qty;
$q[] = $basicEnergy > 0 ? floor($energy / $basicEnergy) : $qty;
$qty = min($q);
}
return $qty;
}
示例8: 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;
}
示例9: changePlanetOptions
/**
* Shows form for planet options.
*
* @param string $planetname
* @param boolean $abandon
* @param string $password
*
* @return Bengine_Game_Controller_Index
*/
protected function changePlanetOptions($planetname, $abandon, $password)
{
$planetname = trim($planetname);
Hook::event("SAVE_PLANET_OPTIONS", array(&$planetname, &$abandon));
if ($abandon == 1) {
$ok = true;
if (Game::getEH()->getPlanetFleetEvents()) {
Logger::addMessage("CANNOT_DELETE_PLANET");
$ok = false;
}
if (Core::getUser()->get("hp") == Core::getUser()->get("curplanet")) {
Logger::addMessage("CANNOT_DELETE_HOMEPLANET");
$ok = false;
}
$result = Core::getQuery()->select("password", "password", "", Core::getDB()->quoteInto("userid = ?", Core::getUser()->get("userid")));
$row = $result->fetchRow();
$result->closeCursor();
$encryption = Core::getOptions("USE_PASSWORD_SALT") ? "md5_salt" : "md5";
$password = Str::encode($password, $encryption);
if (!Str::compare($row["password"], $password)) {
Logger::addMessage("WRONG_PASSWORD");
$ok = false;
}
if ($ok) {
deletePlanet(Game::getPlanet()->getPlanetId(), Core::getUser()->get("userid"), Game::getPlanet()->getData("ismoon"));
Core::getQuery()->update("user", array("curplanet" => Core::getUser()->get("hp")), "userid = ?", array(Core::getUser()->get("userid")));
Core::getUser()->rebuild();
$this->redirect("game/" . SID . "/Index");
}
} else {
if (checkCharacters($planetname)) {
Core::getQuery()->update("planet", array("planetname" => $planetname), "planetid = ?", array(Core::getUser()->get("curplanet")));
$this->redirect("game/" . SID . "/Index");
} else {
Logger::addMessage("INVALID_PLANET_NAME");
}
}
return $this;
}
示例10: infoAction
/**
* Shows all building information.
*
* @param integer $id
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Constructions
*/
protected function infoAction($id)
{
$select = array("name", "demolish", "basic_metal", "basic_silicon", "basic_hydrogen", "basic_energy", "prod_metal", "prod_silicon", "prod_hydrogen", "prod_energy", "special", "cons_metal", "cons_silicon", "cons_hydrogen", "cons_energy", "charge_metal", "charge_silicon", "charge_hydrogen", "charge_energy");
$result = Core::getQuery()->select("construction", $select, "", Core::getDB()->quoteInto("buildingid = ? AND (mode = '1' OR mode = '2' OR mode = '5')", $id));
if ($row = $result->fetchRow()) {
$result->closeCursor();
Core::getLanguage()->load("info,Resource");
Hook::event("BuildingInfoBefore", array(&$row));
// Assign general building data
Core::getTPL()->assign("buildingName", Core::getLanguage()->getItem($row["name"]));
Core::getTPL()->assign("buildingDesc", Core::getLanguage()->getItem($row["name"] . "_FULL_DESC"));
Core::getTPL()->assign("buildingImage", Image::getImage("buildings/" . $row["name"] . ".gif", Core::getLanguage()->getItem($row["name"]), null, null, "leftImage"));
Core::getTPL()->assign("edit", Link::get("game/" . SID . "/Construction_Edit/Index/" . $id, "[" . Core::getLanguage()->getItem("EDIT") . "]"));
// Production and consumption of the building
$prodFormula = false;
if (!empty($row["prod_metal"])) {
$prodFormula = $row["prod_metal"];
$baseCost = $row["basic_metal"];
} else {
if (!empty($row["prod_silicon"])) {
$prodFormula = $row["prod_silicon"];
$baseCost = $row["basic_metal"];
} else {
if (!empty($row["prod_hydrogen"])) {
$prodFormula = $row["prod_hydrogen"];
$baseCost = $row["basic_hydrogen"];
} else {
if (!empty($row["prod_energy"])) {
$prodFormula = $row["prod_energy"];
$baseCost = $row["basic_energy"];
} else {
if (!empty($row["special"])) {
$prodFormula = $row["special"];
$baseCost = 0;
}
}
}
}
}
$consFormula = false;
if (!empty($row["cons_metal"])) {
$consFormula = $row["cons_metal"];
} else {
if (!empty($row["cons_silicon"])) {
$consFormula = $row["cons_silicon"];
} else {
if (!empty($row["cons_hydrogen"])) {
$consFormula = $row["cons_hydrogen"];
} else {
if (!empty($row["cons_energy"])) {
$consFormula = $row["cons_energy"];
}
}
}
}
// Production and consumption chart
$chartType = false;
if ($prodFormula != false || $consFormula != false) {
$chart = array();
$chartType = "cons_chart";
if ($prodFormula && $consFormula) {
$chartType = "prod_and_cons_chart";
} else {
if ($prodFormula) {
$chartType = "prod_chart";
}
}
if (Game::getPlanet()->getBuilding($id) - 7 < 0) {
$start = 7;
} else {
$start = Game::getPlanet()->getBuilding($id);
}
$productionFactor = (double) Core::getConfig()->get("PRODUCTION_FACTOR");
if (!empty($row["prod_energy"])) {
$productionFactor = 1;
}
$currentProduction = 0;
if ($prodFormula) {
$currentProduction = parseFormula($prodFormula, $baseCost, Game::getPlanet()->getBuilding($id)) * $productionFactor;
}
$currentConsumption = 0;
if ($consFormula) {
$currentConsumption = parseFormula($consFormula, 0, Game::getPlanet()->getBuilding($id));
}
for ($i = $start - 7; $i <= Game::getPlanet()->getBuilding($id) + 7; $i++) {
$chart[$i]["level"] = $i;
$chart[$i]["s_prod"] = $prodFormula ? parseFormula($prodFormula, $baseCost, $i) * $productionFactor : 0;
$chart[$i]["s_diffProd"] = $prodFormula ? $chart[$i]["s_prod"] - $currentProduction : 0;
$chart[$i]["s_cons"] = $consFormula ? parseFormula($consFormula, 0, $i) : 0;
$chart[$i]["s_diffCons"] = $consFormula ? $currentConsumption - $chart[$i]["s_cons"] : 0;
$chart[$i]["prod"] = fNumber($chart[$i]["s_prod"]);
$chart[$i]["diffProd"] = fNumber($chart[$i]["s_diffProd"]);
$chart[$i]["cons"] = fNumber($chart[$i]["s_cons"]);
//.........这里部分代码省略.........
示例11: inMissileRange
/**
* Checks if the current solar system is in missile range.
*
* @return boolean
*/
protected function inMissileRange()
{
if ($this->galaxy != Game::getPlanet()->getData("galaxy")) {
return false;
}
if (abs(Game::getPlanet()->getData("system") - $this->system) <= $this->missileRange) {
return true;
}
return false;
}
示例12: updateAction
/**
* Saves resource production factor.
*
* @return Bengine_Game_Controller_Resource
*/
protected function updateAction()
{
if (!Core::getUser()->get("umode")) {
$post = Core::getRequest()->getPOST();
Hook::event("SaveResources");
foreach ($this->data as $key => $value) {
if ($value["level"] > 0) {
$factor = abs(isset($post[$key]) ? $post[$key] : 100);
$factor = $factor > 100 ? 100 : $factor;
Core::getQuery()->update("building2planet", array("prod_factor" => $factor), "buildingid = ? AND planetid = ?", array($key, Core::getUser()->get("curplanet")));
}
}
if (Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID) > 0) {
$satelliteProd = abs($post[39]);
$satelliteProd = $satelliteProd > 100 ? 100 : $satelliteProd;
Core::getQuery()->update("planet", array("solar_satellite_prod" => $satelliteProd), "planetid = ?", array(Core::getUser()->get("curplanet")));
}
}
$this->redirect("game/" . SID . "/Resource");
return $this;
}
示例13: 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;
}
}
//.........这里部分代码省略.........
示例14: espionageAction
/**
* Sends espionage probes.
*
* @param int $target
* @return Bengine_Game_Controller_Ajax_Fleet
*/
protected function espionageAction($target)
{
if (Game::attackingStoppageEnabled()) {
$this->display($this->format(Core::getLang()->get("ATTACKING_STOPPAGE_ENABLED")));
}
$select = array("p.planetid", "g.galaxy", "g.system", "g.position", "u2s.quantity", "sd.capicity", "sd.speed", "sd.consume", "b.name AS shipname");
$joins = "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = p.planetid)";
$joins .= "LEFT JOIN " . PREFIX . "unit2shipyard u2s ON (u2s.planetid = p.planetid)";
$joins .= "LEFT JOIN " . PREFIX . "ship_datasheet sd ON (sd.unitid = u2s.unitid)";
$joins .= "LEFT JOIN " . PREFIX . "construction b ON (b.buildingid = u2s.unitid)";
$result = Core::getQuery()->select("planet p", $select, $joins, Core::getDB()->quoteInto("p.planetid = ? AND u2s.unitid = '38'", Core::getUser()->get("curplanet")));
if ($row = $result->fetchRow()) {
$result->closeCursor();
$joins = "LEFT JOIN " . PREFIX . "planet p ON (g.planetid = p.planetid)";
$joins .= "LEFT JOIN " . PREFIX . "user u ON (u.userid = p.userid)";
$joins .= "LEFT JOIN " . PREFIX . "ban_u b ON (u.userid = b.userid)";
$where = Core::getDB()->quoteInto("g.planetid = ? OR g.moonid = ?", $target);
$result = Core::getQuery()->select("galaxy g", array("g.galaxy", "g.system", "g.position", "u.points", "u.last", "u.umode", "b.to"), $joins, $where);
if ($tar = $result->fetchRow()) {
$result->closeCursor();
Hook::event("AjaxSendFleetEspionage", array($this, &$row, &$tar));
$ignoreNP = false;
if ($tar["last"] <= TIME - 604800) {
$ignoreNP = true;
} else {
if ($tar["to"] >= TIME) {
$ignoreNP = true;
}
}
$data = array();
// Check for newbie protection
if ($ignoreNP === false) {
$isProtected = isNewbieProtected(Core::getUser()->get("points"), $tar["points"]);
if ($isProtected == 1) {
$this->display($this->format(Core::getLanguage()->getItem("TARGET_TOO_WEAK")));
} else {
if ($isProtected == 2) {
$this->display($this->format(Core::getLanguage()->getItem("TARGET_TOO_STRONG")));
}
}
}
// Check for vacation mode
if ($tar["umode"] || Core::getUser()->get("umode")) {
$this->display($this->format(Core::getLanguage()->getItem("TARGET_IN_UMODE")));
}
// Get quantity
if ($row["quantity"] >= Core::getUser()->get("esps")) {
$data["ships"][38]["quantity"] = Core::getUser()->get("esps") > 0 ? Core::getUser()->get("esps") : 1;
} else {
$data["ships"][38]["quantity"] = $row["quantity"];
}
$data["ships"][38]["id"] = 38;
$data["ships"][38]["name"] = $row["shipname"];
$data["maxspeed"] = Game::getSpeed(38, $row["speed"]);
$distance = Game::getDistance($tar["galaxy"], $tar["system"], $tar["position"]);
$time = Game::getFlyTime($distance, $data["maxspeed"]);
$data["consumption"] = Game::getFlyConsumption($data["ships"][38]["quantity"] * $row["consume"], $distance);
if (Game::getPlanet()->getData("hydrogen") < $data["consumption"]) {
$this->display($this->format(Core::getLanguage()->getItem("DEFICIENT_CONSUMPTION")));
}
if ($row["capicity"] * $data["ships"][38]["quantity"] - $data["consumption"] < 0) {
$this->display($this->format(Core::getLanguage()->getItem("DEFICIENT_CAPACITY")));
}
Game::getPlanet()->setData("hydrogen", Game::getPlanet()->getData("hydrogen") - $data["consumption"]);
$data["time"] = $time;
$data["galaxy"] = $tar["galaxy"];
$data["system"] = $tar["system"];
$data["position"] = $tar["position"];
$data["sgalaxy"] = $row["galaxy"];
$data["ssystem"] = $row["system"];
$data["sposition"] = $row["position"];
$data["metal"] = 0;
$data["silicon"] = 0;
$data["hydrogen"] = 0;
Hook::event("AjaxSendFleetEspionageStartEvent", array($row, $tar, &$data));
Game::getEH()->addEvent(11, $time + TIME, Core::getUser()->get("curplanet"), Core::getUser()->get("userid"), $target, $data);
$this->display($this->format(sprintf(Core::getLanguage()->getItem("ESPS_SENT"), $data["ships"][38]["quantity"], $data["galaxy"], $data["system"], $data["position"]), 1));
} else {
$result->closeCursor();
$this->display($this->format("Unkown destination"));
}
} else {
$result->closeCursor();
$this->display($this->format(Core::getLanguage()->getItem("DEFICIENT_ESPS")));
}
return $this;
}
示例15: 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;
}