Пример #1
0
        public ActionResult RemoveZoneDescriptive(string id = "", string authorize = "")
        {
            string message = string.Empty;
            string zoneId  = "";

            if (string.IsNullOrWhiteSpace(authorize))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
                string[]        values     = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries);

                if (values.Count() != 2)
                {
                    message = "You must check the proper authorize radio button first.";
                }
                else
                {
                    string type   = values[0];
                    string phrase = values[1];

                    IZone obj = LiveCache.Get <IZone>(new LiveCacheKey(typeof(IZone), id));

                    if (obj == null)
                    {
                        message = "That does not exist";
                    }
                    else
                    {
                        GrammaticalType grammaticalType    = (GrammaticalType)Enum.Parse(typeof(GrammaticalType), type);
                        ISensoryEvent   existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType &&
                                                                                             occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase));
                        zoneId = obj.BirthMark;

                        if (existingOccurrence != null)
                        {
                            obj.Descriptives.Remove(existingOccurrence);

                            if (obj.Save())
                            {
                                LoggingUtility.LogAdminCommandUsage("*WEB* - LIVE DATA - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                                message = "Delete Successful.";
                            }
                            else
                            {
                                message = "Error; Removal failed.";
                            }
                        }
                        else
                        {
                            message = "That does not exist";
                        }
                    }
                }
            }

            return(RedirectToAction("Zone", new { Message = message, birthMark = id }));
        }
Пример #2
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public ISensoryEvent GetImmediateDescription(IEntity viewer, MessagingType sensoryType)
        {
            ISensoryEvent me = GetSelf(sensoryType);

            switch (sensoryType)
            {
            case MessagingType.Audible:
            case MessagingType.Olefactory:
            case MessagingType.Psychic:
            case MessagingType.Tactile:
            case MessagingType.Taste:
                break;

            case MessagingType.Visible:
                me.Strength = GetVisibleDelta(viewer);
                me.TryModify(GetVisibleDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;
            }

            if (me.Event.Modifiers.Any())
            {
                return(me);
            }

            return(new SensoryEvent(sensoryType));
        }
Пример #3
0
        /// <summary>
        /// Render this to a look command (what something sees when it 'look's at this
        /// </summary>
        /// <returns>the output strings</returns>
        public ILexicalParagraph RenderToVisible(IEntity viewer)
        {
            short strength = GetVisibleDelta(viewer);

            ISensoryEvent me = GetSelf(MessagingType.Visible, strength);

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.Near,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Attached,
                Tense       = LexicalTense.Present
            };

            Lexica verb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "leads", collectiveContext);

            me.Event.TryModify(verb);

            return(new LexicalParagraph(me));
        }
Пример #4
0
 public LexicalParagraph(ISensoryEvent newEvent)
 {
     Events = new List <ISensoryEvent>()
     {
         newEvent
     };
     Sentences = new List <ILexicalSentence>();
 }
Пример #5
0
        public ActionResult RemoveDescriptive(long id, string authorize)
        {
            string message = string.Empty;

            if (string.IsNullOrWhiteSpace(authorize))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
                string[]        values     = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries);

                if (values.Count() != 2)
                {
                    message = "You must check the proper authorize radio button first.";
                }
                else
                {
                    short  type   = short.Parse(values[0]);
                    string phrase = values[1];

                    IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id);

                    if (obj == null)
                    {
                        message = "That does not exist";
                    }
                    else
                    {
                        GrammaticalType grammaticalType    = (GrammaticalType)type;
                        ISensoryEvent   existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType &&
                                                                                             occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase));

                        if (existingOccurrence != null)
                        {
                            obj.Descriptives.Remove(existingOccurrence);

                            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                            {
                                LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                                message = "Delete Successful.";
                            }
                            else
                            {
                                message = "Error; Removal failed.";
                            }
                        }
                        else
                        {
                            message = "That does not exist";
                        }
                    }
                }
            }

            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
Пример #6
0
        /// <summary>
        /// Render this as being show inside a container
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public ILexicalParagraph RenderAsContents(IEntity viewer, MessagingType[] sensoryTypes)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            IList <ISensoryEvent> Messages = new List <ISensoryEvent>();

            //Self becomes the first sense in the list
            foreach (MessagingType sense in sensoryTypes)
            {
                ISensoryEvent me = GetSelf(sense);
                switch (sense)
                {
                case MessagingType.Audible:
                case MessagingType.Olefactory:
                case MessagingType.Psychic:
                case MessagingType.Tactile:
                case MessagingType.Taste:
                    continue;

                case MessagingType.Visible:
                    me.Strength = GetVisibleDelta(viewer);

                    me.TryModify(GetVisibleDescriptives(viewer));

                    me.Event.Context = new LexicalContext(viewer)
                    {
                        Determinant = true,
                        Perspective = NarrativePerspective.None,
                        Plural      = false,
                        Position    = LexicalPosition.InsideOf,
                        Tense       = LexicalTense.Present
                    };

                    LexicalContext skyContext = new LexicalContext(viewer)
                    {
                        Determinant = true,
                        Perspective = NarrativePerspective.None,
                        Plural      = false,
                        Position    = LexicalPosition.None,
                        Tense       = LexicalTense.Present
                    };

                    me.TryModify(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "sky", skyContext));
                    break;
                }

                if (me.Event.Modifiers.Count() > 0)
                {
                    Messages.Add(me);
                }
            }

            return(new LexicalParagraph(Messages));
        }
