Class: Checkers::Ruby2D::Piece

Inherits:
Circle
  • Object
show all
Defined in:
lib/checkers/ruby2d/piece.rb

Constant Summary collapse

HUMAN_PIECE_COLOR =
'red'
HUMAN_KING_COLOR =
'maroon'
AI_PIECE_COLOR =
'yellow'
AI_KING_COLOR =
'orange'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Piece

Returns a new instance of Piece.



13
14
15
16
# File 'lib/checkers/ruby2d/piece.rb', line 13

def initialize(opts = {})
  @player = HUMAN_PIECES.include?(opts[:piece]) ? :human : :ai
  super(opts.merge({ color: piece_color(opts[:piece]) }))
end

Instance Attribute Details

#playerObject

Returns the value of attribute player.



11
12
13
# File 'lib/checkers/ruby2d/piece.rb', line 11

def player
  @player
end