Class: ChessVwong::King

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

Instance Attribute Summary

Attributes inherited from Piece

#color, #current_space, #neighbours

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



4
5
6
# File 'lib/chess_vwong/king.rb', line 4

def character
  color == "w" ? "\u{265A}" : "\u{2654}"
end

#generate_neighbours(current_space) ⇒ Object

Generate all possible Neighbouring Spaces



9
10
11
12
13
14
# File 'lib/chess_vwong/king.rb', line 9

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