Пример #1
0
 /**
  * Checks the event for validation.
  *
  * @return boolean
  */
 protected function _isValid()
 {
     if (!empty($this->_target["planetid"]) && !$this->isNewbieProtected() && $this->_target["userid"] != Core::getUser()->get("userid") && $this->_targetType != "tf" && $this->_checkProbes() && !$this->_target["umode"] && !Game::attackingStoppageEnabled()) {
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * Checks the event for validation.
  *
  * @return boolean
  */
 protected function _isValid()
 {
     $formations = $this->getSpecialData();
     if (!empty($this->_target["userid"]) && $this->_target["userid"] != Core::getUser()->get("userid") && $this->_targetType != "tf" && !$this->_target["umode"] && !$this->isNewbieProtected() && !Game::attackingStoppageEnabled() && is_array($formations)) {
         return true;
     }
     return false;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * Checks the event for validation.
  *
  * @return boolean
  */
 protected function _isValid()
 {
     if (!empty($this->_target["userid"]) && $this->_target["userid"] != Core::getUser()->get("userid") && $this->_targetType == "moon" && !$this->_target["umode"] && !empty($this->_ships[self::DEATH_STAR_CONSTRUCTION_ID]) && !$this->isNewbieProtected() && !Game::attackingStoppageEnabled()) {
         return true;
     }
     return false;
 }
Пример #5
0
 /**
  * (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)
 {
     if (Game::attackingStoppageEnabled()) {
         throw new Recipe_Exception_Generic("Attacking stoppage enabled.");
     }
     Core::getDB()->query("UPDATE " . PREFIX . "unit2shipyard SET quantity = quantity - ? WHERE unitid = ? AND planetid = ?", array($data["rockets"], 52, $event->getPlanetid()));
     Core::getQuery()->delete("unit2shipyard", "quantity = '0'");
     return $this;
 }