Пример #7
0
        /// <summary>
        /// Render this to a look command (what something sees when it 'look's at this)
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public virtual ILexicalParagraph RenderToTouch(IEntity viewer)
        {
            ISensoryEvent self = GetSelf(MessagingType.Tactile);

            self.Strength = GetTactileDelta(viewer);
            self.TryModify(GetTouchDescriptives(viewer));

            return(new LexicalParagraph(self));
        }
Пример #8
0
        /// <summary>
        /// Render this to a look command (what something sees when it 'look's at this)
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public virtual ILexicalParagraph RenderToOlefactory(IEntity viewer)
        {
            ISensoryEvent self = GetSelf(MessagingType.Olefactory);

            self.Strength = GetOlefactoryDelta(viewer);
            self.TryModify(GetOlefactoryDescriptives(viewer));

            return(new LexicalParagraph(self));
        }
Пример #9
0
        public ActionResult AddEditDescriptive(long id, OccurrenceViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id);

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
            }

            ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role &&
                                                                               occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase));

            if (existingOccurrence == null)
            {
                existingOccurrence = new SensoryEvent(vModel.SensoryEventDataObject.SensoryType)
                {
                    Strength = vModel.SensoryEventDataObject.Strength,
                    Event    = new Lexica(vModel.SensoryEventDataObject.Event.Type,
                                          vModel.SensoryEventDataObject.Event.Role,
                                          vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null))
                    {
                        Modifiers = vModel.SensoryEventDataObject.Event.Modifiers
                    }
                };
            }
            else
            {
                existingOccurrence.Strength    = vModel.SensoryEventDataObject.Strength;
                existingOccurrence.SensoryType = vModel.SensoryEventDataObject.SensoryType;
                existingOccurrence.Event       = new Lexica(vModel.SensoryEventDataObject.Event.Type,
                                                            vModel.SensoryEventDataObject.Event.Role,
                                                            vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null))
                {
                    Modifiers = vModel.SensoryEventDataObject.Event.Modifiers
                };
            }

            obj.Descriptives.RemoveWhere(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role &&
                                         occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase));

            obj.Descriptives.Add(existingOccurrence);

            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - Room AddEditDescriptive[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
Пример #10
0
        /// <summary>
        /// Render this to a look command (what something sees when it 'look's at this
        /// </summary>
        /// <returns>the output strings</returns>
        public override ILexicalParagraph RenderToVisible(IEntity viewer)
        {
            short strength = GetVisibleDelta(viewer);

            IPathwayTemplate bS = Template <IPathwayTemplate>();
            ISensoryEvent    me = GetSelf(MessagingType.Visible, strength);

            if (bS.Descriptives.Any())
            {
                foreach (ISensoryEvent desc in bS.Descriptives)
                {
                    me.Event.TryModify(desc.Event);
                }
            }
            else
            {
                LexicalContext collectiveContext = new LexicalContext(viewer)
                {
                    Determinant = true,
                    Perspective = NarrativePerspective.SecondPerson,
                    Plural      = false,
                    Position    = LexicalPosition.Near,
                    Tense       = LexicalTense.Present
                };

                LexicalContext discreteContext = new LexicalContext(viewer)
                {
                    Determinant = true,
                    Perspective = NarrativePerspective.ThirdPerson,
                    Plural      = false,
                    Position    = LexicalPosition.Attached,
                    Tense       = LexicalTense.Present
                };

                Lexica verb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "leads", collectiveContext);

                //Fallback to using names
                if (DirectionType == MovementDirectionType.None)
                {
                    Lexica origin = new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, Origin.TemplateName, discreteContext);
                    origin.TryModify(new Lexica(LexicalType.Noun, GrammaticalType.IndirectObject, Destination.TemplateName, discreteContext));
                    verb.TryModify(origin);
                }
                else
                {
                    Lexica direction = new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, DirectionType.ToString(), discreteContext);
                    Lexica origin    = new Lexica(LexicalType.Noun, GrammaticalType.IndirectObject, Origin.TemplateName, discreteContext);
                    origin.TryModify(new Lexica(LexicalType.Noun, GrammaticalType.IndirectObject, Destination.TemplateName, discreteContext));
                    direction.TryModify(origin);
                }

                me.Event.TryModify(verb);
            }

            return(new LexicalParagraph(me));
        }
