Class: Bchess::King
Constant Summary collapse
- KINGS_REACH =
1
Instance Attribute Summary collapse
-
#moved ⇒ Object
readonly
Returns the value of attribute moved.
Attributes inherited from Piece
Instance Method Summary collapse
- #can_move_to_field?(dcolumn, drow) ⇒ Boolean
- #initiialize(*args) ⇒ Object
- #move(dcolumn, drow) ⇒ Object
- #name ⇒ Object
Methods inherited from Piece
#additional_info?, #at?, #black?, #by_diagonal, #by_line, #can_be_promoted?, #can_en_passant?, #can_make_move?, #can_move?, #can_move_or_take?, #can_take?, #can_take_on_field?, #clear_path?, #initialize, #to_s, #valid?, #valid_position_after?, #white?
Methods included from FieldBetweenHelpers
#column_fields, #diagonal_fields, #fields_between, #row_fields
Methods included from BoardHelpers
#castle_detected?, #en_passant_detected?, #field, #invalid_data?, #kings_present?, #pawn_long_move_detected?, #promotion_detected?, #to_column, #to_row
Constructor Details
This class inherits a constructor from Bchess::Piece
Instance Attribute Details
#moved ⇒ Object (readonly)
Returns the value of attribute moved.
5 6 7 |
# File 'lib/bchess/king.rb', line 5 def moved @moved end |
Instance Method Details
#can_move_to_field?(dcolumn, drow) ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/bchess/king.rb', line 21 def can_move_to_field?(dcolumn, drow) super && ( by_line(dcolumn, drow, KINGS_REACH) || by_diagonal(dcolumn, drow, KINGS_REACH) ) end |
#initiialize(*args) ⇒ Object
7 8 9 10 |
# File 'lib/bchess/king.rb', line 7 def initiialize(*args) super(args) @moved = false end |
#move(dcolumn, drow) ⇒ Object
16 17 18 19 |
# File 'lib/bchess/king.rb', line 16 def move(dcolumn, drow) super(dcolumn, drow) @moved = true end |
#name ⇒ Object
12 13 14 |
# File 'lib/bchess/king.rb', line 12 def name 'K' end |