Exemple #1
0
 public function getPgnMoves(Game $game, $withTime = false)
 {
     $withTime = $withTime && $game->hasMoveTimes();
     if ($withTime) {
         $times = $game->getMoveTimes();
     }
     $pgnMoves = $game->getPgnMoves();
     if (empty($pgnMoves)) {
         return '';
     }
     $moves = $game->getPgnMoves();
     $nbMoves = count($moves);
     $nbTurns = ceil($nbMoves / 2);
     $string = '';
     for ($turns = 1; $turns <= $nbTurns; $turns++) {
         $index = ($turns - 1) * 2;
         $string .= $turns . '. ';
         $string .= $moves[$index] . ' ';
         if ($withTime) {
             $string .= '{' . $times[$index] . '} ';
         }
         if (isset($moves[$index + 1])) {
             $string .= $moves[$index + 1] . ' ';
             if ($withTime) {
                 $string .= '{' . $times[$index + 1] . '} ';
             }
         }
     }
     return trim($string);
 }
 public function findSimilar(Game $game, \DateTime $since)
 {
     return $this->createQueryBuilder()->field('id')->notEqual($game->getId())->field('updatedAt')->gt(new \MongoDate($since->getTimestamp()))->field('status')->equals(Game::STARTED)->field('turns')->equals($game->getTurns())->field('pgnMoves')->equals($game->getPgnMoves())->hint(array('updatedAt' => -1))->getQuery()->execute();
 }