Sha256: 6e198a9233f0f558b330684dbb05229f3f54af4d535d05e1ceb8c3387b872636
Contents?: true
Size: 1002 Bytes
Versions: 5
Compression:
Stored size: 1002 Bytes
Contents
module AlexCodebreaker class Game include AlexCodebreaker::Modules::ArgumentsValidation attr_reader :secret_code, :session def initialize @secret_code = AlexCodebreaker::SecretCodeGenerator.new.secret_code @secret_code_for_hint = @secret_code.clone.uniq @session = Session.new end def hint return unless @session.check_hints process_hint end def guess(user_input) return unless guess_validation(user_input) && @session.check_attempts compare_codes(user_input) end private def process_hint return @secret_code_for_hint.first if @secret_code_for_hint.one? @secret_code_for_hint.delete(@secret_code_for_hint.sample) end def compare_codes(user_input) user_input = format_user_input(user_input) comparison = Comparison.new(user_input, @secret_code.clone) comparison.response end def format_user_input(user_input) user_input.chars.map(&:to_i) end end end
Version data entries
5 entries across 5 versions & 1 rubygems