-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.rb
36 lines (29 loc) · 857 Bytes
/
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
require_relative 'lib/menu'
require_relative 'lib/guesser'
require_relative 'lib/word_picker'
DICTIONARY_PATH = 'dictionaries/sanitized-dictionary.txt'
menu = Menu.new
menu.show_greetings
menu.show_options
menu.clear_screen
puts "Ok, think in a english word, with four letters and without repeated characters"
menu.ask_for_key_to_continue
menu.clear_screen
guesser = Guesser.new(WordPicker.new DICTIONARY_PATH)
word = guesser.get_word
is_correct = menu.say_a_word word
while not is_correct and not word.nil? do
bulls_and_cows = menu.ask_for_bulls_and_cows
menu.clear_screen
word = guesser.get_word(bulls_and_cows)
is_correct = menu.say_a_word word unless word.nil?
end
if word.nil?
new_word = menu.ask_for_a_word
open(DICTIONARY_PATH, 'a') { |f|
f.puts new_word
}
end
menu.clear_screen
menu.show_thanks
menu.ask_for_key_to_continue