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]; INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(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 })); }
public ActionResult AddEditDescriptive(long id, OccurrenceViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(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* - NonPlayerCharacter AddEditDescriptive[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { message = "Error; Edit failed."; } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
/// <summary> /// Gets the actual vision modifier taking into account blindness and other factors /// </summary> /// <returns>the working modifier</returns> public override ValueRange <float> GetVisualRange() { INonPlayerCharacterTemplate dT = Template <INonPlayerCharacterTemplate>(); int returnTop = 1; int returnBottom = 100; //TODO: Check for blindess/magical type affects return(new ValueRange <float>(returnTop, returnBottom)); }
public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "") { string message; if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(removeId); if (obj == null) { message = "That does not exist"; } else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveNPC[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Delete Successful."; } else { message = "Error; Removal failed."; } } else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(unapproveId); if (obj == null) { message = "That does not exist"; } else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned)) { LoggingUtility.LogAdminCommandUsage("*WEB* - UnapproveNPC[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Unapproval Successful."; } else { message = "Error; Unapproval failed."; } } else { message = "You must check the proper remove or unapprove authorization radio button first."; } return(RedirectToAction("Index", new { Message = message })); }
/// <summary> /// News up an entity with its backing data and where to spawn it into /// </summary> /// <param name="backingStore">the backing data</param> /// <param name="spawnTo">where to spawn this into</param> public NonPlayerCharacter(INonPlayerCharacterTemplate backingStore, IGlobalPosition spawnTo) { Inventory = new EntityContainer <IInanimate>(); Qualities = new HashSet <IQuality>(); WillPurchase = new HashSet <IMerchandise>(); WillSell = new HashSet <IMerchandise>(); InventoryRestock = new HashSet <MerchandiseStock>(); TemplateId = backingStore.Id; TeachableProficencies = new HashSet <IQuality>(); Hypothalamus = new Brain(); Race = new Race(); SpawnNewInWorld(spawnTo); }
public ActionResult Edit(int id, string ArchivePath = "") { INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(id); if (obj == null) { return(RedirectToAction("Index", new { Message = "That does not exist" })); } AddEditNPCDataViewModel vModel = new AddEditNPCDataViewModel(ArchivePath, obj) { AuthedUser = UserManager.FindById(User.Identity.GetUserId()) }; return(View("~/Views/GameAdmin/NPC/Edit.cshtml", vModel)); }
public ActionResult Add(AddEditNPCDataViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); INonPlayerCharacterTemplate newObj = vModel.DataObject; string message; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddNPCData[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } return(RedirectToAction("Index", new { Message = message })); }
/// <summary> /// Executes this command /// </summary> internal override bool ExecutionBody() { INonPlayerCharacterTemplate newObject = (INonPlayerCharacterTemplate)Subject; List <string> sb = new List <string>(); IGlobalPosition spawnTo; //No target = spawn to room you're in if (Target != null) { spawnTo = (IGlobalPosition)Target; } else { spawnTo = OriginLocation; } INonPlayerCharacter entityObject = Activator.CreateInstance(newObject.EntityClass, new object[] { newObject, spawnTo }) as INonPlayerCharacter; //TODO: keywords is janky, location should have its own identifier name somehow for output purposes - DISPLAY short/long NAME sb.Add(string.Format("{0} spawned to {1}", entityObject.TemplateName, spawnTo.CurrentZone.Keywords[0])); ILexicalParagraph toActor = new LexicalParagraph(sb.ToString()); ILexicalParagraph toOrigin = new LexicalParagraph("$S$ appears suddenly."); ILexicalParagraph toSubject = new LexicalParagraph("You are ALIVE"); IMessage messagingObject = new Message(toActor) { ToOrigin = new List <ILexicalParagraph> { toOrigin }, ToSubject = new List <ILexicalParagraph> { toSubject } }; messagingObject.ExecuteMessaging(Actor, entityObject, spawnTo.CurrentZone, OriginLocation.CurrentZone, null); return(true); }
public ActionResult AddEditDescriptive(long id, short descriptiveType, string phrase) { string message = string.Empty; INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(id); if (obj == null) { message = "That zone does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } OccurrenceViewModel vModel = new OccurrenceViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = obj, AdminTypeName = "NPC" }; if (descriptiveType > -1) { GrammaticalType grammaticalType = (GrammaticalType)descriptiveType; vModel.SensoryEventDataObject = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType && occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase)); } if (vModel.SensoryEventDataObject != null) { vModel.LexicaDataObject = vModel.SensoryEventDataObject.Event; } else { vModel.SensoryEventDataObject = new SensoryEvent { Event = new Lexica() }; } return(View("~/Views/GameAdmin/NPC/SensoryEvent.cshtml", "_chromelessLayout", vModel)); }
/// <summary> /// Spawn this new into the live world into a specified container /// </summary> /// <param name="spawnTo">the location/container this should spawn into</param> public override void SpawnNewInWorld(IGlobalPosition position) { INonPlayerCharacterTemplate bS = Template <INonPlayerCharacterTemplate>() ?? throw new InvalidOperationException("Missing backing data store on NPC spawn event."); Keywords = bS.Keywords; if (string.IsNullOrWhiteSpace(BirthMark)) { BirthMark = LiveCache.GetUniqueIdentifier(bS); Birthdate = DateTime.Now; } CurrentHealth = bS.TotalHealth; CurrentStamina = bS.TotalStamina; Qualities = bS.Qualities; TotalHealth = bS.TotalHealth; TotalStamina = bS.TotalStamina; Race = bS.Race; Personality = bS.Personality; SurName = bS.SurName; Gender = bS.Gender; WillPurchase = bS.WillPurchase; WillSell = bS.WillSell; InventoryRestock = bS.InventoryRestock; TeachableProficencies = bS.TeachableProficencies; TryMoveTo(position); if (CurrentLocation == null) { throw new NotImplementedException("Objects can't spawn to nothing"); } UpsertToLiveWorldCache(true); KickoffProcesses(); }
public ActionResult Edit(int id, AddEditNPCDataViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); INonPlayerCharacterTemplate obj = TemplateCache.Get <INonPlayerCharacterTemplate>(id); string message; if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", new { Message = message })); } obj.Name = vModel.DataObject.Name; obj.SurName = vModel.DataObject.SurName; obj.Gender = vModel.DataObject.Gender; obj.Race = vModel.DataObject.Race; obj.Personality = vModel.DataObject.Personality; obj.Qualities = vModel.DataObject.Qualities; obj.InventoryRestock = vModel.DataObject.InventoryRestock; obj.TeachableProficencies = vModel.DataObject.TeachableProficencies; obj.WillPurchase = vModel.DataObject.WillPurchase; obj.WillSell = vModel.DataObject.WillSell; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditNPCData[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return(RedirectToAction("Index", new { Message = message })); }