burger_game 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,82 +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
- }
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
82
  ]
data/lib/game_state.rb CHANGED
@@ -1,61 +1,61 @@
1
- require_relative './screen_message'
2
-
3
- class GameState
4
- # Constant variables to hold target money and max reputation for gameplay
5
- TARGET_MONEY = 50.0
6
- MAX_REPUTATION = 10
7
- PAYMENT = 10.0
8
-
9
- def initialize()
10
- @@current_money = 0.0
11
- @@current_reputation = MAX_REPUTATION
12
- @@target_money = TARGET_MONEY
13
- @@max_reputation = MAX_REPUTATION
14
- end
15
-
16
- def set_target_money(cl_target_money)
17
- @@target_money = cl_target_money
18
- end
19
-
20
- def set_max_reputation(cl_max_reputation)
21
- @@max_reputation = cl_max_reputation
22
- @@current_reputation = @@max_reputation
23
- end
24
-
25
- def self.target_money
26
- @@target_money
27
- end
28
-
29
- def self.max_reputation
30
- @@max_reputation
31
- end
32
-
33
- def self.current_money
34
- @@current_money
35
- end
36
-
37
- def self.current_reputation
38
- @@current_reputation
39
- end
40
-
41
- def self.update_money(payment)
42
- @@current_money += payment
43
- end
44
-
45
- def self.update_reputation(reputation)
46
- @@current_reputation += reputation
47
- end
48
-
49
- def display_game_state
50
- state_frame = ScreenMessage.new
51
- spacing = ScreenMessage::SPACING
52
-
53
- game_state = "MONEY / ".rjust((spacing / 2) + 1) + "Goal".ljust(spacing / 2)
54
- game_state += "$#{sprintf('%.2f', @@current_money)} / ".rjust((spacing / 2) + 1) + "$#{sprintf('%.2f', @@target_money)}".ljust(spacing / 2) + "\n\n"
55
- game_state += "+".colorize(:red) * spacing + "\n\n"
56
- game_state += "REPUTATION / ".rjust((spacing / 2) + 1) + "Max Reputation".ljust(spacing / 2)
57
- game_state += "#{@@current_reputation} / ".rjust((spacing / 2) + 1) + "#{@@max_reputation}".ljust(spacing / 2) + "\n\n "
58
-
59
- state_frame.recipe_frame(game_state)
60
- end
1
+ require_relative './screen_message'
2
+
3
+ class GameState
4
+ # Constant variables to hold target money and max reputation for gameplay
5
+ TARGET_MONEY = 50.0
6
+ MAX_REPUTATION = 10
7
+ PAYMENT = 10.0
8
+
9
+ def initialize()
10
+ @@current_money = 0.0
11
+ @@current_reputation = MAX_REPUTATION
12
+ @@target_money = TARGET_MONEY
13
+ @@max_reputation = MAX_REPUTATION
14
+ end
15
+
16
+ def set_target_money(cl_target_money)
17
+ @@target_money = cl_target_money
18
+ end
19
+
20
+ def set_max_reputation(cl_max_reputation)
21
+ @@max_reputation = cl_max_reputation
22
+ @@current_reputation = @@max_reputation
23
+ end
24
+
25
+ def self.target_money
26
+ @@target_money
27
+ end
28
+
29
+ def self.max_reputation
30
+ @@max_reputation
31
+ end
32
+
33
+ def self.current_money
34
+ @@current_money
35
+ end
36
+
37
+ def self.current_reputation
38
+ @@current_reputation
39
+ end
40
+
41
+ def self.update_money(payment)
42
+ @@current_money += payment
43
+ end
44
+
45
+ def self.update_reputation(reputation)
46
+ @@current_reputation += reputation
47
+ end
48
+
49
+ def display_game_state
50
+ state_frame = ScreenMessage.new
51
+ spacing = ScreenMessage::SPACING
52
+
53
+ game_state = "MONEY / ".rjust((spacing / 2) + 1) + "Goal".ljust(spacing / 2)
54
+ game_state += "$#{sprintf('%.2f', @@current_money)} / ".rjust((spacing / 2) + 1) + "$#{sprintf('%.2f', @@target_money)}".ljust(spacing / 2) + "\n\n"
55
+ game_state += "+".colorize(:red) * spacing + "\n\n"
56
+ game_state += "REPUTATION / ".rjust((spacing / 2) + 1) + "Max Reputation".ljust(spacing / 2)
57
+ game_state += "#{@@current_reputation} / ".rjust((spacing / 2) + 1) + "#{@@max_reputation}".ljust(spacing / 2) + "\n\n "
58
+
59
+ state_frame.recipe_frame(game_state)
60
+ end
61
61
  end
