forked from AdaGold/word-guess
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Word-Guess - Kiera & Hannah - Octos #23
Open
Krashaune
wants to merge
6
commits into
Ada-C9:master
Choose a base branch
from
Krashaune:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
887a8d0
Initial draft
Krashaune 9f9aac1
Updated guess loop, if statement based on guess and , printed word te…
Krashaune 325ad9c
Updated word template replacement, added balloon art, and check guess…
Krashaune c31daa3
reorganized code, added photo graphic to print, and win lo/lose message
Krashaune d74530e
working program in need of extra support on Classes and instance vari…
Krashaune c5a6330
progress made in attempt to create game class and use instance variables
Krashaune File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
|
||
# class SecretWord | ||
# attr_accessor :word_template, :secret_word | ||
# # generate secret word | ||
# def initialize(word) | ||
# @secret_word = secret_word | ||
# @word_template = word_template | ||
# end | ||
# end | ||
# | ||
# | ||
# class Visual | ||
# # display orginal visual | ||
# def initialize(photo) | ||
# @photo = photo | ||
# end | ||
# | ||
# end | ||
|
||
picture_1 = " | ||
,-‘’’’-. | ||
,' _ `. | ||
' )_) | | ||
: : | ||
| / | ||
: / | ||
`. ,' | ||
`. ,' | ||
`.,' | ||
`. ,-._ | ||
`-' " | ||
|
||
picture_2 = " | ||
,-‘’’’-. ,-‘’’’-. | ||
,' _ `. ,' _ `. | ||
' )_) | ' )_) | | ||
: : : : | ||
| / | / | ||
: / : / | ||
`. ,' `. ,' | ||
`. ,' `. ,' | ||
`.,' `.,' | ||
`. ,-._ `. ,-._ | ||
`-' `-' " | ||
picture_3 = " | ||
,-‘’’’-. ,-‘’’’-. ,-‘’’’-. | ||
,' _ `. ,' _ `. ,' _ `. | ||
' )_) | ' )_) | ' )_) | | ||
: : : : : : | ||
| / | / | / | ||
: / : / : / | ||
`. ,' `. ,' `. ,' | ||
`. ,' `. ,' `. ,' | ||
`.,' `.,' `.,' | ||
`. ,-._ `. ,-._ `. ,-._ | ||
`-' `-' `-' " | ||
|
||
picture_4 = " | ||
,-‘’’’-. ,-‘’’’-. | ||
,' _ `. ,' _ `. | ||
' )_) | ' )_) | | ||
: : : : | ||
| / | / | ||
: / : / | ||
`. ,' `. ,' | ||
`. ,' `. ,' | ||
`.,' `.,' | ||
`. ,-._ `. ,-._ | ||
`-' `-' | ||
|
||
,-‘’’’-. ,-‘’’’-. | ||
,' _ `. ,' _ `. | ||
' )_) | ' )_) | | ||
: : : : | ||
| / | / | ||
: / : / | ||
`. ,' `. ,' | ||
`. ,' `. ,' | ||
`.,' `.,' | ||
`. ,-._ `. ,-._ | ||
`-' `-' " | ||
|
||
|
||
picture_5 = " | ||
,-‘’’’-. ,-‘’’’-. | ||
,' _ `. ,' _ `. | ||
' )_) | ' )_) | | ||
: : : : | ||
| / | / | ||
: / : / | ||
`. ,' `. ,' | ||
`. ,' `. ,' | ||
`.,' `.,' | ||
`. ,-._ `. ,-._ | ||
`-' `-' | ||
,-‘’’’-. ,-‘’’’-. ,-‘’’’-. | ||
,' _ `. ,' _ `. ,' _ `. | ||
' )_) | ' )_) | ' )_) | | ||
: : : : : : | ||
| / | / | / | ||
: / : / : / | ||
`. ,' `. ,' `. ,' | ||
`. ,' `. ,' `. ,' | ||
`.,' `.,' `.,' | ||
`. ,-._ `. ,-._ `. ,-._ | ||
`-' `-' `-' " | ||
|
||
# puts picture_1 | ||
# puts picture_2 | ||
# puts picture_3 | ||
# puts picture_4 | ||
# puts picture_5 | ||
|
||
|
||
|
||
# optional print sentence of number of guesses left | ||
|
||
word_pool = [ | ||
"plant", | ||
"payment", | ||
"flood", | ||
"decide", | ||
"decorate", | ||
"throat", | ||
"vase", | ||
"adventurous", | ||
"rescue", | ||
"purple", | ||
"wistful", | ||
"nice", | ||
"swanky", | ||
"farm", | ||
"unused", | ||
"grieving", | ||
"alert", | ||
"earsplitting", | ||
"legal", | ||
"suggest" | ||
] | ||
|
||
def get_random_word(word_pool) | ||
random_word = word_pool.sample | ||
return random_word | ||
end | ||
|
||
def check_guess(split_word, guess, word_template) | ||
i = 0 | ||
split_word.each do |split_letter| | ||
if split_letter == guess | ||
word_template[i] = guess | ||
end | ||
i += 1 | ||
end | ||
end | ||
|
||
# def check_guess(split_word, guess, word_template) | ||
# index = 0 | ||
# split_word.each do |letter| | ||
# if "#{split_word[letter]}" == guess | ||
# word_template[index] = guess | ||
# end | ||
# index += 1 | ||
# end | ||
# end | ||
|
||
|
||
|
||
# beginning of user interface Welcome user to game | ||
puts "Welcome to K & H Word Guess" | ||
puts "To play the game you will guess our secret word one letter at a time." | ||
puts "You start out with 5 incorrect guess. USE THEM WISELY\n" | ||
puts picture_5 | ||
|
||
random_word = get_random_word(word_pool) | ||
|
||
puts random_word #this is a tester | ||
|
||
# determine length of secret_word | ||
# def create_word_template(random_word) | ||
word_length = random_word.length | ||
word_template = Array.new(word_length, "_" ) | ||
# end | ||
|
||
split_word = random_word.split('') | ||
# display visual and length of word | ||
print word_template | ||
puts "\n\n" | ||
|
||
incorrect_guesses =[] | ||
while incorrect_guesses.length < 5 | ||
puts "Choose a letter" | ||
guess = gets.chomp | ||
|
||
if random_word.include? "#{guess}" | ||
puts "the word contains #{guess}" | ||
check_guess(split_word, guess, word_template) | ||
if word_template.include?("_") == false | ||
puts "Congratulations - you win!!" | ||
exit | ||
end | ||
# *** allow user to win | ||
# — if all letters guessed before max of guess left | ||
# — if user wins print secret word and congratulate | ||
|
||
else | ||
incorrect_guesses << guess | ||
end | ||
# *** reprint visual and incorrect_guesses | ||
wrong_guess_count = incorrect_guesses.length | ||
|
||
# change visual based on incorrect guesses (get smaller, lose a piece, do something) | ||
case wrong_guess_count | ||
when 0 | ||
print picture_5 | ||
when 1 | ||
print picture_4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of this big |
||
when 2 | ||
print picture_3 | ||
when 3 | ||
print picture_2 | ||
when 4 | ||
print picture_1 | ||
when 5 | ||
print "Game Over! The word was #{random_word}!" | ||
exit | ||
end | ||
puts "\n\n" | ||
puts "You have #{(5 - wrong_guess_count)} guess(es) left!" | ||
puts "\n\n" | ||
puts "The word doesn't include: #{incorrect_guesses}" | ||
puts "\n\n" | ||
puts "#{word_template}" | ||
puts "\n\n" | ||
end | ||
# *** allow user to lose | ||
# — if reach max guesses# | ||
# - losing message | ||
# if user loses print answer to secret word | ||
|
||
|
||
|
||
# — ask user if they want to play again and start gameover if yes |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 197,
.include?
will already return a boolean value, so you don't need a separate comparison to false. Either ofwould suffice.