Exemplo n.º 1
0
 /**
  * Loads the user data to output.
  *
  * @throws Recipe_Exception_Generic
  * @return Bengine_Game_Model_User
  */
 public function getUser()
 {
     if ($this->_user === null) {
         $this->_user = Application::getModel("game/user")->load($this->getUserId());
         if (!$this->_user->getUserid()) {
             throw new Recipe_Exception_Generic("Unkown user signature.");
         }
     }
     return $this->_user;
 }
Exemplo n.º 2
0
 /**
  * @param Bengine_Game_Model_User $user
  * @param Bengine_Game_Model_Planet $planet
  * @return Bengine_Game_Model_Achievement
  */
 public function unlockForUser(Bengine_Game_Model_User $user, Bengine_Game_Model_Planet $planet = null)
 {
     Core::getQuery()->insert("achievement2user", array("achievement_id" => $this->get("achievement_id"), "user_id" => $user->get("userid"), "date" => TIME));
     $this->set("user_id", $user->get("userid"));
     $user->addXP($this->get("xp"));
     if (count($this->getRewards()) > 0) {
         if (null === $planet) {
             $planet = $user->getHomePlanet();
         }
         foreach ($this->getRewards() as $rewardModel) {
             /* @var Bengine_Game_Model_AchievementReward $rewardModel */
             $reward = $rewardModel->getRewardObject();
             $reward->setUser($user)->setPlanet($planet);
             $reward->reward();
         }
     }
     return $this;
 }