Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project1 #89

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added ,
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
109 changes: 109 additions & 0 deletions DIYpizza.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const rls = require("readline-sync");
const pizzaType = ["vegan", "meatLover", "veggie"];
const veganPizza = [
"Vegan Parmesian",
"Mushrooms",
"Cauliflower",
"Fresh Basil",
"Zuchini",
];
const meatLoverPizza = [
"Bacon",
"Hot Sausage",
"Cheese",
"Chicken",
"Pepperoni",
];
const veggiePizza = [
"Baby Spinach",
"Mozzarella",
"Artichoke",
"Bell Pepper",
"Olives",
];
const name = rls.question("Welcome, What is your name:\n");
let toppings = [];
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"
);

if (rls.keyInYN("Ready to DIY Pizza?")) {
startGame();
} else {
quitGame();
}
}

function preparePizza(type, pizzaToppings) {
console.log(pizzaToppings.join());

while (numOfToppings >= 1) {
const userTopping = rls.question("Enter " + type + " Toppings:\n");

if (pizzaToppings.includes(userTopping)) {
toppings.push(userTopping);
numOfToppings--;
console.log("You have " + numOfToppings + " remaining");
} else {
console.log(userTopping + " is not " + type + " topping!");
console.log(pizzaToppings.join());
}
}
}

function startGame() {
numOfToppings = 3;
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]);
}
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. ");
}
}
}
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();
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions textBasedAdventure.js

This file was deleted.