本文整理汇总了PHP中Application::getCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getCollection方法的具体用法?PHP Application::getCollection怎么用?PHP Application::getCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::getCollection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _match
/**
* @return bool
*/
protected function _match()
{
/* @var Bengine_Game_Model_Collection_Assault $collection */
$collection = Application::getCollection("game/assault");
$collection->addAccomplishedFilter();
switch ($this->getId()) {
case "ATTACKER_WON":
$collection->addParticipantFilter($this->getUser(), 1)->addResultFilter(1);
define("DEBUG", true);
return $collection->getCalculatedSize(false) >= $this->getValue();
break;
case "DEFENDER_WON":
$collection->addParticipantFilter($this->getUser(), 0)->addResultFilter(2);
return $collection->getCalculatedSize(false) >= $this->getValue();
break;
case "TOTAL_WON":
$collection->addParticipantFilter($this->getUser())->addResultFilter(1);
return $collection->getCalculatedSize(false) >= $this->getValue();
break;
case "TOTAL_DRAW":
$collection->addParticipantFilter($this->getUser())->addResultFilter(0);
return $collection->getCalculatedSize(false) >= $this->getValue();
break;
case "OVER_ALL":
$collection->addParticipantFilter($this->getUser());
return $collection->getCalculatedSize(false) >= $this->getValue();
break;
}
return false;
}
示例2: getRewards
/**
* @return Bengine_Game_Model_Collection_AchievementReward
*/
public function getRewards()
{
if (!$this->exists("rewards")) {
/* @var Bengine_Game_Model_Collection_AchievementReward $collection */
$collection = Application::getCollection("game/achievementReward");
$collection->addAchievementFilter($this);
$this->set("rewards", $collection);
}
return $this->get("rewards");
}
示例3: userAction
/**
* @var int $user
* @return Bengine_Game_Controller_Achievements
*/
public function userAction($user)
{
Core::getLanguage()->load(array("Achievements"));
$user = Application::getModel("game/user")->load((int) $user);
/* @var Bengine_Game_Model_Collection_Achievement $achievements */
$achievements = Application::getCollection("game/achievement");
$achievements->addUserJoin($user->get("userid"), true)->addDefaultSorting();
$this->view->addLoop("achievements", $achievements);
$this->view->assign("user", $user);
$this->language->assign("leftXP", $user->getLeftXPForNextLevel());
$this->language->assign("nextLevel", $user->get("level") + 1);
$this->language->assign("xp", $user->get("xp"));
$this->language->assign("level", $user->get("level"));
$this->language->assign("achievementUser", Link::get("game/" . SID . "/Profile/Page/" . $user->get("userid"), $user->get("username")));
}
示例4: _execute
/**
* (non-PHPdoc)
* @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
*/
protected function _execute(Bengine_Game_Model_Event $event, array $data)
{
Hook::event("EhAllianceAttack", array($event, &$data, $this));
$assault = new Bengine_Game_Assault($event->getDestination(), $event->getDestinationUserId(), $event);
$assault->addParticipant(Bengine_Game_Assault_Participant::ATTACKER_MODE, $event->getUserid(), $event->getPlanetid(), $event->getTime(), $data);
// Load allied fleets
$allies = Application::getCollection("game/event")->addParentIdFilter($event->getEventid());
foreach ($allies as $ally) {
$assault->addParticipant(Bengine_Game_Assault_Participant::ATTACKER_MODE, $ally->getUserid(), $ally->getPlanetid(), $event->getTime(), $ally->getData());
}
$assault->startAssault($event->getGalaxy2(), $event->getSystem2(), $event->getPosition2())->finish();
Core::getQuery()->delete("formation_invitation", "eventid = ?", null, null, array($event->getEventid()));
Core::getQuery()->delete("attack_formation", "eventid = ?", null, null, array($event->getEventid()));
return $this;
}
示例5: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Constructions
*/
protected function indexAction()
{
Core::getLanguage()->load(array("info", "buildings"));
$mode = self::BUILDING_CONSTRUCTION_TYPE;
$moonType = Game::getPlanet()->getData("ismoon") ? self::MOON_CONSTRUCTION_TYPE : null;
if (!Game::getPlanet()->planetFree()) {
Logger::addMessage("PLANET_FULL", "info");
}
$shipyardSize = Game::getEH()->getShipyardEvents()->getCalculatedSize();
Core::getTPL()->assign("shipyardSize", $shipyardSize);
Core::getLang()->assign("maxFields", fNumber(Game::getPlanet()->getMaxFields()));
Core::getLang()->assign("occupiedFields", Game::getPlanet()->getFields(true));
/* @var Bengine_Game_Model_Collection_Construction $collection */
$collection = Application::getCollection("game/construction");
$collection->addTypeFilter($mode, $moonType ? true : false, $moonType)->addPlanetJoin(Core::getUser()->get("curplanet"))->addDisplayOrder();
Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
Hook::event("ConstructionsLoaded", array($collection));
Core::getTPL()->addLoop("constructions", $collection);
Core::getTPL()->assign("event", $this->event);
return $this;
}
示例6: indexAction
/**
* Index action.
*
* @return Bengine_Game_Controller_Research
*/
protected function indexAction()
{
Core::getLanguage()->load(array("info", "buildings"));
/* @var Bengine_Game_Model_Collection_Construction $collection */
$collection = Application::getCollection("game/construction");
$collection->addTypeFilter(self::RESEARCH_CONSTRUCTION_TYPE, Game::getPlanet()->getData("ismoon"))->addUserJoin(Core::getUser()->get("userid"))->addDisplayOrder();
if (!Game::getPlanet()->getBuilding("RESEARCH_LAB") || !count($collection)) {
Logger::dieMessage("RESEARCH_LAB_REQUIRED");
}
Hook::event("ResearchLoaded", array($collection));
Core::getTPL()->addLoop("constructions", $collection);
Core::getTPL()->assign("event", $this->event);
$canResearch = true;
if (!Game::getEH()->canReasearch()) {
Logger::addMessage("RESEARCH_LAB_UPGRADING", "info");
$canResearch = false;
}
Core::getTPL()->assign("canResearch", $canResearch);
Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js");
return $this;
}
示例7: changeAction
/**
* Changes the ships against resources.
*
* @return Bengine_Game_Controller_Shipyard
*/
protected function changeAction()
{
if (!Core::getConfig()->get("SCRAP_MERCHANT_RATE")) {
$this->redirect("game/" . SID . "/Shipyard");
}
Core::getLanguage()->load(array("info", "buildings"));
$selUnits = Core::getRequest()->getPOST("unit");
/* @var Bengine_Game_Model_Collection_Fleet $availUnits */
$availUnits = Application::getCollection("game/fleet", "game/unit");
$availUnits->addPlanetFilter(Core::getUser()->get("curplanet"));
$metalCredit = 0;
$siliconCredit = 0;
$hydrogenCredit = 0;
$totalQty = 0;
$realUnits = array();
$rate = (double) Core::getConfig()->get("SCRAP_MERCHANT_RATE");
/* @var Bengine_Game_Model_Unit $unit */
foreach ($availUnits as $unit) {
$unitId = $unit->getUnitid();
if (isset($selUnits[$unitId]) && $selUnits[$unitId] > 0) {
$qty = _pos((int) $selUnits[$unitId]);
$qty = min($qty, $unit->getQty());
$metalCredit += $qty * $unit->get("basic_metal");
$siliconCredit += $qty * $unit->get("basic_silicon");
$hydrogenCredit += $qty * $unit->get("basic_hydrogen");
$totalQty += $qty;
$realUnits[(int) $unitId] = $qty;
}
}
$points = ($metalCredit + $siliconCredit + $hydrogenCredit) / 1000;
$metalCredit = floor($metalCredit * $rate);
$siliconCredit = floor($siliconCredit * $rate);
$hydrogenCredit = floor($hydrogenCredit * $rate);
Core::getLang()->assign(array("metalCredit" => fNumber($metalCredit), "siliconCredit" => fNumber($siliconCredit), "hydrogenCredit" => fNumber($hydrogenCredit), "totalQty" => fNumber($totalQty)));
if (Core::getRequest()->getPOST("verify") == "yes") {
/* @var Bengine_Game_Model_Unit $unit */
foreach ($availUnits as $unit) {
$unitId = (int) $unit->getUnitid();
if (isset($realUnits[$unitId])) {
$qty = $realUnits[$unitId];
if ($unit->getQty() <= $qty) {
Core::getQuery()->delete("unit2shipyard", "`unitid` = ? AND `planetid` = ?", null, null, array($unitId, Core::getUser()->get("curplanet")));
} else {
$sql = "UPDATE `" . PREFIX . "unit2shipyard` SET `quantity` = `quantity` - ? WHERE `unitid` = ? AND `planetid` = ?";
Core::getDatabase()->query($sql, array($qty, $unitId, Core::getUser()->get("curplanet")));
}
}
}
$sql = "UPDATE `" . PREFIX . "planet` SET `metal` = `metal` + ?, `silicon` = `silicon` + ?, `hydrogen` = `hydrogen` + ? WHERE `planetid` = ?";
Core::getDatabase()->query($sql, array($metalCredit, $siliconCredit, $hydrogenCredit, Core::getUser()->get("curplanet")));
$sql = "UPDATE `" . PREFIX . "user` SET `points` = `points` - ? WHERE `userid` = ?";
Core::getDatabase()->query($sql, array($points, Core::getUser()->get("userid")));
$this->redirect("game/" . SID . "/Shipyard");
}
$this->setTemplate("shipyard/change");
$this->assign("units", $realUnits);
return $this;
}
示例8: selectMission
/**
* Select the mission to start and stored resources.
*
* @param integer $galaxy
* @param integer $system
* @param integer $position
* @param string $targetType
* @param integer $speed
* @param string $code
* @param int $formation
*
* @return Bengine_Game_Controller_Mission
*/
protected function selectMission($galaxy, $system, $position, $targetType, $speed, $code, $formation)
{
Core::getLang()->load(array("Galaxy"));
$this->noAction = true;
$result = Core::getQuery()->select("temp_fleet", "data", "", Core::getDB()->quoteInto("planetid = ?", Core::getUser()->get("curplanet")));
if ($row = $result->fetchRow()) {
$result->closeCursor();
$targetMode = $targetType == "moon" ? "moonid" : "planetid";
$data = unserialize($row["data"]);
$data["galaxy"] = (int) $galaxy;
$data["system"] = (int) $system;
$data["position"] = (int) $position;
$speed = (int) $speed;
if ($speed <= 0) {
$speed = 1;
} else {
if ($speed > 100) {
$speed = 100;
}
}
$data["speed"] = $speed;
$select = array("p.planetid", "p.planetname", "p.ismoon", "g.destroyed", "u.userid", "u.points", "u.last", "u.umode", "b.to", "u2a.aid");
$joins = "LEFT JOIN " . PREFIX . "planet p ON (p.planetid = g." . $targetMode . ")";
$joins .= "LEFT JOIN " . PREFIX . "user u ON (p.userid = u.userid)";
$joins .= "LEFT JOIN " . PREFIX . "ban_u b ON (u.userid = b.userid)";
$joins .= "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.userid = u.userid)";
$where = Core::getDB()->quoteInto("galaxy = ? AND system = ? AND position = ?", array($galaxy, $system, $position));
$result = Core::getQuery()->select("galaxy g", $select, $joins, $where);
$target = $result->fetchRow();
$result->closeCursor();
if ($target === false) {
$target = null;
}
$targetName = Core::getLanguage()->getItem("UNKNOWN_PLANET");
if (!empty($target["planetid"])) {
$targetName = !$target["destroyed"] ? $target["planetname"] : Core::getLanguage()->getItem("DESTROYED_PLANET");
$data["destination"] = $target["planetid"];
$target["formation"] = (int) $formation;
}
if ($targetType == "tf") {
$targetName .= " (" . Core::getLanguage()->getItem("TF") . ")";
}
$Relations = new Bengine_Game_User_Relation(Core::getUser()->get("userid"), Core::getUser()->get("aid"));
$showHoldingTime = false;
// Check for available missions
$missions = array();
/* @var Bengine_Game_Model_Collection_Event_Type $eventTypes */
$eventTypes = Application::getCollection("game/event_type");
$eventTypes->addBaseTypeFilter("fleet");
/* @var Bengine_Game_Model_Event_Type $eventType */
foreach ($eventTypes as $eventType) {
/* @var $handler Bengine_Game_EventHandler_Handler_Fleet_Abstract */
$handler = $eventType->getEventHandler();
$handler->setRelations($Relations)->setShips($data["ships"])->setTarget($target)->setTargetType($targetType);
if ($handler->isValid()) {
list($tmp, $compareCode) = explode("/", $eventType->getCode());
$missions[$eventType->get("event_type_id")] = array("mode" => $eventType->get("event_type_id"), "mission" => $eventType->getModeName(), "selected" => $compareCode == $code);
if ($eventType->getCode() == "game/alliedFleet") {
$data["alliance_attack"] = $handler->getSpecialData();
} else {
if ($eventType->getCode() == "game/halt") {
$showHoldingTime = true;
}
}
}
}
Hook::event("SetAvailableMissions", array(&$missions, &$data));
unset($data["amissions"]);
foreach ($missions as $key => $value) {
$data["amissions"][] = $key;
}
Core::getQuery()->update("temp_fleet", array("data" => serialize($data)), "planetid = ?", array(Core::getUser()->get("curplanet")));
$distance = Game::getDistance($galaxy, $system, $position);
$consumption = Game::getFlyConsumption($data["consumption"], $distance, $speed);
Core::getTPL()->assign(array("metal" => Game::getPlanet()->getData("metal"), "silicon" => Game::getPlanet()->getData("silicon"), "hydrogen" => Game::getPlanet()->getData("hydrogen") - $consumption, "capacity" => $data["capacity"] - $consumption, "rest" => fNumber($data["capacity"] - $consumption), "showHoldingTime" => $showHoldingTime, "targetName" => $galaxy . ":" . $system . ":" . $position . " " . $targetName));
Core::getTPL()->addLoop("missions", $missions);
$this->setTemplate("mission/step3");
}
return $this;
}
示例9: getPlanets
/**
* @param bool $includeMoons
* @return Bengine_Game_Model_Collection_Planet
*/
public function getPlanets($includeMoons = false)
{
if ($includeMoons) {
if (!$this->exists("planets_w_moons")) {
/* @var Bengine_Game_Model_Collection_Planet $collection */
$collection = Application::getCollection("game/planet");
$collection->addUserFilter($this->get("userid"));
$this->set("planets_w_moons", $collection);
}
return $this->get("planets_w_moons");
}
if (!$this->exists("planets")) {
/* @var Bengine_Game_Model_Collection_Planet $collection */
$collection = Application::getCollection("game/planet");
$collection->addUserFilter($this->get("userid"));
$collection->addMoonFilter(false);
$this->set("planets", $collection);
}
return $this->get("planets");
}
示例10: getCollection
/**
* Returns a model collection.
*
* @return Recipe_Model_Collection_Abstract
*/
public function getCollection()
{
return Application::getCollection($this->getCollectionName(), $this->getModelName())->setResource($this->getResource());
}
示例11: getDefense
/**
* @return Bengine_Game_Model_Collection_Fleet
*/
public function getDefense()
{
if (!$this->exists("defense")) {
/* @var Bengine_Game_Model_Collection_Fleet $collection */
$collection = Application::getCollection("game/fleet");
$collection->addPlanetFilter($this)->addTypeFilter(4);
$this->set("defense", $collection);
}
return $this->get("defense");
}