/// <summary> /// Displays room desc, players, mobs, items and exits /// </summary> /// <param name="room"></param> /// <param name="playerName"></param> /// <returns></returns> public static string DisplayRoom(Room room, string playerName) { string roomTitle = room.title; string roomDescription = room.description; var exitList = string.Empty; foreach (var exit in room.exits) { exitList += exit.name + (exit.name == "East" || exit.name == "West" ? " - " : " - ") + Helpers.FirstLetterToUpper(Startup.ReturnRooms.FirstOrDefault(x => x.areaId == exit.areaId && x.area == exit.area && x.region == exit.region).title) + "\r\n"; } var player = room.players.FirstOrDefault(x => x.Name.Equals(playerName)); if (player != null && player.Status == Player.PlayerStatus.Sleeping) { return("You can't see anything while asleep."); } var itemList = string.Empty; foreach (var item in room.items) { if (item != null) { if (item.itemFlags?.Contains(Item.Item.ItemFlags.invis) == true && player.DetectInvis == false || item.itemFlags?.Contains(Item.Item.ItemFlags.hidden) == true && player.DetectHidden == false) { continue; } if (!item.isHiddenInRoom) { var result = AvsAnLib.AvsAn.Query(item.name); string article = result.Article; if (!string.IsNullOrEmpty(item.description?.room)) { if (item.count > 0) { itemList += $"<p class='roomItems'>({item.count}) {item.description.room}<p>"; } else { itemList += $"<p class='roomItems'>{item.description.room}<p>"; } } else { if (item.count > 0) { itemList += $"<p class='roomItems'>({item.count}) {article} {item.name}'s are on the floor here.<p>"; } else { itemList += $"<p class='roomItems'>{article} {item.name} is on the floor here.<p>"; } } } } } var playerList = string.Empty; if (room.players != null) { foreach (var item in room.players) { if (item.invis == true && player.DetectInvis == false || item.hidden == true && player.DetectHidden == false) { continue; } if (item.nonDectect == true) { continue; } if (item.Effects?.FirstOrDefault( x => x.Name.Equals("Hidden", StringComparison.CurrentCultureIgnoreCase)) != null) { continue; } if (item.Name != playerName) { if (item.Status == Player.PlayerStatus.Standing) { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is here.</p>"; } else if (item.Status == Player.PlayerStatus.Fighting) { if (item.Target.Name == player.Name) { playerList += "<p>You are fighting " + item.Target.Name + "</p>"; } else { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is fighting " + item.Target.Name + "</p>"; } } else if (item.Status == Player.PlayerStatus.Stunned) { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is stunned.</p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Resting) { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is resting here.</p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is sleeping here.</p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Mounted) { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is here riding " + Helpers.ReturnName(null, null, item.Mount.Name).ToLower() + ".</p>"; } else { playerList += "<p>" + LoadRoom.ShowObjectEffects(item) + " is here.</p>"; } } } } var mobList = string.Empty; if (room.mobs != null) { foreach (var item in room.mobs) { if (item.invis == true && player.DetectInvis == false || item.hidden == true && player.DetectHidden == false) { continue; } if (item.nonDectect == true) { continue; } var result = AvsAnLib.AvsAn.Query(item.Name); string article = result.Article; if (item.KnownByName) { article = string.Empty; } var npcName = !string.IsNullOrEmpty(item.NPCLongName) ? item.NPCLongName : $"{item.Name} is here"; if (item.Status == Player.PlayerStatus.Standing) { mobList += $"{Helpers.FirstLetterToUpper(article)} {npcName}.\r\n"; } else if (item.Status == Player.PlayerStatus.Fighting) { mobList += $"{article} {item.Name} is fighting {item.Target.Name}.\r\n"; } else if (item.Status == Player.PlayerStatus.Stunned) { mobList += article + " " + item.Name + " is stunned. \r\n"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Resting) { mobList += article + " " + item.Name + " is resting. \r\n"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { if (!string.IsNullOrEmpty(item.Pose)) { mobList += item.Pose + "\r\n"; } else { mobList += article + " " + item.Name + " is sleeping. \r\n"; } } else { mobList += article + " " + npcName + "\r\n"; } } } string displayRoom = $"<p class='roomTitle'>{roomTitle}<p><p class='roomDescription'>{roomDescription}</p> <pre class='RoomExits'>Exits: \r\n{exitList.ToLower()}</pre> {itemList} {playerList} <pre class='roomMob'>{mobList}</pre>"; return(displayRoom); }
/// <summary> /// Displays room desc, players, mobs, items and exits /// </summary> /// <param name="room"></param> /// <param name="playerName"></param> /// <returns></returns> public static string DisplayRoom(Room room, string playerName) { string roomTitle = room.title; string roomDescription = room.description; var exitList = string.Empty; foreach (var exit in room.exits) { exitList += exit.name + " "; } var player = room.players.FirstOrDefault(x => x.Name.Equals(playerName)); var itemList = string.Empty; ////clean items //var conciseList = new List<Item.Item>(); //foreach (var item in room.items) //{ // if (conciseList.FirstOrDefault(x => x.name.Equals(item.name)) == null) // { // conciseList.Add(item); // } // else // { // var getItem = conciseList.FirstOrDefault(x => x.Equals(item)); // if (getItem != null) // { // getItem.count += 1; // } // } //} ////clean items foreach (var item in room.items) { if (item != null) { if (item.itemFlags?.Contains(Item.Item.ItemFlags.invis) == true && player.DetectInvis == false || item.itemFlags?.Contains(Item.Item.ItemFlags.hidden) == true && player.DetectHidden == false) { continue; } if (!item.isHiddenInRoom) { var result = AvsAnLib.AvsAn.Query(item.name); string article = result.Article; if (!string.IsNullOrEmpty(item.description?.room)) { if (item.count > 0) { itemList += $"<p class='roomItems'>({item.count}) {item.description.room}<p>"; } else { itemList += $"<p class='roomItems'>{item.description.room}<p>"; } } else { if (item.count > 0) { itemList += $"<p class='roomItems'>({item.count}) {item.name} are on the floor here.<p>"; } else { itemList += $"<p class='roomItems'>{article} {item.name} is on the floor here.<p>"; } } } } } var playerList = string.Empty; if (room.players != null) { foreach (var item in room.players) { if (item.invis == true && player.DetectInvis == false || item.hidden == true && player.DetectHidden == false) { continue; } if (item.nonDectect == true) { continue; } if (item.Name != playerName) { if (item.Status == Player.PlayerStatus.Standing) { playerList += LoadRoom.ShowObjectEffects(item) + " is here\r\n"; } else if (item.Status == Player.PlayerStatus.Fighting) { playerList += LoadRoom.ShowObjectEffects(item) + " is fighting " + item.Target.Name + "\r\n"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Resting) { playerList += LoadRoom.ShowObjectEffects(item) + " is resting."; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { playerList += LoadRoom.ShowObjectEffects(item) + " is sleeping."; } else { playerList += LoadRoom.ShowObjectEffects(item) + " is here\r\n"; } } } } var mobList = string.Empty; if (room.mobs != null) { foreach (var item in room.mobs) { if (item.invis == true && player.DetectInvis == false || item.hidden == true && player.DetectHidden == false) { continue; } if (item.nonDectect == true) { continue; } var result = AvsAnLib.AvsAn.Query(item.Name); string article = result.Article; if (item.KnownByName) { article = string.Empty; } if (item.Status == Player.PlayerStatus.Standing) { mobList += "<p class='roomItems'>" + article + " " + item.Name + " is here.<p>"; } else if (item.Status == Player.PlayerStatus.Fighting) { mobList += "<p class='roomItems'>" + article + " " + item.Name + " is fighting " + item.Target.Name + "</p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Resting) { mobList += "<p class='roomItems'>" + article + " " + item.Name + " is resting.<p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { mobList += "<p class='roomItems'>" + article + " " + item.Name + " is sleeping.<p>"; } else { mobList += "<p class='roomItems'>" + article + " " + item.Name + " is here.<p>"; } } } string displayRoom = "<p class='roomTitle'>" + roomTitle + "<p><p class='roomDescription'>" + roomDescription + "</p> <p class='RoomExits'>[ Exits: " + exitList.ToLower() + " ]</p>" + itemList + "\r\n" + playerList + "\r\n" + mobList; // Score.UpdateUiRoom(room.players.FirstOrDefault(x => x.Name.Equals(playerName)), displayRoom); return(displayRoom); }
/// <summary> /// Displays room desc, players, mobs, items and exits /// </summary> /// <param name="room"></param> /// <param name="playerName"></param> /// <returns></returns> public static string DisplayRoom(Room room, string playerName) { string roomTitle = room.title; string roomDescription = room.description; var exitList = string.Empty; foreach (var exit in room.exits) { exitList += exit.name + " "; } var player = room.players.FirstOrDefault(x => x.Name.Equals(playerName)); if (player != null && player.Status == Player.PlayerStatus.Sleeping) { return("You can't see anything while asleep."); } var itemList = string.Empty; foreach (var item in room.items) { if (item != null) { if (item.itemFlags?.Contains(Item.Item.ItemFlags.invis) == true && player.DetectInvis == false || item.itemFlags?.Contains(Item.Item.ItemFlags.hidden) == true && player.DetectHidden == false) { continue; } if (!item.isHiddenInRoom) { var result = AvsAnLib.AvsAn.Query(item.name); string article = result.Article; if (!string.IsNullOrEmpty(item.description?.room)) { if (item.count > 0) { itemList += $"<p class='roomItems'>({item.count}) {item.description.room}<p>"; } else { itemList += $"<p class='roomItems'>{item.description.room}<p>"; } } else { if (item.count > 0) { itemList += $"<p class='roomItems'>({item.count}) {item.name} are on the floor here.<p>"; } else { itemList += $"<p class='roomItems'>{article} {item.name} is on the floor here.<p>"; } } } } } var playerList = string.Empty; if (room.players != null) { foreach (var item in room.players) { if (item.invis == true && player.DetectInvis == false || item.hidden == true && player.DetectHidden == false) { continue; } if (item.nonDectect == true) { continue; } if (item.Name != playerName) { if (item.Status == Player.PlayerStatus.Standing) { playerList += LoadRoom.ShowObjectEffects(item) + " is here\r\n"; } else if (item.Status == Player.PlayerStatus.Fighting) { if (item.Target.Name == player.Name) { playerList += "You are fighting " + item.Target.Name + "\r\n"; } else { playerList += LoadRoom.ShowObjectEffects(item) + " is fighting " + item.Target.Name + "\r\n"; } } else if (item.Status == PlayerSetup.Player.PlayerStatus.Resting) { playerList += LoadRoom.ShowObjectEffects(item) + " is resting."; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { playerList += LoadRoom.ShowObjectEffects(item) + " is sleeping."; } else { playerList += LoadRoom.ShowObjectEffects(item) + " is here\r\n"; } } } } var mobList = string.Empty; if (room.mobs != null) { foreach (var item in room.mobs) { if (item.invis == true && player.DetectInvis == false || item.hidden == true && player.DetectHidden == false) { continue; } if (item.nonDectect == true) { continue; } var result = AvsAnLib.AvsAn.Query(item.Name); string article = result.Article; if (item.KnownByName) { article = string.Empty; } var npcName = !string.IsNullOrEmpty(item.NPCLongName) ?item.NPCLongName : $"{item.Name} is here"; if (item.Status == Player.PlayerStatus.Standing) { mobList += "<p class='roomMob'>" + article + " " + npcName + ".<p>"; } else if (item.Status == Player.PlayerStatus.Fighting) { mobList += "<p class='roomMob'>" + article + " " + item.Name + " is fighting " + item.Target.Name + ".</p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Resting) { mobList += "<p class='roomMob'>" + article + " " + item.Name + " is resting.<p>"; } else if (item.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { if (!string.IsNullOrEmpty(item.Pose)) { mobList += "<p class='roomMob'>" + item.Pose + "<p>"; } else { mobList += "<p class='roomMob'>" + article + " " + item.Name + " is sleeping.<p>"; } } else { mobList += "<p class='roomMob'>" + article + " " + npcName + "<p>"; } } } string displayRoom = "<p class='roomTitle'>" + roomTitle + "<p><p class='roomDescription'>" + roomDescription + "</p> <p class='RoomExits'>[ Exits: " + exitList.ToLower() + " ]</p>" + itemList + "\r\n" + playerList + "\r\n" + mobList; return(displayRoom); }