public function processShot($hitCoordinates) { $this->hitCoordinates = !empty($hitCoordinates['xy']) ? $hitCoordinates['xy'] : $hitCoordinates; if ($this->validateCoordinates()) { $this->convertedCoordinateArray = Convertor::ToArray($this->hitCoordinates); $this->shipPosition = Convertor::ToString($this->hitCoordinates); $this->persistObject = $this->saveData->get(); if ($this->isHitAlreadyPlay()) { $this->message = 'Those coordinates have already been tried.'; } else { $this->saveUserHits($hitCoordinates); if (!$this->isHit($this->hitCoordinates)) { $this->setHitStatus(IBattle::MISS); $this->message = 'OOOH MISS...'; } else { $this->message = 'YEAH, HIT!!!'; $this->setHitStatus(IBattle::HIT); if ($this->isShipSunk()) { $this->message = 'HIT!!! Congratulations you sunk this ship.'; } if ($this->isGameOver()) { $this->message = 'Well done! You completed the game in ' . $this->getShotAttempts() . ' shots.'; } } } } else { $this->message = 'Those coordinates wont work. Please try again.'; } }