Class: Rook

Inherits:
Piece show all
Defined in:
lib/bangkok/piece.rb

Instance Attribute Summary

Attributes inherited from Piece

#color, #piece, #square

Instance Method Summary collapse

Methods inherited from Piece

#clear_to?, create, #move_off_board, #move_to, #to_s

Constructor Details

#initialize(board, listener, color, square) ⇒ Rook

Returns a new instance of Rook.



154
155
156
# File 'lib/bangkok/piece.rb', line 154

def initialize(board, listener, color, square)
  super(board, listener, color, :R, square)
end

Instance Method Details

#could_perform_move(move) ⇒ Object



158
159
160
161
162
163
164
# File 'lib/bangkok/piece.rb', line 158

def could_perform_move(move)
  return false unless super

  square = move.square
  return false if square.file != @square.file && square.rank != @square.rank
  return clear_to?(square)
end