Exemple #1
0
        public override IEnumerable<BoardCoordinate> GetMovesFrom(BoardCoordinate startingLocation, int boardSize)
        {
            yield return new BoardCoordinate(startingLocation.X, startingLocation.Y+1);

            if(!HasMoved)
                yield return new BoardCoordinate(startingLocation.X, startingLocation.Y + 2);
        }
Exemple #2
0
        public void AddPiece(Piece piece, BoardCoordinate moveTarget)
        {
            if(!moveTarget.IsCoordinateValidForBoardSize(BoardSize))
                throw new ArgumentException("moveTarget");

            _pieces[moveTarget.X, moveTarget.Y] = piece;
        }
Exemple #3
0
 public override IEnumerable<BoardCoordinate> GetMovesFrom(BoardCoordinate startingLocation, int boardSize)
 {
     var allDistancesFromStart = Enumerable.Range(1, boardSize+1);
     var allPossibleBoardCoordinates = allDistancesFromStart.SelectMany(sp => GetRadialDiagonalFrom(startingLocation, sp));
     var legalBoardCoordinates = allPossibleBoardCoordinates.Where(bc => bc.IsCoordinateValidForBoardSize(boardSize));
     return legalBoardCoordinates;
 }
Exemple #4
0
 private static IEnumerable<BoardCoordinate> GetRadialDiagonalFrom(BoardCoordinate startingPosition, int distance)
 {
     yield return new BoardCoordinate(startingPosition.X + distance, startingPosition.Y + distance);
     yield return new BoardCoordinate(startingPosition.X + distance, startingPosition.Y - distance);
     yield return new BoardCoordinate(startingPosition.X - distance, startingPosition.Y + distance);
     yield return new BoardCoordinate(startingPosition.X - distance, startingPosition.Y - distance);
 }
Exemple #5
0
        public override IEnumerable<BoardCoordinate> GetMovesFrom(BoardCoordinate startingLocation, int boardSize)
        {
            var availableCoordinates = Enumerable.Range(1, boardSize);
            var verticalMoves = availableCoordinates.Where(y => startingLocation.Y != y)
                .Select(y => new BoardCoordinate(startingLocation.X, y));

            var horizontalMoves = availableCoordinates.Where(x => startingLocation.X != x)
                .Select(x => new BoardCoordinate(x, startingLocation.Y));

            return verticalMoves.Union(horizontalMoves);
        }
Exemple #6
0
 public abstract IEnumerable<BoardCoordinate> GetMovesFrom(BoardCoordinate startingLocation, int boardSize);
Exemple #7
0
 public Piece GetPiece(BoardCoordinate squareInQuestion)
 {
     return _pieces[squareInQuestion.X, squareInQuestion.Y];
 }