public IList <ShipPoint> GetPointsOccupiedByPlacementDirection(ShipPoint startPosition, int shipLength) { var pointList = new List <ShipPoint>(shipLength); for (int i = 0; i < shipLength; i++) { pointList.Add(new ShipPoint() { XCoordinate = startPosition.XCoordinate - i, YCoordinate = startPosition.YCoordinate }); } return(pointList); }
public void AddPoint(ShipPoint point) { AddShip(point.Hit ? true : false); if (point.Hit) { SetStatusHit(); } else if (point.Missed) { SetStatusMissed(); } }
/// <summary> /// Get the Points(X,Y) on board occupied by a ship based on ship Type, Orientation /// and start point location /// </summary> /// <param name="startPosition">start point(x,y) for placing ship</param> /// <param name="orientation">Eg. North/South/West/East</param> /// <returns>List of all the points(x,y) occupied by ship</returns> public virtual IList <ShipPoint> GetPointsOccupiedOnBoard(ShipPoint startPosition, ShipOrientation orientation) { var orientationCalc = _shipOrientationFactory.GetShipPlacementOrientation(orientation); return(orientationCalc?.GetPointsOccupiedByPlacementDirection(startPosition, Size)); }