From 4cd299b1ef0d0c4dd072a8c6dcb0000aa0fe18e6 Mon Sep 17 00:00:00 2001 From: Yesenia L Date: Wed, 6 Jan 2021 00:36:57 -0500 Subject: [PATCH 1/5] Project1 --- .gitignore | 1 + DIYpizza.js | 124 ++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- package-lock.json | 19 ++++++- textBasedAdventure.js | 5 -- 5 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 DIYpizza.js delete mode 100644 textBasedAdventure.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/DIYpizza.js b/DIYpizza.js new file mode 100644 index 0000000..969911d --- /dev/null +++ b/DIYpizza.js @@ -0,0 +1,124 @@ +const rls = require("readline-sync"); +// let nameInput = readline.question("Enter your name: ") + + + //initiate the player to begin + function initiate() { + if(rls.keyInYN("Ready to DIY Pizza?")) { + play() + } + else { + quitGame() + } + } + initiate() + + function quitGame() { + console.log("Come back Soon!") + process.exit() + //exit function + } + + + function play() { + //welcome and ask name + //instructions + //ask to move forward to game + const name = rls.question('Welcome, What is your name:\n'); + console.log("Hi " + name + " nice to meet you!"); { + console.log("") + console.log("Let's make three different Pizzas!") + console.log("First, you will need to pick which Pizza you will make first.") + console.log("Your options are vegan, meatLover, and veggie.") + console.log("You will need to add 3 toppings out of 5 options provided for you.") + console.log("Once you are done with one pizza, choose another until you have completed all three.") + console.log("") + } + if (rls.keyInYN("Are you excited to create your 3 Pizza types?")) { + startGame() + } else { + quitGame() + } + } + + function startGame () { + //3 pizza types + //total 5 topping option for each Pizza Type + //ask player to chose pizza + const pizzaType = ["vegan", "meatLover", "veggie"] + let veganPizza = ["Vegan Parmesian", "Mushrooms", "Cauliflower", "Fresh Basil", "Zuchini"] + let meatLoverPizza = ["Bacon", "Hot Sausage", "Cheese", "Chicken", "Pepperoni"] + let veggiePizza = ["Baby Spinach", "Mozzarella", "Artichoke", "Bell Pepper", "Olives"] + //have user choose pizza type + let userPizza = rls.question("Pick a PizzaType - vegan, meatLover, or veggie:\n") + let toppings = [] + + //vegan pizza + //Provide options + //join toppings + //let them know how many toppings are left + if(userPizza === pizzaType[0]) { + console.log("Let's make a " + pizzaType[0] + " pizza!") + console.log(veganPizza.join()) + let userToppings + let numOfToppings = 3 + while (numOfToppings >= 1) { + userToppings = rls.question("Enter Vegan Pizza Toppings:\n") + if(veganPizza.includes(userToppings)) { + toppings.push(userToppings) + numOfToppings-- + console.log("You have " + numOfToppings + " remaining") + } + else { + console.log(userToppings + " is not " + userPizza + " topping!") + } + } + } + + + //meatLover pizza + //chose 3 toppings + //join them + //tell them how many toppings are left + //ask if they want to continue + if(userPizza === pizzaType[1]) { + console.log("Let's make a " + pizzaType[1] + " pizza!") + console.log(meatLoverPizza.join()) + let userToppings + let numOfToppings = 3 + while (numOfToppings >= 1) { + userToppings = rls.question("Enter meatLover Pizza Toppings:\n") + if(meatLoverPizza.includes(userToppings)) { + toppings.push(userToppings) + numOfToppings-- + console.log("You have " + numOfToppings + " remaining") + } + else { + console.log(userToppings + " is not " + userPizza + " topping!") + } + } + } + //veggie pizza""" + if (userPizza=== pizzaType[2]) { + console.log("Let's make a " + pizzaType[2] + " pizza!") + console.log(veggiePizza.join()) + let userToppings + let numOfToppings = 3 + while (numOfToppings >= 1) { + userToppings = rls.question("Enter Veggie Pizza Toppings:\n") + if(veggiePizza.includes(userToppings)) { + toppings.push(userToppings) + numOfToppings-- + console.log("You have " + numOfToppings + " remaining") + } + else { + console.log(userToppings + " is not " + userPizza + " topping!") + } + } + } + console.log("You have selected " + toppings.join()) + rls.keyInYN("Will that be all?") ? quitGame() : startGame() + //lists toppings chosen + //asks player to restart or end game after each pizza + } + startGame() diff --git a/README.md b/README.md index f0a4dd4..efc9db9 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ let yourVariableHere = readline.question("Enter your name: ") Replace the link below with the link to your Trello project: -[Trello](https://trello.com/b/vbKtMOKj/text-based-adventure-project-plan) +[Trello](https://trello.com/b/dzhj7Ute/text-based-adventure-project-plan) ## Rubric diff --git a/package-lock.json b/package-lock.json index 4e5e2be..c047f7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,25 @@ { "name": "FSW-Text-Based-Adventure", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } + }, + "node_modules/readline-sync": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", + "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==", + "engines": { + "node": ">= 0.8.0" + } + } + }, "dependencies": { "readline-sync": { "version": "1.4.10", diff --git a/textBasedAdventure.js b/textBasedAdventure.js deleted file mode 100644 index d392b19..0000000 --- a/textBasedAdventure.js +++ /dev/null @@ -1,5 +0,0 @@ -const readline1 = require('readline-sync') - -let nameInput = readline.question("Enter your name: ") - -console.log(`Hello ${nameInput}! Welcome to my game.`) From 82aa8bcc9d2c0a50a33c6dce44b02ac193b3a9e5 Mon Sep 17 00:00:00 2001 From: Yesenia L Date: Wed, 6 Jan 2021 00:50:26 -0500 Subject: [PATCH 2/5] edited --- DIYpizza.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DIYpizza.js b/DIYpizza.js index 969911d..a851c53 100644 --- a/DIYpizza.js +++ b/DIYpizza.js @@ -28,10 +28,10 @@ const rls = require("readline-sync"); console.log("Hi " + name + " nice to meet you!"); { console.log("") console.log("Let's make three different Pizzas!") - console.log("First, you will need to pick which Pizza you will make first.") + console.log("One for you and the other two for a friend/s") console.log("Your options are vegan, meatLover, and veggie.") console.log("You will need to add 3 toppings out of 5 options provided for you.") - console.log("Once you are done with one pizza, choose another until you have completed all three.") + console.log("Once you are done with all three pizzas, you can enjoy it for free .") console.log("") } if (rls.keyInYN("Are you excited to create your 3 Pizza types?")) { From 75e9c5f68658f8eba9cbd1f59adb0f7fe5eb0dd4 Mon Sep 17 00:00:00 2001 From: Yesenia L Date: Wed, 27 Jan 2021 18:12:44 -0500 Subject: [PATCH 3/5] unfinished --- , | 0 DIYpizza.js | 242 ++++++++++++++++++++++++++++------------------------ 2 files changed, 131 insertions(+), 111 deletions(-) create mode 100644 , diff --git a/, b/, new file mode 100644 index 0000000..e69de29 diff --git a/DIYpizza.js b/DIYpizza.js index a851c53..c10c0a7 100644 --- a/DIYpizza.js +++ b/DIYpizza.js @@ -1,124 +1,144 @@ const rls = require("readline-sync"); -// let nameInput = readline.question("Enter your name: ") +let veganPizza = [ + "Vegan Parmesian", + "Mushrooms", + "Cauliflower", + "Fresh Basil", + "Zuchini", +]; +let meatLoverPizza = ["Bacon", "Hot Sausage", "Cheese", "Chicken", "Pepperoni"]; +let veggiePizza = [ + "Baby Spinach", + "Mozzarella", + "Artichoke", + "Bell Pepper", + "Olives", +]; +let toppings = []; +const name = rls.question("Welcome, What is your name:\n"); +let numOfToppings = 3; +function play() { + console.log("Hi " + name + " nice to meet you! \n"); + console.log("Let's make three different Pizzas!"); + console.log("\nOne for you and the other two for a friend/s"); + console.log("Your options are vegan, meatLover, and veggie."); + console.log( + "You will need to add 3 toppings out of 5 options provided for you." + ); + console.log( + "Once you are done with all three pizzas, you can enjoy it for free. \n" + ); - //initiate the player to begin - function initiate() { - if(rls.keyInYN("Ready to DIY Pizza?")) { - play() - } - else { - quitGame() - } + if (rls.keyInYN("Ready to DIY Pizza?")) { + startGame(); + } else { + quitGame(); + } +} +//play() + +function startGame() { + //play(); + pizzaType = ["vegan", "meatLover", "veggie"]; + index = rls.keyInSelect(pizzaType, "Which pizza would you like?"); + + // let userPizza = rls.question( + // "Pick a PizzaType - vegan, meatLover, or veggie:\n" + // ); + // if (pizzaType === index[1]) { + console.log("You have selected " + pizzaType[index] + " pizza."); + //console.log("Let's make a " + index[1] + " pizza!"); + console.log(veganPizza.join()); + let userToppings; + //let numOfToppings = 3; + while (numOfToppings >= 1) { + userToppings = rls.question("Enter Vegan Pizza Toppings:\n"); + if (veganPizza.includes(userToppings)) { + toppings.push(userToppings); + numOfToppings--; + console.log("You have " + numOfToppings + " remaining"); + } else if (veganPizza !== userToppings) { + console.log(userToppings + " is not " + pizzaType[index] + " topping!"); + } else { + console.log("This is not an option. Please choose specified toppings."); + veganPizza; } - initiate() + } + numberOfSlices(); + review(pizzaType[index]); + //} - function quitGame() { - console.log("Come back Soon!") - process.exit() - //exit function + if (pizzaType === index[2]) { + console.log("Let's make a " + pizzaType[index] + " pizza!"); + console.log(meatLoverPizza.join()); + while (numOfToppings >= 1) { + let userToppings = rls.question("Enter meatLover Pizza Toppings:\n"); + if (meatLoverPizza.includes(userToppings)) { + toppings.push(userToppings); + numOfToppings--; + console.log("You have " + numOfToppings + " remaining"); + } else { + console.log(userToppings + " is not " + pizzaType[index] + " topping!"); + } } - + numberOfSlices(); + review(pizzaType[index]); + //} - function play() { - //welcome and ask name - //instructions - //ask to move forward to game - const name = rls.question('Welcome, What is your name:\n'); - console.log("Hi " + name + " nice to meet you!"); { - console.log("") - console.log("Let's make three different Pizzas!") - console.log("One for you and the other two for a friend/s") - console.log("Your options are vegan, meatLover, and veggie.") - console.log("You will need to add 3 toppings out of 5 options provided for you.") - console.log("Once you are done with all three pizzas, you can enjoy it for free .") - console.log("") - } - if (rls.keyInYN("Are you excited to create your 3 Pizza types?")) { - startGame() + if (pizzaType === pizzaType[3]) { + console.log("Let's make a " + index[3] + " pizza!"); + console.log(veggiePizza.join()); + let userToppings; + let numOfToppings = 3; + while (numOfToppings >= 1) { + userToppings = rls.question("Enter Veggie Pizza Toppings:\n"); + if (veggiePizza.includes(userToppings)) { + toppings.push(userToppings); + numOfToppings--; + console.log("You have " + numOfToppings + " remaining"); } else { - quitGame() + console.log(userToppings + " is not " + userPizza + " topping!"); } + } + numberOfSlices(); + review(userPizza); } - - function startGame () { - //3 pizza types - //total 5 topping option for each Pizza Type - //ask player to chose pizza - const pizzaType = ["vegan", "meatLover", "veggie"] - let veganPizza = ["Vegan Parmesian", "Mushrooms", "Cauliflower", "Fresh Basil", "Zuchini"] - let meatLoverPizza = ["Bacon", "Hot Sausage", "Cheese", "Chicken", "Pepperoni"] - let veggiePizza = ["Baby Spinach", "Mozzarella", "Artichoke", "Bell Pepper", "Olives"] - //have user choose pizza type - let userPizza = rls.question("Pick a PizzaType - vegan, meatLover, or veggie:\n") - let toppings = [] + //} - //vegan pizza - //Provide options - //join toppings - //let them know how many toppings are left - if(userPizza === pizzaType[0]) { - console.log("Let's make a " + pizzaType[0] + " pizza!") - console.log(veganPizza.join()) - let userToppings - let numOfToppings = 3 - while (numOfToppings >= 1) { - userToppings = rls.question("Enter Vegan Pizza Toppings:\n") - if(veganPizza.includes(userToppings)) { - toppings.push(userToppings) - numOfToppings-- - console.log("You have " + numOfToppings + " remaining") - } - else { - console.log(userToppings + " is not " + userPizza + " topping!") - } - } + function numberOfSlices() { + let slice = rls.question( + "How many slices would you like this pizza cut? Please choose number of slices:6 slices, 8 slices, or 12 slices.\n" + ); + if (slice === "6") { + console.log("You cut this pizza into 6 slices."); + } else if (slice === "8") { + console.log("You cut this into 8 slices."); + } else if (slice === "12") { + console.log("You cut this pizza into 12 slices"); + } else { + console.log("Invalid number of pizza slices. "); + numberOfSlices(); + } } - - - //meatLover pizza - //chose 3 toppings - //join them - //tell them how many toppings are left - //ask if they want to continue - if(userPizza === pizzaType[1]) { - console.log("Let's make a " + pizzaType[1] + " pizza!") - console.log(meatLoverPizza.join()) - let userToppings - let numOfToppings = 3 - while (numOfToppings >= 1) { - userToppings = rls.question("Enter meatLover Pizza Toppings:\n") - if(meatLoverPizza.includes(userToppings)) { - toppings.push(userToppings) - numOfToppings-- - console.log("You have " + numOfToppings + " remaining") - } - else { - console.log(userToppings + " is not " + userPizza + " topping!") - } - } + + function review(userPizzaToppings) { + //creat a forEach loop + let order = rls.keyInYN("Will that be all?"); + if (order) { + console.log("You have selected " + toppings); //.join()) + console.log("Enjoy your " + userPizzaToppings + " pizza!"); + quitGame(); + } else { + startGame(); + } + + function quitGame() { + console.log("Come back Soon!"); + process.exit(); + } } - //veggie pizza""" - if (userPizza=== pizzaType[2]) { - console.log("Let's make a " + pizzaType[2] + " pizza!") - console.log(veggiePizza.join()) - let userToppings - let numOfToppings = 3 - while (numOfToppings >= 1) { - userToppings = rls.question("Enter Veggie Pizza Toppings:\n") - if(veggiePizza.includes(userToppings)) { - toppings.push(userToppings) - numOfToppings-- - console.log("You have " + numOfToppings + " remaining") - } - else { - console.log(userToppings + " is not " + userPizza + " topping!") - } - } - } - console.log("You have selected " + toppings.join()) - rls.keyInYN("Will that be all?") ? quitGame() : startGame() - //lists toppings chosen - //asks player to restart or end game after each pizza - } - startGame() + } +} +play() +//startGame(); From d77514c28dcbbfb5223becbe8476b718dafdb9dc Mon Sep 17 00:00:00 2001 From: Yesenia L Date: Wed, 27 Jan 2021 20:29:04 -0500 Subject: [PATCH 4/5] Finished --- DIYpizza.js | 160 +++++++++++++++++++++------------------------------- 1 file changed, 63 insertions(+), 97 deletions(-) diff --git a/DIYpizza.js b/DIYpizza.js index c10c0a7..e0dd6dc 100644 --- a/DIYpizza.js +++ b/DIYpizza.js @@ -1,21 +1,28 @@ const rls = require("readline-sync"); -let veganPizza = [ +const pizzaType = ["vegan", "meatLover", "veggie"]; +const veganPizza = [ "Vegan Parmesian", "Mushrooms", "Cauliflower", "Fresh Basil", "Zuchini", ]; -let meatLoverPizza = ["Bacon", "Hot Sausage", "Cheese", "Chicken", "Pepperoni"]; -let veggiePizza = [ +const meatLoverPizza = [ + "Bacon", + "Hot Sausage", + "Cheese", + "Chicken", + "Pepperoni", +]; +const veggiePizza = [ "Baby Spinach", "Mozzarella", "Artichoke", "Bell Pepper", "Olives", ]; -let toppings = []; const name = rls.question("Welcome, What is your name:\n"); +let toppings = []; let numOfToppings = 3; function play() { @@ -36,109 +43,68 @@ function play() { quitGame(); } } -//play() -function startGame() { - //play(); - pizzaType = ["vegan", "meatLover", "veggie"]; - index = rls.keyInSelect(pizzaType, "Which pizza would you like?"); +function preparePizza(type, pizzaToppings) { + console.log(pizzaToppings.join()); - // let userPizza = rls.question( - // "Pick a PizzaType - vegan, meatLover, or veggie:\n" - // ); - // if (pizzaType === index[1]) { - console.log("You have selected " + pizzaType[index] + " pizza."); - //console.log("Let's make a " + index[1] + " pizza!"); - console.log(veganPizza.join()); - let userToppings; - //let numOfToppings = 3; while (numOfToppings >= 1) { - userToppings = rls.question("Enter Vegan Pizza Toppings:\n"); - if (veganPizza.includes(userToppings)) { - toppings.push(userToppings); + const userTopping = rls.question("Enter " + type + " Toppings:\n"); + + if (pizzaToppings.includes(userTopping)) { + toppings.push(userTopping); numOfToppings--; console.log("You have " + numOfToppings + " remaining"); - } else if (veganPizza !== userToppings) { - console.log(userToppings + " is not " + pizzaType[index] + " topping!"); } else { - console.log("This is not an option. Please choose specified toppings."); - veganPizza; + console.log(userTopping + " is not " + type + " topping!"); + console.log(pizzaToppings.join()); } } +} + +function startGame() { + numOfToppings = 3; + console.log(toppings); + const index = rls.keyInSelect(pizzaType, "Which pizza would you like?"); + console.log("You have selected " + pizzaType[index] + " pizza."); + if (pizzaType[index] === "vegan") { + preparePizza(pizzaType[index], veganPizza); + } else if (pizzaType[index] === "meatLover") { + preparePizza(pizzaType[index], meatLoverPizza); + } else { + preparePizza(pizzaType[index], veggiePizza); + } numberOfSlices(); review(pizzaType[index]); - //} - - if (pizzaType === index[2]) { - console.log("Let's make a " + pizzaType[index] + " pizza!"); - console.log(meatLoverPizza.join()); - while (numOfToppings >= 1) { - let userToppings = rls.question("Enter meatLover Pizza Toppings:\n"); - if (meatLoverPizza.includes(userToppings)) { - toppings.push(userToppings); - numOfToppings--; - console.log("You have " + numOfToppings + " remaining"); - } else { - console.log(userToppings + " is not " + pizzaType[index] + " topping!"); - } - } - numberOfSlices(); - review(pizzaType[index]); - //} - - if (pizzaType === pizzaType[3]) { - console.log("Let's make a " + index[3] + " pizza!"); - console.log(veggiePizza.join()); - let userToppings; - let numOfToppings = 3; - while (numOfToppings >= 1) { - userToppings = rls.question("Enter Veggie Pizza Toppings:\n"); - if (veggiePizza.includes(userToppings)) { - toppings.push(userToppings); - numOfToppings--; - console.log("You have " + numOfToppings + " remaining"); - } else { - console.log(userToppings + " is not " + userPizza + " topping!"); - } - } - numberOfSlices(); - review(userPizza); - } - //} - - function numberOfSlices() { - let slice = rls.question( - "How many slices would you like this pizza cut? Please choose number of slices:6 slices, 8 slices, or 12 slices.\n" - ); - if (slice === "6") { - console.log("You cut this pizza into 6 slices."); - } else if (slice === "8") { - console.log("You cut this into 8 slices."); - } else if (slice === "12") { - console.log("You cut this pizza into 12 slices"); - } else { - console.log("Invalid number of pizza slices. "); - numberOfSlices(); - } - } - - function review(userPizzaToppings) { - //creat a forEach loop - let order = rls.keyInYN("Will that be all?"); - if (order) { - console.log("You have selected " + toppings); //.join()) - console.log("Enjoy your " + userPizzaToppings + " pizza!"); - quitGame(); - } else { - startGame(); - } - - function quitGame() { - console.log("Come back Soon!"); - process.exit(); - } +} +function numberOfSlices() { + let slice = ""; + while (slice !== "6" && slice !== "8" && slice !== "12") { + slice = rls.question( + "How many slices would you like this pizza cut? Please choose number of slices:6 slices, 8 slices, or 12 slices.\n" + ); + if (slice === "6") { + console.log("You cut this pizza into 6 slices."); + } else if (slice === "8") { + console.log("You cut this into 8 slices."); + } else if (slice === "12") { + console.log("You cut this pizza into 12 slices"); + } else { + console.log("Invalid number of pizza slices. "); } } } -play() -//startGame(); +function review(userPizzaToppings) { + let order = rls.keyInYN("Will that be all?"); + if (order) { + console.log("You have selected " + toppings); //.join()) + console.log("Enjoy your " + userPizzaToppings + " pizza!"); + quitGame(); + } else { + startGame(); + } +} +function quitGame() { + console.log("Come back Soon!"); + process.exit(); +} +play(); From 20f0b0059fa34f03ad8efdd2e6f44cb8476853db Mon Sep 17 00:00:00 2001 From: Yesenia L Date: Thu, 28 Jan 2021 00:19:04 -0500 Subject: [PATCH 5/5] Final Edit --- DIYpizza.js | 1 - 1 file changed, 1 deletion(-) diff --git a/DIYpizza.js b/DIYpizza.js index e0dd6dc..933ed5a 100644 --- a/DIYpizza.js +++ b/DIYpizza.js @@ -63,7 +63,6 @@ function preparePizza(type, pizzaToppings) { function startGame() { numOfToppings = 3; - console.log(toppings); const index = rls.keyInSelect(pizzaType, "Which pizza would you like?"); console.log("You have selected " + pizzaType[index] + " pizza."); if (pizzaType[index] === "vegan") {