forked from Ada-C14/adagrams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wave-2-game.rb
65 lines (47 loc) · 1.29 KB
/
wave-2-game.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require_relative 'lib/adagrams'
def display_welcome_message
puts "Welcome to Adagrams!"
end
def display_drawn_letters(letters)
puts "You have drawn the letters:"
puts letters.join(', ')
end
def display_game_instructions
puts "Please input a word that only uses the letters from the letter bank"
end
def display_needs_valid_input_message
puts "You entered in a word that contains characters not in the letter bank"
display_game_instructions
end
def display_score(score)
puts "Your submitted anagram scored #{score} points"
end
def display_retry_instructions
puts "Should we play another round?"
puts "Enter y to replay"
end
def display_goodbye_message
puts "Thanks for playing Adagrams!"
end
def get_user_input
gets.chomp
end
def run_game
display_welcome_message
should_continue = true
while should_continue
puts "Let's draw 10 letters from the letter pool..."
letter_bank = draw_letters
display_drawn_letters(letter_bank)
display_game_instructions
user_input_word = get_user_input
while ( !(uses_available_letters?(user_input_word, letter_bank)) )
display_needs_valid_input_message
user_input_word = get_user_input
end
display_retry_instructions
should_continue = get_user_input == "y"
end
display_goodbye_message
end
run_game