Class: Chess::Knight
- Inherits:
-
BoardgameEngine::Piece
- Object
- BoardgameEngine::Piece
- Chess::Knight
- Defined in:
- lib/boardgame_engine/chess.rb
Instance Attribute Summary
Attributes inherited from BoardgameEngine::Piece
Instance Method Summary collapse
-
#initialize(owner) ⇒ Knight
constructor
A new instance of Knight.
- #valid_move?(start_location, end_location, board) ⇒ Boolean
Methods inherited from BoardgameEngine::Piece
Constructor Details
#initialize(owner) ⇒ Knight
Returns a new instance of Knight.
212 213 214 215 |
# File 'lib/boardgame_engine/chess.rb', line 212 def initialize(owner) # K was already taken by king, so I had to choose N super(owner, 'N') end |
Instance Method Details
#valid_move?(start_location, end_location, board) ⇒ Boolean
217 218 219 220 221 222 223 |
# File 'lib/boardgame_engine/chess.rb', line 217 def valid_move?(start_location, end_location, board) row, col = start_location end_row, end_col = end_location within_movement(row, col, end_row, end_col) \ && not_occupied(end_row, end_col, board) end |