forked from Ada-C10/adagrams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wave-4-game.rb
78 lines (56 loc) · 1.66 KB
/
wave-4-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
66
67
68
69
70
71
72
73
74
75
76
77
78
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 your submission for the longest anagram you can come up with"
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_highest_score(high_score_hash)
puts "Thanks for playing Adagrams!"
puts "The highest score from this game was #{high_score_hash[:word]}, which was worth #{high_score_hash[:score]} points"
end
def display_goodbye_message
puts "Goodbye!"
end
def get_user_input
gets.chomp
end
def run_game
played_words = []
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
score = score_word(user_input_word)
played_words << user_input_word
display_score(score)
display_retry_instructions
should_continue = get_user_input == "y"
end
display_highest_score(highest_score_from(played_words))
display_goodbye_message
end
run_game