Class: Players::Human

Inherits:
Player
  • Object
show all
Defined in:
lib/ttt-cli/players/human.rb

Constant Summary

Constants included from Emoji

Emoji::DASH, Emoji::O, Emoji::X

Instance Attribute Summary

Attributes inherited from Player

#board, #enemy, #name, #token

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Human

Returns a new instance of Human.



5
6
7
8
# File 'lib/ttt-cli/players/human.rb', line 5

def initialize(params)
  super(params)
  @name = 'Human' unless params[:name]
end

Instance Method Details

#make_move(board) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/ttt-cli/players/human.rb', line 10

def make_move(board)
  move = position
  if !board.cell_taken?(move)
    board.fill_cell(move, @token)
  else
    make_move(board)
  end
end