本文整理汇总了PHP中Logger::dieMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::dieMessage方法的具体用法?PHP Logger::dieMessage怎么用?PHP Logger::dieMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::dieMessage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Shipyard
*/
protected function indexAction()
{
Core::getLanguage()->load(array("info", "buildings"));
$this->setTemplate("shipyard/index");
/* @var Bengine_Game_Model_Collection_Construction $collection */
$collection = Application::getCollection("game/construction", "game/unit");
$collection->addTypeFilter($this->mode, Game::getPlanet()->getData("ismoon"))->addShipyardJoin(Core::getUser()->get("curplanet"))->addDisplayOrder();
if (Game::getPlanet()->getBuilding("SHIPYARD") == 0) {
Logger::dieMessage("SHIPYARD_REQUIRED");
}
if ($this->mode == self::FLEET_CONSTRUCTION_TYPE) {
Core::getTPL()->assign("shipyard", Core::getLanguage()->getItem("SHIP_CONSTRUCTION"));
} else {
Core::getTPL()->assign("shipyard", Core::getLanguage()->getItem("DEFENSE"));
}
if (!$this->canBuildUnits) {
Logger::addMessage("SHIPYARD_UPGRADING", "info");
}
$missions = Game::getEH()->getShipyardEvents();
if (count($missions)) {
Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
/* @var Bengine_Game_Model_Event $event */
$event = $missions->getFirstItem();
Core::getTPL()->assign("remainingTime", $event->getTimeLeft());
Core::getTPL()->assign("currentWork", Core::getLanguage()->getItem($event->getData("mission")));
Core::getTPL()->assign("currentMissionImage", BASE_URL . "img/buildings/" . $event->getData("mission") . ".gif");
Core::getLang()->assign("unitName", Core::getLanguage()->getItem($event->getData("mission")));
}
Core::getTPL()->addLoop("events", $missions);
Core::getTPL()->addLoop("units", $collection);
Core::getTPL()->assign("canBuildUnits", $this->canBuildUnits);
Core::getTPL()->assign("canBuildRockets", $this->canBuildRockets);
$this->assign("orderAction", BASE_URL . "game/" . SID . "/" . $this->getParam("controller") . "/Order");
$this->assign("cancelAction", BASE_URL . "game/" . SID . "/" . $this->getParam("controller") . "/Cancel");
return $this;
}
示例3: upgradeAction
/**
* Check for sufficient resources and start to upgrade building.
*
* @param integer $id Building id to upgrade
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Constructions
*/
protected function upgradeAction($id)
{
// Check events
if ($this->event != false || Core::getUser()->get("umode")) {
$this->redirect("game/" . SID . "/Constructions");
}
if ($id == 12 && Game::getEH()->getResearchEvent()) {
throw new Recipe_Exception_Generic("Do not mess with the url.");
}
$shipyardSize = Game::getEH()->getShipyardEvents()->getCalculatedSize();
if (($id == 8 || $id == 7) && $shipyardSize > 0) {
throw new Recipe_Exception_Generic("Do not mess with the url.");
}
// Check fields
if (!Game::getPlanet()->planetFree()) {
Logger::dieMessage("PLANET_FULLY_DEVELOPED");
}
// Check for requirements
if (!Game::canBuild($id)) {
throw new Recipe_Exception_Generic("You do not fulfil the requirements to build this.");
}
// Load building data
Core::getLanguage()->load(array("info", "buildings"));
$isMoon = Game::getPlanet()->getData("ismoon");
/* @var Bengine_Game_Model_Construction $construction */
$construction = Game::getModel("game/construction");
$construction->load($id);
if (!$construction->getId()) {
throw new Recipe_Exception_Generic("Unkown building :(");
}
$mode = $construction->get("mode");
if ($isMoon && $mode != self::MOON_CONSTRUCTION_TYPE) {
if ($mode == self::BUILDING_CONSTRUCTION_TYPE && !$construction->get("allow_on_moon")) {
throw new Recipe_Exception_Generic("Building not allowed.");
}
}
if (!$isMoon && $mode != self::BUILDING_CONSTRUCTION_TYPE) {
throw new Recipe_Exception_Generic("Building not allowed.");
}
Hook::event("UpgradeBuildingFirst", array($construction));
// Get required resources
$level = Game::getPlanet()->getBuilding($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::BUILDING_CONSTRUCTION_TYPE);
$data["level"] = $level;
$data["buildingid"] = $id;
$data["buildingname"] = $construction->get("name");
Hook::event("UpgradeBuildingLast", array($construction, &$data, &$time));
Game::getEH()->addEvent(1, $time + TIME, Core::getUser()->get("curplanet"), Core::getUser()->get("userid"), null, $data);
$this->redirect("game/" . SID . "/Constructions");
} else {
Logger::dieMessage("INSUFFICIENT_RESOURCES");
}
return $this;
}
示例4: globalMailAction
/**
* Allows the user to write a global mail to all alliance member.
*
* @param string $reply
* @return Bengine_Game_Controller_Alliance
*/
protected function globalMailAction($reply)
{
$result = Core::getQuery()->select("user2ally u2a", array("a.founder", "ar.CAN_WRITE_GLOBAL_MAILS"), "LEFT JOIN " . PREFIX . "alliance a ON (a.aid = u2a.aid) LEFT JOIN " . PREFIX . "allyrank ar ON (ar.rankid = u2a.rank)", Core::getDB()->quoteInto("u2a.userid = ?", Core::getUser()->get("userid")));
if ($row = $result->fetchRow()) {
$result->closeCursor();
if ($row["CAN_WRITE_GLOBAL_MAILS"] || $row["founder"] == Core::getUser()->get("userid")) {
Core::getLanguage()->load("Message");
if ($this->isPost()) {
$message = richtext($this->getParam("message"));
$length = Str::length(strip_tags($message));
$subject = Str::validateXHTML(trim($this->getParam("subject")));
$receiver = $this->getParam("receiver");
if ($length > 2 && $length <= Core::getOptions()->get("MAX_PM_LENGTH") && Str::length($subject) > 0 && Str::length($subject) < 101) {
Hook::event("SendGlobalMail", array($subject, &$message));
if ($receiver == "foo") {
$where = Core::getDB()->quoteInto("aid = ?", $this->aid);
} else {
$where = Core::getDB()->quoteInto("rank = ? AND aid = ?", array($receiver, $this->aid));
}
$_result = Core::getQuery()->select("user2ally", "userid", "", $where);
foreach ($_result->fetchAll() as $_row) {
Core::getQuery()->insert("message", array("mode" => 6, "time" => TIME, "sender" => Core::getUser()->get("userid"), "receiver" => $_row["userid"], "message" => $message, "subject" => $subject, "read" => $_row["userid"] == Core::getUser()->get("userid") ? 1 : 0));
}
$_result->closeCursor();
Logger::addMessage("SENT_SUCCESSFUL", "success");
} else {
if ($length < 3) {
Core::getTPL()->assign("messageError", Logger::getMessageField("MESSAGE_TOO_SHORT"));
}
if ($length > Core::getOptions()->get("MAX_PM_LENGTH")) {
Core::getTPL()->assign("messageError", Logger::getMessageField("MESSAGE_TOO_LONG"));
}
if (Str::length($subject) == 0) {
Core::getTPL()->assign("subjectError", Logger::getMessageField("SUBJECT_TOO_SHORT"));
}
if (Str::length($subject) > 100) {
Core::getTPL()->assign("subjectError", Logger::getMessageField("SUBJECT_TOO_LONG"));
}
Core::getTPL()->assign("subject", $this->getParam("subject"))->assign("message", $this->getParam("message"));
}
} else {
if ($reply) {
$reply = preg_replace("#((RE|FW):\\s)+#is", "\\1", $reply);
Core::getTPL()->assign("subject", $reply);
}
}
$ranks = Core::getQuery()->select("allyrank", array("rankid", "name"), "", Core::getDB()->quoteInto("aid = ?", $this->aid));
Core::getTPL()->assign("maxpmlength", fNumber(Core::getOptions()->get("MAX_PM_LENGTH")));
Core::getTPL()->addLoop("ranks", $ranks);
} else {
Logger::dieMessage("MISSING_RIGHTS_FOR_GLOBAL_MAIL", "warning");
}
} else {
Logger::dieMessage("MISSING_RIGHTS_FOR_GLOBAL_MAIL", "warning");
}
return $this;
}
示例5: subtractHydrogen
/**
* Substracts hydrogen for each galaxy view.
*
* @return Bengine_Game_Controller_Galaxy
*/
protected function subtractHydrogen()
{
if ($this->galaxy != Game::getPlanet()->getData("galaxy") || $this->system != Game::getPlanet()->getData("system")) {
if (Game::getPlanet()->getData("hydrogen") - $this->viewConsumption < 0) {
Logger::dieMessage("DEFICIENT_CONSUMPTION");
}
Game::getPlanet()->setData("hydrogen", Game::getPlanet()->getData("hydrogen") - $this->viewConsumption);
Core::getDB()->query("UPDATE " . PREFIX . "planet SET hydrogen = hydrogen - ? WHERE planetid = ?", array($this->viewConsumption, Core::getUser()->get("curplanet")));
}
return $this;
}
示例6: diePrintError
/**
* Displays the message and shut program down.
*
* @return void
*/
public function diePrintError()
{
Logger::dieMessage($this->message);
return;
}
示例7: 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;
}
}
//.........这里部分代码省略.........
示例8: addAction
/**
* Adds an user to buddylist.
*
* @param integer $userid
*
* @return Bengine_Game_Controller_Friends
*/
protected function addAction($userid)
{
Core::getLanguage()->load(array("Buddylist"));
if ($userid == Core::getUser()->get("userid")) {
Logger::dieMessage("SELF_REQUEST");
}
$where = Core::getDB()->quoteInto("friend1 = ? AND friend2 = ? OR friend1 = ? AND friend2 = ?", array($userid, Core::getUser()->get("userid"), Core::getUser()->get("userid"), $userid));
$result = Core::getQuery()->select("buddylist", array("friend1", "friend2"), "", $where);
if ($result->rowCount() == 0) {
Hook::event("AddToBuddyList", array($userid));
Core::getQuery()->insert("buddylist", array("friend1" => Core::getUser()->get("userid"), "friend2" => $userid));
/* @var Bengine_Game_Model_Message $pm */
$pm = Game::getModel("game/message");
$pm->set("receiver", $userid)->set("mode", Bengine_Game_Model_Message::USER_FOLDER_ID)->set("subject", Core::getLang()->get("FRIEND_REQUEST_RECEIVED"))->set("message", Core::getLang()->get("FRIEND_REQUEST_RECEIVED_MESSAGE"));
$pm->send();
}
return $this->redirect("game/" . SID . "/Friends");
}
示例9: checkForSpam
/**
* Checks if the user send to many message (spam protection).
*
* @return Bengine_Game_Controller_MSG
*/
protected function checkForSpam()
{
if ($max = Core::getConfig()->get("MESSAGE_FLOOD_MAX")) {
$bind = array(Core::getUser()->get("userid"), TIME - Core::getConfig()->get("MESSAGE_FLOOD_SPAN"), Bengine_Game_Model_Message::USER_FOLDER_ID);
$result = Core::getQuery()->select("message", array("COUNT(msgid)"), "", "sender = ? AND time >= ? AND mode = ?", "", 1, "", "", $bind);
if ($result->fetchColumn() >= $max) {
Logger::dieMessage("MESSAGE_FLOOD_INFO", "warning");
}
}
return $this;
}
示例10: 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;
}
示例11: disableUmode
/**
* Disables the vacation mode and starts the resource production.
*
* @return Bengine_Game_Controller_Preferences
*/
protected function disableUmode()
{
setProdOfUser(Core::getUser()->get("userid"), 100);
Core::getQuery()->update("user", array("umode" => 0), "userid = ?", array(Core::getUser()->get("userid")));
Core::getQuery()->update("planet", array("last" => TIME), "userid = ? AND planetid != ?", array(Core::getUser()->get("userid"), Core::getUser()->get("curplanet")));
Core::getUser()->rebuild();
Hook::event("DisableVacationMode");
Logger::dieMessage("UMODE_DISABLED", "info");
return $this;
}