lib/modules/game.rb in codebreaker_karolina-0.1.7 vs lib/modules/game.rb in codebreaker_karolina-0.1.8

- old
+ new

@@ -11,12 +11,10 @@ @secret_code = generate_code.freeze @hint = @secret_code.chars.uniq end def compare_code(guess) - return unless valid_code?(guess) - comparison_result(@secret_code.chars, guess.chars) end def win?(guess) @user.used_attempts += 1 @@ -36,14 +34,14 @@ @user.used_hints += 1 @hint.shuffle!.pop end - private - def valid_code?(code) !!code[/\A[1-6]{4}\z/] end + + private def generate_code Array.new(CODE_SIZE) { rand(NUM_RANGE) }.join end