Sha256: bdb38ef42f41abdb376cb5901489944a8c282219b78be7023920a8ccb8e18339

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

require_relative 'modules/console'
require_relative 'modules/score'

module Codebreaker
  class ConsoleGame
    include Console
    include Score

    def initialize
      @game = Game.new
    end

    def play
      puts 'You should to break a secret code ****.'
      checking
      @game.score_count
      puts "Your score: #{@game.score}!"
      puts 'Do you want to start new game?(y/n)'
      new_game ? play : save_score
    end

    private
    def checking
      until @game.win?
        @game.check_guess(input_code)
        return @game.check_win if @game.attempts.zero?
      end
    end

    def new_game
      @game = Game.new(@game.score) if agree?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Codebreaker_RG2016-0.2.0 lib/codebreaker/console_game.rb