Class: ChessVwong::Piece
- Inherits:
-
Object
- Object
- ChessVwong::Piece
- Defined in:
- lib/chess_vwong/piece.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#current_space ⇒ Object
Returns the value of attribute current_space.
-
#ep_kill ⇒ Object
Returns the value of attribute ep_kill.
-
#neighbours ⇒ Object
Returns the value of attribute neighbours.
-
#turns ⇒ Object
Returns the value of attribute turns.
Instance Method Summary collapse
- #character ⇒ Object
-
#initialize(current_space, color) ⇒ Piece
constructor
A new instance of Piece.
-
#valid_space?(space) ⇒ Boolean
Ensuring the pieces can’t go off board.
Constructor Details
#initialize(current_space, color) ⇒ Piece
Returns a new instance of Piece.
5 6 7 8 9 10 11 |
# File 'lib/chess_vwong/piece.rb', line 5 def initialize(current_space, color) @current_space = current_space @color = color @turns = 0 @neighbours = [] @ep_kill = [] end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
3 4 5 |
# File 'lib/chess_vwong/piece.rb', line 3 def color @color end |
#current_space ⇒ Object
Returns the value of attribute current_space.
4 5 6 |
# File 'lib/chess_vwong/piece.rb', line 4 def current_space @current_space end |
#ep_kill ⇒ Object
Returns the value of attribute ep_kill.
4 5 6 |
# File 'lib/chess_vwong/piece.rb', line 4 def ep_kill @ep_kill end |
#neighbours ⇒ Object
Returns the value of attribute neighbours.
4 5 6 |
# File 'lib/chess_vwong/piece.rb', line 4 def neighbours @neighbours end |
#turns ⇒ Object
Returns the value of attribute turns.
4 5 6 |
# File 'lib/chess_vwong/piece.rb', line 4 def turns @turns end |
Instance Method Details
#character ⇒ Object
18 19 20 |
# File 'lib/chess_vwong/piece.rb', line 18 def character color end |
#valid_space?(space) ⇒ Boolean
Ensuring the pieces can’t go off board
14 15 16 |
# File 'lib/chess_vwong/piece.rb', line 14 def valid_space?(space) true if space.all? { |coordinate| coordinate >= 1 && coordinate < 9 } end |