Module: Boards::MovablePiece
- Included in:
- Chess::Board
- Defined in:
- lib/boardgame_engine/board_modules.rb
Overview
Boards with movable pieces
Instance Method Summary collapse
-
#move_piece(start_location, end_location, set_start_to: nil) ⇒ Piece
Move a piece from at a start location to an end location.
Instance Method Details
#move_piece(start_location, end_location, set_start_to: nil) ⇒ Piece
Move a piece from at a start location to an end location. Should be called after checking that the movement is valid board and game logic wise.
to nil
253 254 255 256 257 258 259 260 |
# File 'lib/boardgame_engine/board_modules.rb', line 253 def move_piece(start_location, end_location, set_start_to: nil) piece = get_piece_at(start_location) set_piece_at(start_location, set_start_to) destination_piece = get_piece_at(end_location) set_piece_at(end_location, piece) destination_piece end |