Пример #1
0
        /// <summary>
        /// Uses config information from the model to get a sample from a distribution over the jokes
        /// </summary>
        /// <returns></returns>
        public Joke NextJoke()
        {
            Joke selectedJoke;

            var jokeDistribution = GetJokeDistribution();

            if (jokeDistribution == null)
            {
                //SharedHelper.LogError("Joke distribution is null");
                return(null);
            }

            var selectionName = jokeDistribution.Sample();

            selectedJoke = JokesProvider.GetJokeByName(selectionName);

            //SharedHelper.Log("GetPureFactAbouUser: selectionName " + selectionName);

            return(selectedJoke);
        }
Пример #2
0
        /// <summary>
        /// Configures when facial expressions are used
        /// </summary>
        /// <param name="item"></param>
        public void SetFacialExpression(CommItem item)
        {
            #region Get Fact Manager
            PureFacts pfManager = (PureFacts)ItemProviders.SingleOrDefault(x => x is PureFacts);
            if (pfManager == null)
            {
                SharedHelper.LogError("No manager in Facts Manager in SetFacialExpression for model " + this.Name);
                return;
            }
            #endregion

            //PureFacts and Jokes will facial expression set at this stage or by Dynamic Function
            //it updates the facial expression, if it is empty

            if (!string.IsNullOrEmpty(item.FacialExpression))
            {
                KorraModelHelper.SetFacialExpressionFlag(item.FacialExpression);
            }
            else //here in most cases we default to smile
            {
                if (item.IsReactionToUser) //default to smile on reaction
                {
                    KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking);
                }
                else
                //Handle PureFacts AboutBot
                if (item.IsPureFact && !item.IsJokePureFact)
                {
                    PureFact fact = (PureFact)pfManager.GetByName(item.Name);

                    if (fact != null && fact.Type == PureFactType.AboutBot)
                    {
                        KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking);
                    }
                }
                else
                if (item.Category == ActionsEnum.ChangeVisualAppearance)
                {
                    KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking);
                }
                else
                if (item.Category == ActionsEnum.ConvinceBuyStatement)
                {
                    KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking);
                }
                else
                if (item.Category == ActionsEnum.ExpressMentalState)
                {
                    KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking);
                }
                else
                //Hnadle Jokes (Normal or PureFacts)
                if (item.SubCategory == SuggestionsEnum.TellJoke && !item.IsJokePureFact)
                {
                    if (!item.IsJokePureFact) //Normal joke
                    {
                        Joke joke = JokesProvider.GetJokeByName(item.Name);

                        if (joke != null && !string.IsNullOrEmpty(joke.FaceExpression)) //check for custom facial expression
                        {
                            KorraModelHelper.SetFacialExpressionFlag(joke.FaceExpression);
                        }
                        else
                        {
                            KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); //default to smile
                        }
                    }
                    else //PureFact joke that had no facial expression set
                    {
                        KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); //default to smile
                    }
                }
                else
                if (item.SubCategory == SuggestionsEnum.ListenToSong ||
                    item.SubCategory == SuggestionsEnum.DoSport ||
                    item.SubCategory == SuggestionsEnum.WatchMovie ||
                    item.SubCategory == SuggestionsEnum.GoOut)
                {
                    KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking);
                }
            }
        }