Class: HumanPlayer
- Inherits:
-
Object
- Object
- HumanPlayer
- Defined in:
- lib/players/human_player.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
writeonly
Sets the attribute board.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Instance Method Summary collapse
-
#initialize(color) ⇒ HumanPlayer
constructor
A new instance of HumanPlayer.
- #make_move ⇒ Object
Constructor Details
#initialize(color) ⇒ HumanPlayer
Returns a new instance of HumanPlayer.
5 6 7 |
# File 'lib/players/human_player.rb', line 5 def initialize(color) @color = color end |
Instance Attribute Details
#board=(value) ⇒ Object (writeonly)
Sets the attribute board
3 4 5 |
# File 'lib/players/human_player.rb', line 3 def board=(value) @board = value end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
2 3 4 |
# File 'lib/players/human_player.rb', line 2 def color @color end |
Instance Method Details
#make_move ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/players/human_player.rb', line 9 def make_move # puts "Enter your move" # i1, i2 = gets.chomp.split # raise BadInputError if i2.nil? i1 = @board.move_cursor i2 = @board.move_cursor [i1, i2] end |