Class: Knight
Class Method Summary collapse
Methods inherited from Piece
capturable?, destination_occupied?, obstructed?
Class Method Details
.move_is_valid?(orig, dest, board) ⇒ Boolean
6 7 8 9 10 11 12 |
# File 'lib/pieces/knight.rb', line 6 def self.move_is_valid?(orig, dest, board) x_offset = (orig[0] - dest[0]).abs y_offset = (orig[1] - dest[1]).abs (!destination_occupied?(dest, board) || capturable?(orig, dest, board)) && (x_offset == 2 && y_offset == 1) || (x_offset == 1 && y_offset == 2) end |