本文整理汇总了PHP中Game::getCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::getCollection方法的具体用法?PHP Game::getCollection怎么用?PHP Game::getCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::getCollection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pageAction
/**
* Displays the profile page for an user.
*
* @param integer $user_id
*
* @return Bengine_Game_Controller_Profile
*/
protected function pageAction($user_id)
{
$user = Game::getModel("game/user")->load($user_id);
$profile = Game::getCollection("game/profile");
$profile->addUserFilter($user_id)->addSortIndex()->addListFilter();
$avatar = Game::getModel("game/profile")->loadByCode("AVATAR", $user_id);
$about = Game::getModel("game/profile")->loadByCode("ABOUT_ME", $user_id);
$this->assign("user", $user);
$this->assign("aboutMe", $about->getData());
$this->assign("avatar", $avatar->getData());
$this->assign("username", $user->getUsername());
$this->assign("points", $user->getFormattedPoints());
$this->assign("status", $user->getStatusString());
$this->assign("rank", $user->getFormattedRank());
$this->assign("regdate", $user->getFormattedRegDate());
$this->assign("pm", $user->getPmLink());
$this->assign("moderate", $user->getModerateLink());
$this->assign("addToBuddylist", $user->getFriendLink());
$this->assign("pm", $user->getPmLink());
$this->assign("allianceName", $user->getAid() ? $user->getAlliance()->getPageLink() : " ");
Core::getTPL()->addLoop("profile", $profile);
$this->assign("canEdit", Core::getUser()->get("userid") == $user_id || Core::getUser()->ifPermissions(array("CAN_EDIT_PROFILES")));
$this->assign("editLink", Link::get("game/" . SID . "/Profile/Edit/" . $user_id, Core::getLang()->get("EDIT_PROFILE")));
Core::getLang()->assign("profileUsername", $user->getUsername());
return $this;
}
示例2: _match
/**
* @return bool
*/
protected function _match()
{
/* @var Bengine_Game_Model_Collection_Friend $collection */
$collection = Game::getCollection("game/friend");
$collection->addUserFilter($this->getUser()->get("userid"))->addAcceptedFilter();
return $collection->getCalculatedSize() >= $this->getValue();
}
示例3: _add
/**
* (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)
{
$collection = Game::getCollection("game/event");
$collection->addUserFilter($event->getUserid())->addPlanetFilter($event->getPlanetid())->addBaseTypeFilter($event->getMode);
$_event = $collection->getFirstItem(new Object());
if ($_event->getEventid()) {
return false;
}
$this->removeResourceFromPlanet($data);
return $this;
}
示例4: sessionsAction
/**
* Shows all sessions for the user.
*
* @return Bengine_Game_Controller_Moderator
*/
protected function sessionsAction()
{
/* @var Bengine_Game_Model_Collection_SessionLog $sessionLog */
$sessionLog = Game::getCollection("game/sessionLog");
$sessionLog->addTimeOrder();
if ($ip = $this->getParam("ip")) {
$sessionLog->addIpFilter($ip);
} else {
if ($id = $this->getParam("id")) {
$sessionLog->addUserFilter($id);
} else {
$this->redirect("game/" . SID . "/Index");
}
}
Core::getTPL()->addLoop("sessionLog", $sessionLog);
return $this;
}
示例5: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Index
*/
protected function indexAction()
{
Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
Core::getTPL()->addHTMLHeaderFile("lib/jquery.news.js", "js");
$this->buildingEvent = Game::getEH()->getCurPlanetBuildingEvent();
// Messages
$result = Core::getQuery()->select("message", "msgid", "", Core::getDB()->quoteInto("`receiver` = ? AND `read` = '0'", Core::getUser()->get("userid")));
$msgs = $result->rowCount();
$result->closeCursor();
Core::getTPL()->assign("unreadmsg", $msgs);
if ($msgs == 1) {
Core::getTPL()->assign("newMessages", Link::get("game/" . SID . "/MSG", Core::getLanguage()->getItem("F_NEW_MESSAGE")));
} else {
if ($msgs > 1) {
Core::getTPL()->assign("newMessages", Link::get("game/" . SID . "/MSG", sprintf(Core::getLanguage()->getItem("F_NEW_MESSAGES"), $msgs)));
}
}
// Fleet events
$fleetEvent = Game::getEH()->getFleetEvents();
$fe = array();
if ($fleetEvent) {
foreach ($fleetEvent as $f) {
$fe[$f["eventid"]] = $this->parseEvent($f);
if (!is_array($fe[$f["eventid"]])) {
unset($fe[$f["eventid"]]);
}
}
Hook::event("MainFleetEventsOutput", array(&$fe));
}
Core::getTPL()->addLoop("fleetEvents", $fe);
Core::getTPL()->assign("serverTime", Date::timeToString(1, TIME, "", false));
Core::getTPL()->assign("buildingEvent", $this->buildingEvent);
Core::getTPL()->assign("occupiedFields", Game::getPlanet()->getFields(true));
Core::getTPL()->assign("planetImage", Image::getImage("planets/" . Game::getPlanet()->getData("picture") . Core::getConfig()->get("PLANET_IMG_EXT"), Game::getPlanet()->getData("planetname"), "200px", "200px"));
Core::getTPL()->assign("freeFields", Game::getPlanet()->getMaxFields());
Core::getTPL()->assign("planetDiameter", fNumber(Game::getPlanet()->getData("diameter")));
Core::getTPL()->assign("planetNameLink", Link::get("game/" . SID . "/Index/PlanetOptions", Game::getPlanet()->getData("planetname")));
Core::getTPL()->assign("planetPosition", Game::getPlanet()->getCoords());
Core::getTPL()->assign("planetTemp", Game::getPlanet()->getData("temperature"));
Core::getTPL()->assign("points", Link::get("game/" . SID . "/Ranking", fNumber(floor(Core::getUser()->get("points")))));
// Points
$result = Core::getQuery()->select("user", "userid");
Core::getLang()->assign("totalUsers", fNumber($result->rowCount()));
$result->closeCursor();
$where = Core::getDB()->quoteInto("(`username` < ? AND `points` >= {points}) OR `points` > {points}", array(Core::getUser()->get("username")));
$where = str_replace("{points}", (double) Core::getUser()->get("points"), $where);
$result = Core::getQuery()->select("user", array("COUNT(`userid`)+1 AS rank"), "", $where, "", 1);
Core::getLang()->assign("rank", fNumber($result->fetchColumn()));
$result->closeCursor();
if (Game::getPlanet()->getData("moonid") > 0) {
if (Game::getPlanet()->getData("ismoon")) {
// Planet has moon
$where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ? AND g.position = ?", array(Game::getPlanet()->getData("moongala"), Game::getPlanet()->getData("moonsys"), Game::getPlanet()->getData("moonpos")));
$result = Core::getQuery()->select("galaxy g", array("p.planetid", "p.planetname", "p.picture"), "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.planetid)", $where);
} else {
// Planet of current moon
$where = Core::getDB()->quoteInto("g.galaxy = ? AND g.system = ? AND g.position = ?", array(Game::getPlanet()->getData("galaxy"), Game::getPlanet()->getData("system"), Game::getPlanet()->getData("position")));
$result = Core::getQuery()->select("galaxy g", array("p.planetid", "p.planetname", "p.picture"), "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g.moonid)", $where);
}
$row = $result->fetchRow();
$result->closeCursor();
Core::getTPL()->assign("moon", $row["planetname"]);
$img = Image::getImage("planets/" . $row["picture"] . Core::getConfig()->get("PLANET_IMG_EXT"), $row["planetname"], 50, 50);
Core::getTPL()->assign("moonImage", "<a title=\"" . $row["planetname"] . "\" class=\"goto pointer\" href=\"" . $row["planetid"] . "\">" . $img . "</a>");
} else {
Core::getTPL()->assign("moon", "");
Core::getTPL()->assign("moonImage", "");
}
// Current events
$research = Game::getEH()->getResearchEvent();
Core::getTPL()->assign("research", $research);
$shipyardMissions = Game::getEH()->getShipyardEvents();
Core::getTemplate()->assign("shipyardMissions", $shipyardMissions);
/* @var Bengine_Game_Model_Collection_News $news */
$news = Game::getCollection("game/news");
$news->addSortIndexOrder()->addEnabledFilter()->addLanguageFilter();
Core::getTPL()->addLoop("news", $news);
Hook::event("GameIndexAction");
return $this;
}
示例6: executeJump
/**
* Executes star gate jump and update shipyard informations.
*
* @param integer $moonid
* @throws Recipe_Exception_Generic
* @return Bengine_Game_Controller_Mission
*/
protected function executeJump($moonid)
{
$this->noAction = true;
$result = Core::getQuery()->select("temp_fleet", "data", "", Core::getDB()->quoteInto("planetid = ?", Core::getUser()->get("curplanet")));
if ($temp = $result->fetchRow()) {
$result->closeCursor();
$temp = unserialize($temp["data"]);
Hook::event("ExecuteStarGateJump", array(&$temp));
if (!in_array($moonid, $temp["moons"])) {
throw new Recipe_Exception_Generic("Unkown moon.");
}
foreach ($temp["ships"] as $key => $value) {
$where = Core::getDB()->quoteInto("unitid = ? AND planetid = ?", array($key, Core::getUser()->get("curplanet")));
$_result = Core::getQuery()->select("unit2shipyard", array("quantity"), "", $where);
$availQty = $_result->fetchRow();
$_result->closeCursor();
if ($availQty < $value["quantity"]) {
throw new Recipe_Exception_Generic("Sorry, you have been attacked. Process stopped.");
}
Core::getDB()->query("UPDATE " . PREFIX . "unit2shipyard SET quantity = quantity - ? WHERE unitid = ? AND planetid = ?", array($value["quantity"], $key, Core::getUser()->get("curplanet")));
/* @var Bengine_Game_Model_Collection_Fleet $shipyard */
$shipyard = Game::getCollection("game/fleet");
$shipyard->addPlanetFilter($moonid);
$shipyard->addTypeFilter(3);
$shipyard->getSelect()->where("u2s.unitid = ?", $key);
if ($shipyard->count() > 0) {
Core::getDB()->query("UPDATE " . PREFIX . "unit2shipyard SET quantity = quantity + ? WHERE planetid = ? AND unitid = ?", array($value["quantity"], $moonid, $key));
} else {
Core::getQuery()->insert("unit2shipyard", array("unitid" => $key, "planetid" => $moonid, "quantity" => $value["quantity"]));
}
}
Core::getQuery()->delete("unit2shipyard", "quantity = ?", null, null, array(0));
Core::getQuery()->insert("stargate_jump", array("planetid" => Core::getUser()->get("curplanet"), "time" => TIME, "data" => serialize($temp)));
Core::getQuery()->delete("temp_fleet", "planetid = ?", null, null, array(Core::getUser()->get("curplanet")));
Logger::addMessage("JUMP_SUCCESSFUL", "success");
}
return $this;
}
示例7: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_MonitorPlanet
*/
protected function indexAction()
{
$this->validate()->subtractHydrogen();
Hook::event("StarSurveillanceStart", array($this->planetData));
/* @var Bengine_Game_Model_Collection_Event $collection */
$collection = Game::getCollection("game/event");
$collection->addTimeFilter()->addPlanetFilter($this->planetid)->addBaseTypeFilter("fleet");
Hook::event("StarSurveillanceEventsLoaded", array($collection));
$events = array();
/* @var Bengine_Game_Model_Event $row */
foreach ($collection as $row) {
// Mission is missle attack >> hide
if ($row->getCode() == "game/missileAttack") {
continue;
}
// Do not show mission on return fly from original planet
if ($row->getCode() == "game/return" && $this->planetData->getPlanetid() == $row->getPlanetid() && $row->getDestination() != $row->getPlanetid()) {
continue;
}
// Mission is recycling AND destination planet is the scanned planet >> hide
if ($row->getCode() == "game/recycling" && $row->getDestination() == $this->planetData->getPlanetid() && $row->getDestination() != $row->getPlanetid()) {
continue;
}
// Original mission is recycling AND original planet is the scanned planet >> hide
if ($row->getOrgMode() == 9 && $row->getPlanetid() == $this->planetData->getPlanetid() && $row->getDestination() != $row->getPlanetid()) {
continue;
}
// Hide return missions if destination is a moon (always)
if ($row->getCode() == "game/return" && $row->getDestinationIsmoon()) {
continue;
}
// Mission is position and on return >> hide
if ($row->getOrgMode() == 6) {
continue;
}
Hook::event("StarSurveillanceEventItem", array($row));
Core::getLanguage()->assign("planet", $row->getPlanetname());
Core::getLanguage()->assign("coords", $row->getPlanetCoords());
Core::getLanguage()->assign("target", $row->getCode() != "game/recycling" ? $row->getDestinationPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
Core::getLanguage()->assign("targetcoords", $row->getDestinationCoords());
Core::getLanguage()->assign("username", $row->getUsername());
Core::getLanguage()->assign("mission", $row->getCode() == "return" ? $row->getOrgModeName() : $row->getModeName());
Core::getLanguage()->assign("fleet", $row->getFleetString());
if ($row->getCode() == "holding") {
$message = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_2");
} else {
if ($row->getCode() == "return" && $row->getUserid() == $this->planetData->getUserid()) {
$message = Core::getLanguage()->getItem("STAR_SUR_MSG_RETURN");
} else {
$message = Core::getLanguage()->getItem("STAR_SUR_MSG");
}
}
$events[] = array("eventid" => $row->getEventid(), "class" => $row->getCssClass(), "time" => $row->getFormattedTimeLeft(), "time_r" => $row->getTimeLeft(), "message" => $message);
}
if (count($events) > 0) {
Core::getLanguage()->load("info");
}
Core::getTPL()->addLoop("events", $events);
Core::getTPL()->assign("num_rows", count($events));
// Assignments
Core::getLanguage()->assign("target", $this->planetData["planetname"]);
Core::getLanguage()->assign("targetuser", $this->planetData["username"]);
Core::getLanguage()->assign("targetcoords", "[" . $this->planetData["galaxy"] . ":" . $this->planetData["system"] . ":" . $this->planetData["position"] . "]");
$this->setIsAjax();
return $this;
}
示例8: readFolderAction
/**
* Shows content of a message folder.
*
* @param integer $id Folder id
*
* @return Bengine_Game_Controller_MSG
*/
protected function readFolderAction($id)
{
if ($this->isPost()) {
$this->deleteMessages($id, $this->getParam("deleteOption"), $this->getParam("msgid", array()));
}
$pagination = $this->getPagination($id);
$pagination->render();
$readMessages = array();
/* @var Bengine_Game_Model_Collection_Message $messages */
$messages = Game::getCollection("game/message");
$messages->addTimeOrder()->addFolderJoin()->addReceiverFilter(Core::getUser()->get("userid"))->addFolderFilter($id)->setPagination($pagination);
$folderObjCache = array();
/* @var Bengine_Game_Model_Message $message */
foreach ($messages as $message) {
Hook::event("ReadMessageFirst", array($message));
$folderCode = $message->get("folder_class");
if (!isset($folderObjCache[$folderCode])) {
$folderClass = explode("/", $folderCode);
$folderClass = $folderClass[0] . "/messageFolder_" . $folderClass[1];
$folderObj = Application::factory($folderClass);
$folderObjCache[$folderCode] = $folderObj;
} else {
$folderObj = $folderObjCache[$folderCode];
}
$folderObj->formatMessage($message);
if (!$message->get("read")) {
$readMessages[] = (int) $message->get("msgid");
}
Hook::event("ReadMessageLast", array($message));
}
if (count($readMessages) > 0) {
Core::getQuery()->update("message", array("read" => 1), "msgid = " . implode(" OR msgid = ", $readMessages));
}
Core::getTPL()->addLoop("messages", $messages);
Core::getTPL()->assign("mode", $id);
Core::getTPL()->assign("pagination", $pagination);
return $this;
}
示例9: getEventCollectionTemplate
/**
* Returns an event collection default schema for the current user.
*
* @return Bengine_Game_Model_Collection_Event
*/
public function getEventCollectionTemplate()
{
/* @var Bengine_Game_Model_Collection_Event $collection */
$collection = Game::getCollection("game/event");
$collection->addUserFilter(Core::getUser()->get("userid"))->addTimeOrder()->addTimeFilter()->addNoRaceConditionFilter();
return $collection;
}
示例10: updateUserData
//.........这里部分代码省略.........
$result->closeCursor();
if (!checkEmail($email)) {
$email = Core::getUser()->get("email");
Logger::addMessage("EMAIL_INVALID");
} else {
$successMsg = "EMAIL_CHANGED";
if (Core::getConfig()->get("EMAIL_ACTIVATION_CHANGED_EMAIL")) {
$activation = randString(8);
$url = BASE_URL . Core::getLang()->getOpt("langcode") . "/signup/activation/key:" . $activation;
Core::getLang()->assign("username", $username);
Core::getTemplate()->assign("activationUrl", $url);
$template = new Recipe_Email_Template("email_changed");
$mail = new Email($email, Core::getLanguage()->getItem("EMAIL_ACTIVATION"));
$template->send($mail);
$successMsg .= "_REVALIDATE";
}
Logger::addMessage($successMsg, "success");
}
} else {
$result->closeCursor();
Logger::addMessage("EMAIL_EXISTS");
$email = Core::getUser()->get("email");
}
}
// Check password
$pwLength = Str::length($pw);
if ($pwLength > 0) {
if ($pwLength >= Core::getOptions()->get("MIN_PASSWORD_LENGTH") && $pwLength <= Core::getOptions()->get("MAX_PASSWORD_LENGTH")) {
$successMsg = "PASSWORD_CHANGED";
if ($activation == "" && Core::getConfig()->get("EMAIL_ACTIVATION_CHANGED_PASSWORD")) {
$activation = randString(8);
$url = BASE_URL . Core::getLang()->getOpt("langcode") . "/signup/activation/key:" . $activation;
Core::getLang()->assign("username", $username);
Core::getTemplate()->assign("activationUrl", $url);
Core::getTemplate()->assign("newPassword", $pw);
$template = new Recipe_Email_Template("password_changed");
$mail = new Email($email, Core::getLanguage()->getItem("PASSWORD_ACTIVATION"));
$template->send($mail);
$successMsg .= "_REVALIDATE";
}
$encryption = Core::getOptions("USE_PASSWORD_SALT") ? "md5_salt" : "md5";
$pw = Str::encode($pw, $encryption);
Core::getQuery()->update("password", array("password" => $pw, "time" => TIME), "userid = ?", array(Core::getUser()->get("userid")));
Logger::addMessage($successMsg, "success");
} else {
Logger::addMessage("PASSWORD_INVALID");
}
}
// Umode
if ($umode == 1) {
// Check if umode can be activated
/* @var Bengine_Game_Model_Collection_Event $events */
$events = Game::getCollection("game/event");
$events->addVacationModeFilter(Core::getUser()->get("userid"));
$eventCount = $events->getCalculatedSize();
if ($eventCount > 0) {
Logger::dieMessage("CANNOT_ACTIVATE_UMODE");
}
$umodemin = TIME + Core::getConfig()->get("MIN_VACATION_MODE");
setProdOfUser(Core::getUser()->get("userid"), 0);
} else {
$umodemin = 0;
$umode = 0;
}
// Deletition
$delete = !$delete ? 0 : TIME + self::DELETE_PROTECTION_TIME;
// Other prefs
$ipcheck = (int) $ipcheck;
if (!Core::getConfig()->get("USER_EDIT_IP_CHECK")) {
$ipcheck = Core::getUser()->get("ipcheck");
} else {
if ($ipcheck > 0) {
$ipcheck = 1;
}
}
if ($esps > 99) {
$esps = 99;
} else {
if ($esps <= 0) {
$esps = 1;
}
}
Hook::event("SaveUserDataLast", array(&$username, &$usertitle, &$email, &$templatepackage, &$theme, &$umode, &$umodemin, &$delete, $ipcheck, $esps, &$js_interface));
// Save it
$spec = array("username" => $username, "usertitle" => $usertitle, "email" => $email, "temp_email" => $email, "activation" => $activation, "languageid" => $language, "templatepackage" => $templatepackage, "theme" => $theme, "ipcheck" => $ipcheck, "umode" => $umode, "umodemin" => $umodemin, "delete" => $delete, "esps" => $esps, "js_interface" => $js_interface);
// Feeds
if ($generate_key) {
$new_key = randString(16);
$result = Core::getQuery()->select("feed_keys", array("feed_key"), "", Core::getDB()->quoteInto("user_id = ?", Core::getUser()->get("userid")));
if ($result->rowCount() > 0) {
// User has a feed key
Core::getQuery()->update("feed_keys", array("feed_key" => $new_key), "user_id = ?", array(Core::getUser()->get("userid")));
} else {
Core::getQuery()->insert("feed_keys", array("user_id" => Core::getUser()->get("userid"), "feed_key" => $new_key));
}
}
Core::getQuery()->update("user", $spec, "userid = ?", array(Core::getUser()->get("userid")));
Core::getUser()->rebuild();
return $this;
}