class Checkers::Ruby2D::Piece
Constants
- AI_KING_COLOR
- AI_PIECE_COLOR
- HUMAN_KING_COLOR
- HUMAN_PIECE_COLOR
Attributes
player[RW]
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
# 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
Private Instance Methods
piece_color(piece)
click to toggle source
# File lib/checkers/ruby2d/piece.rb, line 20 def piece_color(piece) if HUMAN_PIECES.include?(piece) piece == HUMAN_PIECE ? HUMAN_PIECE_COLOR : HUMAN_KING_COLOR else piece == AI_PIECE ? AI_PIECE_COLOR : AI_KING_COLOR end end