コード例 #1
0
ファイル: Friends.php プロジェクト: enriquesomolinos/Bengine
 /**
  * Index action.
  *
  * @return Bengine_Game_Controller_Friends
  */
 protected function indexAction()
 {
     Core::getLanguage()->load(array("Statistics", "Buddylist"));
     if ($this->isPost()) {
         if ($this->getParam("delete")) {
             $this->remove($this->getParam("remove", array()));
         }
         if ($this->getParam("accept")) {
             $this->acceptRequest($this->getParam("relid"));
         }
     }
     $bl = array();
     $select = array("b.relid", "b.friend1", "b.friend2", "b.accepted", "u1.username as user1", "u1.points as points1", "u1.last as lastlogin1", "u2.points as points2", "u2.username as user2", "u2.last as lastlogin2", "a1.tag as ally1", "a1.aid as allyid1", "a2.tag as ally2", "a2.aid as allyid2", "g1.galaxy as gala1", "g1.system as sys1", "g1.position as pos1", "g2.galaxy as gala2", "g2.system as sys2", "g2.position as pos2");
     $joins = "LEFT JOIN " . PREFIX . "user u1 ON (u1.userid = b.friend1)";
     $joins .= "LEFT JOIN " . PREFIX . "user u2 ON (u2.userid = b.friend2)";
     $joins .= "LEFT JOIN " . PREFIX . "galaxy g1 ON (g1.planetid = u1.hp)";
     $joins .= "LEFT JOIN " . PREFIX . "galaxy g2 ON (g2.planetid = u2.hp)";
     $joins .= "LEFT JOIN " . PREFIX . "user2ally u2a1 ON (u2a1.userid = b.friend1)";
     $joins .= "LEFT JOIN " . PREFIX . "user2ally u2a2 ON (u2a2.userid = b.friend2)";
     $joins .= "LEFT JOIN " . PREFIX . "alliance a1 ON (a1.aid = u2a1.aid)";
     $joins .= "LEFT JOIN " . PREFIX . "alliance a2 ON (a2.aid = u2a2.aid)";
     $result = Core::getQuery()->select("buddylist b", $select, $joins, Core::getDB()->quoteInto("b.friend1 = ? OR b.friend2 = ?", Core::getUser()->get("userid")), "u1.points DESC, u2.points DESC, u1.username ASC, u2.username ASC");
     foreach ($result->fetchAll() as $row) {
         Hook::event("ShowBuddyFirst", array(&$row));
         if ($row["friend1"] == Core::getUser()->get("userid")) {
             if ($row["lastlogin2"] > TIME - 900) {
                 $status = Image::getImage("on.gif", getTimeTerm(TIME - $row["lastlogin2"]));
             } else {
                 $status = Image::getImage("off.gif", getTimeTerm(TIME - $row["lastlogin2"]));
             }
             $username = Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($row["user2"]), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))) . " " . Link::get("game/" . SID . "/Profile/Page/" . $row["friend2"], $row["user2"]);
             $points = $row["points2"];
             $position = getCoordLink($row["gala2"], $row["sys2"], $row["pos2"]);
             $ally = Link::get("game/" . SID . "/Alliance/Page/" . $row["allyid2"], $row["ally2"]);
         } else {
             if ($row["lastlogin1"] > TIME - 900) {
                 $status = Image::getImage("on.gif", getTimeTerm(TIME - $row["lastlogin1"]));
             } else {
                 $status = Image::getImage("off.gif", getTimeTerm(TIME - $row["lastlogin1"]));
             }
             $username = Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($row["user1"]), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))) . " " . Link::get("game/" . SID . "/Profile/Page/" . $row["friend1"], $row["user1"]);
             $points = $row["points1"];
             $position = getCoordLink($row["gala1"], $row["sys1"], $row["pos1"]);
             $ally = Link::get("game/" . SID . "/Alliance/Page/" . $row["allyid1"], $row["ally1"]);
         }
         $bl[$row["relid"]]["f1"] = $row["friend1"];
         $bl[$row["relid"]]["f2"] = $row["friend2"];
         $bl[$row["relid"]]["relid"] = $row["relid"];
         $bl[$row["relid"]]["username"] = $username;
         $bl[$row["relid"]]["accepted"] = $row["accepted"];
         $bl[$row["relid"]]["points"] = fNumber($points);
         $bl[$row["relid"]]["status"] = $status;
         $bl[$row["relid"]]["position"] = $position;
         $bl[$row["relid"]]["ally"] = $ally;
         Hook::event("ShowBuddyLast", array($row, &$bl));
     }
     $result->closeCursor();
     Core::getTPL()->addLoop("buddylist", $bl);
     return $this;
 }
