-
-
Save 121watts/861eec0cd3df213060a4 to your computer and use it in GitHub Desktop.
execute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def execute | |
until (user_input == "q") || (@position_match == 4) | |
print "enter your guess ~> " | |
@user_input = gets.chomp.downcase | |
validator = GuessValidator.new(@user_input) | |
@turns += 1 | |
@turns_left -= 1 | |
if validator.correct_length? == false || validator.correct_letters? == false | |
puts 'Your guess must be a length of FOUR and' | |
puts "be of these colors #{'(r)ed'.red}, #{'(y)ellow'.yellow}, #{'(g)reen'.green}, #{'(b)lue'.blue}" | |
else | |
matcher = PatternMatcher.new(@user_input, @secret_pattern) | |
matcher.content_match | |
matcher.position_match | |
@content_match = matcher.output[:correct_content] | |
@position_match = matcher.output[:correct_position] | |
puts "You have #{@content_match} content matches and #{@position_match} position matches" | |
puts "You have taken #{@turns} turn(s)" | |
puts "#{@turns_left} turn(s) left!" | |
if @position_match == 4 | |
timer | |
end | |
if @turns_left == 0 | |
puts "You LOOOOOOSE Muahahahah!" | |
end | |
end | |
end | |
puts "Thanks for playing MASTERmind" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment