<commit_before>module StCodebreaker
  class Interface
    def initialize
      @game = Game.new
    end

    def greeting
      print "
      Welcome to codebreaker game.
      Here you must to guess the 4 digit code, wich numbers is from 1 to 6
      Commands:
        1 - start
        2 - statistics
        3 - exit
      "
      print '-> '
      case gets.chomp
      when '1' then play
      when '2' then show_stats
      when '3' then print 'exit'
      else print 'Incorrect input'
      end
    end

    def save_stats
      puts 'Input your name: '
      name = $stdin.gets.chomp
      @game.save(name)
      play_again
    end

    def play
      while @game.attempts > 0
        puts "You have #{@game.attempts} tries. Type 'h' for hint"
        print 'Your guess: '
        case guess = gets.chomp
        when 'h' then puts @game.hint
        else
          result = @game.compare(guess)
          puts result
          if result == '++++'
            save_stats
            break
          end
        end
      end
      play_again if @game.attempts.zero?
    end

    def read_stats
      File.read('stats.txt')
    end

    def play_again
      puts 'Play again? [y/n]'
      @game = Game.new
      gets.chomp == 'y' ? play : exit
    end

    def show_stats
      puts read_stats
      greeting
    end
  end
end<commit_msg>minor fixes<commit_after>module StCodebreaker
  class Interface
    def initialize
      @game = Game.new
    end

    def greeting
      print "
      Welcome to codebreaker game.
      Here you must to guess the 4 digit code, wich numbers is from 1 to 6
      Commands:
        1 - start
        2 - statistics
        3 - exit
      "
      print '-> '
      case gets.chomp
      when '1' then play
      when '2' then show_stats
      when '3' then exit
      else print 'Incorrect input'
      end
    end

    def save_stats
      puts 'Input your name: '
      name = $stdin.gets.chomp
      @game.save(name)
      play_again
    end

    def play
      while @game.attempts > 0
        puts "You have #{@game.attempts} tries. Type 'h' for hint"
        print 'Your guess: '
        case guess = gets.chomp
        when 'h' then puts @game.hint
        else
          result = @game.compare(guess)
          puts result
          if result == '++++'
            save_stats
            break
          end
        end
      end
      play_again if @game.attempts.zero?
    end

    def read_stats
      File.read('../../stats.txt')
    end

    def play_again
      puts 'Play again? [y/n]'
      @game = Game.new
      gets.chomp == 'y' ? play : exit
    end

    def show_stats
      puts read_stats
      greeting
    end
  end
end
{'fraction_non_alphanumeric': 0.0766939687267312, 'fraction_numerical': 0.007446016381236039, 'mean_word_length': 1.4810710987996307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3198924', 'n_tokens_mistral': 844, 'n_tokens_neox': 817, 'n_words': 275}