Class: SteppingPiece
Instance Attribute Summary
Attributes inherited from Piece
Instance Method Summary collapse
Methods inherited from Piece
#dup, #in_range_of_enemy?, #initialize, #move_into_check?, #sum_positions, #symbol, #valid_moves
Constructor Details
This class inherits a constructor from Piece
Instance Method Details
#moves ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pieces/stepping_piece.rb', line 6 def moves moves = [] move_diffs.each do |diff| new_pos = [@pos.first + diff.first, @pos.last + diff.last] next unless @board.on_board?(new_pos) if @board.occupied?(new_pos) next if @board.piece_at(new_pos).color == self.color end moves << new_pos end moves end |