示例#1
0
 public function load($manager)
 {
     $mates = $this->gameRepository->createRecentMateQuery()->getQuery()->execute();
     foreach ($mates as $mate) {
         $trial = new Trial();
         $trial->setGame($mate);
         $trial->setUser($mate->getWinner()->getUser());
         $trial->setScore(70);
         $manager->persist($trial);
     }
     $manager->flush();
 }
示例#2
0
 /**
  * Decide whether or not to open a trial for this game
  *
  * @return null
  **/
 public function study(Game $game)
 {
     if (!$game->getIsRated()) {
         return;
     }
     if ($game->getFullmoveNumber() < 10) {
         return;
     }
     if (!($winner = $game->getWinner())) {
         return;
     }
     $blurFactor = $this->calculateBlurFactor($winner);
     $timePerMove = $this->calculateTimePerMove($game);
     $score = $this->trialScoreCalculator->calculateScore($blurFactor, $timePerMove);
     if ($score < 75) {
         return;
     }
     $trial = new Trial();
     $trial->setGame($game);
     $trial->setUser($winner->getUser());
     $trial->setScore($score);
     $this->objectManager->persist($trial);
 }