/**
  * Special method to load each type of game notification.  New badge, badge grade change, and level up.
  */
 public function actionLoadGameNotificationsSampler()
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         throw new NotSupportedException();
     }
     //Level up notification
     $coinsValue = GameCoinRules::getCoinsByLevel(2);
     $gameNotification = new GameNotification();
     $gameNotification->user = Yii::app()->user->userModel;
     $gameNotification->setLevelChangeByNextLevelValue(2, $coinsValue);
     $saved = $gameNotification->save();
     //New badge notification
     $gameNotification = new GameNotification();
     $gameNotification->user = Yii::app()->user->userModel;
     $gameNotification->setNewBadgeByType('LoginUser');
     $saved = $gameNotification->save();
     //Badge grade up notification
     $gameNotification = new GameNotification();
     $gameNotification->user = Yii::app()->user->userModel;
     $gameNotification->setBadgeGradeChangeByTypeAndNewGrade('LoginUser', 5);
     $saved = $gameNotification->save();
     //New collection Item
     GameCollection::processRandomReceivingCollectionItemByUser(Yii::app()->user->userModel);
     echo "Demo data has been loaded. Go back to the application.";
 }
 public function testGetCoinsByLevel()
 {
     $this->assertEquals(2, GameCoinRules::getCoinsByLevel(2));
     $this->assertEquals(10, GameCoinRules::getCoinsByLevel(223131));
 }
 /**
  * @param int $nextLevelValue
  * @throws FailedToSaveModelException
  */
 protected static function processLevelChangeGameNotification($nextLevelValue)
 {
     assert('is_int($nextLevelValue)');
     $coinsValue = GameCoinRules::getCoinsByLevel((int) $nextLevelValue);
     $gameNotification = new GameNotification();
     $gameNotification->user = Yii::app()->user->userModel;
     $gameNotification->setLevelChangeByNextLevelValue($nextLevelValue, $coinsValue);
     $saved = $gameNotification->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     $gameCoin = GameCoin::resolveByPerson(Yii::app()->user->userModel);
     $gameCoin->addValue($coinsValue);
     $saved = $gameCoin->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
 }