Sha256: e48490964a0acf0c9ecb46757d2126a7ee8144f6f74d48b1dea719ca20b572e2

Contents?: true

Size: 574 Bytes

Versions: 11

Compression:

Stored size: 574 Bytes

Contents

require 'just_chess/pieces/piece'

module JustChess

  # = Rook
  #
  # The piece that moves any number of squares orthogonally.
  class Rook < Piece

    # All the squares that the piece can move to and/or capture.
    #
    # @param [Square] square
    #   the origin square.
    #
    # @param [GameState] game_state
    #   the current game state.
    #
    # @return [SquareSet]
    def destinations(square, game_state)
      game_state.squares.orthogonal(square).unoccupied_or_occupied_by_opponent(player_number).unblocked(square, game_state.squares)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
just_chess-1.0.9 lib/just_chess/pieces/rook.rb
just_chess-1.0.8 lib/just_chess/pieces/rook.rb
just_chess-1.0.7 lib/just_chess/pieces/rook.rb
just_chess-1.0.6 lib/just_chess/pieces/rook.rb
just_chess-1.0.5 lib/just_chess/pieces/rook.rb
just_chess-1.0.4 lib/just_chess/pieces/rook.rb
just_chess-1.0.3 lib/just_chess/pieces/rook.rb
just_chess-1.0.2 lib/just_chess/pieces/rook.rb
just_chess-1.0.1 lib/just_chess/pieces/rook.rb
just_chess-1.0.0 lib/just_chess/pieces/rook.rb
just_chess-0.1.0 lib/just_chess/pieces/rook.rb