public ActionResult Edit(long id, AddEditPathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(id); if (obj == null) { return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", vModel)); } obj.Name = vModel.DataObject.Name; obj.DegreesFromNorth = vModel.DataObject.DegreesFromNorth; obj.InclineGrade = vModel.DataObject.InclineGrade; obj.Origin = vModel.DataObject.Origin; obj.Destination = vModel.DataObject.Destination; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditPathwayTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { message = "Error; Edit failed."; } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
public ActionResult EditLocalePathway(long id, AddEditZonePathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(id); if (obj == null) { message = "That does not exist"; return(RedirectToAction("Edit", new { Message = message, id })); } obj.Name = vModel.DataObject.Name; obj.DegreesFromNorth = vModel.DataObject.DegreesFromNorth; obj.InclineGrade = vModel.DataObject.InclineGrade; obj.Destination = TemplateCache.Get <IRoomTemplate>(vModel.DestinationRoom.Id); if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditPathwayTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { message = "Error; Edit failed."; } return(RedirectToAction("Edit", new { Message = message, obj.Origin.Id })); }
/// <summary> /// News up an entity with its backing data /// </summary> /// <param name="backingStore">the backing data</param> public Pathway(IPathwayTemplate backingStore) { Enter = new Message(); TemplateId = backingStore.Id; DirectionType = Utilities.TranslateToDirection(backingStore.DegreesFromNorth, backingStore.InclineGrade); GetFromWorldOrSpawn(); }
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]; IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(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()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(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* - Pathway AddEditDescriptive[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { message = "Error; Edit failed."; } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
public ActionResult Edit(int id) { string message = string.Empty; IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id); if (obj == null) { message = "That does not exist"; return(RedirectToRoute("ErrorOrClose", new { Message = message })); } AddEditRoomTemplateViewModel vModel = new AddEditRoomTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidZones = TemplateCache.GetAll <IZoneTemplate>(), ValidLocales = TemplateCache.GetAll <ILocaleTemplate>().Where(locale => locale.Id != obj.ParentLocation.Id), ValidLocaleRooms = TemplateCache.GetAll <IRoomTemplate>().Where(room => room.Id != obj.Id && room.ParentLocation.Id == obj.ParentLocation.Id), ValidRooms = TemplateCache.GetAll <IRoomTemplate>().Where(room => room.Id != obj.Id), ValidModels = TemplateCache.GetAll <IDimensionalModelData>(), DataObject = obj, }; IPathwayTemplate zoneDestination = obj.GetZonePathways().FirstOrDefault(); if (zoneDestination != null) { vModel.ZonePathway = zoneDestination; } else { vModel.ZonePathway = new PathwayTemplate() { Destination = obj.ParentLocation.ParentLocation, Origin = obj }; } IPathwayTemplate localeRoomPathway = obj.GetLocalePathways().FirstOrDefault(); if (localeRoomPathway != null) { vModel.LocaleRoomPathway = localeRoomPathway; vModel.LocaleRoomPathwayDestinationLocale = ((IRoomTemplate)localeRoomPathway.Destination).ParentLocation; vModel.ValidLocaleRooms = TemplateCache.GetAll <IRoomTemplate>().Where(room => localeRoomPathway.Id == room.ParentLocation.Id); } else { vModel.LocaleRoomPathway = new PathwayTemplate() { Origin = obj }; vModel.LocaleRoomPathwayDestinationLocale = new LocaleTemplate(); } return(View("~/Views/GameAdmin/Room/Edit.cshtml", "_chromelessLayout", vModel)); }
public ActionResult Add(long id, long originRoomId, long destinationRoomId, int degreesFromNorth = 0, int incline = 0) { //New room or existing room if (destinationRoomId.Equals(-1)) { IRoomTemplate origin = TemplateCache.Get <IRoomTemplate>(originRoomId); AddPathwayWithRoomTemplateViewModel vModel = new AddPathwayWithRoomTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = TemplateCache.GetAll <IRoomTemplate>(), Origin = origin, DataObject = new PathwayTemplate() { DegreesFromNorth = degreesFromNorth, InclineGrade = incline }, Destination = new RoomTemplate() { ParentLocation = origin.ParentLocation } }; vModel.Destination.ParentLocation = vModel.Origin.ParentLocation; return(View("~/Views/GameAdmin/Pathway/AddWithRoom.cshtml", "_chromelessLayout", vModel)); } else { IRoomTemplate origin = TemplateCache.Get <IRoomTemplate>(originRoomId); IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(destinationRoomId); IPathwayTemplate pathwayTemplate = TemplateCache.Get <IPathwayTemplate>(id); if (pathwayTemplate == null) { pathwayTemplate = new PathwayTemplate() { Origin = origin, Destination = destination, DegreesFromNorth = degreesFromNorth, InclineGrade = incline }; } AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = TemplateCache.GetAll <IRoomTemplate>().Where(rm => !rm.Id.Equals(originRoomId)), DataObject = pathwayTemplate }; return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", "_chromelessLayout", vModel)); } }
/// <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)); }
public ActionResult AddWithRoom(AddPathwayWithRoomTemplateViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IRoomTemplate origin = TemplateCache.Get <IRoomTemplate>(vModel.Origin.Id); IRoomTemplate newRoom = vModel.Destination; newRoom.ParentLocation = origin.ParentLocation; string message = string.Empty; if (newRoom.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) != null) { IPathwayTemplate newObj = vModel.DataObject; newObj.Destination = newRoom; newObj.Origin = origin; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { if (vModel.CreateReciprocalPath) { PathwayTemplate reversePath = new PathwayTemplate { Name = newObj.Name, DegreesFromNorth = Utilities.ReverseDirection(newObj.DegreesFromNorth), Origin = newObj.Destination, Destination = newObj.Origin, Model = newObj.Model, InclineGrade = newObj.InclineGrade * -1 }; if (reversePath.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Reverse Path creation FAILED. Origin path creation SUCCESS."; } } LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathwayWithRoom[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } } else { message = "Error; Creation failed."; } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
/// <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) { //We can't even try this until we know if the data is there IPathwayTemplate bS = Template <IPathwayTemplate>() ?? throw new InvalidOperationException("Missing backing data store on pathway spawn event."); Keywords = new string[] { bS.Name.ToLower(), DirectionType.ToString().ToLower() }; if (string.IsNullOrWhiteSpace(BirthMark)) { BirthMark = LiveCache.GetUniqueIdentifier(bS); Birthdate = DateTime.Now; } DegreesFromNorth = bS.DegreesFromNorth; InclineGrade = bS.InclineGrade; DirectionType = Utilities.TranslateToDirection(DegreesFromNorth, InclineGrade); Descriptives = bS.Descriptives; //paths need two locations if (bS.Origin.GetType() == typeof(RoomTemplate)) { Origin = ((IRoomTemplate)bS.Origin).GetLiveInstance(); } else { Origin = ((IZoneTemplate)bS.Origin).GetLiveInstance(); } if (bS.Destination.GetType() == typeof(RoomTemplate)) { Destination = ((IRoomTemplate)bS.Destination).GetLiveInstance(); } else { Destination = ((IZoneTemplate)bS.Destination).GetLiveInstance(); } CurrentLocation = (IGlobalPosition)Origin.CurrentLocation.Clone(); Model = bS.Model; //Enter = new Message(new string[] { bS.MessageToActor }, new string[] { "$A$ enters you" }, new string[] { }, new string[] { bS.MessageToOrigin }, new string[] { bS.MessageToDestination }); //Enter.ToSurrounding.Add(MessagingType.Visible, new Tuple<int, IEnumerable<string>>(bS.VisibleStrength, new string[] { bS.VisibleToSurroundings })); //Enter.ToSurrounding.Add(MessagingType.Audible, new Tuple<int, IEnumerable<string>>(bS.AudibleStrength, new string[] { bS.AudibleToSurroundings })); UpsertToLiveWorldCache(true); Save(); }
public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "") { AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()) }; if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(removeId); if (obj == null) { } else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - RemovePathway[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { } } else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove)) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(unapproveId); if (obj == null) { } else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned)) { LoggingUtility.LogAdminCommandUsage("*WEB* - UnapprovePathway[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { } } else { } return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", vModel)); }
public ActionResult Add(AddEditPathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate newObj = vModel.DataObject; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathway[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
/// <summary> /// Gets a room in a direction if there is one based on the world map the room belongs to /// </summary> /// <param name="origin">The room we're starting in</param> /// <param name="direction">The direction we're moving in</param> /// <returns>null or a RoomTemplate</returns> public static ILocationData GetLocationInDirection(ILocationData origin, MovementDirectionType direction) { //We can't find none directions on a map if (origin == null || direction == MovementDirectionType.None) { return(null); } IEnumerable <IPathwayTemplate> paths = origin.GetPathways(); IPathwayTemplate dirPath = paths.FirstOrDefault(path => path.DirectionType == direction); if (dirPath != null) { return(dirPath.Destination); } return(null); }
public ActionResult AddEditLocalePath(long id, long localeId) { ILocaleTemplate locale = TemplateCache.Get <ILocaleTemplate>(localeId); if (locale == null) { return(RedirectToAction("Edit", new { Message = "Locale is invalid.", id })); } IEnumerable <IRoomTemplate> validRooms = TemplateCache.GetAll <IRoomTemplate>().Where(rm => rm.ParentLocation.Equals(locale)); if (validRooms.Count() == 0) { return(RedirectToAction("Edit", new { Message = "Locale has no rooms.", id })); } IZoneTemplate origin = TemplateCache.Get <IZoneTemplate>(id); IPathwayTemplate existingPathway = origin.GetLocalePathways().FirstOrDefault(path => ((IRoomTemplate)path.Destination).ParentLocation.Equals(locale)); AddEditZonePathwayTemplateViewModel vModel = new AddEditZonePathwayTemplateViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), ValidMaterials = TemplateCache.GetAll <IMaterial>(), ValidModels = TemplateCache.GetAll <IDimensionalModelData>().Where(model => model.ModelType == DimensionalModelType.Flat), ValidRooms = validRooms, }; if (existingPathway != null) { vModel.DataObject = existingPathway; vModel.DestinationRoom = (IRoomTemplate)existingPathway.Destination; } else { vModel.DataObject = new PathwayTemplate() { Origin = origin }; } return(View("~/Views/GameAdmin/Zone/AddEditLocalePath.cshtml", vModel)); }
//We have to render our pathway out, an empty space for the potential pathway back and the destination room private static long[,,] AddDirectionToMap(long[,,] dataMap, MovementDirectionType transversalDirection, IRoomTemplate origin, int diameter, int centerX, int centerY, int centerZ, HashSet <IRoomTemplate> roomPool) { IEnumerable <IPathwayTemplate> pathways = origin.GetPathways(true); Tuple <int, int, int> directionalSteps = Utilities.GetDirectionStep(transversalDirection); int xStepped = centerX + directionalSteps.Item1; int yStepped = centerY + directionalSteps.Item2; int zStepped = centerZ + directionalSteps.Item3; //If we're not over diameter budget and there is nothing there already (we might have already rendered the path and room) then render it //When the next room tries to render backwards it'll run into the existant path it came from and stop the chain here if (xStepped > 0 && xStepped <= diameter && yStepped > 0 && yStepped <= diameter && zStepped > 0 && zStepped <= diameter && dataMap[xStepped - 1, yStepped - 1, zStepped - 1] < 0) { IPathwayTemplate thisPath = pathways.FirstOrDefault(path => (path.DirectionType == transversalDirection && path.Origin.Equals(origin) && path.Destination.EntityClass.GetInterfaces().Contains(typeof(IRoom))) || (path.DirectionType == Utilities.ReverseDirection(transversalDirection) && path.Destination.Equals(origin) && path.Origin.EntityClass.GetInterfaces().Contains(typeof(IRoom))) ); if (thisPath != null) { long locId = thisPath.Destination.Id; if (thisPath.Destination.Id.Equals(origin.Id)) { locId = thisPath.Origin.Id; } IRoomTemplate passdownOrigin = TemplateCache.Get <IRoomTemplate>(locId); if (passdownOrigin != null) { dataMap[xStepped - 1, yStepped - 1, zStepped - 1] = passdownOrigin.Id; dataMap = AddFullRoomToMap(dataMap, passdownOrigin, diameter, xStepped, yStepped, zStepped, roomPool); } } } return(dataMap); }
public ActionResult AddEditDescriptive(long id, short descriptiveType, string phrase) { string message = string.Empty; IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(id); if (obj == null) { message = "That pathway does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } OccurrenceViewModel vModel = new OccurrenceViewModel { AuthedUser = UserManager.FindById(User.Identity.GetUserId()), DataObject = obj, AdminTypeName = "Pathway" }; 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/Pathway/SensoryEvent.cshtml", "_chromelessLayout", vModel)); }
/// <summary> /// Gets the opposite room from the origin based on direction /// </summary> /// <param name="origin">The room we're looking to oppose</param> /// <param name="direction">The direction the room would be in (this method will reverse the direction itself)</param> /// <returns>The room that is in the direction from our room</returns> public static IRoomTemplate GetOpposingRoom(IRoomTemplate origin, MovementDirectionType direction) { //There is no opposite of none directionals if (origin == null || direction == MovementDirectionType.None) { return(null); } MovementDirectionType oppositeDirection = ReverseDirection(direction); System.Collections.Generic.IEnumerable <IPathwayTemplate> paths = TemplateCache.GetAll <IPathwayTemplate>(); IPathwayTemplate ourPath = paths.FirstOrDefault(pt => origin.Equals(pt.Destination) && pt.DirectionType == oppositeDirection); if (ourPath != null) { return((IRoomTemplate)ourPath.Destination); } return(null); }
public ActionResult AddLocalePathway(long id, AddEditZonePathwayTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IZoneTemplate obj = TemplateCache.Get <IZoneTemplate>(id); IPathwayTemplate newObj = vModel.DataObject; newObj.Destination = TemplateCache.Get <IRoomTemplate>(vModel.DestinationRoom.Id); newObj.Origin = obj; if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathway[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToAction("Edit", new { Message = message, id })); }
private static string RenderPathwayToAsciiForModals(IPathwayTemplate path, long originId, MovementDirectionType directionType, bool forAdmin = false) { string returnValue = string.Empty; string asciiCharacter = Utilities.TranslateDirectionToAsciiCharacter(directionType); long destinationId = -1; string destinationName = string.Empty; PathwayType pathType = PathwayType.None; if (path != null && path.Destination != null) { destinationName = path.Destination.Name; destinationId = path.Destination.Id; pathType = path.Type; } if (forAdmin) { if (path != null) { if (pathType == PathwayType.Rooms) { returnValue = string.Format("<a href='#' class='editData pathway AdminEditPathway' pathwayId='{0}' fromRoom='{3}' toRoom='{4}' title='Edit - {5} path to {1}' data-id='{0}'>{2}</a>", path.Id, destinationName, asciiCharacter, originId, destinationId, directionType.ToString()); } else { string classString = "zone"; if (pathType == PathwayType.Locale) { classString = "locale"; } returnValue = string.Format("<a class='pathway {4}' title='{5}: {3} to {1}' data-id='{0}'>{2}</a>", path.Id, destinationName, asciiCharacter, directionType.ToString(), classString, path.Name); } } else { string roomString = string.Format("Add - {0} path and room", directionType.ToString()); if (!string.IsNullOrWhiteSpace(destinationName)) { roomString = string.Format("Add {0} path to {1}", directionType.ToString(), destinationName); } returnValue = string.Format("<a href='#' class='addData pathway AdminAddPathway' pathwayId='-1' fromRoom='{0}' toRoom='{4}' data-direction='{1}' data-incline='{2}' title='{3}'>+</a>", originId, Utilities.TranslateDirectionToDegrees(directionType).Item1, Utilities.GetBaseInclineGrade(directionType), roomString, destinationId); } } else if (path != null) { if (pathType == PathwayType.Rooms) { returnValue = string.Format("<a href='#' class='pathway nonAdminPathway' title='{3}: {1}{4} to {2}{5}' data-id='{6}'>{0}</a>", asciiCharacter, directionType, destinationName, path.Name, originId, destinationId, path.Id); } else { string classString = "zone"; if (pathType == PathwayType.Locale) { classString = "locale"; } returnValue = string.Format("<a class='pathway {4}' title='{5}: {3} to {1}' data-id='{0}'>{2}</a>", path.Id, destinationName, asciiCharacter, directionType.ToString(), classString, path.Name); } } return(returnValue); }
public ActionResult Add(long localeId, AddEditRoomTemplateViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); ILocaleTemplate locale = TemplateCache.Get <ILocaleTemplate>(localeId); IRoomTemplate newObj = vModel.DataObject; newObj.ParentLocation = locale; newObj.Coordinates = new Coordinate(0, 0, 0); //TODO: fix this IPathwayTemplate zoneDestination = null; if (vModel.ZonePathway?.Destination != null && !string.IsNullOrWhiteSpace(vModel.ZonePathway.Name)) { IZoneTemplate destination = TemplateCache.Get <IZoneTemplate>(vModel.ZonePathway.Destination.Id); zoneDestination = new PathwayTemplate() { DegreesFromNorth = -1, Name = vModel.ZonePathway.Name, Origin = newObj, Destination = destination, InclineGrade = vModel.ZonePathway.InclineGrade, Model = vModel.ZonePathway.Model }; } IPathwayTemplate localeRoomPathway = null; if (vModel.LocaleRoomPathwayDestination != null && !string.IsNullOrWhiteSpace(vModel.LocaleRoomPathwayDestination.Name)) { IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(vModel.LocaleRoomPathwayDestination.Id); localeRoomPathway = new PathwayTemplate() { DegreesFromNorth = vModel.LocaleRoomPathway.DegreesFromNorth, Name = vModel.LocaleRoomPathway.Name, Origin = newObj, Destination = destination, InclineGrade = vModel.LocaleRoomPathway.InclineGrade, Model = vModel.LocaleRoomPathway.Model }; } if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { if (zoneDestination != null) { zoneDestination.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } if (localeRoomPathway != null) { localeRoomPathway.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } message = "Error; Creation failed."; } else { LoggingUtility.LogAdminCommandUsage("*WEB* - AddRoomTemplate[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); }
private static string[,] RenderRoomAndPathwaysForMapNode(int x, int y, IRoomTemplate RoomTemplate, IRoomTemplate centerRoom, string[,] expandedMap, bool currentRoom, bool forAdmin, MapRenderMode renderMode) { IEnumerable <IPathwayTemplate> pathways = RoomTemplate.GetPathways(); int expandedRoomX = x * 3 + 1; int expandedRoomY = y * 3 + 1; switch (renderMode) { case MapRenderMode.Normal: IPathwayTemplate ePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.East); IPathwayTemplate nPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.North); IPathwayTemplate nePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.NorthEast); IPathwayTemplate nwPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.NorthWest); IPathwayTemplate sPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.South); IPathwayTemplate sePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.SouthEast); IPathwayTemplate swPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.SouthWest); IPathwayTemplate wPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.West); //The room expandedMap[expandedRoomX, expandedRoomY] = RenderRoomToAscii(RoomTemplate, RoomTemplate.GetZonePathways().Any(), RoomTemplate.GetLocalePathways().Any() , !forAdmin && currentRoom, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(nwPath, RoomTemplate.Id, MovementDirectionType.NorthWest, forAdmin); expandedMap[expandedRoomX, expandedRoomY + 1] = RenderPathwayToAsciiForModals(nPath, RoomTemplate.Id, MovementDirectionType.North, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(nePath, RoomTemplate.Id, MovementDirectionType.NorthEast, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY] = RenderPathwayToAsciiForModals(wPath, RoomTemplate.Id, MovementDirectionType.West, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY] = RenderPathwayToAsciiForModals(ePath, RoomTemplate.Id, MovementDirectionType.East, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(swPath, RoomTemplate.Id, MovementDirectionType.SouthWest, forAdmin); expandedMap[expandedRoomX, expandedRoomY - 1] = RenderPathwayToAsciiForModals(sPath, RoomTemplate.Id, MovementDirectionType.South, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(sePath, RoomTemplate.Id, MovementDirectionType.SouthEast, forAdmin); break; case MapRenderMode.Upwards: IPathwayTemplate upPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.Up); IPathwayTemplate upePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpEast); IPathwayTemplate upnPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpNorth); IPathwayTemplate upnePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpNorthEast); IPathwayTemplate upnwPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpNorthWest); IPathwayTemplate upsPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpSouth); IPathwayTemplate upsePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpSouthEast); IPathwayTemplate upswPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpSouthWest); IPathwayTemplate upwPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.UpWest); expandedMap[expandedRoomX, expandedRoomY] = RenderPathwayToAsciiForModals(upPath, RoomTemplate.Id, MovementDirectionType.Up, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(upnwPath, RoomTemplate.Id, MovementDirectionType.UpNorthWest, forAdmin); expandedMap[expandedRoomX, expandedRoomY + 1] = RenderPathwayToAsciiForModals(upnPath, RoomTemplate.Id, MovementDirectionType.UpNorth, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(upnePath, RoomTemplate.Id, MovementDirectionType.UpNorthEast, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY] = RenderPathwayToAsciiForModals(upwPath, RoomTemplate.Id, MovementDirectionType.UpWest, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY] = RenderPathwayToAsciiForModals(upePath, RoomTemplate.Id, MovementDirectionType.UpEast, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(upswPath, RoomTemplate.Id, MovementDirectionType.UpSouthWest, forAdmin); expandedMap[expandedRoomX, expandedRoomY - 1] = RenderPathwayToAsciiForModals(upsPath, RoomTemplate.Id, MovementDirectionType.UpSouth, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(upsePath, RoomTemplate.Id, MovementDirectionType.UpSouthEast, forAdmin); break; case MapRenderMode.Downwards: IPathwayTemplate downPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.Down); IPathwayTemplate downePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownEast); IPathwayTemplate downnPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownNorth); IPathwayTemplate downnePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownNorthEast); IPathwayTemplate downnwPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownNorthWest); IPathwayTemplate downsPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownSouth); IPathwayTemplate downsePath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownSouthEast); IPathwayTemplate downswPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownSouthWest); IPathwayTemplate downwPath = pathways.FirstOrDefault(path => path.DirectionType == MovementDirectionType.DownWest); expandedMap[expandedRoomX, expandedRoomY] = RenderPathwayToAsciiForModals(downPath, RoomTemplate.Id, MovementDirectionType.Down, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(downnwPath, RoomTemplate.Id, MovementDirectionType.DownNorthWest, forAdmin); expandedMap[expandedRoomX, expandedRoomY + 1] = RenderPathwayToAsciiForModals(downnPath, RoomTemplate.Id, MovementDirectionType.DownNorth, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY + 1] = RenderPathwayToAsciiForModals(downnePath, RoomTemplate.Id, MovementDirectionType.DownNorthEast, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY] = RenderPathwayToAsciiForModals(downwPath, RoomTemplate.Id, MovementDirectionType.DownWest, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY] = RenderPathwayToAsciiForModals(downePath, RoomTemplate.Id, MovementDirectionType.DownEast, forAdmin); expandedMap[expandedRoomX - 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(downswPath, RoomTemplate.Id, MovementDirectionType.DownSouthWest, forAdmin); expandedMap[expandedRoomX, expandedRoomY - 1] = RenderPathwayToAsciiForModals(downsPath, RoomTemplate.Id, MovementDirectionType.DownSouth, forAdmin); expandedMap[expandedRoomX + 1, expandedRoomY - 1] = RenderPathwayToAsciiForModals(downsePath, RoomTemplate.Id, MovementDirectionType.DownSouthEast, forAdmin); break; } return(expandedMap); }
public ActionResult Edit(int id, AddEditRoomTemplateViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IPathwayTemplate zoneDestination = null; IPathwayTemplate localeRoomPathway = null; IRoomTemplate obj = TemplateCache.Get <IRoomTemplate>(id); if (obj == null) { string message = "That does not exist"; return(RedirectToRoute("ModalErrorOrClose", new { Message = message })); } obj.Name = vModel.DataObject.Name; obj.Medium = vModel.DataObject.Medium; obj.Qualities = vModel.DataObject.Qualities; if (vModel.ZonePathway?.Destination != null && !string.IsNullOrWhiteSpace(vModel.ZonePathway.Name)) { IZoneTemplate destination = TemplateCache.Get <IZoneTemplate>(vModel.ZonePathway.Destination.Id); zoneDestination = obj.GetZonePathways().FirstOrDefault(); if (zoneDestination == null) { zoneDestination = new PathwayTemplate() { DegreesFromNorth = vModel.ZonePathway.DegreesFromNorth, Name = vModel.ZonePathway.Name, Origin = obj, Destination = destination, InclineGrade = vModel.ZonePathway.InclineGrade, Model = vModel.ZonePathway.Model }; } else { zoneDestination.Model = vModel.ZonePathway.Model; zoneDestination.Name = vModel.ZonePathway.Name; zoneDestination.InclineGrade = vModel.ZonePathway.InclineGrade; //We switched zones, this makes things more complicated if (zoneDestination.Id != vModel.ZonePathway.Destination.Id) { zoneDestination.Destination = destination; } } } if (vModel.LocaleRoomPathwayDestination != null && !string.IsNullOrWhiteSpace(vModel.LocaleRoomPathwayDestination.Name)) { IRoomTemplate destination = TemplateCache.Get <IRoomTemplate>(vModel.LocaleRoomPathwayDestination.Id); localeRoomPathway = obj.GetLocalePathways().FirstOrDefault(); if (localeRoomPathway == null) { localeRoomPathway = new PathwayTemplate() { DegreesFromNorth = vModel.LocaleRoomPathway.DegreesFromNorth, Name = vModel.LocaleRoomPathway.Name, Origin = obj, Destination = destination, InclineGrade = vModel.LocaleRoomPathway.InclineGrade, Model = vModel.LocaleRoomPathway.Model }; } else { localeRoomPathway.Model = vModel.LocaleRoomPathway.Model; localeRoomPathway.Name = vModel.LocaleRoomPathway.Name; localeRoomPathway.InclineGrade = vModel.LocaleRoomPathway.InclineGrade; localeRoomPathway.Destination = destination; } } if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { if (zoneDestination != null) { zoneDestination.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } if (localeRoomPathway != null) { localeRoomPathway.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)); } LoggingUtility.LogAdminCommandUsage("*WEB* - EditRoomTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); } else { } return(RedirectToRoute("ModalErrorOrClose")); }