Class: Chess::Rook

Inherits:
BoardgameEngine::Piece show all
Defined in:
lib/boardgame_engine/chess.rb

Instance Attribute Summary

Attributes inherited from BoardgameEngine::Piece

#owner, #status

Instance Method Summary collapse

Methods inherited from BoardgameEngine::Piece

#kill, #to_s

Constructor Details

#initialize(owner) ⇒ Rook

Returns a new instance of Rook.



168
169
170
# File 'lib/boardgame_engine/chess.rb', line 168

def initialize(owner)
  super(owner, 'R')
end

Instance Method Details

#valid_move?(start_location, end_location, board) ⇒ Boolean

Returns:

  • (Boolean)


172
173
174
175
176
177
178
# File 'lib/boardgame_engine/chess.rb', line 172

def valid_move?(start_location, end_location, board)
  row, col = start_location
  end_row, end_col = end_location

  board.clear_horz_path?(row, col, end_row, end_col, board) \
  || board.clear_vert_path?(row, col, end_row, end_col, board)
end