lib/game_logic.rb
# check if guessed letter is in word and has not already been guessed
# pushes guess to @guessed arr, modifies guess_state
check if guessed letter is in word and has not already been guessed
pushes guess to @guessed arr, modifies guess_state
check if guessed letter is in word and has not already been guessed pushes guess to @guessed arr modifies guess_state
def check_guess?(guess, word, guess_state, guesses)
    if guesses.include?(guess) 
      repeat_guess(guess)
      return false
    elsif word.include?(guess) 
      word.split('').each_with_index do |letter, i|
        guess_state[i] = letter == guess ? letter : guess_state[i]
      end
      correct_guess
      @guesses.push(guess)
      @cur_guess_status = guess_state
    else 
      incorrect_guess
      @guesses.push(guess)
      @guesses_remaining -= 1
    end
    true
  end
def check_guess? ( guess , word , guess_state , guesses ) if guesses . include? ( guess ) repeat_guess ( guess ) return false elsif word . include? ( guess ) word . split ( '' ) . each_with_index do | letter , i | guess_state [ i ] = letter == guess ? letter : guess_state [ i ] end correct_guess @guesses . push ( guess ) @cur_guess_status = guess_state else incorrect_guess @guesses . push ( guess ) @guesses_remaining -= 1 end true end
check if guessed letter is in word and has not already been guessed
pushes guess to @guessed arr, modifies guess_state
check if guessed letter is in word and has not already been guessed pushes guess to @guessed arr modifies guess_state
# letter has already been guessed # correct guess # incorrect guess
guess
<not_specific>
word
<not_specific>
guess_state
<not_specific>
guesses
<not_specific>