Пример #11
0
        public LexicalSentence(ISensoryEvent lex)
        {
            Modifiers = new List <Tuple <ISensoryEvent, short> >();
            Subject   = new List <Tuple <ISensoryEvent, short> >();
            Predicate = new List <Tuple <ISensoryEvent, short> >();
            Type      = SentenceType.Statement;

            SensoryType = lex.SensoryType;
            SetLanguage(lex.Event.Context?.Language);
            AddEvent(lex);
        }
Пример #12
0
        /// <summary>
        /// Fluent (returns itself), add a lexica to the sentence, sentence logic applies here
        /// </summary>
        /// <param name="lex"></param>
        /// <returns></returns>
        public ILexicalSentence AddEvent(ISensoryEvent lex, bool recursive = true)
        {
            lex.Event.Context.Language = Language;

            //Contractive rules
            IDictata lexDict = lex.Event.GetDictata();

            foreach (IContractionRule contractionRule in Language.ContractionRules.Where(rul => rul.First == lexDict || rul.Second == lexDict))
            {
                if (!lex.Event.Modifiers.Any(mod => contractionRule.First.Equals(mod.GetDictata()) || contractionRule.Second.Equals(mod.GetDictata())))
                {
                    continue;
                }

                lex.Event.Modifiers.RemoveWhere(mod => contractionRule.First.Equals(mod.GetDictata()) || contractionRule.Second.Equals(mod.GetDictata()));

                lex.Event.Phrase = contractionRule.Contraction.Name;
            }

            //Sentence placement rules
            SentenceGrammarRule rule = Language.SentenceRules.FirstOrDefault(rul => rul.Type == Type && rul.Fragment == lex.Event.Role);

            if (rule != null)
            {
                //subject
                if (rule.SubjectPredicate)
                {
                    Subject.Add(new Tuple <ISensoryEvent, short>(lex, rule.ModificationOrder));
                }
                else
                {
                    Predicate.Add(new Tuple <ISensoryEvent, short>(lex, rule.ModificationOrder));
                }
            }
            else
            {
                Modifiers.Add(new Tuple <ISensoryEvent, short>(lex, 99));
            }

            if (recursive)
            {
                HashSet <ILexica> newMods = new HashSet <ILexica>();
                foreach (ILexica mod in lex.Event.Modifiers.Where(mod => mod.Role != GrammaticalType.None && mod.Role != GrammaticalType.Descriptive))
                {
                    AddEvent(new SensoryEvent(mod, lex.Strength, lex.SensoryType));
                    newMods.Add(mod);
                }

                lex.Event.Modifiers.RemoveWhere(modi => newMods.Any(mods => mods.Equals(modi)));
            }

            return(this);
        }
Пример #13
0
        /// <summary>
        /// Write out the sentence
        /// </summary>
        /// <returns>The sentence in full string form.</returns>
        public string Describe()
        {
            if (Subject.Count + Predicate.Count <= 1)
            {
                return(string.Empty);
            }

            IEnumerable <ISensoryEvent> lexes = Unpack();
            StringBuilder sb = new StringBuilder();

            //Listable pass rules
            List <Tuple <ISensoryEvent[], int> > lexList = new List <Tuple <ISensoryEvent[], int> >();
            int i = 0;

            foreach (var lexPair in lexes.GroupBy(lexi => new { lexi.Event.Role, lexi.Event.Type, lexi.Event.Context.Position }))
            {
                IWordRule rule = Language.WordRules.OrderByDescending(rul => rul.RuleSpecificity())
                                 .FirstOrDefault(rul => rul.Matches(lexPair.First().Event));

                if (rule != null && rule.Listable)
                {
                    lexList.Add(new Tuple <ISensoryEvent[], int>(lexPair.ToArray(), rule.ModificationOrder + i++));
                }
                else
                {
                    foreach (ISensoryEvent modifier in lexPair)
                    {
                        lexList.Add(new Tuple <ISensoryEvent[], int>(new ISensoryEvent[] { modifier }, i++));
                    }
                }
            }

            foreach (Tuple <ISensoryEvent[], int> grouping in lexList.OrderBy(mod => mod.Item2))
            {
                if (grouping.Item1.Length > 1)
                {
                    sb.Append(grouping.Item1.Select(lexi => lexi.Describe()).CommaList(RenderUtility.SplitListType.OxfordComma) + " ");
                }
                else
                {
                    ISensoryEvent item = grouping.Item1[0];

                    sb.Append(item.Describe() + " ");
                }
            }

            //Ensure every sentence starts with a caps letter
            //Do punctuation
            return(string.Format("{1}{0}{2}",
                                 sb.ToString().CapsFirstLetter(true).Trim(),
                                 Language.PrecedentPunctuation ? PunctuationMark : "",
                                 Language.AntecendentPunctuation ? PunctuationMark : ""));
        }
