public static void WakePlayer(IHubContext context, PlayerSetup.Player player, Room.Room room) { if (player.Status == PlayerSetup.Player.PlayerStatus.Sleeping) { player.Status = PlayerSetup.Player.PlayerStatus.Standing; context.SendToClient("You wake and stand up", player.HubGuid); foreach (var character in room?.players) { if (player != character) { var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wakes and stands up."; context.SendToClient(roomMessage, character.HubGuid); } } if (!string.IsNullOrEmpty(room.EventWake)) { Event.ParseCommand(room.EventWake, player, null, room, "wake"); } foreach (var mob in room.mobs) { if (!string.IsNullOrEmpty(mob.EventWake)) { Event.ParseCommand(mob.EventWake, player, mob, room, "wake"); } } Command.ParseCommand("look", player, room); CheckEvent.FindEvent(CheckEvent.EventType.Wake, player, "awakening awake"); } else { context.SendToClient("You are already awake", player.HubGuid); } }
/// <summary> /// Wears an item /// </summary> /// <param name="player">The Player</param> /// <param name="itemToWear">Item to wear</param> public static void WearItem(Player player, string itemToWear, bool wield = false) { var room = Cache.getRoom(player); if (string.IsNullOrEmpty(itemToWear)) { HubContext.SendToClient("Wear what?", player.HubGuid); return; } var oldPlayer = player; if (!itemToWear.Equals("all", StringComparison.CurrentCultureIgnoreCase)) { var findObject = Events.FindNth.Findnth(itemToWear); int nth = findObject.Key; string itemToFind = findObject.Value; var foundItem = FindItem.Item(player.Inventory, nth, itemToFind, Item.ItemLocation.Inventory); // player.Inventory.Find(i => i.name.ToLower().Contains(itemToWear.ToLower())); if (foundItem == null) { if (wield) { HubContext.SendToClient("You do not have that item to wield.", player.HubGuid); return; } HubContext.SendToClient("You do not have that item to wear.", player.HubGuid); return; } foundItem.location = Item.ItemLocation.Worn; var slot = Enum.GetName(typeof(Item.EqSlot), foundItem.slot); //TODO: WTF is this? var eqLocation = player.Equipment.GetType().GetProperty(slot); if (slot == null) { return; } // Log error? What the hell is eqLocation? var hasValue = eqLocation.GetValue(player.Equipment); if (hasValue.ToString() != "Nothing") { RemoveItem(player, hasValue.ToString(), true); } eqLocation.SetValue(player.Equipment, foundItem.name); if (foundItem.ArmorRating != null) { player.ArmorRating += foundItem.ArmorRating.Armour; } if (!wield || !slot.Equals(Item.EqSlot.Wielded.ToString())) { HubContext.SendToClient("You wear " + foundItem.name, player.HubGuid); var result = AvsAnLib.AvsAn.Query(foundItem.name); string article = result.Article; foreach (var character in room.players) { if (player != character) { var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wears {article} {foundItem.name}"; HubContext.SendToClient(roomMessage, character.HubGuid); } } //Wear event CheckEvent.FindEvent(CheckEvent.EventType.Wear, player, foundItem.name); } else { HubContext.SendToClient("You wield " + foundItem.name, player.HubGuid); var result = AvsAnLib.AvsAn.Query(foundItem.name); string article = result.Article; foreach (var character in room.players) { if (player != character) { var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wields {article} {foundItem.name}"; HubContext.SendToClient(roomMessage, character.HubGuid); } } } Score.UpdateUiInventory(player); Score.ReturnScoreUI(player); } else { var listOfItemsWorn = string.Empty; foreach (var item in player.Inventory.Where(x => x.location.Equals(Item.ItemLocation.Inventory))) { if (item.location == Item.ItemLocation.Inventory && item.equipable == true) { var slot = Enum.GetName(typeof(Item.EqSlot), item.slot); //TODO: WTF is this? if (slot != null) { var eqLocation = player.Equipment.GetType().GetProperty(slot); if (eqLocation != null) { var hasValue = eqLocation.GetValue(player.Equipment); if (hasValue.ToString() != "Nothing") { RemoveItem(player, hasValue.ToString(), true); } } item.location = Item.ItemLocation.Worn; eqLocation.SetValue(player.Equipment, item.name); if (item.ArmorRating != null) { player.ArmorRating += item.ArmorRating.Armour; } listOfItemsWorn += $" {item.name}"; if (!wield || !slot.Equals("wield", StringComparison.CurrentCultureIgnoreCase)) { var result = AvsAnLib.AvsAn.Query(item.name); string article = result.Article; HubContext.SendToClient("You wear " + article + item.name, player.HubGuid); foreach (var character in room.players) { if (player != character) { var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wears {article} {item.name}"; HubContext.SendToClient(roomMessage, character.HubGuid); } } } else { var result = AvsAnLib.AvsAn.Query(item.name); string article = result.Article; HubContext.SendToClient("You wield " + article + item.name, player.HubGuid); foreach (var character in room.players) { if (player != character) { var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wields {article} {item.name}"; HubContext.SendToClient(roomMessage, character.HubGuid); } } } } } } CheckEvent.FindEvent(CheckEvent.EventType.Wear, player, listOfItemsWorn); } Score.UpdateUiInventory(player); Score.ReturnScoreUI(player); Cache.updatePlayer(player, oldPlayer); }