refactor: changed addSyrup() paramaters

Now addSyrup() takes in the currentDrink.recipe,makes a new one and returns that value
This commit is contained in:
Joshua Shoemaker 2017-02-01 17:46:32 -06:00
parent 75f24043b3
commit 3d6d7644be
3 changed files with 79 additions and 6 deletions

View File

@ -34,7 +34,7 @@ document.addEventListener('DOMContentLoaded', function(){
currentDrink = addRecipe(currentDrink, dataValue); currentDrink = addRecipe(currentDrink, dataValue);
break; break;
case "SYRUP": case "SYRUP":
currentDrink = addSyrup(currentDrink, dataValue); Object.assign(currentDrink.recipe, addSyrup(currentDrink.recipe, dataValue, currentDrink.size));
break; break;
case "CONTROL": case "CONTROL":
changeMenu(dataValue); changeMenu(dataValue);

View File

@ -137,14 +137,17 @@ function addRecipe(drink, recipe){
return drink; return drink;
} }
function addSyrup(drink, syrup, qunatity){ function addSyrup(recipe, syrup, size, qunatity){
let pumps = 0; let pumps = 0;
if(qunatity){ if(qunatity){
pumps = qunatity pumps = qunatity
} }
else if(size){
pumps = standardPumps(size);
}
else{ else{
pumps = standardPumps(drink.size); pumps = 1;
} }
s = { s = {
@ -152,14 +155,14 @@ function addSyrup(drink, syrup, qunatity){
count: pumps count: pumps
} }
let otherSyrups = _.without(drink.recipe.addedSyrups, _.findWhere(drink.recipe.addedSyrups, { let otherSyrups = _.without(recipe.addedSyrups, _.findWhere(recipe.addedSyrups, {
name: syrup name: syrup
})); }));
otherSyrups.push(s); otherSyrups.push(s);
drink.recipe.addedSyrups = otherSyrups; recipe.addedSyrups = otherSyrups;
return drink; return recipe;
} }
function standardPumps(size, mod){ function standardPumps(size, mod){

View File

@ -1,3 +1,62 @@
function americano (drink) {
let recipe = {
name: "Americano",
assigned: true,
shots: standardShots(drink.size, 1),
milk: milkTypes.TWOPERCENT
}
return recipe;
}
function espresso (drink) {
let recipe = {
name: "Espresso",
assigned: true
}
return recipe;
}
function espressoMacchiato (drink) {
let recipe = {
name: "Espresso Macchiato",
assigned: true,
shots: standardShots(drink.size),
milk: milkTypes.TWOPERCENT
}
return recipe;
}
function espressoConPanna (drink) {
let recipe = {
name: "Espresso Macchiato",
assigned: true,
milk: milkTypes.TWOPERCENT
}
return recipe;
}
function starbucksDoubleShotOnIce (drink) {
let recipe = {
name: "Starbucks Double Shot On Ice",
assigned: true,
shots: shotsSBDS(),
milk: milkTypes.TWOPERCENT
}
function shotsSBDS(){
switch (drink.size){
case drinkSizes.TALL:
return 2;
case drinkSizes.GRANDE:
return 3;
case drinkSizes.VENTI:
return 5;
default:
return 0;
}
}
return recipe;
}
function latte (drink) { function latte (drink) {
let recipe = { let recipe = {
name: "Latte", name: "Latte",
@ -8,6 +67,17 @@ function latte (drink) {
return recipe; return recipe;
} }
function cinnamonDolceLatte (drink) {
let recipe = {
name: "Cinnamon Dolce Latte",
assigned: true,
shots: standardShots(drink.size),
milk: milkTypes.TWOPERCENT
}
addSyrup(drink, "Cinnamon Dolce")
return recipe;
}
function skinnyLatte (drink) { function skinnyLatte (drink) {
let recipe = { let recipe = {
name: "Skinny Syrup Latte", name: "Skinny Syrup Latte",