Пример #14
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public virtual ILexicalParagraph GetFullDescription(IEntity viewer, MessagingType[] sensoryTypes = null)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            IList <ISensoryEvent> Messages = new List <ISensoryEvent>();

            //Self becomes the first sense in the list
            foreach (MessagingType sense in sensoryTypes)
            {
                ISensoryEvent self = GetSelf(sense);

                switch (sense)
                {
                case MessagingType.Audible:
                    self.Strength = GetAudibleDelta(viewer);

                    self.TryModify(GetAudibleDescriptives(viewer));
                    break;

                case MessagingType.Olefactory:
                    self.Strength = GetOlefactoryDelta(viewer);

                    self.TryModify(GetOlefactoryDescriptives(viewer));
                    break;

                case MessagingType.Psychic:
                case MessagingType.Taste:
                    break;

                case MessagingType.Tactile:
                    self.Strength = GetTactileDelta(viewer);

                    self.TryModify(GetTouchDescriptives(viewer));
                    break;

                case MessagingType.Visible:
                    self.Strength = GetVisibleDelta(viewer);

                    self.TryModify(GetVisibleDescriptives(viewer));
                    break;
                }

                if (self.Event.Modifiers.Count() > 0)
                {
                    Messages.Add(self);
                }
            }

            return(new LexicalParagraph(Messages));
        }
Пример #15
0
        public virtual ILexicalParagraph RenderResourceCollection(IEntity viewer, int amount)
        {
            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.Around,
                Tense       = LexicalTense.Present
            };

            ISensoryEvent me = GetImmediateDescription(viewer, MessagingType.Visible);

            me.TryModify(new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, amount.ToString(), collectiveContext));

            return(new LexicalParagraph(me));
        }
