示例#1
0
 /**
  * Initializing the newbie protection status.
  *
  * @return Bengine_Game_Model_User
  */
 public function initNewbieProtectionStatus()
 {
     $isProtected = isNewbieProtected(Core::getUser()->get("points"), $this->getPoints());
     if ($isProtected == 1) {
         $this->setNewbieStatus(" <span class=\"weak-player\">n</span> ");
         $this->setUsernameClass("weak-player");
     } else {
         if ($isProtected == 2) {
             $this->setNewbieStatus(" <span class=\"strong-player\">s</span> ");
             $this->setUsernameClass("strong-player");
         } else {
             $this->setNewbieStatus("");
         }
     }
     return $this;
 }
示例#2
0
 /**
  * Formats an user record.
  *
  * @param array $row	User data
  *
  * @return array		Formatted user data
  */
 protected function formatRow(array $row)
 {
     Hook::event("FormatUserListRowFirst", array(&$row, $this));
     if (empty($row["userid"])) {
         return $row;
     }
     // Quick buttons
     $row["message"] = Link::get("game/" . SID . "/MSG/Write/" . $row["username"], $this->pmPic);
     $row["buddyrequest"] = Link::get("game/" . SID . "/Friends/Add/" . $row["userid"], $this->buddyPic);
     $row["moderator"] = Link::get("game/" . SID . "/Moderator/Index/" . $row["userid"], $this->modPic);
     $row["level_link"] = Link::get("game/" . SID . "/Achievements/User/" . $row["userid"], $row["level"]);
     $userClass = "";
     $inactive = "";
     $ban = "";
     $umode = "";
     $status = "";
     // Newbie protection
     if ($this->newbieProtection && Core::getUser()->userid != $row["userid"]) {
         $isProtected = isNewbieProtected($this->points, $row["points"]);
         if ($isProtected == 1) {
             $status = " <span class=\"weak-player\">n</span> ";
             $userClass = "weak-player";
         } else {
             if ($isProtected == 2) {
                 $status = " <span style=\"strong-player\">s</span> ";
                 $userClass = "strong-player";
             }
         }
     }
     // User activity
     if ($row["useractivity"] <= TIME - Core::getConfig()->get("INACTIVE_USER_TIME_1")) {
         $inactive = " i ";
     }
     if ($row["useractivity"] <= TIME - Core::getConfig()->get("INACTIVE_USER_TIME_2")) {
         $inactive = " i I ";
     }
     // User banned?
     if ($row["to"] >= TIME) {
         $ban = " <span class=\"banned\">b</span> ";
         $userClass = "banned";
     }
     // Vacation mode
     if ($row["umode"]) {
         $umode = " <span class=\"vacation-mode\">v</span> ";
         $userClass = "vacation-mode";
     }
     $row["user_status"] = sprintf("%s%s%s", $inactive, $ban, $umode);
     $row["user_status_long"] = sprintf("%s%s%s%s", $inactive, $ban, $umode, $status);
     $title = !empty($row["usertitle"]) ? $row["usertitle"] : Core::getLang()->get("GO_TO_PROFILE");
     $row["alliance"] = "";
     if (!empty($row["aid"]) && !empty($row["tag"])) {
         $row["alliance"] = $this->formatAllyTag($row["tag"], $row["name"], $row["aid"]);
         if ($this->fetchRankByQuery) {
             $row["alliance_rank"] = $this->getAllianceRank($row["aid"], $this->pointType);
         }
     }
     if (isset($row["ismoon"]) && $row["ismoon"] && !empty($row["moongala"]) && !empty($row["moonsys"]) && !empty($row["moonpos"])) {
         $row["position"] = getCoordLink($row["moongala"], $row["moonsys"], $row["moonpos"]);
     } else {
         if (!empty($row["galaxy"]) && !empty($row["system"]) && !empty($row["position"])) {
             $row["position"] = getCoordLink($row["galaxy"], $row["system"], $row["position"]);
         }
     }
     // Points
     if ($this->fetchRankByQuery) {
         $row["rank"] = $this->getUserRank($row[$this->pointType], $row["username"], $this->pointType);
     } else {
         if (isset($row["rank"])) {
             $row["rank"] = fNumber($row["rank"]);
         }
     }
     if (isset($row["points"])) {
         $row["points"] = fNumber(floor($row[$this->pointType]));
     }
     if (isset($row["fpoints"])) {
         $row["fpoints"] = fNumber(floor($row["fpoints"]));
     }
     if (isset($row["dpoints"])) {
         $row["dpoints"] = fNumber(floor($row["dpoints"]));
     }
     if (isset($row["rpoints"])) {
         $row["rpoints"] = fNumber(floor($row["rpoints"]));
     }
     $row["username"] = Link::get("game/" . SID . "/Profile/Page/" . $row["userid"], $this->formatUsername($row["username"], $row["userid"], $row["aid"], $userClass), $title);
     Hook::event("FormatUserListRowLast", array(&$row, $this));
     return $row;
 }
示例#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 if the target is newbie protected.
  *
  * @return boolean
  */
 public function isNewbieProtected()
 {
     $ignoreNP = false;
     $newbieprotected = false;
     if ($this->_target["last"] <= TIME - 604800) {
         $ignoreNP = true;
     } else {
         if ($this->_target["to"] >= TIME) {
             $ignoreNP = true;
         }
     }
     if (!$ignoreNP) {
         $newbieprotected = isNewbieProtected(Core::getUser()->get("points"), $this->_target["points"]);
     }
     return $newbieprotected;
 }