Exemple #1
0
        /// <summary>
        /// Generates a random sentence.
        /// </summary>
        /// <returns></returns>
        public static string RandomSentence()
        {
            string text;

            NounType noun = Table[MUDMath.NumberRange(0, Table.Length - 1)];
            VerbType verb = VerbType.Table[MUDMath.NumberRange(0, VerbType.Table.Length - 1)];

            while (noun.Animate == false)
            {
                noun = Table[MUDMath.NumberRange(0, Table.Length - 1)];
            }

            if (MUDMath.NumberPercent() > 50)
            {
                if (MUDString.IsVowel(noun.Name))
                {
                    text = String.Format("An ");
                }
                else
                {
                    text = String.Format("A ");
                }
            }
            else
            {
                text = String.Format("The ");
            }

            text += noun.Name;
            text += " ";
            text += verb.Name;
            if (verb.DirectObject != VerbType.DirectObjectType.none)
            {
                noun = Table[MUDMath.NumberRange(0, Table.Length - 1)];

                if (MUDString.IsVowel(noun.Name))
                {
                    text += " an ";
                }
                else
                {
                    text += " a ";
                }

                text += noun.Name;
            }

            if (MUDMath.NumberPercent() > 80)
            {
                text += "!";
            }
            else
            {
                text += ".";
            }

            return(text);
        }