Пример #16
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public virtual ISensoryEvent GetImmediateDescription(IEntity viewer, MessagingType sense)
        {
            ISensoryEvent me = GetSelf(sense);

            switch (sense)
            {
            case MessagingType.Audible:
                me.Strength = GetAudibleDelta(viewer);

                me.TryModify(GetAudibleDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;

            case MessagingType.Olefactory:
                me.Strength = GetOlefactoryDelta(viewer);

                me.TryModify(GetOlefactoryDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;

            case MessagingType.Psychic:
                me.Strength = GetPsychicDelta(viewer);

                me.TryModify(GetPsychicDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;

            case MessagingType.Tactile:
                me.Strength = GetTactileDelta(viewer);

                me.TryModify(GetTouchDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;

            case MessagingType.Taste:
                me.Strength = GetTasteDelta(viewer);

                me.TryModify(GetTasteDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;

            case MessagingType.Visible:
                me.Strength = GetVisibleDelta(viewer);

                me.TryModify(GetVisibleDescriptives(viewer).Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                break;
            }

            return(me);
        }
Пример #17
0
        /// <summary>
        /// Render this as being show inside a container
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public virtual ILexicalParagraph RenderAsContents(IEntity viewer, MessagingType[] sensoryTypes)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            //Add the existential modifiers
            ISensoryEvent me = GetImmediateDescription(viewer, sensoryTypes[0]);

            me.TryModify(LexicalType.Noun, GrammaticalType.DirectObject, "ground")
            .TryModify(
                new Tuple <LexicalType, GrammaticalType, string>[] {
                new Tuple <LexicalType, GrammaticalType, string>(LexicalType.Article, GrammaticalType.IndirectObject, "in")
            }
                );

            return(new LexicalParagraph(me));
        }
Пример #18
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public override ILexicalParagraph GetFullDescription(IEntity viewer, MessagingType[] sensoryTypes = null)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.None,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Far,
                Tense       = LexicalTense.Present
            };

            //Self becomes the first sense in the list
            List <ISensoryEvent> sensoryOutput = new List <ISensoryEvent>();

            foreach (MessagingType sense in sensoryTypes)
            {
                ISensoryEvent me = GetSelf(sense);
                switch (sense)
                {
                case MessagingType.Audible:
                    me.Strength = GetAudibleDelta(viewer);

                    IEnumerable <ISensoryEvent> aDescs = GetAudibleDescriptives(viewer);

                    if (aDescs.Count() == 0)
                    {
                        continue;
                    }

                    me.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    ILexica uberSounds = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "hear", collectiveContext);
                    uberSounds.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSounds.TryModify(newDesc);
                    }

                    if (uberSounds.Modifiers.Any())
                    {
                        me.TryModify(uberSounds);
                    }

                    break;

                case MessagingType.Olefactory:
                    me.Strength = GetOlefactoryDelta(viewer);

                    IEnumerable <ISensoryEvent> oDescs = GetOlefactoryDescriptives(viewer);

                    if (oDescs.Count() == 0)
                    {
                        continue;
                    }

                    me.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    ILexica uberSmells = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "smell", collectiveContext);
                    uberSmells.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSmells.TryModify(newDesc);
                    }

                    if (uberSmells.Modifiers.Any())
                    {
                        me.TryModify(uberSmells);
                    }

                    break;

                case MessagingType.Psychic:
                    me.Strength = GetPsychicDelta(viewer);

                    IEnumerable <ISensoryEvent> pDescs = GetPsychicDescriptives(viewer);

                    if (pDescs.Count() == 0)
                    {
                        continue;
                    }

                    me.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica collectivePsy = new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext);

                    ILexica uberPsy = collectivePsy.TryModify(LexicalType.Verb, GrammaticalType.Verb, "sense");
                    uberPsy.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberPsy.TryModify(newDesc);
                    }

                    if (uberPsy.Modifiers.Any())
                    {
                        me.TryModify(collectivePsy);
                    }

                    break;

                case MessagingType.Taste:
                    continue;

                case MessagingType.Tactile:
                    me.Strength = GetTactileDelta(viewer);

                    //Add the temperature
                    me.TryModify(LexicalType.Verb, GrammaticalType.Verb, "feels").TryModify(new Lexica[] {
                        new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, MeteorologicalUtilities.ConvertHumidityToType(EffectiveHumidity()).ToString(), collectiveContext),
                        new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, MeteorologicalUtilities.ConvertTemperatureToType(EffectiveTemperature()).ToString(), collectiveContext)
                    });

                    break;

                case MessagingType.Visible:
                    me.Strength = GetVisibleDelta(viewer);

                    IEnumerable <ISensoryEvent> vDescs = GetVisibleDescriptives(viewer);

                    if (vDescs.Count() > 0)
                    {
                        me.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                        Lexica collectiveSight = new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext);

                        ILexica uberSight = collectiveSight.TryModify(LexicalType.Verb, GrammaticalType.Verb, "see");
                        uberSight.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                        foreach (ISensoryEvent desc in vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                        {
                            Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                            newDesc.TryModify(desc.Event.Modifiers);

                            uberSight.TryModify(newDesc);
                        }

                        if (uberSight.Modifiers.Any())
                        {
                            me.TryModify(collectiveSight);
                        }
                    }

                    //Describe the size and population of this zone
                    DimensionalSizeDescription zoneSize = GeographicalUtilities.ConvertSizeToType(GetModelDimensions(), GetType());

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, zoneSize.ToString());

                    //Render people in the zone
                    CrowdSizeDescription populationSize = GeographicalUtilities.GetCrowdSize(GetContents <IMobile>().Count());

                    string crowdSize = "abandoned";
                    if ((short)populationSize > (short)zoneSize)
                    {
                        crowdSize = "crowded";
                    }
                    else if (populationSize > CrowdSizeDescription.Intimate)
                    {
                        crowdSize = "sparsely populated";
                    }

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, crowdSize);

                    break;
                }

                if (me != null)
                {
                    sensoryOutput.Add(me);
                }
            }

            foreach (ICelestial celestial in GetVisibileCelestials(viewer))
            {
                sensoryOutput.AddRange(celestial.RenderAsContents(viewer, sensoryTypes).Events);
            }

            foreach (IWeatherEvent wEvent in WeatherEvents)
            {
                sensoryOutput.AddRange(wEvent.RenderAsContents(viewer, sensoryTypes).Events);
            }

            foreach (INaturalResourceSpawn <IFlora> resource in FloraNaturalResources)
            {
                sensoryOutput.AddRange(resource.Resource.RenderResourceCollection(viewer, resource.RateFactor).Events);
            }

            foreach (INaturalResourceSpawn <IFauna> resource in FaunaNaturalResources)
            {
                sensoryOutput.AddRange(resource.Resource.RenderResourceCollection(viewer, resource.RateFactor).Events);
            }

            foreach (INaturalResourceSpawn <IMineral> resource in MineralNaturalResources)
            {
                sensoryOutput.AddRange(resource.Resource.RenderResourceCollection(viewer, resource.RateFactor).Events);
            }

            //render our locales out
            foreach (ILocale locale in LiveCache.GetAll <ILocale>().Where(loc => loc.ParentLocation?.TemplateId == TemplateId))
            {
                sensoryOutput.AddRange(locale.RenderAsContents(viewer, sensoryTypes).Events);
            }

            //render our locales out
            foreach (IPathway path in GetPathways())
            {
                sensoryOutput.AddRange(path.RenderAsContents(viewer, sensoryTypes).Events);
            }

            return(new LexicalParagraph(sensoryOutput));
        }
