Class: ChessData::Moves::PromotionPawnMove

Inherits:
SimplePawnMove show all
Defined in:
lib/chess_data/moves.rb

Overview

Methods to support a pawn move leading to promotion.

Instance Method Summary collapse

Methods inherited from SimplePawnMove

#to_s

Constructor Details

#initialize(string) ⇒ PromotionPawnMove

Returns a new instance of PromotionPawnMove.



368
369
370
371
372
373
374
# File 'lib/chess_data/moves.rb', line 368

def initialize string
  @move_string = string
  string =~ MatchPromotionPawnMove
  string.split("=")
  @destination = $1
  @piece = $2
end

Instance Method Details

#make_move(board) ⇒ Object

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



377
378
379
380
381
382
# File 'lib/chess_data/moves.rb', line 377

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