Module: EnPassantHelpers
- Included in:
- Bchess::Board
- Defined in:
- lib/bchess/helpers/en_passant_helpers.rb
Instance Method Summary collapse
- #execute_en_passant(piece, row, column) ⇒ Object
- #long_pawn_move(piece, column, row) ⇒ Object
- #remove_en_passant(piece, column, row) ⇒ Object
- #validate_en_passant(_piece, _column, _row) ⇒ Object
Instance Method Details
#execute_en_passant(piece, row, column) ⇒ Object
7 8 9 10 |
# File 'lib/bchess/helpers/en_passant_helpers.rb', line 7 def execute_en_passant(piece, row, column) piece.move(row, column) remove_old_piece(*remove_en_passant(piece, *transform_field(@en_passant)), piece.color) end |
#long_pawn_move(piece, column, row) ⇒ Object
17 18 19 20 21 |
# File 'lib/bchess/helpers/en_passant_helpers.rb', line 17 def long_pawn_move(piece, column, row) piece.move(column, row) direction = piece.color == Bchess::WHITE ? 1 : -1 @en_passant = field(column, (row + piece.row) / 2 - direction) end |
#remove_en_passant(piece, column, row) ⇒ Object
12 13 14 15 |
# File 'lib/bchess/helpers/en_passant_helpers.rb', line 12 def remove_en_passant(piece, column, row) direction = piece.color == Bchess::WHITE ? 1 : -1 [column, row - direction] end |
#validate_en_passant(_piece, _column, _row) ⇒ Object
2 3 4 5 |
# File 'lib/bchess/helpers/en_passant_helpers.rb', line 2 def validate_en_passant(_piece, _column, _row) # TODO true end |