Пример #19
0
        /// <summary>
        /// Render this as being show inside a container
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public override ILexicalParagraph RenderAsContents(IEntity viewer, MessagingType[] sensoryTypes)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.None,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Far,
                Tense       = LexicalTense.Present
            };

            List <ISensoryEvent> sensoryOutput = new List <ISensoryEvent>();

            foreach (MessagingType sense in sensoryTypes)
            {
                SensoryEvent me        = new SensoryEvent(new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext), 0, sense);
                ILexica      senseVerb = null;
                IEnumerable <ISensoryEvent> senseDescs = Enumerable.Empty <ISensoryEvent>();

                switch (sense)
                {
                case MessagingType.Audible:
                    me.Strength = GetAudibleDelta(viewer);

                    senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "hear", collectiveContext);

                    IEnumerable <ISensoryEvent> audibleDescs = GetAudibleDescriptives(viewer);

                    if (audibleDescs.Count() == 0)
                    {
                        continue;
                    }

                    ISensoryEvent audibleNoun = null;
                    if (!audibleDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject))
                    {
                        audibleNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "noise", discreteContext), me.Strength, sense);
                    }
                    else
                    {
                        audibleNoun = audibleDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject);
                    }

                    audibleNoun.TryModify(audibleDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                    senseDescs = new List <ISensoryEvent>()
                    {
                        audibleNoun
                    };
                    break;

                case MessagingType.Olefactory:
                    me.Strength = GetOlefactoryDelta(viewer);

                    senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "smell", collectiveContext);

                    IEnumerable <ISensoryEvent> smellDescs = GetOlefactoryDescriptives(viewer);

                    if (smellDescs.Count() == 0)
                    {
                        continue;
                    }

                    ISensoryEvent smellNoun = null;
                    if (!smellDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject))
                    {
                        smellNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "odor", discreteContext), me.Strength, sense);
                    }
                    else
                    {
                        smellNoun = smellDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject);
                    }

                    smellNoun.TryModify(smellDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                    senseDescs = new List <ISensoryEvent>()
                    {
                        smellNoun
                    };
                    break;

                case MessagingType.Psychic:
                    me.Strength = GetPsychicDelta(viewer);

                    senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "sense", collectiveContext);

                    IEnumerable <ISensoryEvent> psyDescs = GetPsychicDescriptives(viewer);

                    if (psyDescs.Count() == 0)
                    {
                        continue;
                    }

                    ISensoryEvent psyNoun = null;
                    if (!psyDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject))
                    {
                        psyNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "presence", discreteContext), me.Strength, sense);
                    }
                    else
                    {
                        psyNoun = psyDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject);
                    }

                    psyNoun.TryModify(psyDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                    senseDescs = new List <ISensoryEvent>()
                    {
                        psyNoun
                    };
                    break;

                case MessagingType.Tactile:
                case MessagingType.Taste:
                    continue;

                case MessagingType.Visible:
                    me.Strength = GetVisibleDelta(viewer);

                    senseVerb = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "see", collectiveContext);

                    IEnumerable <ISensoryEvent> seeDescs = GetVisibleDescriptives(viewer);

                    if (seeDescs.Count() == 0)
                    {
                        continue;
                    }

                    ISensoryEvent seeNoun = null;
                    if (!seeDescs.Any(desc => desc.Event.Role == GrammaticalType.DirectObject))
                    {
                        seeNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "thing", discreteContext), me.Strength, sense);
                    }
                    else
                    {
                        seeNoun = seeDescs.FirstOrDefault(desc => desc.Event.Role == GrammaticalType.DirectObject);
                    }

                    seeNoun.TryModify(seeDescs.Where(desc => desc.Event.Role == GrammaticalType.Descriptive));
                    senseDescs = new List <ISensoryEvent>()
                    {
                        seeNoun
                    };
                    break;
                }

                if (senseVerb != null && senseDescs.Count() > 0)
                {
                    IEnumerable <ILexica> senseEvents = senseDescs.Select(desc => desc.Event);

                    foreach (ILexica evt in senseEvents)
                    {
                        evt.Context = discreteContext;
                        senseVerb.TryModify(evt);
                    }

                    me.TryModify(senseVerb);
                    sensoryOutput.Add(me);
                }
            }

            return(new LexicalParagraph(sensoryOutput));
        }
