本文整理汇总了PHP中Game::getEH方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::getEH方法的具体用法?PHP Game::getEH怎么用?PHP Game::getEH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::getEH方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cancelAction
/**
* @return Bengine_Game_Controller_Shipyard
*/
protected function cancelAction()
{
$events = Core::getRequest()->getPOST("shipyard_events");
foreach ($events as $eventId) {
$event = Game::getModel("game/event")->load((int) $eventId);
if ($event->get("userid") == Core::getUser()->get("userid")) {
Game::getEH()->removeEvent($event);
}
}
$this->redirect("game/" . SID . "/" . Core::getRequest()->getGET("controller"));
return $this;
}
示例2: infoAction
//.........这里部分代码省略.........
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"]);
$chart[$i]["diffCons"] = fNumber($chart[$i]["s_diffCons"]);
}
Hook::event("BuildingInfoProduction", array(&$chart));
Core::getTPL()->addLoop("chart", $chart);
}
if ($chartType) {
Core::getTPL()->assign("chartType", "game/constructions/" . $chartType);
}
// Show demolish function
$factor = floatval($row["demolish"]);
if (Game::getPlanet()->getBuilding($id) > 0 && $factor > 0.0) {
Core::getTPL()->assign("buildingLevel", Game::getPlanet()->getBuilding($id));
Core::getTPL()->assign("demolish", true);
$metal = "";
$_metal = 0;
$silicon = "";
$_silicon = 0;
$hydrogen = "";
$_hydrogen = 0;
if ($row["basic_metal"] > 0) {
$_metal = 1 / $factor * parseFormula($row["charge_metal"], $row["basic_metal"], Game::getPlanet()->getBuilding($id));
$metal = Core::getLanguage()->getItem("METAL") . ": " . fNumber($_metal);
}
Core::getTPL()->assign("metal", $metal);
if ($row["basic_silicon"] > 0) {
$_silicon = 1 / $factor * parseFormula($row["charge_silicon"], $row["basic_silicon"], Game::getPlanet()->getBuilding($id));
$silicon = Core::getLanguage()->getItem("SILICON") . ": " . fNumber($_silicon);
}
Core::getTPL()->assign("silicon", $silicon);
if ($row["basic_hydrogen"] > 0) {
$_hydrogen = 1 / $factor * parseFormula($row["charge_hydrogen"], $row["basic_hydrogen"], Game::getPlanet()->getBuilding($id));
$hydrogen = Core::getLanguage()->getItem("HYDROGEN") . ": " . fNumber($_hydrogen);
}
Core::getTPL()->assign("hydrogen", $hydrogen);
$time = getBuildTime($_metal, $_silicon, self::BUILDING_CONSTRUCTION_TYPE);
Core::getTPL()->assign("dimolishTime", getTimeTerm($time));
$showLink = Game::getPlanet()->getData("metal") >= $_metal && Game::getPlanet()->getData("silicon") >= $_silicon && Game::getPlanet()->getData("hydrogen") >= $_hydrogen;
if ($id == 12 && Game::getEH()->getResearchEvent()) {
$showLink = false;
}
$shipyardSize = Game::getEH()->getShipyardEvents()->getCalculatedSize();
if (($id == 8 || $id == 7) && $shipyardSize > 0) {
$showLink = false;
}
Core::getTPL()->assign("showLink", $showLink && !$this->event && !Core::getUser()->get("umode"));
Core::getTPL()->assign("demolishNow", Link::get("game/" . SID . "/Constructions/Demolish/{$id}", Core::getLanguage()->getItem("DEMOLISH_NOW")));
} else {
Core::getTPL()->assign("demolish", false);
}
Hook::event("BuildingInfoAfter", array(&$row));
} else {
$result->closeCursor();
throw new Recipe_Exception_Generic("Unkown building. You'd better don't manipulate the URL. We see everything ;)");
}
return $this;
}
示例3: parseEvent
/**
* Parses an event.
*
* @param Bengine_Game_Model_Event $f
*
* @return array Parsed event data
*/
protected function parseEvent(Bengine_Game_Model_Event $f)
{
if ($f->getCode() == "game/alliedFleet" && $f->getUserid() != Core::getUser()->get("userid")) {
return false;
// Hide foreign formations
}
$event = array();
$event["time_r"] = $f->getTimeLeft();
$event["time"] = $f->getFormattedTimeLeft();
$event["eventid"] = $f->getEventid();
$event["time_finished"] = Date::timeToString(1, $f->getTime());
$event["raw_coordinates"] = $f->getDestinationCoords(false);
Core::getLanguage()->assign("rockets", $f->getData("rockets", 0));
Core::getLanguage()->assign("planet", !$f->getData("oldmode") || $f->getData("oldmode") != 9 ? $f->getPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
// TODO: Old mode should be translated to code
Core::getLanguage()->assign("coords", $f->getPlanetCoords());
Core::getLanguage()->assign("target", $f->getCode() != "game/recycling" ? $f->getDestinationPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
Core::getLanguage()->assign("targetcoords", $f->getDestinationCoords());
Core::getLanguage()->assign("metal", fNumber($f->getData("metal", 0)));
Core::getLanguage()->assign("silicon", fNumber($f->getData("silicon", 0)));
Core::getLanguage()->assign("hydrogen", fNumber($f->getData("hydrogen", 0)));
Core::getLanguage()->assign("username", $f->getUsername());
Core::getLanguage()->assign("message", Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($f->getUsername()), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))));
Core::getLanguage()->assign("mission", $f->getCode() == "game/return" ? $f->getOrgModeName() : $f->getModeName());
Core::getLanguage()->assign("fleet", $f->getFleetString());
$event["class"] = $f->getCssClass();
if ($f->getCode() == "game/allianceAttack") {
if ($f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
} else {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OTHER");
}
$allyFleets = Game::getEH()->getFormationFleets($f->getEventid());
foreach ($allyFleets as $af) {
$coords = $af->getPlanetCoords();
$msg = Core::getLanguage()->getItem("FLEET_MESSAGE_FORMATION");
$msg = sprintf($msg, $af->getUsername(), $af->getPlanetname(), $coords, $af->getFleetString());
$event["message"] .= $msg;
}
} else {
if ($f->getCode() == "game/alliedFleet") {
$mainFleet = Game::getModel("game/event")->load($f->getParentId());
if ($mainFleet->getUsierid() == Core::getUser()->get("userid")) {
return false;
}
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
$allyFleets = Game::getEH()->getFormationFleets($mainFleet->getEventid());
$allyFleets->add($mainFleet);
foreach ($allyFleets as $af) {
if ($af->getUserid() == Core::getUser()->get("userid")) {
continue;
}
$coords = $af->getPlanetCoords();
$msg = Core::getLanguage()->getItem("FLEET_MESSAGE_FORMATION");
$msg = sprintf($msg, $af->getUsername(), $af->getPlanetname(), $coords, $af->getFleetString());
$event["message"] .= $msg;
}
} else {
if ($f->getCode() == "game/holding" && $f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_1");
} else {
if ($f->getCode() == "game/holding") {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_2");
} else {
if ($f->getCode() == "game/return" && $f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_RETURN");
} else {
if ($f->getUserid() == Core::getUser()->get("userid") && $f->getCode() == "game/missileAttack") {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_ROCKET_ATTACK");
} else {
if ($f->getCode() == "game/missileAttack") {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_ROCKET_ATTACK_FOREIGN");
} else {
if ($f->getUserid() == Core::getUser()->get("userid")) {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
} else {
$event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OTHER");
}
}
}
}
}
}
}
}
return $event;
}
示例4: retreatFleet
/**
* Retreats a fleet back to its origin planet.
*
* @param integer $id
*
* @return Bengine_Game_Controller_Mission
*/
protected function retreatFleet($id)
{
$this->noAction = true;
Hook::event("RetreatFleet", array(&$id));
Game::getEH()->removeEvent($id);
$this->redirect("game/" . SID . "/Mission");
return $this;
}
示例5: 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;
}
示例6: abortAction
/**
* Aborts the current research event.
*
* @param integer $id Building id
*
* @return Bengine_Game_Controller_Research
*/
protected function abortAction($id)
{
if (Core::getUser()->get("umode") || !$this->event) {
$this->redirect("game/" . SID . "/Research");
}
$result = Core::getQuery()->select("construction", array("buildingid"), "", Core::getDB()->quoteInto("buildingid = ? AND mode = '2'", $id));
if ($row = $result->fetchRow()) {
$result->closeCursor();
Hook::event("AbortResearch", array($this));
Game::getEH()->removeEvent($this->event->get("eventid"));
$this->redirect("game/" . SID . "/Research");
}
$result->closeCursor();
return $this;
}