class Rchess::Paths::King
Public Instance Methods
paths()
click to toggle source
# File lib/rchess/paths/king.rb, line 4 def paths [basic_paths, rock_paths].flatten(1) end
Private Instance Methods
basic_paths()
click to toggle source
# File lib/rchess/paths/king.rb, line 18 def basic_paths [Bishop.new({coord: @coord, board: @board, power: 1}), Rook.new({coord: @coord, board: @board, power: 1})] end
rock_paths()
click to toggle source
# File lib/rchess/paths/king.rb, line 10 def rock_paths [{x: -3, y: 0}, {x: 2, y: 0}].select do |delta| dstCoord = self.coord.apply_delta(delta) oponent_color = self.color == Piece::WHITE_COLOR ? Piece::BLACK_COLOR : Piece::WHITE_COLOR !self.board.coord_is_threatened_by_color?(dstCoord, oponent_color) end end