protected function setUpTwoPlayerGame($game)
 {
     $user1 = $this->em->getRepository('AppBundle:User')->find(1);
     $player1 = new Player($user1, Game::FLIP_TYPE_HEADS);
     $player1->setGame($game);
     $this->em->persist($player1);
     $user2 = $this->em->getRepository('AppBundle:User')->find(2);
     $player2 = new Player($user2, Game::FLIP_TYPE_TAILS);
     $player2->setGame($game);
     $this->em->persist($player2);
     $game->setRandomGenerator(new RandomHeadTailsGenerator());
     $game->playGame();
     $this->em->flush();
 }
 protected function setUpTwoPlayerGameWhereOnlyOnePlayerHasViewedTheGame($manager)
 {
     $game = $this->getReference('game-utah');
     $player1 = new Player($this->getReference('user-ricardo75'), Game::FLIP_TYPE_HEADS);
     $player1->setGame($game);
     $manager->persist($player1);
     $player2 = new Player($this->getReference('user-flipshark'), Game::FLIP_TYPE_TAILS);
     $player2->setGame($game);
     $player2->setViewedGame(true);
     $manager->persist($player2);
     $game->setRandomGenerator(new RandomHeadTailsGenerator());
     $game->playGame();
     $manager->flush();
 }
 public function freePlayerAction($userId, $gameId, $origin)
 {
     $player = new Player();
     $user = $this->getDoctrine()->getRepository('AppBundle:User')->find($userId);
     $player->setUser($user);
     $game = $this->getDoctrine()->getRepository('AppBundle:Game')->find($gameId);
     $systName = $game->getSystName();
     $player->setGame($game);
     $em = $this->getDoctrine()->getManager();
     $em->persist($player);
     $em->flush();
     if ($origin == 'index') {
         return $this->redirectToRoute('labelilan');
     } elseif ($origin == 'show') {
         return $this->redirectToRoute('game_show', ['id' => $game->getId()]);
     }
 }
 protected function createPlayerAddToGameAndPersist(User $user, Game $game, $flipType, EntityManager $em)
 {
     $player = new Player($user, $flipType);
     // this method sets the players game and also adds the player to the game
     $player->setGame($game);
     $em->persist($player);
 }
Exemple #5
0
 /**
  * @param  Player $player
  */
 public function addPlayer(\AppBundle\Entity\Player $player)
 {
     $player->setGame($this);
     $this->player[] = $player;
 }