/** * Имплементация метода выдачи очков пользователям за найденные решения */ 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); } }
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); } }
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); } }
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); } }
public function givePointsImpl(GivePointsContext $ctxt, $cnt = null, $reason = null) { $ctxt->givePoints($cnt, $reason); }
public function doGivePoints(GivePointsContext $ctxt) { $ctxt->givePoints(5, null, true); }