Sha256: 45a194c7164e46c56db577a73216deb77b38d591b8fdaf58e05e41c1a8cda96f
Contents?: true
Size: 834 Bytes
Versions: 2
Compression:
Stored size: 834 Bytes
Contents
require "./lib/edlvj_codebreaker.rb" module Codebreaker class Console def initialize @game = Game.new end def play p @game.stat puts "You have #{Game::ATTEMPS} attemps and #{Game::HINT} hint. Enter 'hint' for get hint. And 'exit' for exit from a game." until @game.loose? case code = gets.chomp when 'hint' puts "The hint is #{ @game.get_hint }" when 'exit' exit when /^[1-6]{4}$/ puts @game.match_guess(code) end break if @game.win? end save @game = Game.new if try_again? play end def try_again? puts 'Do you want try again?(y/n)' gets.chomp == 'y' ? true : exit end def save puts 'Enter your name:' user_name = gets.chomp @game.save_stat( user_name ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
edlvj_codebreaker-0.3.2 | lib/console.rb |
edlvj_codebreaker-0.3.1 | lib/console.rb |