public function testFailedReceiveShot() { $point = new Coordinate(1, 1); $x = 2; $y = 1; $result = $point->receiveShot($x, $y); $coordinateHit = $point->isHit(); $this->assertFalse($result); $this->assertFalse($coordinateHit); }
/** * When adding a new point to a ship, each point should have one * axis of which the values are in sequence. * * Check to see if the new point follows this sequence. * * @param Coordinate $point Point to check * @return boolean True when the point follows sequence, False on failure. */ public function orientatedCoordinateFollowsSequence(Coordinate $point) { $lastPoint = end($this->points); if ($this->orientation === self::ORIENTATION_HORIZONTAL) { $lastValue = $lastPoint->getPositionX(); $newValue = $point->getPositionX(); } else { $lastValue = $lastPoint->getPositionY(); $newValue = $point->getPositionY(); } if ($newValue === $lastValue - 1 || $newValue === $lastValue + 1) { return true; } return false; }