data/lib/player_option.rb CHANGED
@@ -1,86 +1,86 @@
1
- # Import Gems
2
- require 'tty-prompt'
3
-
4
- require_relative './recipe'
5
-
6
- class PlayerOption
7
- def initialize
8
- # Create instance of TTY Prompt
9
- @prompt = TTY::Prompt.new
10
- end
11
-
12
- def launch_game
13
- player_response = @prompt.select("Do you want to launch the game?") do |menu|
14
- menu.choice "Launch Game"
15
- menu.choice "Exit"
16
- end
17
-
18
- if player_response == "Launch Game"
19
- true
20
- else
21
- false
22
- end
23
- end
24
-
25
- def start_game
26
- player_response = @prompt.select("What would you like to do?") do |menu|
27
- menu.choice "View 'How to Play'"
28
- menu.choice "Start Game"
29
- end
30
-
31
- if player_response == "Start Game"
32
- true
33
- else
34
- false
35
- end
36
- end
37
-
38
- def get_selection
39
- # Get ingredient names (array of strings)
40
- ingredient_names = []
41
- Recipe.ingredient_lists[0].each do |list|
42
- ingredient_names << list.keys.join
43
- end
44
-
45
- # Remove duplicate last value
46
- ingredient_names.pop
47
-
48
- # Variable to collect user input of item and quntity
49
- player_recipe = []
50
-
51
- # Loop prompt until player done selecting ingredients
52
- loop do
53
- # Loop through ingredients for player to choose
54
- puts
55
- item = @prompt.select("What would you like to add? (stack from bottom up)") do |item|
56
- ingredient_names.each do |ingredient|
57
- item.choice ingredient
58
- end
59
-
60
- # Option to finish selecting
61
- item.choice "Done"
62
- end
63
-
64
- # Exit loop if Done
65
- break if item === "Done"
66
-
67
- # Ask for quantity
68
- puts "How many \"#{item}\"? (Enter 0 to 5)"
69
- # Quantity input validation loop
70
- while quantity = gets.strip do
71
- # Must be a whole number 0 to 5
72
- if (quantity =~ /^[0-5]$/)
73
- break
74
- else
75
- puts "Please enter a number from 0 to 5:"
76
- end
77
- end
78
-
79
- # Collect player's selections
80
- player_recipe << { item => quantity.to_i }
81
- end
82
-
83
- # Array of ingredient-quantity hashes
84
- player_recipe
85
- end
1
+ # Import Gems
2
+ require 'tty-prompt'
3
+
4
+ require_relative './recipe'
5
+
6
+ class PlayerOption
7
+ def initialize
8
+ # Create instance of TTY Prompt
9
+ @prompt = TTY::Prompt.new
10
+ end
11
+
12
+ def launch_game
13
+ player_response = @prompt.select("Do you want to launch the game?") do |menu|
14
+ menu.choice "Launch Game"
15
+ menu.choice "Exit"
16
+ end
17
+
18
+ if player_response == "Launch Game"
19
+ true
20
+ else
21
+ false
22
+ end
23
+ end
24
+
25
+ def start_game
26
+ player_response = @prompt.select("What would you like to do?") do |menu|
27
+ menu.choice "View 'How to Play'"
28
+ menu.choice "Start Game"
29
+ end
30
+
31
+ if player_response == "Start Game"
32
+ true
33
+ else
34
+ false
35
+ end
36
+ end
37
+
38
+ def get_selection
39
+ # Get ingredient names (array of strings)
40
+ ingredient_names = []
41
+ Recipe.ingredient_lists[0].each do |list|
42
+ ingredient_names << list.keys.join
43
+ end
44
+
45
+ # Remove duplicate last value
46
+ ingredient_names.pop
47
+
48
+ # Variable to collect user input of item and quntity
49
+ player_recipe = []
50
+
51
+ # Loop prompt until player done selecting ingredients
52
+ loop do
53
+ # Loop through ingredients for player to choose
54
+ puts
55
+ item = @prompt.select("What would you like to add? (stack from bottom up)") do |item|
56
+ ingredient_names.each do |ingredient|
57
+ item.choice ingredient
58
+ end
59
+
60
+ # Option to finish selecting
61
+ item.choice "Done"
62
+ end
63
+
64
+ # Exit loop if Done
65
+ break if item === "Done"
66
+
67
+ # Ask for quantity
68
+ puts "How many \"#{item}\"? (Enter 0 to 5)"
69
+ # Quantity input validation loop
70
+ while quantity = gets.strip do
71
+ # Must be a whole number 0 to 5
72
+ if (quantity =~ /^[0-5]$/)
73
+ break
74
+ else
75
+ puts "Please enter a number from 0 to 5:"
76
+ end
77
+ end
78
+
79
+ # Collect player's selections
80
+ player_recipe << { item => quantity.to_i }
81
+ end
82
+
83
+ # Array of ingredient-quantity hashes
84
+ player_recipe
85
+ end
86
86
  end