burger_game 1.0.3 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05baef14f9fdefed6aed8fc8cfe38e484f0c15b7d0739d982bb4f39fd1ded774
4
- data.tar.gz: 0d5eb2c019edab1f15a2048fa0837a773cac711d45f1723d884fce654aad5333
3
+ metadata.gz: f9d711569adebde4fbd1ae27a861cb160378b45658f375a5fbdded774ad289a4
4
+ data.tar.gz: dcba13dc529790b559b5ca546929b31bedacf7f8ec9ea5ce35b73c26e6691280
5
5
  SHA512:
6
- metadata.gz: 2537a953f3d897effdced5cafb72e4572f70f78880fb167d0387db7512bd25bef031fb31cc25e82408bfb7df4b8721c31fcc14c06788ace6a8569b1db94fe073
7
- data.tar.gz: 4286d65a31cc90608c5077e04226cac032cbbd26dd835c659254e707caa097dba4e7e44993ebf109d3a2a6498bd56ee4900b52086feac763a26a7710134c790d
6
+ metadata.gz: e3d467517cc36dedf39ab549d58f1b0b8857815d705e1dc988f767449dea1d53cd0d6173ab85ed7196d0a65a7d6b2c1e1dcc30bb5e97a5a581aa0bedf2a70bf4
7
+ data.tar.gz: cea4ab9615652a2e80606d57b2eed9a87530c828f64e8048306c84a647779b557a1f3ff0e5c027714c386a3a9aa9cf11dc7a325e11c4333dfca97263e6c79a09
data/README.md ADDED
@@ -0,0 +1,662 @@
1
+ # Software Development Plan: Burger Game
2
+
3
+ >
4
+ > GitHub repository link: [https://github.com/petitejess/burger_game.git](https://github.com/petitejess/burger_game.git)
5
+ >
6
+ >
7
+ > RubyGems repository link: [https://rubygems.org/gems/burger_game](https://rubygems.org/gems/burger_game)
8
+ >
9
+
10
+  
11
+
12
+ <!-- TABLE OF CONTENTS -->
13
+ <details open="open">
14
+ <summary>Table of Contents</summary>
15
+ <ol>
16
+ <li>
17
+ <a href="#purpose">Purpose</a>
18
+ <ul>
19
+ <li><a href="#what-it-does">What It Does</a></li>
20
+ <li><a href="#problems-and-solutions">Problems and Solutions</a></li>
21
+ <li><a href="#target-audience">Target Audience</a></li>
22
+ <li><a href="#how-they-use-it">How They Use It</a></li>
23
+ </ul>
24
+ </li>
25
+ <li>
26
+ <a href="#features">Features</a>
27
+ <ul>
28
+ <li><a href="#main-features">Main Features</a></li>
29
+ <li><a href="#supporting-features">Supporting Features</a></li>
30
+ </ul>
31
+ </li>
32
+ <li>
33
+ <a href="#user-interface-and-user-experience">User Interface and User Experience</a>
34
+ <ul>
35
+ <li><a href="#how-users-find-features">How Users Find Features</a></li>
36
+ <li><a href="#how-users-use-features">How Users Use Features</a></li>
37
+ <li><a href="#how-errors-handled-and-displayed">How Errors Handled and Displayed</a></li>
38
+ </ul>
39
+ </li>
40
+ <li>
41
+ <a href="#flowchart-diagram">Flowchart Diagram</a>
42
+ </li>
43
+ <li>
44
+ <a href="#implementation-plan">Implementation Plan</a>
45
+ <ul>
46
+ <li><a href="#trello-summary">Trello Summary</a></li>
47
+ <li><a href="#trello-screenshots">Trello Screenshots</a></li>
48
+ </ul>
49
+ </li>
50
+ <li>
51
+ <a href="#installation-and-usage">Installation and Usage</a>
52
+ <ul>
53
+ <li><a href="#prerequisites">Prerequisites</a></li>
54
+ <li><a href="#ruby-gem-installation-and-usage">Ruby Gem (Installation and Usage)</a></li>
55
+ <li><a href="#bash-script-installation-and-usage">Bash Script (Installation and Usage)</a></li>
56
+ <li><a href="#dependencies">Dependencies</a></li>
57
+ </ul>
58
+ </li>
59
+ <li><a href="#acknowledgements">Acknowledgements</a></li>
60
+ </ol>
61
+ </details>
62
+
63
+ &nbsp;
64
+
65
+ ## Purpose
66
+
67
+ This text-based Ruby terminal game app demonstrates the level of understanding of terminal applications, programming fundamentals, such as variables (and their scope), iteration/conditional control structures, methods, objects, classes, error handling, etc. It also demonstrates the level of understanding of algorithm, Object-Oriented Programming (OOP) principles (encapsulation, abstraction, inheritance, and polymorphism) and Test Driven Development (TDD) approach.
68
+
69
+ ### What It Does
70
+
71
+ This simple text-based Ruby *terminal game app*, simulates a burger shop, where you need to build the meal for the customers with different requests and preferences.
72
+
73
+ Players would find themselves as the owner of a Ruby burger shop and they will have to memorise their menu. First, they want to identify the burger name with the ingredients, and the quantity needed for each ingredient. Next, they want to memorise the stack order of the burger, as they will need to build the burger stack from bottom up. When customers show up, they will give an order and state their preferences. Players would need to add or reduce the quantity that the customers have preferred and build the burger.
74
+
75
+ The winning condition is when players reach the target *money* goal, and the losing condition is when the shop’s *reputation* drops to 0 (zero).
76
+
77
+ ### Problems and Solutions
78
+
79
+ This app is developed for entertainment purpose in a form of a mini perception and memory test game. It also helps people to learn to pay attention to small details, such as when customers are expressing their preferences in a form of a sentence.
80
+
81
+ On the developer's perspective, this app provides an exercise on programming fundamentals, OOP concepts and TDD process using Ruby programming language and RSpec as the tool.
82
+
83
+ ### Target Audience
84
+
85
+ The gameplay offered by this app is suitable for people who like memory/puzzle games or text-based terminal games. The game only requires basic Math (addition and subtraction) and basic English command knowledge.
86
+
87
+ This game could provide entertainment for people who likes role-playing, where they might be curious of what the customers’ responses be when they are either happy, neutral, or angry.
88
+
89
+ ### How They Use It
90
+
91
+ For people who likes memory/puzzle games, this might be a challenge as they would need to memorise quite a lot of things. They would also need to interpret a short and sometimes indirect instruction of what is expected for the result. A basic addition or subtraction is involved to solve each problem.
92
+
93
+ For people who likes role-playing games, they may find it somewhat interesting. Each customer in the game has different responses for each different mood (happy, neutral, angry). That may encourage people to intentionally make the customers angry just to see the responses.
94
+
95
+ &nbsp;
96
+
97
+ ---
98
+
99
+ &nbsp;
100
+
101
+ ## Features
102
+
103
+ This app consists of a total of seven features that can be separated into two categories, Main Features and Supporting Features. Basically, the Main Features have the bare minimum things that make this app works and the Supporting Features adds functionalities to increase user experience.
104
+
105
+ ### Main Features
106
+
107
+ #### 1. Selectable options (ingredient list) and text input validation
108
+
109
+ Users are given selectable options for list of ingredients to choose from, so no manual ingredient name typing is necessary. **TTY Prompt** gem is used to handle the selection input and formatting. Users will only have to move arrow key up and down, and press Enter key to select one of the available options.
110
+
111
+ ![Ingredient options using TTY Prompt](../docs/images/player-options.jpg "Selectable options.")
112
+
113
+ Input for ingredient quantity is of the number data type (integer) within a pre-set range of 0 to 5. Regex validation using *while conditional* statement is used to handle input, to prompt user input again if it does not pass validation.
114
+
115
+ ![Quantity prompt with validation](../docs/images/player-qty-input-validation.jpg "Text input for quantity.")
116
+
117
+ #### 2. Score Calculation
118
+
119
+ Score in the game is calculated based on comparison between user input and expected solution for each problem (customer’s request and preference). One (1) point is added to the score for every ingredient correctly selected with correct quantity entered in the correct order.
120
+
121
+ ![User input compared with expected result, calculating score](../docs/images/main-feature-2.jpg "Score calculation based on player's input compared wtih customer's request.")
122
+
123
+ Score calculations are done in a method within a class and are made by looping through user input which is an array of hashes, using *each with index loop* comparing a set of ingredient-quantity from user with the set of expected ingredient-quantity requested in an orderly manner.
124
+
125
+ The total score is stored in an *instance variable* where it would then be checked again using nested *if-elsif-else conditional* statement in another method in the same class to get the correct the mood, which also stored in an *instance variable*. The mood is used in another method in the same class going through another nested *if-elsif-else conditional* statement to manipulate winning/losing criteria calculation.
126
+
127
+ #### 3. Winning and Losing Conditions
128
+
129
+ The total score is used to get customer’s mood, to display appropriate text response. The mood is used again to update current money and rep status.
130
+
131
+ ![Score calculation towards mood, money and reputation, and win/lose condition](../docs/images/main-feature-3.jpg "Calculation flow to determine winning and losing state.")
132
+
133
+ There are two conditions that control the game’s flow of winning and losing. Users win the game if the current money reaches the target money. Users lose the game if current shop's reputation gets to 0.
134
+
135
+ These two values are stored in *class variables* in GameState class. The calculation from the previous feature (Score Calculation) counts toward these class variables. The *if conditional* control flow is used to handle the output of winning or losing scene. **TTY Box** gem is used to format the output on the screen, and **Artii** gem is used to style Game Over text message.
136
+
137
+ ### Supporting Features
138
+
139
+ #### 1. Options to View Instructions or Start Game
140
+
141
+ Users will have the options to view instructions of how to play the game or to start the game.
142
+
143
+ ![Instructions and Prologue message boxes](../docs/images/supporting-feature-1.jpg "How to Play option and Start Game option.")
144
+
145
+ A *loop do-end* is used to bring users back to home screen after they finish reading the instructions. The *if conditional* statement, based on users’ input (from option selections), is used to break out of the loop to continue the game if user input chooses Start Game. **TTY Box** gem is used to format the message output on the screen.
146
+
147
+ #### 2. Shop’s Menu Display
148
+
149
+ The menu consists of several recipes that are stored as JavaScript Object Notation (JSON) format in a file. **JSON** gem is used to parse the file into Ruby data structure. Nested *each loop* is used to go through each data structures to get the values.
150
+
151
+ Error handling is used to rescue error while reading the JSON file. The error is handled using *begin-rescue-end* block, for error from not finding the file in destination, as well as standard error.
152
+
153
+ **TTY Box** and **Colorize** gems are used to add styling to the output, adding box and coloured accent to the recipe display printed to the screen. The *loop-do-end* is used to print all recipes on the screen.
154
+
155
+ ![Recipe title, divider, ingredient list alignment](../docs/images/supporting-feature-2.jpg "Recipe display.")
156
+
157
+ Each recipe displayed inside a box, with the name of the burger (title) on the first line, separated by a divider (***), followed by ingredient-quantity listed line per line.
158
+
159
+ #### 3. Randomised Customers
160
+
161
+ To make the app a little bit more interesting, a random element is brought to the game play. Instead of going through the array of customer data sets in an orderly manner, customers’ data are pulled randomly using `rand()` method.
162
+
163
+ ![method rand() used to generate random number n to get customer n request data from JSON file](../docs/images/supporting-feature-3.jpg "Flow of displaying randomised customer request.")
164
+
165
+ A randomised number (within length of the array of customer data sets) is generated, then used to call the data set for customer with the said index in the customer array. Then the appropriate customer’s request is displayed. Also, after score calculation, the customer’s response is given based on the mood (happy, neutral, or angry), controlled by *if conditional* statement.
166
+
167
+ #### 4. Customer Response Display
168
+
169
+ Each customer has different responses for each mood. There are *happy*, *neutral*, and *angry* types of mood and each has different text response. All these requests and responses are stored as JavaScript Object Notation (JSON) format.
170
+
171
+ ![Sample of customer's responses for happy, neutral, and angry mood](../docs/images/supporting-feature-4.jpg "Various customer's responses.")
172
+
173
+ The app reads the file and parse the content to serve the correct text request or response belonging to each customer for the correct type of mood. The **JSON** gem is used to parse the data into Ruby data structure and nested *each* loop used to go through the array of hashes. Then, **TTY Box** is used to format the output on the screen.
174
+
175
+ Error handling is used to rescue error while reading the JSON file. The error is handled using *begin-rescue-end* block, for error from not finding the file in destination, as well as standard error.
176
+
177
+ &nbsp;
178
+
179
+ ---
180
+
181
+ &nbsp;
182
+
183
+ ## User Interface and User Experience
184
+
185
+ This section will explain a narrative of how users will find out how to use each feature, use those features, and how errors are handled by the app and displayed to users.
186
+
187
+ ### How Users Find Features
188
+
189
+ Users will be able to find out the available options that can be used for command line arguments from the usage information in the README.md file in the app root directory.
190
+
191
+ After installing and running the app, once users choose to launch the game, after viewing prologue message, users will be able to find the features starting from *start menu options*.
192
+
193
+ Once users choose to start the game, they will find the *shop's menu display* feature. All the available recipes in the shop's menu will be displayed to users.
194
+
195
+ After that, users will find the *randomised customer* feature, where they will see a request message from a random customer.
196
+
197
+ Next, users will find the *selectable options and text input validation* feature through input prompt of ingredients list and input prompt for ingredient quantity.
198
+
199
+ Users will then find the *score calculation* feature as the app compares the collection of their inputs with the expected result.
200
+
201
+ After the app calculates the score, users will be able to find the *customer response display* feature, where a response message is given accordingly.
202
+
203
+ Users will be able to find the last feature, *winning and losing conditions*, when they make progress through the game and game state is changed.
204
+
205
+
206
+ ### How Users Use Features
207
+
208
+ Users use the command line arguments to set custom values for target money and maximum reputation to make the game easier or hard.
209
+
210
+ The *start menu options* feature provides two options, where users can choose to view the instructions of how to play the game or to start the game.
211
+
212
+ The *shop's menu display* feature displays each recipe in a neat format for users to easily glance the recipe to memorise the details.
213
+
214
+ Users get a random customer request from *randomised customer* feature each time.
215
+
216
+ Users enter input for ingredient name and quantity using the *selectable options and text input validation* feature. They can select ingredient using up/down arrow keys and enter quantity with numbers between 0-5. If they enter a value other than whole number 0 to 5 for the quantity, they will be prompted again.
217
+
218
+ Users use the *score calculation* feature to get the customer's mood that is used to display appropriate customer's response.
219
+
220
+ Users use *customer response display* feature to find out if the customer is happy (score is perfect), neutral (score is within threshold), or (score is bad) angry.
221
+
222
+ Users use the *winning and losing conditions* feature to reach the end of the game. The game can finally end when users meet on the conditions, when current money reaches target money (Win) or when current reputation gets to 0 (Game Over).
223
+
224
+ ### How Errors Handled and Displayed
225
+
226
+ #### Error Handling for Command Line Argument
227
+
228
+ Error handling for command line argument is handled by the *begin-rescue-end* block that would rescue invalid option, missing argument, parse error, and other errors.
229
+
230
+ As per installation and usage information, upon running the app, users will have the options to raise or lower the bar for winning and losing criteria using the command line argument(s). This can be done by entering the desired option(s) and value(s) through command line when running the app. Complete information can be found in Installation and Usage section in README.md document or by opening the Help menu for this app in command line using option `-h` or `--help`.
231
+
232
+ Errors from command line argument parsing within the app are handled by the below block of rescue code:
233
+
234
+ ![Error handling code snippet](../docs/images/error-handling-cl-argument.jpg "Error handling for command line argument parsing.")
235
+
236
+ Custom error messages are given, followed by the message from the instance of the exception.
237
+
238
+ #### Error Handling for File Not Found
239
+
240
+ Error handling for reading JSON files is handled by the *begin-rescue-end* block that would rescue file not found error and other errors.
241
+
242
+ ![Error handling code snippet](../docs/images/error-handling-recipe-file.jpg "Error handling for reading recipe JSON file.")
243
+
244
+ ![Error handling code snippet](../docs/images/error-handling-customer-file.jpg "Error handling for reading customer JSON files.")
245
+
246
+ Custom error messages are given, followed by the message from the instance of the exception.
247
+
248
+ &nbsp;
249
+
250
+ ---
251
+
252
+ &nbsp;
253
+
254
+ ## Flowchart Diagram
255
+
256
+ ![Burger Game Flowchart](../docs/burger_game_flowchart.jpg "Flowchart showing the logic flow of the app.")
257
+
258
+ &nbsp;
259
+
260
+ ---
261
+
262
+ &nbsp;
263
+
264
+ ## Implementation Plan
265
+
266
+ Trello project management tool was used to manage the app development.
267
+
268
+ >
269
+ > Trello board link: https://trello.com/b/wPtcTui7
270
+ >
271
+
272
+ ### Trello Summary
273
+
274
+ Initial plan showed that features were separated between three main features (in Main Features list) and four supporting features (in Backlog list).
275
+
276
+ ![List of Backlog and list of Main Features](../docs/images/trello-cropped-00.jpg "Initial plan on Trello board.")
277
+
278
+ &nbsp;
279
+
280
+ #### Feature 1: Options to see instructions or to start the game
281
+
282
+ *(Due Date: 19 May 2021 17:00)*
283
+
284
+ Description: When players run the app, they will be greeted with a welcome message on home screen where they have 2 options to choose from:
285
+
286
+ - How to Play: If players choose the How to Play option, instructions of how to play the game will be shown on screen. At the end of the instructions, players will find option to go back to home screen.
287
+ - Start Game: If players choose the Start Game option, the game will start and continue to the next scene where they will be shown a prologue.
288
+
289
+ **Tasks:**
290
+
291
+ - [x] Prepare instructions message
292
+ - [x] Prepare prologue
293
+ - [x] Prepare instructions message
294
+ - [x] Look for Gem for table display
295
+ - [x] Create UI
296
+ - [x] Create test case for display
297
+ - [x] Create code to pass test
298
+
299
+ **Code Implementation:**
300
+
301
+ - [x] If-else statement for options
302
+ - [x] Loop for user input
303
+ - [x] Import Gem, utilise function(s)
304
+
305
+ &nbsp;
306
+
307
+ #### Feature 2: Formatted display for showing shop's menu
308
+
309
+ *(Due Date: 19 May 2021 17:00)*
310
+
311
+ Description: Players will be shown the shop's menu in a format that helps them to easily memorise things.
312
+
313
+ **Tasks:**
314
+
315
+ - [x] Create shop’s menu
316
+ - [x] Look for Gem to colorise text
317
+ - [x] Create UI
318
+ - [x] Create test case for display
319
+ - [x] Create code to pass test
320
+
321
+ **Code Implementation:**
322
+
323
+ - [x] Loop to display each menu item
324
+ - [x] Import Gem, utilise function(s)
325
+
326
+ &nbsp;
327
+
328
+ #### Feature 3: Randomised customers with set of request (and associated preferences) and responses
329
+
330
+ *(Due Date: 20 May 2021 17:00)*
331
+
332
+ Description: Players will get requests from various randomised customers with their set of request and associated preferences. Once customers' requests are fulfilled, score is calculated, then customer response is displayed based on score.
333
+
334
+ **Tasks:**
335
+
336
+ - [x] Create customers and their sets
337
+ - [x] Prepare customer responses
338
+ - [x] Create UI
339
+ - [x] Create test case for display
340
+ - [x] Create code to pass test
341
+
342
+ **Code Implementation:**
343
+
344
+ - [x] Loop through data structure
345
+ - [x] Use rand() for random customer implementation
346
+
347
+ &nbsp;
348
+
349
+ #### MAIN Feature 4: Selectable options for list of ingredients, so no manual entry (typing) is needed, and quantity input as integer within a pre-set range
350
+
351
+ *(Due Date: 20 May 2021 17:00)*
352
+
353
+ Description: Players will be given selectable options for list of ingredients to choose from, so no manual ingredient name typing is needed. Input for quantity will be of number data type (integer) within a pre-set range of 0 to 5.
354
+
355
+ **Tasks:**
356
+
357
+ - [x] Look for Gem for input selection formatting
358
+ - [x] Create UI
359
+ - [x] Create test case for display
360
+ - [x] Create test case for option input
361
+ - [x] Create user input validation
362
+ - [x] Create code to pass tests
363
+
364
+ **Code Implementation:**
365
+
366
+ - [x] Loop for user input
367
+ - [x] Import Gem, utilise function(s)
368
+
369
+ &nbsp;
370
+
371
+ #### MAIN Feature 5: Score calculation based on customer's request and preferences compared to player's input
372
+
373
+ *(Due Date: 21 May 2021 17:00)*
374
+
375
+ Description: Score will be calculated based on comparison between customer's request/preferences and player's input. Ideally score +1 for every ingredient correctly selected with correct quantity entered by players. Check if total score meets certain threshold to give appropriate customer's response and provide values to be used in calculation for money and reputation.
376
+
377
+ **Tasks:**
378
+
379
+ - [x] Create test case for comparison calculation
380
+ - [x] Create test case for correct customer response type
381
+ - [x] Create test case for correct calculation towards money and reputation
382
+ - [x] Create code to pass tests
383
+
384
+ **Code Implementation:**
385
+
386
+ - [x] Loop through data structure for comparison calculation
387
+ - [x] If-elsif-else statement for score threshold
388
+ - [x] Switch case statement for different types of customer responses
389
+ - [x] If-elsif-else statement for giving value to add money or reduce reputation
390
+
391
+ &nbsp;
392
+
393
+ #### Feature 6: Get customers' responses from a JSON file
394
+
395
+ *(Due Date: 21 May 2021 17:00)*
396
+
397
+ Description: Various customers' happy, neutral, angry responses are stored in a JSON file, used in the code by parsing it.
398
+
399
+ **Tasks:**
400
+
401
+ - [x] Look for Gem for JSON parsing
402
+ - [x] Prepare JSON file populated with happy, neutral, angry customer responses
403
+ - [x] Create test case for display
404
+ - [x] Create code to pass tests
405
+
406
+ **Code Implementation:**
407
+
408
+ - [x] Import Gem, utilise function(s)
409
+
410
+ &nbsp;
411
+
412
+ #### MAIN Feature 7: Lose/win criteria based on reputation and money
413
+
414
+ *(Due Date: 21 May 2021 17:00)*
415
+
416
+ Description: Players will lose the game once their reputation value hits zero (0). Players will win the game once they reach the target money. Once players meet the losing/winning criteria, they will be shown either Game Over or Win message and that will be the end of the game.
417
+
418
+ **Tasks:**
419
+
420
+ - [x] Prepare Game Over message
421
+ - [x] Prepare Win message
422
+ - [x] Create UI
423
+ - [x] Create test case for display
424
+ - [x] Create code to pass tests
425
+
426
+ **Code Implementation:**
427
+
428
+ - [x] If-else statement for win/lose
429
+
430
+ &nbsp;
431
+
432
+ ### Trello Screenshots
433
+
434
+ Initial plan:
435
+
436
+ ![Trello Screenshot 00](../docs/trello-screenshots/trello-00.jpg "Initial plan.")
437
+
438
+ ![Trello Screenshot 01](../docs/trello-screenshots/trello-01.jpg "Start of implementation.")
439
+
440
+ &nbsp;
441
+
442
+ <!-- Trello Screenshots of Implementation Records -->
443
+ <details>
444
+ <summary>... List of Other Screenshots of Implementation Records</summary>
445
+
446
+ &nbsp;
447
+
448
+ ![Trello Screenshot 02](../docs/trello-screenshots/trello-02.jpg "Implementation.")
449
+
450
+ ![Trello Screenshot 03](../docs/trello-screenshots/trello-03.jpg "Implementation.")
451
+
452
+ ![Trello Screenshot 04](../docs/trello-screenshots/trello-04.jpg "Implementation.")
453
+
454
+ ![Trello Screenshot 05](../docs/trello-screenshots/trello-05.jpg "Implementation.")
455
+
456
+ ![Trello Screenshot 06](../docs/trello-screenshots/trello-06.jpg "Implementation.")
457
+
458
+ ![Trello Screenshot 07](../docs/trello-screenshots/trello-07.jpg "Implementation.")
459
+
460
+ ![Trello Screenshot 08](../docs/trello-screenshots/trello-08.jpg "Implementation.")
461
+
462
+ ![Trello Screenshot 09](../docs/trello-screenshots/trello-09.jpg "Implementation.")
463
+
464
+ ![Trello Screenshot 10](../docs/trello-screenshots/trello-10.jpg "Implementation.")
465
+
466
+ ![Trello Screenshot 11](../docs/trello-screenshots/trello-11.jpg "Implementation.")
467
+
468
+ ![Trello Screenshot 12](../docs/trello-screenshots/trello-12.jpg "Implementation.")
469
+ </details>
470
+
471
+ &nbsp;
472
+
473
+ Last stage:
474
+
475
+ ![Trello Screenshot 13](../docs/trello-screenshots/trello-13.jpg "Last stage of implementation.")
476
+
477
+ ![Trello Screenshot 14](../docs/trello-screenshots/trello-14.jpg "Final stage.")
478
+
479
+ &nbsp;
480
+
481
+ ---
482
+
483
+ &nbsp;
484
+
485
+ ## Installation and Usage
486
+
487
+ There are two options available to install Burger Game app: **Ruby Gem** or **Bash Script**. This is assuming the prerequisites are met prior to installation attempt.
488
+
489
+ Please see below guidelines and instructions for installation options and usage.
490
+
491
+ ### Prerequisites
492
+
493
+ The app has been tested using below systems:
494
+
495
+ | Platform | Operating System | Description |
496
+ |:---:|:---:|:---|
497
+ | Windows | Windows 10, Windows 7 SP1 | Tested for Ruby Gem: installation and usage |
498
+ | macOS | macOS Mojave 10.14 | Tested for Ruby Gem and Bash Script: installation and usage |
499
+ | Linux | Ubuntu Focal Fossa 20.04 LTS | Tested for Ruby Gem and Bash Script: installation and usage |
500
+
501
+ &nbsp;
502
+
503
+ #### Install Ruby
504
+
505
+ This game was built on **Ruby version 2.7.3**. This is the minimum requirement for the app to run as intended. To check Ruby version installed in your system, in the terminal, run:
506
+
507
+ ```
508
+ ruby -v
509
+ ```
510
+
511
+ For Ruby update/installation guide, please refer to the official Ruby documentation: [https://www.ruby-lang.org/en/documentation/installation/](https://www.ruby-lang.org/en/documentation/installation/).
512
+
513
+ &nbsp;
514
+ &nbsp;
515
+
516
+ ### Ruby Gem (Installation and Usage)
517
+
518
+ The most convenient way to install this app is by installing this app as a Gem. Executable file is also available.
519
+
520
+ Please see below instructions for installation of Burger Game gem.
521
+
522
+ 1. Open terminal, install Burger Game gem:
523
+
524
+ ```
525
+ gem install burger_game
526
+ ```
527
+ 2. To start the game:
528
+
529
+ ```
530
+ start_burger_game
531
+ ```
532
+ OR To start the game with **options** (command line arguments):
533
+
534
+ ```
535
+ start_burger_game [OPTION]
536
+ ```
537
+
538
+ **Options** available:
539
+
540
+ Usage (Gem's executable): start_burger_game [*OPTION*]
541
+
542
+ - -h, --help:
543
+ - Print this Help menu for Burger Game.
544
+ - -m, --money [*TARGET_MONEY*]
545
+ - Change TARGET_MONEY. The lower the value, the easier to WIN. Default is 50. Enter number 10 to 99.
546
+ - -r, --reputation [*MAX_REPUTATION*]
547
+ - Change MAX_REPUTATION. The lower the value, the easier to GAME OVER. Default is 10. Enter number 1 to 10.
548
+
549
+ Examples:
550
+
551
+ - To view Help menu:
552
+
553
+ ```
554
+ start_burger_game -h
555
+ ```
556
+ - To set *TARGET_MONEY*:
557
+ ```
558
+ start_burger_game -m 30
559
+ ```
560
+ - To set *MAX_REPUTATION*:
561
+ ```
562
+ start_burger_game -r 5
563
+ ```
564
+ - To set both *TARGET_MONEY* and *MAX_REPUTATION*:
565
+ ```
566
+ start_burger_game -m 30 -r 5
567
+ ```
568
+
569
+ &nbsp;
570
+ &nbsp;
571
+
572
+ ### Bash Script (Installation and Usage)
573
+
574
+ Another way to install this app is by using the bash script.
575
+
576
+ 1. Clone from repository:
577
+
578
+ ```
579
+ git clone https://github.com/petitejess/burger_game.git
580
+ ```
581
+ 2. Change directory:
582
+
583
+ ```
584
+ cd burger_game/src/
585
+ ```
586
+ 3. Run script to install and run the app the first time:
587
+
588
+ ```
589
+ ./install.sh [OPTION]
590
+ ```
591
+ - The next time you want to only run the game (no need to install again), just run the script:
592
+ ```
593
+ ./burger_game.sh [OPTION]
594
+ ```
595
+
596
+ **Options** available:
597
+
598
+ Usage (bash script - install game): ./install.sh [*OPTION*]
599
+
600
+ Usage (bash script - run game): ./burger_game.sh [*OPTION*]
601
+
602
+ - -h, --help:
603
+ - Print this Help menu for Burger Game.
604
+ - -m, --money [*TARGET_MONEY*]
605
+ - Change TARGET_MONEY. The lower the value, the easier to WIN. Default is 50. Enter number 10 to 99.
606
+ - -r, --reputation [*MAX_REPUTATION*]
607
+ - Change MAX_REPUTATION. The lower the value, the easier to GAME OVER. Default is 10. Enter number 1 to 10.
608
+
609
+ Examples:
610
+
611
+ - To view Help menu:
612
+
613
+ ```
614
+ ./burger_game.sh -h
615
+ ```
616
+ - To set *TARGET_MONEY*:
617
+ ```
618
+ ./burger_game.sh -m 30
619
+ ```
620
+ - To set *MAX_REPUTATION*:
621
+ ```
622
+ ./burger_game.sh -r 5
623
+ ```
624
+ - To set both *TARGET_MONEY* and *MAX_REPUTATION*:
625
+ ```
626
+ ./burger_game.sh -m 30 -r 5
627
+ ```
628
+
629
+ &nbsp;
630
+ &nbsp;
631
+
632
+ ### Dependencies
633
+
634
+ Gem dependencies are handled by *add_runtime_dependency* when installing with Ruby Gem installation option, and by *Bundler* gem when installing with Bash Script installation option. The information below is only for reference.
635
+
636
+ List of Gems used in building the app:
637
+
638
+ | Gem Name | Version | Description |
639
+ |:---:|:---:|:---|
640
+ | artii | v.2.1 | Used for text formatting |
641
+ | colorize | v.0.8.1 | Used for text formatting |
642
+ | json | v.2.5 | Used to parse JSON file |
643
+ | tty-box | v.0.7.0 | Used for border/table formatting |
644
+ | tty-prompt | v.0.23.1 | Used for user input with selectable options|
645
+ | rspec | v.3.10 | Used for code testing |
646
+ | bundler | v.2.2 | Used for gem dependencies |
647
+
648
+ &nbsp;
649
+
650
+ ---
651
+
652
+ &nbsp;
653
+
654
+ ## Acknowledgements
655
+
656
+ - ASCII Art:
657
+ - Image of a burger and chips created with ASCII characters included in the app (in Win message) is owned by **Joan G. Stark** and attribution is given as per directed by the artist.
658
+
659
+ - Ruby Gems
660
+ - TTY Prompt, TTY Box, Artii: MIT Licence
661
+ - Colorize: GPL-2.0 Licence
662
+ - JSON: Ruby Licence
data/burger_game.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "burger_game"
3
- s.version = "1.0.3"
3
+ s.version = "1.1.1"
4
4
  s.summary = "A Ruby Burger Game"
5
5
  s.description = "A simple text-based Ruby terminal game, that simulates a burger shop, where you need to build the meal for the customers with different requests and preferences."
6
6
  s.authors = ["Jessica Gozali"]
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
  "./Gemfile",
13
13
  "./Gemfile.lock",
14
14
  "./LICENSE",
15
+ "./README.md",
15
16
  "./bin/start_burger_game",
16
17
  "./lib/burger_game.rb",
17
18
  "./lib/customer_request.rb",
data/lib/burger_game.rb CHANGED
@@ -23,16 +23,16 @@ class BurgerGame
23
23
 
24
24
  # Handle command line argument
25
25
  opt_parser = OptionParser.new do |opt|
26
- opt.banner = "Usage: start_burger_game [options]"
26
+ opt.banner = "Usage (Gem's executable): start_burger_game [OPTION]\nOR\nUsage (bash script - install game): install.sh [OPTION]\nUsage (bash script - run game): burger_game.sh [OPTION]\n\n"
27
27
 
28
- opt.on("-h", "--help", "Print this Help menu for Ruby Burger Game.") do |arg|
28
+ opt.on("-h", "--help", "Print this Help menu for Burger Game.") do |arg|
29
29
  puts opt
30
30
  exit
31
31
  end
32
32
 
33
- opt.on("-m", "--money TARGET_MONEY", screen.display_h_money) { |arg| options.target_money = arg }
33
+ opt.on("-m", "--money [TARGET_MONEY]", screen.display_h_money) { |arg| options.target_money = arg }
34
34
 
35
- opt.on("-r", "--reputation MAX_REPUTATION", screen.display_h_reputation) { |arg| options.max_reputation = arg }
35
+ opt.on("-r", "--reputation [MAX_REPUTATION]", screen.display_h_reputation) { |arg| options.max_reputation = arg }
36
36
  end
37
37
 
38
38
  # ERROR HANDLING for command line argument
@@ -154,6 +154,8 @@ class BurgerGame
154
154
  puts
155
155
  screen.go_to_next
156
156
 
157
+ ARGV.clear
158
+
157
159
  # Feature 4: Selectable options for list of ingredients, so no manual entry (typing) is needed.
158
160
  # Quantity input as integer within a pre-set range.
159
161
  # Display player's options
@@ -5,7 +5,8 @@ class CustomerRequest
5
5
  # ERROR HANDLING for reading files
6
6
  begin
7
7
  # Read customer_request.JSON file
8
- customer_file = File.read('./customer_request.json')
8
+ customer_file = File.read(File.join(File.dirname(__FILE__), './customer_request.json'))
9
+
9
10
  rescue Errno::ENOENT => e
10
11
  puts "Could not find customer_request.json file. Please put customer_request.json in the 'data' directory."
11
12
  puts e.message
@@ -18,7 +19,8 @@ class CustomerRequest
18
19
 
19
20
  begin
20
21
  # Read customer_response.JSON file
21
- response_file = File.read('./customer_response.json')
22
+ response_file = File.read(File.join(File.dirname(__FILE__), './customer_response.json'))
23
+
22
24
  rescue Errno::ENOENT => e
23
25
  puts "Could not find customer_response.json file. Please put customer_response.json in the 'data' directory."
24
26
  puts e.message
data/lib/player_option.rb CHANGED
@@ -67,7 +67,7 @@ class PlayerOption
67
67
  # Ask for quantity
68
68
  puts "How many \"#{item}\"? (Enter 0 to 5)"
69
69
  # Quantity input validation loop
70
- while quantity = gets.strip do
70
+ while quantity = $stdin.gets.strip do
71
71
  # Must be a whole number 0 to 5
72
72
  if (quantity =~ /^[0-5]$/)
73
73
  break
data/lib/recipe.rb CHANGED
@@ -8,7 +8,8 @@ class Recipe
8
8
  # ERROR HANDLING for reading files
9
9
  begin
10
10
  # Read recipe.JSON file
11
- file = File.read('./recipe.json')
11
+ file = File.read(File.join(File.dirname(__FILE__), './recipe.json'))
12
+
12
13
  rescue Errno::ENOENT => e
13
14
  puts "Could not find recipe.json file. Please put recipe.json in the 'data' directory."
14
15
  puts e.message
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.3
4
+ version: 1.1.1
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-26 00:00:00.000000000 Z
11
+ date: 2021-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,6 +119,7 @@ files:
119
119
  - "./Gemfile"
120
120
  - "./Gemfile.lock"
121
121
  - "./LICENSE"
122
+ - "./README.md"
122
123
  - "./bin/start_burger_game"
123
124
  - "./burger_game.gemspec"
124
125
  - "./lib/burger_game.rb"