Пример #1
0
 public function foundNumber($value)
 {
     $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     // Recuperation de la partie en cours
     $game = new Game();
     $currentGame = $game->getCurrentGame($em);
     // Recuperation des cartes correspondantes a la partie
     $currentCards = getCurrentsCards($em, $currentGame);
     // Modification de la valeurs "found" des cartes avec le chiffre venant d'être tiré
     $numbers = new Numbers();
     $cards = $numbers->foundNumbersByCards($em, $value, $currentCards);
     $entities = $em->getRepository('Application\\Entity\\Numbers')->findAll();
     foreach ($entities as $entite) {
         $entite->setActive("0");
         $em->persist($entite);
     }
     $em->flush();
     $this->layout('layout/empty');
     echo "OK";
 }
Пример #2
0
 public function chooseNumbersCard($em, $card)
 {
     $arrNumbers = [];
     // Tirage des nombres
     for ($i = 0; $i < 25; $i++) {
         $nb = rand(1, 99);
         if (!in_array($nb, $arrNumbers)) {
             $arrNumbers[] = $nb;
         } else {
             $i--;
         }
     }
     // AJout a la BDD
     foreach ($arrNumbers as $number) {
         $num = new Numbers();
         $num->setNumber($number);
         $num->setFound(0);
         $num->setCard($card);
         $em->persist($card);
     }
     $em->flush();
 }