burger_game 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +10 -10
- data/Gemfile.lock +60 -60
- data/LICENSE +674 -674
- data/bin/start_burger_game +10 -10
- data/burger_game.gemspec +37 -37
- data/lib/burger_game.rb +198 -198
- data/lib/customer_request.json +171 -171
- data/lib/customer_request.rb +131 -131
- data/lib/customer_response.json +81 -81
- data/lib/game_state.rb +60 -60
- data/lib/player_option.rb +85 -85
- data/lib/recipe.json +34 -34
- data/lib/recipe.rb +73 -73
- data/lib/score_comparison.rb +66 -66
- data/lib/screen_message.rb +170 -170
- data/spec/burger_game_spec.rb +127 -127
- metadata +2 -2
data/spec/burger_game_spec.rb
CHANGED
@@ -1,128 +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
|
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
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: burger_game
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jessica Gozali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|