Пример #20
0
        /// <summary>
        /// Render a natural resource collection to a viewer
        /// </summary>
        /// <param name="viewer">the entity looking</param>
        /// <param name="amount">How much of it there is</param>
        /// <returns>a view string</returns>
        public override ILexicalParagraph RenderResourceCollection(IEntity viewer, int amount)
        {
            if (amount <= 0)
            {
                return(new LexicalParagraph());
            }

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.None,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Attached,
                Tense       = LexicalTense.Present
            };
            string sizeWord;

            if (amount < 20)
            {
                sizeWord = "sparse";
            }
            else if (amount < 50)
            {
                sizeWord = "small";
            }
            else if (amount < 200)
            {
                sizeWord = "";
            }
            else
            {
                sizeWord = "vast";
            }

            SensoryEvent observer = new SensoryEvent(new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext), 0, MessagingType.Visible)
            {
                Strength = GetVisibleDelta(viewer)
            };

            SensoryEvent collectiveNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.DirectObject, "forest", collectiveContext),
                                                           GetVisibleDelta(viewer), MessagingType.Visible);

            ISensoryEvent me = GetSelf(MessagingType.Visible, GetVisibleDelta(viewer));

            me.Event.Role = GrammaticalType.Descriptive;

            collectiveNoun.TryModify(me);

            SensoryEvent senseVerb = new SensoryEvent(new Lexica(LexicalType.Verb, GrammaticalType.Verb, "see", collectiveContext), me.Strength, MessagingType.Visible);

            if (!string.IsNullOrWhiteSpace(sizeWord))
            {
                collectiveNoun.TryModify(new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, sizeWord, discreteContext));
            }

            senseVerb.TryModify(collectiveNoun);
            observer.TryModify(senseVerb);

            return(new LexicalParagraph(observer));
        }
Пример #21
0
 /// <summary>
 /// Try to add a modifier to a lexica
 /// </summary>
 /// <param name="modifier">the lexica that is the modifier</param>
 /// <returns>Whether or not it succeeded</returns>
 public ILexica TryModify(ISensoryEvent modifier, bool passthru = false)
 {
     return(TryModify(modifier.Event, passthru));
 }
Пример #22
0
        /// <summary>
        /// Render a natural resource collection to a viewer
        /// </summary>
        /// <param name="viewer">the entity looking</param>
        /// <param name="amount">How much of it there is</param>
        /// <returns>a view string</returns>
        public override ILexicalParagraph RenderResourceCollection(IEntity viewer, int amount)
        {
            if (amount <= 0)
            {
                return(new LexicalParagraph());
            }

            LexicalContext personalContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.Around,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.None,
                Tense       = LexicalTense.Present
            };

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = false,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.PartOf,
                Tense       = LexicalTense.Present
            };
            string sizeWord;

            if (amount < 20)
            {
                sizeWord = "sparse";
            }
            else if (amount < 50)
            {
                sizeWord = "small";
            }
            else if (amount < 200)
            {
                sizeWord = "";
            }
            else
            {
                sizeWord = "large";
            }

            SensoryEvent collectiveNoun = new SensoryEvent(new Lexica(LexicalType.Noun, GrammaticalType.Subject, Race.CollectiveNoun, discreteContext),
                                                           GetVisibleDelta(viewer), MessagingType.Visible);

            ISensoryEvent me = GetSelf(MessagingType.Visible, GetVisibleDelta(viewer));

            me.Event.Role    = GrammaticalType.Descriptive;
            me.Event.Context = collectiveContext;

            collectiveNoun.TryModify(me);

            if (!string.IsNullOrWhiteSpace(sizeWord))
            {
                collectiveNoun.TryModify(new Lexica(LexicalType.Adjective, GrammaticalType.Descriptive, sizeWord, discreteContext));
            }

            Lexica observer = new Lexica(LexicalType.Pronoun, GrammaticalType.DirectObject, "you", personalContext);

            collectiveNoun.TryModify(new Lexica(LexicalType.Verb, GrammaticalType.Verb, "roams", personalContext).TryModify(observer, true));

            return(new LexicalParagraph(collectiveNoun));
        }
