Sha256: 6f90ef16fab972a874630b228e69fbbe0e2a371694477b5e9c4abae457d1dfda

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

module Codebreaker
  module Console
    def input
      gets.chomp
    end

    def agree?
      input =~ /^(yes|y)$/i ? true : false
    end

    def input_name
      print 'Please, enter your name: '
      input
    end

    def input_code
      puts "You have #{@game.attempts} attempts and #{@game.hint} hint."
      print 'Type your secret code or "hint": '
      player_code = input
      if  player_code.size == Codebreaker::Game::CODE_SIZE ||
          player_code      == 'hint'
        player_code
      else
        puts 'You should type 4 numbers in code or "hint"!!!'
        input_code
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Codebreaker_RG2016-0.2.0 lib/codebreaker/modules/console.rb