/**
 * Rook.js - Rook piece implementation
 * Handles horizontal and vertical movement
 */

import { Piece } from './Piece.js';

export class Rook extends Piece {
    constructor(color, position) {
        super(color, position);
        this.type = 'rook';
    }

    /**
     * Check if rook can castle
     * @returns {boolean} True if not moved
     */
    canCastle() {
        return !this.hasMoved;
    }

    /**
     * Get valid moves for rook
     * Rook moves horizontally or vertically any number of squares
     * @param {Board} board - Game board
     * @returns {Position[]} Array of valid positions
     */
    getValidMoves(board) {
        // Horizontal and vertical directions
        const directions = [
            [-1, 0], // Up
            [1, 0],  // Down
            [0, -1], // Left
            [0, 1]   // Right
        ];

        return this.getSlidingMoves(board, directions);
    }
}
