Class: Chess::Pieces::Rook

Inherits:
Piece
  • Object
show all
Includes:
RookMoves
Defined in:
lib/chess/pieces/rook.rb

Overview

Rook

Instance Attribute Summary

Attributes inherited from Piece

#color, #pos, #valid_moves

Instance Method Summary collapse

Methods included from RookMoves

#east_moves, #north_moves, #south_moves, #west_moves

Methods inherited from Piece

#black?, #initialize, #white?

Constructor Details

This class inherits a constructor from Chess::Pieces::Piece

Instance Method Details

#possible_moves(board) ⇒ Array

all possible_moves of Rook

Parameters:

Returns:

  • (Array)

    possible_moves_arr



66
67
68
69
70
71
72
73
74
75
# File 'lib/chess/pieces/rook.rb', line 66

def possible_moves(board)
  file = @pos[0]
  rank = @pos[1]
  moves = []
  moves += north_moves(board, file, rank)
  moves += south_moves(board, file, rank)
  moves += west_moves(board, file, rank)
  moves += east_moves(board, file, rank)
  moves
end