Class: HumanPlayer
- Inherits:
-
Object
- Object
- HumanPlayer
- Defined in:
- lib/ttt_malisa/human_player.rb
Instance Attribute Summary collapse
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
Instance Method Summary collapse
-
#initialize(mark, board, display) ⇒ HumanPlayer
constructor
A new instance of HumanPlayer.
- #move ⇒ Object
Constructor Details
#initialize(mark, board, display) ⇒ HumanPlayer
Returns a new instance of HumanPlayer.
4 5 6 7 8 |
# File 'lib/ttt_malisa/human_player.rb', line 4 def initialize(mark, board, display) @board = board @display = display @mark = mark end |
Instance Attribute Details
#mark ⇒ Object (readonly)
Returns the value of attribute mark.
2 3 4 |
# File 'lib/ttt_malisa/human_player.rb', line 2 def mark @mark end |
Instance Method Details
#move ⇒ Object
10 11 12 13 14 |
# File 'lib/ttt_malisa/human_player.rb', line 10 def move @display.(@mark) index = @display.retrieve_user_input.to_i - 1 @board.valid_move?(index) ? @board.mark(index, @mark) : move end |