public IBrainSkill SelectSkill(List <IBrainSkill> skills, IBrainOrder order) { var key = order.Order; if (!skillsDictionary.ContainsKey(key)) { throw new BrainException($"I don't know how to \"{key}\"!"); } return(skillsDictionary[key]); }
public IBrainResult Process(IBrainOrder order) { switch (order.Order) { case "iam": case "introduce": if (order.Parameters.Any()) { return(new IntroductionResult(order.Parameters.FirstOrDefault().ToString())); } else { throw new BrainException("You can't introduce me to nothing!"); } default: throw new BrainException($"I forgot how to {order.Order}!"); } }
public IBrainResult Process(IBrainOrder order) { if (!order.Parameters.Any()) { return(HelpMe()); } var inquiry = order.Parameters.FirstOrDefault().ToString(); if (inquiry == "allskills") { return(new HelpResult(new OrdersCollection(new Dictionary <string, string>(_brain.Skills.Select(s => s.HelpMe()).SelectMany(h => h.Orders))))); } if (!_skills.ContainsKey(inquiry)) { throw new BrainException($"I don't know anything about \"{inquiry}\"!"); } var skill = _skills[inquiry]; return(skill.HelpMe(inquiry)); }
public IBrainResult Process(IBrainOrder order) { return(new StoppingResult()); }
public IBrainResult Process(IBrainOrder order) { return(new TextResult($"Brainy: {order.Order}, I'm Brainy")); }