Class: JbcdenTtt::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/jbcden_ttt/player.rb

Defined Under Namespace

Classes: InvalidCharacterError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ Player

Returns a new instance of Player.



9
10
11
12
13
14
15
# File 'lib/jbcden_ttt/player.rb', line 9

def initialize(symbol)
  if symbol == "x" || symbol == "o"
    @symbol = symbol
  else
    raise InvalidCharacterError
  end
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol.



8
9
10
# File 'lib/jbcden_ttt/player.rb', line 8

def symbol
  @symbol
end

Instance Method Details

#human?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/jbcden_ttt/player.rb', line 22

def human?
  true
end

#make_move(board, coordinate) ⇒ Object



17
18
19
20
# File 'lib/jbcden_ttt/player.rb', line 17

def make_move(board, coordinate)
  tile = BoardMapper.map_string(board, coordinate)
  tile.mark(symbol)
end