Module: Chess::Pieces::BishopMoves
Overview
BishopMoves
Instance Method Summary collapse
- #north_east_moves(board, file, rank) ⇒ Object
- #north_west_moves(board, file, rank) ⇒ Object
- #south_east_moves(board, file, rank) ⇒ Object
- #south_west_moves(board, file, rank) ⇒ Object
Instance Method Details
#north_east_moves(board, file, rank) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/chess/pieces/bishop.rb', line 33 def north_east_moves(board, file, rank) north_east = board.north_east_pos(file, rank) moves = [] while board.empty_at?(*north_east) moves << north_east if board.pos_in_range?(north_east) north_east = board.north_east_pos(*north_east) end moves << north_east if board.pos_in_range?(north_east) && board.enemy_at?(*north_east) moves end |
#north_west_moves(board, file, rank) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/chess/pieces/bishop.rb', line 9 def north_west_moves(board, file, rank) north_west = board.north_west_pos(file, rank) moves = [] while board.empty_at?(*north_west) moves << north_west if board.pos_in_range?(north_west) north_west = board.north_west_pos(*north_west) end moves << north_west if board.pos_in_range?(north_west) && board.enemy_at?(*north_west) moves end |
#south_east_moves(board, file, rank) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chess/pieces/bishop.rb', line 45 def south_east_moves(board, file, rank) south_east = board.south_east_pos(file, rank) moves = [] while board.empty_at?(*south_east) moves << south_east if board.pos_in_range?(south_east) south_east = board.south_east_pos(*south_east) end moves << south_east if board.pos_in_range?(south_east) && board.enemy_at?(*south_east) moves end |
#south_west_moves(board, file, rank) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chess/pieces/bishop.rb', line 21 def south_west_moves(board, file, rank) south_west = board.south_west_pos(file, rank) moves = [] while board.empty_at?(*south_west) moves << south_west if board.pos_in_range?(south_west) south_west = board.south_west_pos(*south_west) end moves << south_west if board.pos_in_range?(south_west) && board.enemy_at?(*south_west) moves end |