public function testIsSunk()
 {
     $mast = 'B2';
     $allShips = new CoordsCollection(['B1', 'B2', 'B3']);
     $allShots = new CoordsCollection(['B1', 'B3']);
     $this->assertTrue($this->battleManager->isSunk($mast, $allShips, $allShots));
     $mast = 'B3';
     $allShips = new CoordsCollection(['B1', 'B2', 'B3', 'B4']);
     $allShots = new CoordsCollection(['B1', 'B2', 'B4']);
     $this->assertTrue($this->battleManager->isSunk($mast, $allShips, $allShots));
     $mast = 'B3';
     $allShips = new CoordsCollection(['B3']);
     $allShots = new CoordsCollection([]);
     $this->assertTrue($this->battleManager->isSunk($mast, $allShips, $allShots));
     $mast = 'B3';
     $allShips = new CoordsCollection(['B1', 'B2', 'B3', 'B4']);
     $allShots = new CoordsCollection(['B1', 'B4']);
     $this->assertFalse($this->battleManager->isSunk($mast, $allShips, $allShots));
 }
 /**
  * Example response:<pre>
  *  {"timestamp":"2016-11-11T16:21:16+0000"} # for chat
  *  {"result":"miss"} # for shot</pre>
  *
  * @ApiDoc(
  *  resource=true,
  *  description="Create new event",
  *  section="Event",
  *  statusCodes={
  *     201="Event created",
  *     400="Incorrect parameter provided",
  *     404="Game not found",
  *     409="Action not allow due to game flow restrictions"
  *  }
  * )
  *
  * @Tag(expression="'game-' ~ game.getId() ~ 'events'")
  * @Security("game.belongsToUser(user)")
  * @RequestParam(
  *     name="type",
  *     requirements=@Assert\Choice(callback = {"AppBundle\Entity\Event", "getTypes"})
  * )
  * @RequestParam(name="value", requirements=".*\S.*", allowBlank=false, default=true)
  *
  * @param ParamFetcher $paramFetcher
  * @param Game $game
  * @return Response
  */
 public function postEventAction(ParamFetcher $paramFetcher, Game $game)
 {
     $event = new Event();
     $event->setGame($game)->setPlayer($game->getPlayerNumber())->setType($paramFetcher->get('type'))->setValue($paramFetcher->get('value'));
     $data = null;
     switch ($event->getType()) {
         case Event::TYPE_CHAT:
             $event->applyCurrentTimestamp();
             $data = ['timestamp' => $event->getTimestamp()];
             break;
         case Event::TYPE_SHOT:
             $shotResult = $this->battleManager->getShotResult($event);
             $event->setValue([$event->getValue(), $shotResult]);
             $data = ['result' => $shotResult];
             break;
     }
     $this->entityManager->persist($event);
     $this->entityManager->flush();
     $view = $this->routeRedirectView('api_v1_get_game_event', ['game' => $game->getId(), 'event' => $event->getId()])->setData($data);
     return $this->handleView($view);
 }