Пример #23
0
        /// <summary>
        /// Render this in a short descriptive style
        /// </summary>
        /// <param name="viewer">The entity looking</param>
        /// <returns>the output strings</returns>
        public override ILexicalParagraph GetFullDescription(IEntity viewer, MessagingType[] sensoryTypes = null)
        {
            if (sensoryTypes == null || sensoryTypes.Count() == 0)
            {
                sensoryTypes = new MessagingType[] { MessagingType.Audible, MessagingType.Olefactory, MessagingType.Psychic, MessagingType.Tactile, MessagingType.Taste, MessagingType.Visible };
            }

            LexicalContext collectiveContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.SecondPerson,
                Plural      = false,
                Position    = LexicalPosition.Around,
                Tense       = LexicalTense.Present
            };

            LexicalContext discreteContext = new LexicalContext(viewer)
            {
                Determinant = true,
                Perspective = NarrativePerspective.ThirdPerson,
                Plural      = false,
                Position    = LexicalPosition.Attached,
                Tense       = LexicalTense.Present
            };

            //Self becomes the first sense in the list
            List <ISensoryEvent> messages = new List <ISensoryEvent>();

            foreach (MessagingType sense in sensoryTypes)
            {
                ISensoryEvent me = GetSelf(sense);

                switch (sense)
                {
                case MessagingType.Audible:
                    me.Strength = GetAudibleDelta(viewer);

                    IEnumerable <ISensoryEvent> aDescs = GetAudibleDescriptives(viewer);

                    me.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    ILexica uberSounds = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "hear", collectiveContext);
                    uberSounds.TryModify(aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in aDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.Subject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        me.TryModify(newDesc);
                    }

                    if (uberSounds.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberSounds);
                    }

                    break;

                case MessagingType.Olefactory:
                    me.Strength = GetOlefactoryDelta(viewer);

                    IEnumerable <ISensoryEvent> oDescs = GetOlefactoryDescriptives(viewer);

                    me.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberSmells = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "smell", collectiveContext);
                    uberSmells.TryModify(oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in oDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSmells.TryModify(newDesc);
                    }

                    if (uberSmells.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberSmells);
                    }

                    break;

                case MessagingType.Psychic:
                    me.Strength = GetPsychicDelta(viewer);

                    IEnumerable <ISensoryEvent> pDescs = GetPsychicDescriptives(viewer);

                    me.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica collectivePsy = new Lexica(LexicalType.Pronoun, GrammaticalType.Subject, "you", collectiveContext);

                    ILexica uberPsy = collectivePsy.TryModify(LexicalType.Verb, GrammaticalType.Verb, "sense");
                    uberPsy.TryModify(pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in pDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberPsy.TryModify(newDesc);
                    }

                    if (uberPsy.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(collectivePsy);
                    }

                    break;

                case MessagingType.Taste:
                    me.Strength = GetTasteDelta(viewer);

                    IEnumerable <ISensoryEvent> taDescs = GetTasteDescriptives(viewer);

                    me.TryModify(taDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberTaste = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "taste", collectiveContext);
                    uberTaste.TryModify(taDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in taDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberTaste.TryModify(newDesc);
                    }

                    if (uberTaste.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberTaste);
                    }

                    break;

                case MessagingType.Tactile:
                    me.Strength = GetTactileDelta(viewer);

                    IEnumerable <ISensoryEvent> tDescs = GetOlefactoryDescriptives(viewer);

                    me.TryModify(tDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberTouch = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "feel", collectiveContext);
                    uberTouch.TryModify(tDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in tDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberTouch.TryModify(newDesc);
                    }

                    if (uberTouch.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberTouch);
                    }

                    break;

                case MessagingType.Visible:
                    me.Strength = GetVisibleDelta(viewer);

                    IEnumerable <ISensoryEvent> vDescs = GetVisibleDescriptives(viewer);

                    me.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Descriptive));

                    Lexica uberSight = new Lexica(LexicalType.Verb, GrammaticalType.Verb, "appears", collectiveContext);
                    uberSight.TryModify(vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.DirectObject).Select(adesc => adesc.Event));

                    foreach (ISensoryEvent desc in vDescs.Where(adesc => adesc.Event.Role == GrammaticalType.Subject))
                    {
                        Lexica newDesc = new Lexica(desc.Event.Type, GrammaticalType.DirectObject, desc.Event.Phrase, discreteContext);
                        newDesc.TryModify(desc.Event.Modifiers);

                        uberSight.TryModify(newDesc);
                    }

                    if (uberSight.Modifiers.Any(mod => mod.Role == GrammaticalType.Subject))
                    {
                        me.TryModify(uberSight);
                    }

                    //Describe the size and population of this zone
                    DimensionalSizeDescription objectSize = GeographicalUtilities.ConvertSizeToType(GetModelDimensions(), GetType());

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, objectSize.ToString());

                    //Render people in the zone
                    ObjectContainmentSizeDescription bulgeSizeAdjective = GeographicalUtilities.GetObjectContainmentSize(GetContents <IInanimate>().Sum(obj => obj.GetModelVolume()), GetModelVolume());

                    me.TryModify(LexicalType.Adjective, GrammaticalType.Descriptive, bulgeSizeAdjective.ToString());

                    break;
                }

                messages.Add(me);
            }

            return(new LexicalParagraph(messages));
        }
Пример #24
0
        /// <summary>
        /// Add an event to the cluster
        /// </summary>
        /// <param name="newEvent">the event to add</param>
        /// <returns>Fluent response</returns>
        public ILexicalParagraph AddEvent(ISensoryEvent newEvent)
        {
            Events.Add(newEvent);

            return(this);
        }