/** * Process a request for hit a ship. * * @param integer $yPosition * @param integer $xPosition * @return bool */ public function hitPosition($yPosition, $xPosition) { $shipPosition = $this->shipsGrid->getPosition($yPosition, $xPosition); $position = $this->getPosition($yPosition, $xPosition); $output = false; $this->isSunk = false; $this->currentShip = $this->shipsGrid->getShipByPosition($shipPosition); if (false !== $this->currentShip && self::DEFAULT_VALUE == $position) { $this->currentShip->hit(); $this->sunkConsequences(); $this->shipsGrid->updateShip($this->currentShip, $shipPosition); $output = true; } else { if (self::HIT_VALUE == $position) { $output = true; } } return $output; }