Class: ChessData::Moves::PromotionPawnCapture

Inherits:
PawnCapture
  • Object
show all
Defined in:
lib/chess_data/moves.rb

Overview

Methods to support a pawn move which is both a capture and a promotion.

Instance Method Summary collapse

Constructor Details

#initialize(move) ⇒ PromotionPawnCapture

Returns a new instance of PromotionPawnCapture.



436
437
438
439
440
441
442
# File 'lib/chess_data/moves.rb', line 436

def initialize move
  @move_string = move
  move =~ MatchPromotionPawnCapture
  @source = $1
  @destination = $2
  @piece = $3
end

Instance Method Details

#make_move(board) ⇒ Object

Returns a new instance of the board after move is made.



449
450
451
452
453
454
# File 'lib/chess_data/moves.rb', line 449

def make_move board
  @piece.downcase! if board.to_move == "b"
  revised_board = super board
  revised_board[@destination] = @piece
  return revised_board
end

#to_sObject



444
445
446
# File 'lib/chess_data/moves.rb', line 444

def to_s
  @move_string
end