コード例 #2
0
ファイル: Unit.php プロジェクト: enriquesomolinos/Bengine
 public function getProductionTime($formatted = false)
 {
     if (!$this->exists("production_time")) {
         $this->set("production_time", getBuildTime($this->get("basic_metal"), $this->get("basic_silicon"), $this->get("mode")));
     }
     $time = $this->get("production_time");
     return $formatted ? getTimeTerm($time) : $time;
 }
コード例 #3
0
 /**
  * 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"]);
                 $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;
 }
コード例 #4
0
ファイル: Alliance.php プロジェクト: enriquesomolinos/Bengine
 /**
  * Displays the memberlist.
  *
  * @return Bengine_Game_Controller_Alliance
  */
 protected function memberlistAction()
 {
     if ($this->aid == Core::getUser()->get("aid")) {
         $select = array("ar.CAN_SEE_MEMBERLIST", "ar.CAN_MANAGE", "ar.CAN_BAN_MEMBER", "ar.CAN_SEE_ONLINE_STATE", "a.founder", "a.showmember");
         $where = Core::getDB()->quoteInto("u2a.userid = ? AND u2a.aid = ?", array(Core::getUser()->get("userid"), $this->aid));
         $result = Core::getQuery()->select("user2ally u2a", $select, "LEFT JOIN " . PREFIX . "allyrank ar ON (u2a.rank = ar.rankid) LEFT JOIN " . PREFIX . "alliance a ON (a.aid = u2a.aid)", $where);
         $row = $result->fetchRow();
         $result->closeCursor();
         if ($row["founder"] != Core::getUser()->get("userid")) {
             $can_see_memberlist = $row["showmember"] ? 1 : $row["CAN_SEE_MEMBERLIST"];
             $can_manage = $row["CAN_MANAGE"];
             $can_ban_member = $row["CAN_BAN_MEMBER"];
             $can_see_onlie_state = $row["CAN_SEE_ONLINE_STATE"];
         } else {
             $can_see_memberlist = 1;
             $can_manage = 1;
             $can_ban_member = 1;
             $can_see_onlie_state = 1;
         }
         Core::getTPL()->assign("founder", $row["founder"]);
     } else {
         $result = Core::getQuery()->select("alliance", "showmember", "", Core::getDB()->quoteInto("aid = ?", $this->aid));
         $row = $result->fetchRow();
         $result->closeCursor();
         $can_see_memberlist = $row["showmember"];
         $can_manage = 0;
         $can_ban_member = 0;
         $can_see_onlie_state = 0;
     }
     unset($row);
     unset($result);
     if ($can_see_memberlist) {
         if ($can_manage) {
             if (Core::getRequest()->getPOST("changeMembers")) {
                 $result = Core::getQuery()->select("user2ally", "userid", "", Core::getDB()->quoteInto("aid = ?", $this->aid));
                 foreach ($result->fetchAll() as $row) {
                     if ($rankid = Core::getRequest()->getPOST("rank_" . $row["userid"])) {
                         Core::getQuery()->update("user2ally", array("rank" => $rankid), "userid = ? AND aid = ?", array($row["userid"], $this->aid));
                     }
                 }
                 $result->closeCursor();
             } else {
                 if (count(Core::getRequest()->getPOST()) > 0) {
                     foreach (Core::getRequest()->getPOST() as $key => $value) {
                         if (preg_match("#^kick\\_#i", $key)) {
                             $kickuserid = Str::replace("kick_", "", $key);
                             Hook::event("KickMember", array($kickuserid));
                             Core::getQuery()->delete("user2ally", "userid = ? AND aid = ?", null, null, array($kickuserid, $this->aid));
                             $_result = Core::getQuery()->select("user2ally", "userid", "", Core::getDB()->quoteInto("aid = ?", $this->aid));
                             foreach ($_result->fetchAll() as $_row) {
                                 new Bengine_Game_AutoMsg(102, $_row["userid"], TIME, array());
                             }
                             $_result->closeCursor();
                             unset($_row);
                             break;
                         }
                     }
                 }
             }
             $ranks = array();
             $result = Core::getQuery()->select("allyrank", array("rankid", "name"), "", Core::getDB()->quoteInto("aid = ?", $this->aid));
             foreach ($result->fetchAll() as $row) {
                 $ranks[$row["rankid"]]["name"] = $row["name"];
             }
             Hook::event("AllianceRanks", array(&$ranks));
             $result->closeCursor();
         }
         if ($can_ban_member && $can_see_onlie_state) {
             $colspan = "8";
         } else {
             if ($can_ban_member || $can_see_onlie_state) {
                 $colspan = "7";
             } else {
                 $colspan = "6";
             }
         }
         Core::getTPL()->assign("colspan", $colspan);
         Core::getTPL()->assign("can_manage", $can_manage);
         Core::getTPL()->assign("can_ban_member", $can_ban_member);
         Core::getTPL()->assign("can_see_onlie_state", $can_see_onlie_state);
         $select = array("u2a.userid", "u.username", "u.points AS points", "u2a.joindate", "u.last", "g.galaxy", "g.system", "g.position", "ar.rankid", "ar.name AS rankname", "a.tag", "a.founder", "a.foundername");
         $joins = "LEFT JOIN " . PREFIX . "user u ON (u.userid = u2a.userid)";
         $joins .= "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = u.hp)";
         $joins .= "LEFT JOIN " . PREFIX . "allyrank ar ON (ar.rankid = u2a.rank)";
         $joins .= "LEFT JOIN " . PREFIX . "alliance a ON (a.aid = u2a.aid)";
         $result = Core::getQuery()->select("user2ally u2a", $select, $joins, Core::getDB()->quoteInto("u2a.aid = ?", $this->aid), "u.points DESC LIMIT 100");
         $sum = 0;
         $membercount = 0;
         $members = array();
         foreach ($result->fetchAll() as $row) {
             $uid = $row["userid"];
             $members[$uid]["userid"] = $uid;
             $members[$uid]["username"] = $row["username"];
             $members[$uid]["points"] = fNumber(floor($row["points"]));
             $members[$uid]["joindate"] = Date::timeToString(1, $row["joindate"]);
             $members[$uid]["last"] = $row["last"];
             if ($can_manage) {
                 $members[$uid]["rankselection"] = $this->getRankSelect($ranks, $row["rankid"]);
             }
             if ($row["founder"] == $row["userid"]) {
                 if ($row["foundername"] != "") {
                     $members[$uid]["rank"] = $row["foundername"];
                 } else {
                     $members[$uid]["rank"] = Core::getLanguage()->getItem("FOUNDER");
                 }
             } else {
                 if ($row["rankname"]) {
                     $members[$uid]["rank"] = $row["rankname"];
                 } else {
                     $members[$uid]["rank"] = Core::getLanguage()->getItem("NEWBIE");
                 }
             }
             $members[$uid]["position"] = getCoordLink($row["galaxy"], $row["system"], $row["position"]);
             if (Core::getUser()->get("userid") != $uid) {
                 $members[$uid]["message"] = Link::get("game/" . SID . "/MSG/Write/" . $row["username"], Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE")));
             }
             if (TIME - $row["last"] < 900) {
                 $members[$uid]["online"] = Image::getImage("on.gif", getTimeTerm(TIME - $row["last"]));
             } else {
                 $members[$uid]["online"] = Image::getImage("off.gif", getTimeTerm(TIME - $row["last"]));
             }
             $sum += $row["points"];
             $membercount++;
         }
         $result->closeCursor();
         Hook::event("ShowMemberList", array(&$members));
         Core::getTPL()->assign("totalmembers", fNumber($membercount));
         Core::getTPL()->assign("totalpoints", fNumber(floor($sum)));
         Core::getTPL()->addLoop("members", $members);
     }
     return $this;
 }
コード例 #5
0
ファイル: Mission.php プロジェクト: enriquesomolinos/Bengine
 /**
  * Select the mission's target and speed.
  *
  * @param integer $galaxy
  * @param integer $system
  * @param integer $position
  * @param string $targetType
  * @param string $code
  * @param array $ships
  *
  * @return Bengine_Game_Controller_Mission
  */
 protected function selectCoordinates($galaxy, $system, $position, $targetType, $code, $ships)
 {
     $this->noAction = true;
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
     $galaxy = $galaxy > 0 ? (int) $galaxy : Game::getPlanet()->getData("galaxy");
     $system = $system > 0 ? (int) $system : Game::getPlanet()->getData("system");
     $position = $position > 0 ? (int) $position : Game::getPlanet()->getData("position");
     $targetType = $targetType == "tf" ? "tf" : ($targetType == "moon" ? "moon" : "planet");
     $data = array("ships" => array());
     Core::getQuery()->delete("temp_fleet", "planetid = ?", null, null, array(Core::getUser()->get("curplanet")));
     $select = array("u2s.unitid", "u2s.quantity", "d.capicity", "d.speed", "d.consume", "b.name");
     $joins = "LEFT JOIN " . PREFIX . "construction b ON (b.buildingid = u2s.unitid)";
     $joins .= "LEFT JOIN " . PREFIX . "ship_datasheet d ON (d.unitid = u2s.unitid)";
     $result = Core::getQuery()->select("unit2shipyard u2s", $select, $joins, Core::getDB()->quoteInto("b.mode = '3' AND u2s.planetid = ?", Core::getUser()->get("curplanet")));
     $capacity = 0;
     $consumption = 0;
     $speed = 0;
     $quantity = 0;
     foreach ($result->fetchAll() as $row) {
         $id = $row["unitid"];
         $quantity = isset($ships[$id]) ? (int) $ships[$id] : 0;
         if ($quantity > $row["quantity"]) {
             $quantity = $row["quantity"];
         }
         if ($quantity > 0) {
             $id = (int) $id;
             $capacity += $row["capicity"] * $quantity;
             $data["ships"][$id]["quantity"] = $quantity;
             $data["ships"][$id]["name"] = $row["name"];
             $data["ships"][$id]["id"] = $id;
             $shipSpeed = Game::getSpeed($id, $row["speed"]);
             if ($speed == 0 || $shipSpeed < $speed) {
                 $speed = $shipSpeed;
             }
             $consumption += $row["consume"] * $quantity;
         }
     }
     $result->closeCursor();
     if (count($data["ships"]) > 0 && $speed > 0) {
         $distance = Game::getDistance($galaxy, $system, $position);
         $time = Game::getFlyTime($distance, $speed);
         Hook::event("MissionSetData", array(&$data, &$quantity, &$consumption, &$speed, &$capacity));
         Core::getTPL()->assign(array("galaxy" => $galaxy, "system" => $system, "position" => $position, "targetType" => $targetType, "code" => $code, "oGalaxy" => Game::getPlanet()->getData("galaxy"), "oSystem" => Game::getPlanet()->getData("system"), "oPos" => Game::getPlanet()->getData("position"), "maxspeedVar" => $speed, "distance" => $distance, "capacity_raw" => $capacity, "basicConsumption" => $consumption, "time" => getTimeTerm($time), "maxspeed" => fNumber($speed), "capacity" => fNumber($capacity - Game::getFlyConsumption($consumption, $distance)), "fuel" => fNumber(Game::getFlyConsumption($consumption, $distance))));
         $data["consumption"] = $consumption;
         $data["maxspeed"] = $speed;
         $data["capacity"] = $capacity;
         $data = serialize($data);
         Core::getQuery()->insert("temp_fleet", array("planetid" => Core::getUser()->get("curplanet"), "data" => $data));
         // Short speed selection
         $selectbox = "";
         for ($n = 10; $n > 0; $n--) {
             $selectbox .= createOption($n * 10, $n * 10, 0);
         }
         Core::getTPL()->assign("speedFromSelectBox", $selectbox);
         // Invatations for alliance attack
         $invitations = array();
         $joins = "LEFT JOIN " . PREFIX . "events e ON (e.eventid = fi.eventid)";
         $joins .= "LEFT JOIN " . PREFIX . "attack_formation af ON (e.eventid = af.eventid)";
         $joins .= "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = e.destination)";
         $joins .= "LEFT JOIN " . PREFIX . "galaxy m ON (m.moonid = e.destination)";
         $select = array("af.eventid", "af.name", "af.time", "g.galaxy", "g.system", "g.position", "m.galaxy AS moongala", "m.system AS moonsys", "m.position AS moonpos");
         $_result = Core::getQuery()->select("formation_invitation fi", $select, $joins, Core::getDB()->quoteInto("fi.userid = ? AND af.time > '" . TIME . "'", Core::getUser()->get("userid")));
         foreach ($_result->fetchAll() as $_row) {
             $_row["type"] = 0;
             if (!empty($_row["moongala"]) && !empty($_row["moonsys"]) && !empty($_row["moonpos"])) {
                 $_row["galaxy"] = $_row["moongala"];
                 $_row["system"] = $_row["moonsys"];
                 $_row["position"] = $_row["moonpos"];
                 $_row["type"] = 2;
             }
             $_row["time_r"] = $_row["time"] - TIME;
             $_row["formatted_time"] = getTimeTerm($_row["time_r"]);
             $invitations[] = $_row;
         }
         $_result->closeCursor();
         Core::getTPL()->addLoop("invitations", $invitations);
         // Planet shortlinks
         $sl = array();
         $order = "p.sort_index ASC, p.planetid ASC";
         $where = Core::getDB()->quoteInto("p.userid = ? AND p.planetid != ?", array(Core::getUser()->get("userid"), Core::getUser()->get("curplanet")));
         $_result = Core::getQuery()->select("planet p", array("p.ismoon", "p.planetname", "g.galaxy", "g.system", "g.position", "gm.galaxy moongala", "gm.system as moonsys", "gm.position as moonpos"), "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = p.planetid) LEFT JOIN " . PREFIX . "galaxy gm ON (gm.moonid = p.planetid)", $where, $order);
         foreach ($_result->fetchAll() as $_row) {
             $sl[] = array("planetname" => $_row["planetname"], "galaxy" => $_row["ismoon"] ? $_row["moongala"] : $_row["galaxy"], "system" => $_row["ismoon"] ? $_row["moonsys"] : $_row["system"], "position" => $_row["ismoon"] ? $_row["moonpos"] : $_row["position"], "type" => $_row["ismoon"] ? 2 : 0);
         }
         $_result->closeCursor();
         Hook::event("MissionPlanetQuickLinks", array(&$sl));
         Core::getTPL()->addLoop("shortlinks", $sl);
         $this->setTemplate("mission/step2");
     } else {
         Logger::addMessage("NO_SHIPS_SELECTED");
     }
     return $this;
 }
コード例 #6
0
ファイル: Event.php プロジェクト: enriquesomolinos/Bengine
 /**
  * Returns the formatted time left before event will be completed.
  *
  * @return string
  */
 public function getFormattedTimeLeft()
 {
     return getTimeTerm($this->getTimeLeft());
 }
コード例 #7
0
 /**
  * Returns production time.
  *
  * @param bool $formatted
  * @return int|string
  */
 public function getProductionTime($formatted = false)
 {
     if (!$this->exists("production_time")) {
         $required = $this->calculateRequiredResources();
         $time = getBuildTime($required["required_metal"], $required["required_silicon"], $this->get("mode"));
         $this->set("production_time", $time);
     }
     $time = $this->get("production_time");
     return $formatted ? getTimeTerm($time) : $time;
 }