Class: ChessVwong::Knight

Inherits:
Piece
  • Object
show all
Defined in:
lib/chess_vwong/knight.rb

Instance Attribute Summary

Attributes inherited from Piece

#color, #current_space, #ep_kill, #neighbours, #turns

Instance Method Summary collapse

Methods inherited from Piece

#initialize, #valid_space?

Constructor Details

This class inherits a constructor from ChessVwong::Piece

Instance Method Details

#characterObject



3
4
5
# File 'lib/chess_vwong/knight.rb', line 3

def character
  color == 'w' ? "\u{2658}" : "\u{265E}"
end

#generate_neighbours(current_space) ⇒ Object

Generate all possible Neighbouring Spaces



8
9
10
11
12
13
# File 'lib/chess_vwong/knight.rb', line 8

def generate_neighbours(current_space)
  moves = [[1, 2], [-1, 2], [1, -2], [-1, -2], [2, 1], [-2, 1], [2, -1], [-2, -1]]
  moves.each do |move|
    neigbour_helper(current_space, move[0], move[1])
  end
end