burger_game 0.1.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/Gemfile.lock +60 -0
- data/LICENSE +674 -0
- data/bin/start_burger_game +10 -0
- data/burger_game.gemspec +37 -0
- data/lib/burger_game.rb +149 -146
- data/lib/customer_request.json +172 -0
- data/lib/customer_request.rb +9 -2
- data/lib/customer_response.json +82 -0
- data/lib/player_option.rb +3 -3
- data/lib/recipe.json +35 -0
- data/lib/recipe.rb +7 -1
- data/lib/screen_message.rb +52 -20
- data/spec/burger_game_spec.rb +128 -0
- metadata +115 -6
data/lib/customer_request.rb
CHANGED
@@ -5,7 +5,7 @@ class CustomerRequest
|
|
5
5
|
# ERROR HANDLING for reading files
|
6
6
|
begin
|
7
7
|
# Read customer_request.JSON file
|
8
|
-
customer_file = File.read('./lib/
|
8
|
+
customer_file = File.read('./lib/customer_request.json')
|
9
9
|
rescue Errno::ENOENT => e
|
10
10
|
puts "Could not find customer_request.json file. Please put customer_request.json in the 'data' directory."
|
11
11
|
puts e.message
|
@@ -18,7 +18,7 @@ class CustomerRequest
|
|
18
18
|
|
19
19
|
begin
|
20
20
|
# Read customer_response.JSON file
|
21
|
-
response_file = File.read('./lib/
|
21
|
+
response_file = File.read('./lib/customer_response.json')
|
22
22
|
rescue Errno::ENOENT => e
|
23
23
|
puts "Could not find customer_response.json file. Please put customer_response.json in the 'data' directory."
|
24
24
|
puts e.message
|
@@ -34,11 +34,13 @@ class CustomerRequest
|
|
34
34
|
@@customer_responses = JSON.parse(response_file)
|
35
35
|
|
36
36
|
# Collect customer names (array of strings)
|
37
|
+
# and number of customers
|
37
38
|
# and customer recipe names request (array of strings)
|
38
39
|
# and customer ingredient changes (array of hashes)
|
39
40
|
# and customer requests text (array of strings)
|
40
41
|
# and customer preferences text (array of strings)
|
41
42
|
@@customer_names = []
|
43
|
+
@@no_of_customer = 0
|
42
44
|
@@customer_recipe_names = []
|
43
45
|
@@customer_ingredient_changes = []
|
44
46
|
@@customer_requests_text = []
|
@@ -52,6 +54,7 @@ class CustomerRequest
|
|
52
54
|
@@customer_preferences_text << request[2].values.join
|
53
55
|
end
|
54
56
|
end
|
57
|
+
@@no_of_customer = @@customer_names.length
|
55
58
|
|
56
59
|
# Collect customer responses (array of arrays of hashes)
|
57
60
|
@@responses = []
|
@@ -62,6 +65,10 @@ class CustomerRequest
|
|
62
65
|
def initialize
|
63
66
|
end
|
64
67
|
|
68
|
+
def self.no_of_customer
|
69
|
+
@@no_of_customer
|
70
|
+
end
|
71
|
+
|
65
72
|
def get_request(customer_no)
|
66
73
|
# Get all original recipes for base recipes (array of hashes)
|
67
74
|
base_recipes = Recipe.all_recipes
|
@@ -0,0 +1,82 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
" A Customer ":
|
4
|
+
{
|
5
|
+
"happy": "*Customer seems happy*\nOh what a lovely burger you gave me!\nThank you!",
|
6
|
+
"neutral": "You sure you don't miss a thing or two in this burger...?",
|
7
|
+
"angry": "*Customer is angry*\nHey, I don't think I ordered this...\n*Customer pushes the burger back to you*"
|
8
|
+
}
|
9
|
+
},
|
10
|
+
{
|
11
|
+
" Captain Australia ":
|
12
|
+
{
|
13
|
+
"happy": "*Customer seems happy*\nWOW! That's one bloody awesome burger!\nBetter than Maccas for sure! Ta!",
|
14
|
+
"neutral": "Hey mate, you sure this burger is mine..?\n*Captain thinks you are being dodgy...*",
|
15
|
+
"angry": "*Customer is angry*\n... Are you sure YOU want ME to PAY for THIS..?\n*Captain is flexing his muscle while looking directly into your soul...*"
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{
|
19
|
+
" John Citizen ":
|
20
|
+
{
|
21
|
+
"happy": "*Customer seems happy*\nWonderful! Now, this is what you call a burger-to-die-for!",
|
22
|
+
"neutral": "Excuse me, this burger seems unsophisticated to me...",
|
23
|
+
"angry": "*Customer is angry*\nHorrible!! I hope you close down!"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
{
|
27
|
+
" Jane Citizen ":
|
28
|
+
{
|
29
|
+
"happy": "*Customer seems happy*\nWoo-hoo! This burger will give me strength to face John tomorrow!",
|
30
|
+
"neutral": "Ermm... This burger looks wrong..?\nBut I already gave half of it to John...",
|
31
|
+
"angry": "*Customer is angry*\nNoooo... Why are you being mean?\nYou are not John... *Jane covers her face and walks away*"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
" Scott Morris ":
|
36
|
+
{
|
37
|
+
"happy": "*Customer seems happy*\nOh wow, you made a delicously-hand-stacked burger!\nLet me shake your hands!",
|
38
|
+
"neutral": "I thought this burger was mine...\nBut, it looks like it belongs to someone else..?",
|
39
|
+
"angry": "*Customer is angry*\nStop it! Just! Stop! It!\nThis is ridiculous! This is un-Australian!"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
" The Mighty Princess ":
|
44
|
+
{
|
45
|
+
"happy": "*Customer seems happy*\nAww.. You've done well, my dear law abiding citizen.\nHere, claim your reward! *throws you a gold bullion*",
|
46
|
+
"neutral": "Is this what they call a burger..?\nOr, is it just me being too entitled..?\n*The Mighty Princess looks confused*",
|
47
|
+
"angry": "*Customer is angry*\nYOU! *gestures angrily* I'm the Princess! You do what I say!\n*The Mighty Princess starts climbing the counter top...*"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
" Donald T. ":
|
52
|
+
{
|
53
|
+
"happy": "*Customer seems happy*\nYou did it! You are now a member of my fans club!\nHere, take my money!",
|
54
|
+
"neutral": "Meh, I could build a better burger shop in this area.\n*Donald T. shrugs his shoulders*",
|
55
|
+
"angry": "*Customer is angry*\nWHAT IS THIS! I'm going to build a wall here.\nAnd, YOU are going to pay for it!"
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
" Mickey M. ":
|
60
|
+
{
|
61
|
+
"happy": "*Customer seems happy*\nOh boy! This is nice! Thank you, burger shop owner!\n*Mickey M. leaves a signature on the counter top*",
|
62
|
+
"neutral": "Hmm... I think this burger is not what I'm after...\n*Mickey M. shakes his head. He looks confused*",
|
63
|
+
"angry": "*Customer is angry*\nOoh... I'm glad I didn't ask my wife to try this burger!\nAnd, no! I don't know Donald T.! *Mickey M. tries to look angry*"
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
" Unicorn ":
|
68
|
+
{
|
69
|
+
"happy": "*Customer seems happy*\nYay! A burger for me! Thank you!\nI'm going to paint a rainbow for you!",
|
70
|
+
"neutral": "Eh? This doesn't look like my order..?\n*Unicorn's rainbow looks fading*",
|
71
|
+
"angry": "*Customer is angry*\nEeeekk!\n*Unicorn dashes out of the store crying out rainbow tears*"
|
72
|
+
}
|
73
|
+
},
|
74
|
+
{
|
75
|
+
" A Robot ":
|
76
|
+
{
|
77
|
+
"happy": "*Customer seems happy*\nBeep... Good... You restore my faith in humanity...\n*Robot pays in bitcoins*",
|
78
|
+
"neutral": "Oily.. Beep... No likey... Beep..",
|
79
|
+
"angry": "*Customer is angry*\nBEEE-EEP! BEEEEEEE-EEP! EEEEEEPPPP!\n*Robot malfunctions and grows into a giant robot*"
|
80
|
+
}
|
81
|
+
}
|
82
|
+
]
|
data/lib/player_option.rb
CHANGED
@@ -9,7 +9,7 @@ class PlayerOption
|
|
9
9
|
@prompt = TTY::Prompt.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def launch_game
|
13
13
|
player_response = @prompt.select("Do you want to launch the game?") do |menu|
|
14
14
|
menu.choice "Launch Game"
|
15
15
|
menu.choice "Exit"
|
@@ -22,7 +22,7 @@ class PlayerOption
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def start_game
|
26
26
|
player_response = @prompt.select("What would you like to do?") do |menu|
|
27
27
|
menu.choice "View 'How to Play'"
|
28
28
|
menu.choice "Start Game"
|
@@ -35,7 +35,7 @@ class PlayerOption
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def get_selection
|
39
39
|
# Get ingredient names (array of strings)
|
40
40
|
ingredient_names = []
|
41
41
|
Recipe.ingredient_lists[0].each do |list|
|
data/lib/recipe.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"Normal Burger":
|
4
|
+
[
|
5
|
+
{"Bun": 1},
|
6
|
+
{"Tomato Sauce": 1},
|
7
|
+
{"Lettuce": 1},
|
8
|
+
{"Grilled Chicken": 1},
|
9
|
+
{"Cheese": 1},
|
10
|
+
{"Bun": 1}
|
11
|
+
]
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"Healthy Burger":
|
15
|
+
[
|
16
|
+
{"Bun": 1},
|
17
|
+
{"Cheese": 1},
|
18
|
+
{"Tomato Sauce": 1},
|
19
|
+
{"Grilled Chicken": 2},
|
20
|
+
{"Lettuce": 3},
|
21
|
+
{"Bun": 1}
|
22
|
+
]
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"Questionable Burger":
|
26
|
+
[
|
27
|
+
{"Bun": 1},
|
28
|
+
{"Cheese": 3},
|
29
|
+
{"Tomato Sauce": 4},
|
30
|
+
{"Grilled Chicken": 4},
|
31
|
+
{"Lettuce": 2},
|
32
|
+
{"Bun": 1}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
]
|
data/lib/recipe.rb
CHANGED
@@ -8,7 +8,7 @@ class Recipe
|
|
8
8
|
# ERROR HANDLING for reading files
|
9
9
|
begin
|
10
10
|
# Read recipe.JSON file
|
11
|
-
file = File.read('./lib/
|
11
|
+
file = File.read('./lib/recipe.json')
|
12
12
|
rescue Errno::ENOENT => e
|
13
13
|
puts "Could not find recipe.json file. Please put recipe.json in the 'data' directory."
|
14
14
|
puts e.message
|
@@ -25,6 +25,7 @@ class Recipe
|
|
25
25
|
# Collect recipe names (array of strings)
|
26
26
|
# and ingredient lists (array of arrays of hashes)
|
27
27
|
@@recipe_names = []
|
28
|
+
@@no_of_recipe = 0
|
28
29
|
@@ingredient_lists = []
|
29
30
|
@@all_recipes.each do |recipe|
|
30
31
|
@@recipe_names << recipe.keys[0]
|
@@ -32,6 +33,7 @@ class Recipe
|
|
32
33
|
@@ingredient_lists << list
|
33
34
|
end
|
34
35
|
end
|
36
|
+
@@no_of_recipe = @@recipe_names.length
|
35
37
|
|
36
38
|
def initialize
|
37
39
|
end
|
@@ -44,6 +46,10 @@ class Recipe
|
|
44
46
|
@@recipe_names
|
45
47
|
end
|
46
48
|
|
49
|
+
def self.no_of_recipe
|
50
|
+
@@no_of_recipe
|
51
|
+
end
|
52
|
+
|
47
53
|
def self.ingredient_lists
|
48
54
|
@@ingredient_lists
|
49
55
|
end
|
data/lib/screen_message.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Import Gems
|
2
2
|
require 'tty-box'
|
3
|
-
require 'tty-screen'
|
4
3
|
require 'tty-prompt'
|
4
|
+
require 'artii'
|
5
5
|
|
6
6
|
class ScreenMessage
|
7
7
|
# Constant variable for display formatting space
|
@@ -22,18 +22,11 @@ class ScreenMessage
|
|
22
22
|
msg = "You have entered an invalid value #{input}\nPlease enter the value in a valid format. Use -h or --help to view Help menu.\n"
|
23
23
|
end
|
24
24
|
|
25
|
-
def go_to_next
|
26
|
-
# Create instance of TTY Prompt
|
27
|
-
prompt = TTY::Prompt.new
|
28
|
-
|
29
|
-
prompt.select("Press enter to continue.", %w(Next))
|
30
|
-
end
|
31
|
-
|
32
25
|
# Method for displaying message frame
|
33
26
|
def msg_frame(title, msg, height = 10)
|
34
27
|
msg_box = TTY::Box.frame({
|
35
28
|
enable_color: true, # force to always color output
|
36
|
-
width:
|
29
|
+
width: 80,
|
37
30
|
height: height,
|
38
31
|
align: :center,
|
39
32
|
padding: 3,
|
@@ -73,9 +66,15 @@ class ScreenMessage
|
|
73
66
|
end
|
74
67
|
|
75
68
|
def display_welcome
|
69
|
+
# Create instance of Artii
|
70
|
+
artii = Artii::Base.new
|
76
71
|
title = " WELCOME "
|
77
|
-
msg = "Hello there... Welcome to
|
78
|
-
|
72
|
+
msg = "Hello there... Welcome to" + "\n\n"
|
73
|
+
msg += artii.asciify('Burger Game') + "\n\n"
|
74
|
+
msg += "We are going to build burgers for customers." + "\n"
|
75
|
+
msg += "Clear your mind, put on your best smile..." + "\n"
|
76
|
+
msg += "And... we're ready to stack 'em burgers!"
|
77
|
+
height = 24
|
79
78
|
|
80
79
|
# Format output using frame
|
81
80
|
msg_frame(title, msg, height)
|
@@ -83,8 +82,12 @@ class ScreenMessage
|
|
83
82
|
|
84
83
|
def display_instructions
|
85
84
|
title = " HOW TO PLAY "
|
86
|
-
msg = "Instructions:\n\n1. When shop's Menu is displayed, memorise burger names, ingredients and quantity needed, and ingredients stack order
|
87
|
-
|
85
|
+
msg = "Instructions:\n\n1. When shop's Menu is displayed, memorise \"burger names\", \"ingredients\" and \"quantity\" needed, and ingredients \"stack order\"." + "\n\n"
|
86
|
+
msg += "2. Customer's request will consists of the \"name of the burger\", and custom \"preferences\", such as 'no sauce' or 'extra 1 patty'." + "\n\n"
|
87
|
+
msg += "3. Select ingredient and quantity needed in order, from \"bottom\" of the stack \"to the top\". Enter \"0\" for requests that ask to leave some ingredients out because we need to keep the correct order of the stack." + "\n\n"
|
88
|
+
msg += "4. When you build the burger perfectly as per customer request, the happy customer will increase your reputation by 1 point and pay $10 for the burger. Otherwise, if you miss a thing or two, but still acceptable, the pay would be halved but no reputation points given. If you fail to make a decent burger for the customer, the angry customer will not pay and they will take 1 point off your reputation." + "\n\n"
|
89
|
+
msg += "5. Keep enough customers happy and earn money to meet the target (You Win). Be careful not to make too many customers angry and let your reputation get to 0 (Game Over)."
|
90
|
+
height = 32
|
88
91
|
|
89
92
|
# Format output using frame
|
90
93
|
msg_frame(title, msg, height)
|
@@ -92,8 +95,14 @@ class ScreenMessage
|
|
92
95
|
|
93
96
|
def display_prologue
|
94
97
|
title = " PROLOGUE "
|
95
|
-
msg = "Ruby Burger is dedicated in fulfilling the ever growing customers' demand of customised and personalised burgers.\n
|
96
|
-
|
98
|
+
msg = "Ruby Burger is dedicated in fulfilling the ever growing customers' demand of customised and personalised burgers.\n"
|
99
|
+
msg += "Our job is to build a burger following our shop's Menu recipes, while adjusting into different customers' preferences.\n"
|
100
|
+
msg += "In the next scene, we will memorise our Menu and recipes." + "\n\n"
|
101
|
+
msg += "Hint:\n"
|
102
|
+
msg += "Memorise \"burger names\", \"ingredients\" and \"quantity\" needed, and ingredients \"stack order\".\n"
|
103
|
+
msg += "Build burger from \"bottom up\". Select ingredients from the bottom of the stack to the top as seen in the recipes.\n"
|
104
|
+
msg += "Enter \"0\" for requests that ask to leave some ingredients to keep the correct order of the stack."
|
105
|
+
height = 22
|
97
106
|
|
98
107
|
# Format output using frame
|
99
108
|
msg_frame(title, msg, height)
|
@@ -115,10 +124,12 @@ class ScreenMessage
|
|
115
124
|
msg += " \\ ````` / | |" + "\n"
|
116
125
|
msg += " |``--........--'`| '.______.'" + "\n"
|
117
126
|
msg += "\\ / " + "\n"
|
118
|
-
msg += "jgs `'----------'` " + "\n\n"
|
127
|
+
msg += "jgs `'----------'` " + "\n\n\n"
|
119
128
|
|
120
|
-
msg += "-- all ASCII artwork copyrighted ©1996-01 --
|
121
|
-
msg += "
|
129
|
+
msg += "-- all ASCII artwork copyrighted ©1996-01 --" + "\n"
|
130
|
+
msg += "Joan G. Stark" + "\n"
|
131
|
+
msg += "-- All Rights Reserved --" + "\n\n"
|
132
|
+
msg += "\n~ END ~"
|
122
133
|
|
123
134
|
height = 35
|
124
135
|
|
@@ -127,13 +138,34 @@ class ScreenMessage
|
|
127
138
|
end
|
128
139
|
|
129
140
|
def display_game_over
|
141
|
+
# Create instance of Artii
|
142
|
+
artii = Artii::Base.new
|
130
143
|
title = " GAME OVER "
|
131
|
-
msg =
|
144
|
+
msg = artii.asciify('GAME OVER') + "\n\n"
|
145
|
+
msg += "Oh no! Everyone is leaving because you didn't stack the right burgers!" + "\n\n"
|
146
|
+
msg += "Owning a burger shop, especially a Ruby one, is tough.\n"
|
147
|
+
msg += "You need to practice hard (or just use the handicap ARGV in command line, read the instruction in the installation/usage guide in README.md).\n\nDon't give up! You can always try again next time!" + "\n\n"
|
132
148
|
msg += "You are lucky this is just a game..."
|
133
149
|
msg += "\n\n\n~ END ~"
|
134
|
-
height =
|
150
|
+
height = 30
|
135
151
|
|
136
152
|
# Format output using frame
|
137
153
|
msg_frame(title, msg, height)
|
138
154
|
end
|
155
|
+
|
156
|
+
def go_to_next
|
157
|
+
# Create instance of TTY Prompt
|
158
|
+
prompt = TTY::Prompt.new
|
159
|
+
|
160
|
+
input = prompt.select("Do you want to continue?") do |menu|
|
161
|
+
menu.choice "Next"
|
162
|
+
menu.choice "Exit"
|
163
|
+
end
|
164
|
+
|
165
|
+
if input == "Exit"
|
166
|
+
exit
|
167
|
+
else
|
168
|
+
input
|
169
|
+
end
|
170
|
+
end
|
139
171
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require_relative '../lib/burger_game'
|
2
|
+
require_relative '../lib/screen_message'
|
3
|
+
require_relative '../lib/recipe'
|
4
|
+
require_relative '../lib/player_option'
|
5
|
+
require_relative '../lib/customer_request'
|
6
|
+
require_relative '../lib/score_comparison'
|
7
|
+
require_relative '../lib/game_state'
|
8
|
+
|
9
|
+
# Test case for Feature 1
|
10
|
+
# and for MAIN FEATURES: Feature 7
|
11
|
+
describe ScreenMessage do
|
12
|
+
# This block runs before each test case defined in 'it' block
|
13
|
+
before(:each) do
|
14
|
+
@screen_message = ScreenMessage.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it "check if display_welcome is defined" do
|
18
|
+
expect(@screen_message.display_welcome.class).to eq(String)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "check if display_instructions is defined" do
|
22
|
+
expect(@screen_message.display_instructions.class).to eq(String)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "check if display_prologue is defined" do
|
26
|
+
expect(@screen_message.display_prologue.class).to eq(String)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "check if display_win is defined" do
|
30
|
+
expect(@screen_message.display_win.class).to eq(String)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "check if display_win is defined" do
|
34
|
+
expect(@screen_message.display_game_over.class).to eq(String)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Test case for Feature 2
|
39
|
+
describe Recipe do
|
40
|
+
it "should display the recipe" do
|
41
|
+
recipe = Recipe.new
|
42
|
+
recipe_no = 1
|
43
|
+
expect(recipe.display_recipe(recipe_no).class).to eq(String)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Test case for Feature 3
|
48
|
+
# and for Feature 6
|
49
|
+
describe CustomerRequest do
|
50
|
+
# This block runs before each test case defined in 'it' block
|
51
|
+
before(:each) do
|
52
|
+
@customer = CustomerRequest.new
|
53
|
+
@customer_no = 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should display customer request" do
|
57
|
+
expect(@customer.display_request(@customer_no).class).to eq(String)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should display customer response" do
|
61
|
+
mood = "angry"
|
62
|
+
expect(@customer.display_response(@customer_no, mood).class).to eq(String)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Test case for MAIN FEATURES: Feature 4
|
67
|
+
describe PlayerOption do
|
68
|
+
# This block runs before each test case defined in 'it' block
|
69
|
+
before(:each) do
|
70
|
+
@player_selections = PlayerOption.new
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should launch the game" do
|
74
|
+
expect(@player_selections.launch_game.class).to be(TrueClass) | be(FalseClass)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should start the game" do
|
78
|
+
expect(@player_selections.start_game.class).to be(TrueClass) | be(FalseClass)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should get player's options" do
|
82
|
+
expect(@player_selections.get_selection.class).to eq(Array)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Test case for MAIN FEATURES: Feature 5
|
87
|
+
describe ScoreComparison do
|
88
|
+
# This block runs before each test case defined in 'it' block
|
89
|
+
before(:each) do
|
90
|
+
player_recipe = [{ "Bun" => 1 }, { "Lettuce" => 2}, { "Grilled Chicken" => 2 }, { "Tomato Sauce" => 4 }, { "Cheese" => 3 }]
|
91
|
+
customer_no = 1
|
92
|
+
customer = CustomerRequest.new
|
93
|
+
@compare = ScoreComparison.new(player_recipe, customer.get_request(customer_no))
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should calculate score for player input and customer request comparison" do
|
97
|
+
expect(@compare.get_score).to be(4)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should get correct customer mood" do
|
101
|
+
expect(@compare.get_mood(@compare.get_score)).to eq("neutral")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe GameState do
|
106
|
+
# This block runs before each test case defined in 'it' block
|
107
|
+
before(:each) do
|
108
|
+
player_recipe = [{ "Bun" => 1 }, { "Lettuce" => 2 }, { "Grilled Chicken" => 2 }, { "Tomato Sauce" => 4 }, { "Cheese" => 3 }]
|
109
|
+
customer_no = 1
|
110
|
+
customer = CustomerRequest.new
|
111
|
+
@compare = ScoreComparison.new(player_recipe, customer.get_request(customer_no))
|
112
|
+
@game_state = GameState.new
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should get correct current money amount" do
|
116
|
+
score = @compare.get_score
|
117
|
+
mood = @compare.get_mood(score)
|
118
|
+
expect(@compare.calculate_state(mood)[0]).to be(5.0)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should get correct current reputation points" do
|
122
|
+
expect(@compare.calculate_state(@compare.get_mood(@compare.get_score))[1]).to be(10)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should display game state" do
|
126
|
+
expect(@game_state.display_game_state.class).to eq(String)
|
127
|
+
end
|
128
|
+
end
|