-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.rb
76 lines (60 loc) · 2.15 KB
/
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
require "./dish.rb"
require "./ingredient.rb"
require "./bowl.rb"
require "./display.rb"
class Game
def self.start
bowl = Bowl.new
puts "Let's start building your salad!"
puts "Stage 1: Choose your base ingredients. Type 'done' when finished."
loop do
puts "Available base ingredients: #{bowl.available_ingredients[:base].map(&:name).join(', ')}"
choice = gets.chomp
break if choice.downcase == 'done'
bowl.add_base_ingredient(choice)
end
puts "Stage 2: Choose your protein. Type 'done' when finished."
loop do
puts "Available protein ingredients: #{bowl.available_ingredients[:protein].map(&:name).join(', ')}"
choice = gets.chomp
break if choice.downcase == 'done'
bowl.add_protein_ingredient(choice)
end
puts "Stage 3: Choose your dressing oil. Type 'done' when finished."
loop do
puts "Available dressing oils: #{bowl.available_ingredients[:dressing_oil].map(&:name).join(', ')}"
choice = gets.chomp
break if choice.downcase == 'done'
bowl.add_dressing_oil_ingredient(choice)
end
puts "Stage 4: Choose your dressing acid. Type 'done' when finished."
loop do
puts "Available dressing acids: #{bowl.available_ingredients[:dressing_acid].map(&:name).join(', ')}"
choice = gets.chomp
break if choice.downcase == 'done'
bowl.add_dressing_acid_ingredient(choice)
end
puts "Stage 5: Choose your crunch. Type 'done' when finished."
loop do
puts "Available crunch ingredients: #{bowl.available_ingredients[:crunch].map(&:name).join(', ')}"
choice = gets.chomp
break if choice.downcase == 'done'
bowl.add_crunch_ingredient(choice)
end
Display.show_evaluation(bowl)
end
end
# # Example usage:
Game.start
# bowl = bowl.new
# # Stage 1: Base
# bowl.add_base_ingredient("Lettuce")
# bowl.add_base_ingredient("Spinach")
# # Stage 2: Protein
# bowl.add_protein_ingredient("Grilled Chicken")
# # Stage 3: Dressing
# bowl.add_dressing_oil_ingredient("Olive Oil")
# bowl.add_dressing_acid_ingredient("Lemon Juice")
# # Stage 4: Crunch
# bowl.add_crunch_ingredient("Croutons")
# Display.show_evaluation(bowl)