From 670969d09f1b2b0f0df4fec26ef0437d72c67fc9 Mon Sep 17 00:00:00 2001 From: justine Date: Thu, 25 Feb 2016 13:25:20 -0800 Subject: [PATCH 01/18] "Practicing committing. :D" --- word_guess.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 word_guess.rb diff --git a/word_guess.rb b/word_guess.rb new file mode 100644 index 0000000..e69de29 From 95b812aa36c27a106972bee22bea9a3bb3b2ed7a Mon Sep 17 00:00:00 2001 From: Risha Date: Thu, 25 Feb 2016 13:34:38 -0800 Subject: [PATCH 02/18] Added class --- word_guess.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/word_guess.rb b/word_guess.rb index e69de29..6bf7789 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -0,0 +1,2 @@ +class WordGuess +end From 05d9adbe7c925d4d1c393991cf86ab5c92f0e09f Mon Sep 17 00:00:00 2001 From: justine Date: Thu, 25 Feb 2016 14:01:29 -0800 Subject: [PATCH 03/18] Fleshing out our outline. --- word_guess.rb | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/word_guess.rb b/word_guess.rb index 6bf7789..24a860c 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -1,2 +1,40 @@ +# Word Guess 2.25.16 Risha Allen & Justine Winnie + +# Determine what type of ASCII art your team would like to utilize - be creative! +# Think through how you think you should structure your code. Your code should utilize class(es) and methods to keep functionality contained. +# Create a program that will accept one user guess input and print it out in the terminal. +# +# Primary Requirements +# +# Game play +# +# The user should be able to input a single letter at a time. +# Between each guess, the board should be redrawn to the terminal output (Ascii art!). +# Display the letters that have already been guessed before each player guesses a new letter. +# Technical +# +# You should be able to play your game by running it using ruby from the terminal. +# Use Ruby class objects to contain your game logic. You may be able to implement your solution using just one class, but consider how isolating related functionality into separate classes may increase your code's readability and maintainability. + +#Create an array of possible words for the player to guess. Use sample to get one word from array. + +#Print ASCII art and mystery word. + +#Ask player to guess a letter. +#Capture the guess and push to array "letters you've guessed" +#Checks whether letter is in mystery word. + +#If true: +#Print "Got it right!" +#Print mystery word with correct guessed letter inserted. +#Loop back to Guess. + +#Else/if false, print "Wrong!" and remove one section of ASCII art. +#Print "Try again!" +#Loop back to Guess. + + + + class WordGuess -end +end From 8b968cdc153c3287d27b4ebb2d102dd30cc1bae4 Mon Sep 17 00:00:00 2001 From: Risha Date: Thu, 25 Feb 2016 14:21:07 -0800 Subject: [PATCH 04/18] Added instructions for the user about rules of the game. --- word_guess.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/word_guess.rb b/word_guess.rb index 24a860c..3d6c628 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -27,14 +27,36 @@ #If true: #Print "Got it right!" #Print mystery word with correct guessed letter inserted. +# variable current guess. When == mystery, they win! #Loop back to Guess. #Else/if false, print "Wrong!" and remove one section of ASCII art. #Print "Try again!" -#Loop back to Guess. +#Loop back to Guess. +# a method that will print an updated image to the string. that informs of the amount left +# store the art in an array which will be indexed [0].....ect +# syntax: print pie array with index[1] +# a method + +#Reprint the ASCII image, the guessed letters the status of the mystery word +# (create a method) +#When word mystery word is complete +# puts the correct word +# print ASCII art +# puts "you won!" +# exit +#When ASCII art is gone! +# puts "you lost" +# exit class WordGuess + +puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, you will lose a piece of pie." +puts "You must guess the correct word before you run out of pie." + + + end From 515d698f6c3e0f3b132557a7a96126946db84cb8 Mon Sep 17 00:00:00 2001 From: justine Date: Thu, 25 Feb 2016 15:00:42 -0800 Subject: [PATCH 05/18] Made frog. --- word_guess.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/word_guess.rb b/word_guess.rb index 24a860c..3f202f5 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -31,8 +31,28 @@ #Else/if false, print "Wrong!" and remove one section of ASCII art. #Print "Try again!" -#Loop back to Guess. +#Loop back to Guess. + +def froggy + + + @ . . @ + (-------) + ( >___< ) + ^^ ~ ~ ^^ + \\\\\\\/////// + + @ . . @ + (-------) +( >___< ) +^^ ~ ~ ^^ +\\\\\\\/////// + @ . . @ + (-------) + ( >___< ) + ^^ ~ ~ ^^ + \\\\\\\/////// From 7c3c8b29686ffcc098dabdc68f1d006a370dd8ef Mon Sep 17 00:00:00 2001 From: Risha Date: Thu, 25 Feb 2016 16:03:59 -0800 Subject: [PATCH 06/18] completed the image of frog. was able to have frog display to terminal. --- word_guess.rb | 64 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index d1b3326..da86da5 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -38,26 +38,30 @@ # store the art in an array which will be indexed [0].....ect # syntax: print pie array with index[1] -def froggy - - - @ . . @ - (-------) - ( >___< ) - ^^ ~ ~ ^^ - \\\\\\\/////// - - @ . . @ - (-------) -( >___< ) -^^ ~ ~ ^^ -\\\\\\\/////// - - @ . . @ - (-------) - ( >___< ) - ^^ ~ ~ ^^ - \\\\\\\/////// +#def froggy + +# # +# @ . . @ +# (-------) +# ( >___< ) +# ^^ ~ ~ ^^ +# \\\\\\\/////// +# # +# # @ . . @ +# (-------) +# ( >___< ) +# +# +# +# +# ^^ ~ ~ ^^ +# \\\\\\\/////// +# +# @ . . @ +# (-------) +# ( >___< ) +# ^^ ~ ~ ^^ +# \\\\\\\/////// #Reprint the ASCII image, the guessed letters the status of the mystery word # (create a method) @@ -78,6 +82,26 @@ class WordGuess puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, you will lose a piece of pie." puts "You must guess the correct word before you run out of pie." +puts frog1 = " @ . . @ + (-------) + ( >___< ) + ^^ ~ ~ ^^ + \\\\\\\///////" + +puts frog2 = " @ . . @ + (-------) + ( >___< ) + ^^ ~ ~ ^^" + +puts frog3 = " @ . . @ + (-------) + ( >___< )" + +puts frog4 = " @ . . @ + (-------)" + +puts frog5 = " @ . . @" +puts frog6 = " " end From a55f25a7ac19fafc6be9cc7545eda487a7048926 Mon Sep 17 00:00:00 2001 From: justine Date: Thu, 25 Feb 2016 16:24:29 -0800 Subject: [PATCH 07/18] Made frog array. --- word_guess.rb | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index da86da5..aec2b24 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -39,6 +39,7 @@ # syntax: print pie array with index[1] #def froggy +#end # # # @ . . @ @@ -82,26 +83,51 @@ class WordGuess puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, you will lose a piece of pie." puts "You must guess the correct word before you run out of pie." -puts frog1 = " @ . . @ + +frog1 = " @ . . @ + (-------) + ( >___< ) + ^^ ~ ~ ^^ + \\\\\\\/////// + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" + +frog2 = " @ . . @ (-------) ( >___< ) ^^ ~ ~ ^^ - \\\\\\\///////" + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" -puts frog2 = " @ . . @ +frog3 = " @ . . @ (-------) ( >___< ) - ^^ ~ ~ ^^" + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" -puts frog3 = " @ . . @ +frog4 = " @ . . @ (-------) - ( >___< )" + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" + +frog5 = " @ . . @ +~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~" -puts frog4 = " @ . . @ - (-------)" +frog6 = " " -puts frog5 = " @ . . @" +frogarray = [] +frogarray.push(frog1, frog2, frog3, frog4, frog5, frog6) -puts frog6 = " " +frogarray[1] end From 44ddedd550907f860636e5916073a6fd9123e7fc Mon Sep 17 00:00:00 2001 From: Risha Date: Thu, 25 Feb 2016 17:00:01 -0800 Subject: [PATCH 08/18] Worked on the random word array. --- word_guess.rb | 97 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index aec2b24..cd5d619 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -17,8 +17,11 @@ # Use Ruby class objects to contain your game logic. You may be able to implement your solution using just one class, but consider how isolating related functionality into separate classes may increase your code's readability and maintainability. #Create an array of possible words for the player to guess. Use sample to get one word from array. - -#Print ASCII art and mystery word. +# mystery_words = %w(get red kitty nose) +# +# #Print ASCII art and mystery word. +# puts frogarray[0] +# puts mystery_words.sample #Ask player to guess a letter. #Capture the guess and push to array "letters you've guessed" @@ -80,54 +83,72 @@ class WordGuess -puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, you will lose a piece of pie." -puts "You must guess the correct word before you run out of pie." + frog1 = " @ . . @ + (-------) + ( >___< )`` + ^^ ~ ~ ^^ + \\\\\\\/////// + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" + frog2 = " @ . . @ + (-------) + ( >___< ) + ^^ ~ ~ ^^ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" -frog1 = " @ . . @ - (-------) - ( >___< ) - ^^ ~ ~ ^^ - \\\\\\\/////// - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + frog3 = " @ . . @ + (-------) + ( >___< ) + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" -frog2 = " @ . . @ - (-------) - ( >___< ) - ^^ ~ ~ ^^ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + frog4 = " @ . . @ + (-------) + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" -frog3 = " @ . . @ - (-------) - ( >___< ) + frog5 = " @ . . @ + ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" -frog4 = " @ . . @ - (-------) - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + frog6 = " " + + frogarray = [] + frogarray.push(frog1, frog2, frog3, frog4, frog5, frog6) +#Create an array of possible words for the player to guess. Use sample to get one word from array. +mystery_words = %w(get red kitty nose) + +puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, the frog will sink into the water a little more." +puts "You must guess the correct word before the frog is submerged." +puts "Lets get started!" +#Print ASCII art and mystery word. +puts frogarray[0] +# puts mystery_words.sample + + + +# word = mystery_words.sample +puts "nose".split(/./) +# puts split + + -frog5 = " @ . . @ -~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~" +# words_display = [] +# words_display << mystery_words.sample.char +# puts words_display -frog6 = " " -frogarray = [] -frogarray.push(frog1, frog2, frog3, frog4, frog5, frog6) -frogarray[1] end From 6107fcedb0ad2025c0fc7f1a01a7b3d184010f3a Mon Sep 17 00:00:00 2001 From: justine Date: Fri, 26 Feb 2016 10:18:29 -0800 Subject: [PATCH 09/18] Made an array of the letters of the mystery wordgit add word_guess.rb --- word_guess.rb | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index cd5d619..cb4163a 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -134,21 +134,8 @@ class WordGuess puts "Lets get started!" #Print ASCII art and mystery word. puts frogarray[0] -# puts mystery_words.sample - - - -# word = mystery_words.sample -puts "nose".split(/./) -# puts split - - - -# words_display = [] -# words_display << mystery_words.sample.char -# puts words_display - - +words_display = mystery_words.sample.chars +# print words_display end From a39ac46ccbb2f32b8eae0bbff584dff9b57be964 Mon Sep 17 00:00:00 2001 From: Risha Date: Fri, 26 Feb 2016 10:42:44 -0800 Subject: [PATCH 10/18] Created the dashes to correspond with the lettters. And now are working with the frog display. --- word_guess.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/word_guess.rb b/word_guess.rb index cb4163a..a27332a 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -134,8 +134,27 @@ class WordGuess puts "Lets get started!" #Print ASCII art and mystery word. puts frogarray[0] - +# guesses = false +# until guesses == words_display || words_display = mystery_words.sample.chars # print words_display +# replace the letter in mystery word with dashes +n = words_display.length +dashed_word = ("-" * n).chars +p dashed_word + +puts "What letter do you want to guess?" +guessed_letter = gets.chomp +# index where they have guessed +#guessed_letter = [] + +# display for each turn +#wrong_guesses = [] + +if guessed_letter != words_display[0..-1] + puts "No! #{guessed_letter} is wrong" + wrong_guesses.push("#{guessed_letter}") + + frogarray[g +=1] end From f8ee65ddfd491350c194533ef672682890ce3e34 Mon Sep 17 00:00:00 2001 From: justine Date: Fri, 26 Feb 2016 11:03:42 -0800 Subject: [PATCH 11/18] We added an if loop for when the player guesses the wrong letter, all the way up until they lose the game. --- word_guess.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index a27332a..9fbd942 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -149,12 +149,26 @@ class WordGuess #guessed_letter = [] # display for each turn -#wrong_guesses = [] +#wrong guess!!!! if guessed_letter != words_display[0..-1] puts "No! #{guessed_letter} is wrong" + +# store the wrong guess in an array. + wrong_guesses = [] wrong_guesses.push("#{guessed_letter}") - frogarray[g +=1] +# print the frog starting to drown. +g = wrong_guesses.length + puts frogarray[g] + + # uh oh, you lost. + when g == 5 + puts "Sorry, you lost. The frog is totally submerged!" + exit + end +end + + end From 9f9507d67c4438f83cef7a7cff522333100a3271 Mon Sep 17 00:00:00 2001 From: Risha Date: Fri, 26 Feb 2016 12:49:06 -0800 Subject: [PATCH 12/18] this is a resend --- word_guess.rb | 85 ++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index 9fbd942..39643d5 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -129,46 +129,53 @@ class WordGuess #Create an array of possible words for the player to guess. Use sample to get one word from array. mystery_words = %w(get red kitty nose) -puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, the frog will sink into the water a little more." -puts "You must guess the correct word before the frog is submerged." -puts "Lets get started!" -#Print ASCII art and mystery word. -puts frogarray[0] -# guesses = false -# until guesses == words_display || -words_display = mystery_words.sample.chars -# print words_display -# replace the letter in mystery word with dashes -n = words_display.length -dashed_word = ("-" * n).chars -p dashed_word - -puts "What letter do you want to guess?" -guessed_letter = gets.chomp -# index where they have guessed -#guessed_letter = [] - -# display for each turn - -#wrong guess!!!! -if guessed_letter != words_display[0..-1] - puts "No! #{guessed_letter} is wrong" - -# store the wrong guess in an array. - wrong_guesses = [] - wrong_guesses.push("#{guessed_letter}") - -# print the frog starting to drown. -g = wrong_guesses.length - puts frogarray[g] - - # uh oh, you lost. - when g == 5 + puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, the frog will sink into the water a little more." + puts "You must guess the correct word before the frog is submerged." + puts "Lets get started!" + #Print ASCII art and mystery word. + puts frogarray[0] + # guesses = false + # until guesses == words_display || + words_display = mystery_words.sample.chars + # print words_display + # replace the letter in mystery word with dashes + n = words_display.length + dashed_word = ("-" * n).chars + p dashed_word + + puts "What letter do you want to guess?" + guessed_letter = gets.chomp + # index where they have guessed + #guessed_letter = [] + + # display for each turn + # store the wrong guess in an array. + wrong_guesses = [] + + # print the frog starting to drown. + g = wrong_guesses.length + #wrong guess!!!! + while g != 5 + if guessed_letter != words_display[0..-1] + puts "No! #{guessed_letter} is wrong" + + # store the wrong guess in an array. + + wrong_guesses.push("#{guessed_letter}") + + # print the frog starting to drown. + g = wrong_guesses.length + puts frogarray[g] + + elsif guessed_letter == words_display[0..-1] + puts "#{guessed_letter} is one!" + puts frogarray[g] + + # uh oh, you lost. + if g == 5 puts "Sorry, you lost. The frog is totally submerged!" exit + end end -end - - - + end end From 3ba950371fac2fb366634e2c280291d15ff497b1 Mon Sep 17 00:00:00 2001 From: justine Date: Fri, 26 Feb 2016 13:16:34 -0800 Subject: [PATCH 13/18] Started working on outcome for when the guessed letter is correct. --- word_guess.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index 39643d5..7e38ef3 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -155,7 +155,7 @@ class WordGuess # print the frog starting to drown. g = wrong_guesses.length #wrong guess!!!! - while g != 5 + # while g != 5 if guessed_letter != words_display[0..-1] puts "No! #{guessed_letter} is wrong" @@ -164,18 +164,23 @@ class WordGuess wrong_guesses.push("#{guessed_letter}") # print the frog starting to drown. - g = wrong_guesses.length + # g = wrong_guesses.length puts frogarray[g] - elsif guessed_letter == words_display[0..-1] + else guessed_letter == words_display[0..-1] puts "#{guessed_letter} is one!" puts frogarray[g] - + # where is the guessed_letter in words_display + # replace the dash (a string) at that index with guessed_letter + a = words_display.index(guessed_letter) + puts a + + # uh oh, you lost. - if g == 5 - puts "Sorry, you lost. The frog is totally submerged!" - exit - end + # if g == 5 + # puts "Sorry, you lost. The frog is totally submerged!" + # exit + # end end - end + # end end From 32ec91ec1364de24b1ae38d719de2c448a9c17e9 Mon Sep 17 00:00:00 2001 From: Risha Date: Fri, 26 Feb 2016 15:56:55 -0800 Subject: [PATCH 14/18] Starting while loop --- word_guess.rb | 53 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index 7e38ef3..35e5eff 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -150,37 +150,40 @@ class WordGuess # display for each turn # store the wrong guess in an array. - wrong_guesses = [] - - # print the frog starting to drown. - g = wrong_guesses.length - #wrong guess!!!! - # while g != 5 - if guessed_letter != words_display[0..-1] - puts "No! #{guessed_letter} is wrong" - - # store the wrong guess in an array. - - wrong_guesses.push("#{guessed_letter}") - - # print the frog starting to drown. - # g = wrong_guesses.length - puts frogarray[g] - - else guessed_letter == words_display[0..-1] + while words_display != dashed_word + if words_display.include?(guessed_letter) puts "#{guessed_letter} is one!" - puts frogarray[g] + # puts frogarray[g] # where is the guessed_letter in words_display # replace the dash (a string) at that index with guessed_letter a = words_display.index(guessed_letter) - puts a - + # puts a + dashed_word[a] = guessed_letter + + elsif + wrong_guesses = [] + g = wrong_guesses.length + 1 + + puts "No! #{guessed_letter} is wrong" + # store the wrong guess in an array. + wrong_guesses.push("#{guessed_letter}") + # print the frog starting to drown. + # g = wrong_guesses.length + + else + g == 5 + puts "Sorry, you lost. The frog is totally submerged!" + exit + puts frogarray[g] + end + print dashed_word + print wrong_guesses # uh oh, you lost. - # if g == 5 - # puts "Sorry, you lost. The frog is totally submerged!" - # exit + # end - end # end + end + # else + # puts "You win!" end From 358e19ad36b9bc2381bd00872fb041a8bcada0b7 Mon Sep 17 00:00:00 2001 From: Risha Date: Mon, 29 Feb 2016 10:33:19 -0800 Subject: [PATCH 15/18] updated project. --- word_guess.rb | 113 +++++++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 47 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index 35e5eff..ee4657f 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -1,3 +1,5 @@ +require 'pry' +require 'colorize' # Word Guess 2.25.16 Risha Allen & Justine Winnie # Determine what type of ASCII art your team would like to utilize - be creative! @@ -83,23 +85,23 @@ class WordGuess - frog1 = " @ . . @ + frog1 = " @ . . @ (-------) - ( >___< )`` + ( >___< ) ^^ ~ ~ ^^ - \\\\\\\/////// - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + //////\\\\\\\/////// + ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~ ".colorize(:green) - frog2 = " @ . . @ + frog2 = " @ . . @ (-------) ( >___< ) ^^ ~ ~ ^^ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~".colorize(:green) - frog3 = " @ . . @ + frog3 = " @ . . @ (-------) ( >___< ) ~~~~~~~~~~~~~~ @@ -107,7 +109,7 @@ class WordGuess ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" - frog4 = " @ . . @ + frog4 = " @ . . @ (-------) ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ @@ -115,14 +117,19 @@ class WordGuess ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" - frog5 = " @ . . @ + frog5 = " @ . . @ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~" - frog6 = " " + frog6 = " ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~" frogarray = [] frogarray.push(frog1, frog2, frog3, frog4, frog5, frog6) @@ -136,54 +143,66 @@ class WordGuess puts frogarray[0] # guesses = false # until guesses == words_display || + # sample is a method on the array class + # chars is a method on the string class and returns an array of characters words_display = mystery_words.sample.chars # print words_display # replace the letter in mystery word with dashes n = words_display.length - dashed_word = ("-" * n).chars + dashed_word = ("-" * n).chars.to_a p dashed_word - puts "What letter do you want to guess?" - guessed_letter = gets.chomp + # index where they have guessed #guessed_letter = [] - + wrong_guesses = [] # display for each turn - # store the wrong guess in an array. - while words_display != dashed_word + # store the wrong guess in an array + while dashed_word.include?("-") && wrong_guesses.length < 5 + puts "What letter do you want to guess?" + guessed_letter = gets.chomp if words_display.include?(guessed_letter) - puts "#{guessed_letter} is one!" + puts "That is correct!" # puts frogarray[g] # where is the guessed_letter in words_display # replace the dash (a string) at that index with guessed_letter - a = words_display.index(guessed_letter) + # ["r", "e", "d"].index("r") + # => 0 + # a = words_display.index(guessed_letter) # puts a - dashed_word[a] = guessed_letter - - elsif - wrong_guesses = [] - g = wrong_guesses.length + 1 - - puts "No! #{guessed_letter} is wrong" - # store the wrong guess in an array. - wrong_guesses.push("#{guessed_letter}") - # print the frog starting to drown. - # g = wrong_guesses.length - - else - g == 5 - puts "Sorry, you lost. The frog is totally submerged!" - exit - puts frogarray[g] + # a = 0 + # dashed_word[a] = guessed_letter + a = [] + words_display.each_with_index do |val, ind| # this method will keep looping through every thing in the array until gets all + if val == guessed_letter # "r" + a.push(ind) # 0 + end + a.each do |i| + dashed_word[i] = guessed_letter + end + end + # dashed_word.include?(words_display) + # puts "You won!" + + else + puts "No! #{guessed_letter} is wrong\n" + ## if guessed_letter.include?(wrong_guesses.to_s) # this is not working + puts "you have already guessed this letter, please guess again." + # end + wrong_guesses.push("#{guessed_letter}") + # wrong_guesses.length means "how many things in the array" + # print the frog starting to drown. + # checking for + puts frogarray[wrong_guesses.length] end - print dashed_word - print wrong_guesses - - # uh oh, you lost. - - # end - # end + if wrong_guesses.length == 5 + puts "Sorry, you lost. The frog is totally submerged!" + exit + end + p "The mystery word: " + p dashed_word + p "Letters you have guessed so far: " + p wrong_guesses end - # else - # puts "You win!" end + From 33e5b72d0c18d6cad09ed72a8586a33ebf3e3892 Mon Sep 17 00:00:00 2001 From: Risha Date: Mon, 29 Feb 2016 12:06:24 -0800 Subject: [PATCH 16/18] Final product, colorized the frog --- word_guess.rb | 72 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index ee4657f..a76be79 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -88,48 +88,48 @@ class WordGuess frog1 = " @ . . @ (-------) ( >___< ) - ^^ ~ ~ ^^ - //////\\\\\\\/////// + ^^ ~ ~ ^^ ".colorize(:green) + + "\n //////\\\\\\\/////// ~~~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~~~ ".colorize(:green) + ~~~~~~~~~~~~~~~~ ".colorize(:blue) frog2 = " @ . . @ (-------) ( >___< ) - ^^ ~ ~ ^^ + ^^ ~ ~ ^^ ".colorize(:green) + + "\n ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~".colorize(:green) + ~~~~~~~~~~~~~~ ".colorize(:blue) frog3 = " @ . . @ (-------) - ( >___< ) + ( >___< ) ".colorize(:green) + + "\n ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + ~~~~~~~~~~~~~~".colorize(:blue) frog4 = " @ . . @ - (-------) + (-------)".colorize(:green) + + "\n ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + ~~~~~~~~~~~~~~ ".colorize(:blue) - frog5 = " @ . . @ - ~~~~~~~~~~~~~~ + frog5 = " @ . . @".colorize(:green) + + "\n ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + ~~~~~~~~~~~~~~ ".colorize(:blue) frog6 = " ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ - ~~~~~~~~~~~~~~" + ~~~~~~~~~~~~~~ ".colorize(:blue) frogarray = [] frogarray.push(frog1, frog2, frog3, frog4, frog5, frog6) @@ -138,7 +138,7 @@ class WordGuess puts "Welcome to Word Guess.\nYour goal is to guess the correct word.\nEach time you guess a wrong letter not in the mystery word, the frog will sink into the water a little more." puts "You must guess the correct word before the frog is submerged." - puts "Lets get started!" + puts "Let's get started!" #Print ASCII art and mystery word. puts frogarray[0] # guesses = false @@ -163,6 +163,7 @@ class WordGuess guessed_letter = gets.chomp if words_display.include?(guessed_letter) puts "That is correct!" + puts frogarray[wrong_guesses.length] # puts frogarray[g] # where is the guessed_letter in words_display # replace the dash (a string) at that index with guessed_letter @@ -181,28 +182,39 @@ class WordGuess dashed_word[i] = guessed_letter end end + # end # dashed_word.include?(words_display) # puts "You won!" - else - puts "No! #{guessed_letter} is wrong\n" - ## if guessed_letter.include?(wrong_guesses.to_s) # this is not working - puts "you have already guessed this letter, please guess again." + elsif wrong_guesses.include?(guessed_letter) && dashed_word.include?(guessed_letter) # this is not working + puts "You have already guessed this letter, please guess again." + puts frogarray[wrong_guesses.length] # end + else puts "No! #{guessed_letter} is wrong\n" wrong_guesses.push("#{guessed_letter}") - # wrong_guesses.length means "how many things in the array" - # print the frog starting to drown. - # checking for puts frogarray[wrong_guesses.length] end + # wrong_guesses.length means "how many things in the array" + # print the frog starting to drown. + + p "The mystery word: " + p dashed_word + p "Wrong letters you have guessed so far: " + p wrong_guesses + end if wrong_guesses.length == 5 puts "Sorry, you lost. The frog is totally submerged!" exit end - p "The mystery word: " - p dashed_word - p "Letters you have guessed so far: " - p wrong_guesses - end + + if dashed_word.include?("-") == false + puts "You won!" + end + end - + # uh oh, you lost. + # end + # end + # end + # else + # puts "You win!" From 266a22de8edfa537aef8250163f32a59f588fe97 Mon Sep 17 00:00:00 2001 From: justine Date: Mon, 29 Feb 2016 12:35:26 -0800 Subject: [PATCH 17/18] Cleaned up comments a bit. --- word_guess.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index a76be79..666284b 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -182,14 +182,10 @@ class WordGuess dashed_word[i] = guessed_letter end end - # end - # dashed_word.include?(words_display) - # puts "You won!" - elsif wrong_guesses.include?(guessed_letter) && dashed_word.include?(guessed_letter) # this is not working + elsif wrong_guesses.include?(guessed_letter) && dashed_word.include?(guessed_letter) puts "You have already guessed this letter, please guess again." puts frogarray[wrong_guesses.length] - # end else puts "No! #{guessed_letter} is wrong\n" wrong_guesses.push("#{guessed_letter}") puts frogarray[wrong_guesses.length] @@ -212,9 +208,4 @@ class WordGuess end end - # uh oh, you lost. - # end - # end - # end - # else - # puts "You win!" + From 600a4afd7ebe9fe0c468a5bcec1ffcc994404f3c Mon Sep 17 00:00:00 2001 From: justine Date: Mon, 29 Feb 2016 12:37:23 -0800 Subject: [PATCH 18/18] Cleaned up comments a bit. --- word_guess.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/word_guess.rb b/word_guess.rb index 666284b..e1e88fd 100644 --- a/word_guess.rb +++ b/word_guess.rb @@ -198,14 +198,16 @@ class WordGuess p "Wrong letters you have guessed so far: " p wrong_guesses end + + # when you've guessed wrong 5 times, you lose. if wrong_guesses.length == 5 puts "Sorry, you lost. The frog is totally submerged!" exit end - if dashed_word.include?("-") == false - puts "You won!" - end + # or, if there are no more dashes left, you win! + if dashed_word.include?("-") == false + puts "You won!" + end end -