Class: Chess::Pieces::Bishop

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

Overview

Bishop

Instance Attribute Summary

Attributes inherited from Piece

#color, #pos, #valid_moves

Instance Method Summary collapse

Methods included from BishopMoves

#north_east_moves, #north_west_moves, #south_east_moves, #south_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 Bishop

Parameters:

Returns:

  • (Array)

    possible_moves_arr



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

def possible_moves(board)
  file = @pos[0]
  rank = @pos[1]
  moves = []
  moves += north_west_moves(board, file, rank)
  moves += north_east_moves(board, file, rank)
  moves += south_west_moves(board, file, rank)
  moves += south_east_moves(board, file, rank)
  moves
end