Class: ChessEngine::King

Inherits:
Piece
  • Object
show all
Defined in:
lib/chess_engine/piece.rb

Instance Attribute Summary

Attributes inherited from Piece

#color, #moves_count, #symbol

Instance Method Summary collapse

Methods inherited from Piece

#beats_diagonally?, #beats_straight?, #inspect

Constructor Details

#initialize(color) ⇒ King

Returns a new instance of King.



42
43
44
45
# File 'lib/chess_engine/piece.rb', line 42

def initialize(color)
  super
  @symbol = (@color == :black) ? "\u265A" : "\u2654"
end

Instance Method Details

#movesObject



47
48
49
50
# File 'lib/chess_engine/piece.rb', line 47

def moves
  [[0, 1], [0, -1], [1, 0], [-1, 0],
  [1, 1], [1, -1], [-1, 1], [-1, -1]]
end