Exemple #1
0
 /**
  * Имплементация метода выдачи очков пользователям за найденные решения
  */
 private function doGivePoints(GivePointsContext $ctxt)
 {
     $tillNum = min(ChessKnightBean::inst()->getUserSolvedCnt($ctxt->getUserId()), self::MAX_TASKS);
     for ($index = 1; $index <= $tillNum; $index++) {
         $ctxt->givePoints(self::POINTS_PER_TASK, $index);
     }
 }
Exemple #2
0
 private function tryGivePoints(GivePointsContext $ctxt, $testingId)
 {
     if ($ctxt->hasPoints($testingId)) {
         return;
         //---
     }
     $testResult = TestingBean::inst()->getTestingResult($testingId, $ctxt->getUserId());
     if ($testResult && $testResult->getPercent() >= self::PASS_THRESHOLD_PCNT) {
         $ctxt->givePoints(5, $testingId);
     }
 }
Exemple #3
0
 public function givePointsImpl(GivePointsContext $ctxt, $hodesStr = null)
 {
     if (!is_string($hodesStr) || !is_numeric($hodesStr) || strlen($hodesStr) != 4 || in_array($hodesStr, array('5123', '1352'))) {
         return;
         //---
     }
     $hodesArr[] = (int) $hodesStr[0];
     $hodesArr[] = (int) $hodesStr[1];
     $hodesArr[] = (int) $hodesStr[2];
     $hodesArr[] = (int) $hodesStr[3];
     if ($this->isValid($hodesArr)) {
         $ctxt->givePoints(2, $hodesStr);
     }
 }
Exemple #4
0
 public function givePointsImpl(GivePointsContext $ctxt, $modeHodes = null)
 {
     if ($ctxt->hasPoints()) {
         return;
         //---
     }
     $check = array('m0R' => 8, 'm0K' => 16, 'm0B' => 14, 'm0N' => 32, 'm0Q' => 8, 'm1R' => 8, 'm1K' => 9, 'm1B' => 8, 'm1N' => 12, 'm1Q' => 5);
     $valid = false;
     if (is_array($modeHodes) && count($modeHodes) == 2) {
         foreach ($modeHodes as $mode => $hodes) {
             foreach ($hodes as $fig => $hod) {
                 $key = $mode . $fig;
                 $valid = array_key_exists($key, $check) && is_numeric($check[$key]) && strlen($hod) == $check[$key] * 2;
                 if (!$valid) {
                     return;
                     //Невалидный ответ ---
                 }
             }
         }
     }
     if ($valid) {
         $ctxt->givePoints(10);
     }
 }
Exemple #5
0
 public function givePointsImpl(GivePointsContext $ctxt, $cnt = null, $reason = null)
 {
     $ctxt->givePoints($cnt, $reason);
 }
Exemple #6
0
 /**
  * Метод проверяет контекст выдачи очков и выполняет все необходимые действия, если очки были даны
  */
 private function checkGivePointsContext(PsUser $user, GivePointsContext $ctxt)
 {
     $given = $ctxt->getGivenPoints();
     /* @var $pointDo UserPointDO */
     foreach ($given as $pointDo) {
         MSG_PointsGiven::inst()->sendSystemMsg($user, $pointDo->getPointId());
     }
     return count($given) > 0;
 }
Exemple #7
0
 public function doGivePoints(GivePointsContext $ctxt)
 {
     $ctxt->givePoints(5, null, true);
 }