Sha256: 48886f71a15d4a93cce01884c7900c16ecc1c382dc49b6f0dd2b4babc0d2fa61
Contents?: true
Size: 696 Bytes
Versions: 7
Compression:
Stored size: 696 Bytes
Contents
module Codebreaker class Game include Engine include Score ATTEMPTS = 7 HINT = 1 CODE_SIZE = 4 RANGE = 1..6 attr_accessor :secret_code, :player, :hint, :attempts def initialize(player = Player.new) @secret_code = Array.new(CODE_SIZE) { rand(RANGE) }.join @player = player @hint = HINT @attempts = ATTEMPTS start end def start puts "You have #{@attempts} attempts and #{@hint} hint." check_guess score new_game? ? start : save_score? end private def new_game? puts 'Do you want to start new game?(y/n)' Game.new(@player) if @player.agree? end end end
Version data entries
7 entries across 7 versions & 1 rubygems