Module: InputHandler
- Included in:
- Game
- Defined in:
- lib/capim_tictactoe/input_handler.rb
Instance Method Summary collapse
Instance Method Details
#fetch_human_spot(board, human_marker) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/capim_tictactoe/input_handler.rb', line 6 def fetch_human_spot(board, human_marker) spot = nil loop do spot = gets.chomp spot = validate_input(board, spot) break if spot puts "Please enter a valid integer that corresponds to an empty spot (#{board.available_spots.join(', ')})" end board.grid.spot_marker(spot, human_marker) end |
#parse_args ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/capim_tictactoe/input_handler.rb', line 19 def parse_args @options = { game_mode: :hard, ascii_art: true, jokes: true } OptionParser.new do |opts| opts. = Rainbow('Usage: capim_tictactoe [options], the game will default to challenging mode.').red opts.on('-e', '--easy', 'Runs the game in easy mode.') do @options[:game_mode] = :easy end opts.on('-a', '--noart', 'Runs the game without ASCII art.') do @options[:ascii_art] = false end opts.on('-j', '--nojokes', 'Runs the game without the silly lines.') do @options[:jokes] = false end end.parse! end |