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 })); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Simply send a sensory event to the glancer; If they can see it, they'll get the output. var sender = actionInput.Controller; var message = new SensoryMessage(SensoryType.Sight, 100, this.BuildGlance(sender.Thing)); var sensoryEvent = new SensoryEvent(sender.Thing, message); sender.Thing.Eventing.OnMiscellaneousEvent(sensoryEvent, EventScope.SelfOnly); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Simply send a sensory event to the glancer; If they can see it, they'll get the output. var actor = actionInput.Actor; var message = new SensoryMessage(SensoryType.Sight, 100, BuildGlance(actor)); var sensoryEvent = new SensoryEvent(actor, message); actor.Eventing.OnMiscellaneousEvent(sensoryEvent, EventScope.SelfOnly); }
/// <summary> /// Executes the command. /// </summary> /// <remarks>Verify that the Guards pass first.</remarks> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { IController sender = actionInput.Controller; var contextMessage = new ContextualString(sender.Thing, sender.Thing) { ToOriginator = "You have entered the combat state.", ToReceiver = "You see $Aggressor.Name shift into a combat stance.", ToOthers = "You see $Aggressor.Name shift into a combat stance.", }; var sm = new SensoryMessage(SensoryType.Debug, 100, contextMessage); var senseEvent = new SensoryEvent(sender.Thing, sm); }
/// <summary>Executes the command.</summary> /// <remarks>Verify that the Guards pass first.</remarks> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { var actor = actionInput.Actor; var contextMessage = new ContextualString(actor, null) { ToOriginator = "You have entered the combat state.", ToReceiver = $"You see {actor.Name} shift into a combat stance.", ToOthers = $"You see {actor.Name} shift into a combat stance.", }; var sm = new SensoryMessage(SensoryType.Debug, 100, contextMessage); var senseEvent = new SensoryEvent(actor, sm); actor.Eventing.OnMiscellaneousEvent(senseEvent, EventScope.ParentsDown); }
/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { // Simply send a sensory event to the glancer; if they can see it, they'll get the output. // @@@ TODO: For advanced scenarios, this might want to somehow restrict the event from cascading; // IE if a tiny pixie character is inside a human player's backpack, they shouldn't receive // the human player's glance output. (As is the event cascades and all Children get it too). // Alternatively, the sense processor can look at the ActiveThing and the sense type to decide // whether to echo the output; IE said pixie might still get Sound-based simple sensory event // output even though they aren't in the same location; they may hear it through the backpack. // @@@ Actually, BuildGlance might cause the print to only occur to the sender anyway due to the // usage of ContextualStringUsage.OnlyWhenBeingPassedToReceiver; needs testing! IController sender = actionInput.Controller; var message = new SensoryMessage(SensoryType.Sight, 100, this.BuildGlance(sender.Thing)); var sensoryEvent = new SensoryEvent(sender.Thing, message); sender.Thing.Eventing.OnMiscellaneousEvent(sensoryEvent, EventScope.SelfDown); }
/// <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)); }
/// <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)); }
/// <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)); }