Class: TicTacToe::Human
Instance Attribute Summary
Attributes inherited from Player
Instance Method Summary collapse
Methods inherited from Player
#assign_symbol, create, #initialize
Constructor Details
This class inherits a constructor from TicTacToe::Player
Instance Method Details
#choose_symbol ⇒ Object
3 4 5 |
# File 'lib/tic_tac_toe/human.rb', line 3 def choose_symbol @symbol = Input.symbol(message: "would you like to play as x or o ? (please enter 'x' or 'o')") end |
#get_move(board) ⇒ Object
7 8 9 10 11 |
# File 'lib/tic_tac_toe/human.rb', line 7 def get_move(board) input = Input.board_position(message: "#{@name}: select position in the form x,y where x and y are between 1 and #{board.board_array.size}") m = input.split(",").map { |i| i.to_i - 1 } { x: m.first, y: m.last } end |