Class: TakaTicTacToe::PlayerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/taka_tic_tac_toe/player_factory.rb

Instance Method Summary collapse

Instance Method Details

#create(input) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/taka_tic_tac_toe/player_factory.rb', line 3

def create(input)
  if input[:type] == :computer
    player = Computer.new(input[:mark], input[:opponent_mark])
    player.set_difficulty(input[:difficulty])
  elsif input[:type] == :human
    player = Human.new(input[:mark])
  else
    raise "unknown player type"
  end
  player
end