Class: TTT::Interface::CLI::HumanPlayer
- Inherits:
-
Player
- Object
- Player
- TTT::Interface::CLI::HumanPlayer
show all
- Defined in:
- lib/ttt/interface/cli/players.rb
Instance Attribute Summary
Attributes inherited from Player
#cli, #game, #marker
Instance Method Summary
collapse
Methods inherited from Player
#initialize
Instance Method Details
#available_moves_regex ⇒ Object
47
48
49
50
|
# File 'lib/ttt/interface/cli/players.rb', line 47
def available_moves_regex
moves = game.available_moves
/^[#{moves.join}]$/
end
|
#list_available_moves ⇒ Object
43
44
45
|
# File 'lib/ttt/interface/cli/players.rb', line 43
def list_available_moves
game.available_moves.join(', ')
end
|
#take_turn ⇒ Object
36
37
38
39
40
41
|
# File 'lib/ttt/interface/cli/players.rb', line 36
def take_turn
fileout.puts "The nine squares consecutively map to a number. "\
"Topleft starts at 1, topright continues with 3, and bottomright ends with 9."
move = prompt "Where would you like to move? (#{list_available_moves}) ", :validate => available_moves_regex
game.mark move.to_i
end
|