public override void DoStep(Dialog userInput, IBartenderController controller, String garnish) { MessageToUser = String.Format("Garnish the drink with {0}.", garnish); NextGrammarNeeded = BartenderApp.ConfirmationRuleName; IsStepDone = true; ShouldCancel = false; }
public virtual void DoStep(Dialog d, IBartenderController controller) { IsStepDone = true; ShouldCancel = false; MessageToUser = null; NextGrammarNeeded = null; }
public override void DoStep(Dialog userInput, IBartenderController controller, Ingredient ingredient) { controller.DispenseLiquid(ingredient.GetAvailableKeys(controller.AvailableLiquids).First(), ingredient.AmountQuantityInmL); IsStepDone = true; ShouldCancel = false; MessageToUser = null; NextGrammarNeeded = null; }
public RecipeStepCall Call(Dialog userResponse, IBartenderController controller) { CallInternal(userResponse, controller); if (!_step.IsStepDone || ShouldCancel || _nextStep == null) { return(this); } return(_nextStep.Call(null, controller)); }
public override void DoStep(Dialog d, IBartenderController controller) { if (_endAfterCall || DoStepIsCalled) { IsStepDone = true; } else { IsStepDone = false; } DoStepIsCalled = true; }
private static void TestDoStepAllTrueAnswers(ShakeStep step, IBartenderController bartender, int numTrueAnswers, String expectedAnswer, bool shouldBeFinished) { Dictionary <String, String> trueInput = new Dictionary <string, string> { { "answer", "true" }, }; for (int i = 0; i < numTrueAnswers + 1; i++) { step.DoStep(new Dialog(trueInput, "Test Phrase"), bartender); } Assert.AreEqual(expectedAnswer, step.MessageToUser); Assert.AreEqual(shouldBeFinished, step.IsStepDone); Assert.AreEqual("Shake", step.Name); Assert.AreEqual(shouldBeFinished ? null : BartenderApp.ConfirmationRuleName, step.NextGrammarNeeded); Assert.AreEqual(false, step.ShouldCancel); }
public override void DoStep(Dialog userInput, IBartenderController controller, Ingredient ingredient) { if (userInput == null || String.IsNullOrEmpty(userInput.GetPropertyValue("answer"))) { MessageToUser = String.Format("Add {0} to the glass and tell me when you are done.", ingredient.Name); NextGrammarNeeded = BartenderApp.ConfirmationRuleName; IsStepDone = false; ShouldCancel = false; } else { IsStepDone = true; ShouldCancel = !Boolean.Parse(userInput.GetPropertyValue("answer")); MessageToUser = null; NextGrammarNeeded = null; } }
public override void DoStep(Dialog userInput, IBartenderController controller) { if (userInput == null || String.IsNullOrEmpty(userInput.GetPropertyValue("answer"))) { MessageToUser = String.Format("Strain the drink."); NextGrammarNeeded = BartenderApp.ConfirmationRuleName; IsStepDone = false; ShouldCancel = false; } else { IsStepDone = true; ShouldCancel = !Boolean.Parse(userInput.GetPropertyValue("answer")); MessageToUser = null; NextGrammarNeeded = null; } }
public override void DoStep(Dialog userInput, IBartenderController controller) { if (userInput == null || String.IsNullOrEmpty(userInput.GetPropertyValue("answer"))) { MessageToUser = String.Format("Place a {1} glass underneath the spout of the bartender so I can make you a {0}.", _drinkName, _glassName); NextGrammarNeeded = BartenderApp.ConfirmationRuleName; IsStepDone = false; ShouldCancel = false; } else { ShouldCancel = !Boolean.Parse(userInput.GetPropertyValue("answer")); IsStepDone = true; MessageToUser = null; NextGrammarNeeded = null; } }
public override void DoStep(Dialog userInput, IBartenderController controller) { switch (_state) { case ShakeStepState.Start: MessageToUser = String.Format("Pour the drink into a shaker."); NextGrammarNeeded = BartenderApp.ConfirmationRuleName; IsStepDone = false; ShouldCancel = false; _state = ShakeStepState.HasSwitchedGlasses; break; case ShakeStepState.HasSwitchedGlasses: ShouldCancel = !Boolean.Parse(userInput.GetPropertyValue("answer")); IsStepDone = ShouldCancel; MessageToUser = ShouldCancel ? null : String.Format("Shake the drink."); NextGrammarNeeded = ShouldCancel ? null : BartenderApp.ConfirmationRuleName; _state = ShakeStepState.HasShaken; break; case ShakeStepState.HasShaken: ShouldCancel = !Boolean.Parse(userInput.GetPropertyValue("answer")); IsStepDone = ShouldCancel; MessageToUser = ShouldCancel ? null : String.Format("Pour the drink back into the glass."); NextGrammarNeeded = ShouldCancel ? null : BartenderApp.ConfirmationRuleName; _state = ShakeStepState.HasReturnedToGlass; break; case ShakeStepState.HasReturnedToGlass: IsStepDone = true; ShouldCancel = !Boolean.Parse(userInput.GetPropertyValue("answer")); MessageToUser = null; NextGrammarNeeded = null; break; default: break; } }
private static void TestDoStepFalseAnswer(ShakeStep step, IBartenderController bartender, int numTrueAnswers) { Dictionary <String, String> trueInput = new Dictionary <string, string> { { "answer", "true" }, }; Dictionary <String, String> falseInput = new Dictionary <string, string> { { "answer", "false" }, }; for (int i = 0; i < numTrueAnswers + 1; i++) { step.DoStep(new Dialog(trueInput, "Test Phrase"), bartender); } step.DoStep(new Dialog(falseInput, "Test Phrase"), bartender); Assert.AreEqual(null, step.MessageToUser); Assert.AreEqual(true, step.IsStepDone); Assert.AreEqual("Shake", step.Name); Assert.AreEqual(null, step.NextGrammarNeeded); Assert.AreEqual(true, step.ShouldCancel); }
protected virtual void CallInternal(Dialog userResponse, IBartenderController controller) { _step.DoStep(userResponse, controller); }
public virtual void DoStep(Dialog d, IBartenderController controller, T argument) { base.DoStep(d, controller); }
protected override void CallInternal(Dialog userResponse, IBartenderController controller) { (_step as RecipeStep <T>).DoStep(userResponse, controller, _argument); }
public override string Speak() { base.Speak(); Dialog phrase = CurrentDialog; String subCommand = phrase.GetPropertyValue("Subcommand"); IEnumerable <IBartenderController> controllers = ConfigManager.FindAllComponentsOfType <IBartenderController>(); if (!controllers.Any()) { ConversationIsOver = true; return(String.Empty); } else if (String.IsNullOrEmpty(subCommand) && _isCleaningPumps) { ConversationIsOver = true; if (Boolean.Parse(phrase.GetPropertyValue("answer"))) { foreach (IBartenderController controller in controllers) { foreach (String pump in controller.AvailableLiquids) { controller.DispenseLiquid(pump, 25); } } return("Cleaning the pumps now."); } else { return("Never mind."); } } else if (subCommand.Equals("cleanPumps")) { ConversationIsOver = false; _isCleaningPumps = true; _nextGrammarName = BartenderApp.ConfirmationRuleName; return("Make sure that the pumps are all no longer in the drinks. Pumps will run one at a time until all have been cleaned. Tell me when you are ready."); } else if (String.IsNullOrEmpty(subCommand)) { ConversationIsOver = false; if (_call == null) { _drinkBeingMade = phrase.GetPropertyValue("DrinkName"); DrinkRecipe recipe = _recipeProvider.Drinks.Single(d => d.Name.Equals(_drinkBeingMade)); _controllerInUse = controllers.FirstOrDefault(s => recipe.CanMakeFromRecipes(s.AvailableLiquids)); if (_controllerInUse == null) { ConversationIsOver = true; return(String.Empty); } _call = recipe.Start(); } _call = _call.Call(phrase, _controllerInUse); if (_call.IsDone) { ConversationIsOver = true; if (String.IsNullOrEmpty(_call.MessageToUser)) { return(String.Format("Your {0} is now being made.", _drinkBeingMade)); } else { return(_call.MessageToUser); } } else if (_call.ShouldCancel) { ConversationIsOver = true; return("Never mind"); } else { _nextGrammarName = _call.NextGrammarNeeded; return(_call.MessageToUser); } } else if (subCommand.Equals("drinkList")) { ConversationIsOver = true; IEnumerable <String> ingredients = controllers.SelectMany(s => s.AvailableLiquids).ToList(); IEnumerable <DrinkRecipe> recipes = _recipeProvider.Drinks.Where(drink => drink.CanMakeFromRecipes(ingredients)).ToList(); return(String.Format("I can make {0}.", SayList(recipes.Select(d => d.Name).ToList()))); } else if (subCommand.Equals("ingredientList")) { ConversationIsOver = true; String drinkBeingMade = phrase.GetPropertyValue("DrinkName"); DrinkRecipe recipe = _recipeProvider.Drinks.Single(d => d.Name.Equals(drinkBeingMade)); return(String.Format("A {0} contains {1}.", recipe.Name, SayList(recipe.Ingredients.Select(d => d.Name).ToList()))); } return(String.Empty); }