public static void DropItemInRoom(Character.Models.Character player, Room.Models.Room room, InventoryItem itemToDrop) { player.Attributes.CarriedItemsCount -= 1; room.RoomItems.InventoryItems.Add(itemToDrop); AttributeHandler.UpdatePlayerAttributesFromInventoryItem(player, itemToDrop, true); player.CarriedItems.Remove(itemToDrop); }
public static void DropItemInRoom(Character.Models.Character player, Room.Models.Room room, InventoryItem itemBeingDropped) { AttributeHandler.UpdatePlayerAttributesFromInventoryItem(player, itemBeingDropped, true); player.Attributes.CarriedItemsCount -= itemBeingDropped.InventorySpaceConsumed; room.RoomItems.InventoryItems.Add(itemBeingDropped); player.CarriedItems.Remove(itemBeingDropped); }
public static void DropWeaponAndPickupNew(Character.Models.Character player, Room.Models.Room room, WeaponItem weaponToAddToPlayer) { room.RoomItems.WeaponItems.Add(player.WeaponItem); AttributeHandler.UpdatePlayerAttributesFromWeaponItem(player, player.WeaponItem, true); AttributeHandler.UpdatePlayerAttributesFromWeaponItem(player, weaponToAddToPlayer); weaponToAddToPlayer.InOriginalLocation = false; player.WeaponItem = weaponToAddToPlayer; room.RoomItems.WeaponItems.Remove(weaponToAddToPlayer); }
// This is the main game loop, and only stops when the player enters a 'null' room private static void TheAdventure(Character.Models.Character player, Room.Models.Room room) { var currentRoom = room; while (true) { currentRoom = RoomHandler.EnterRoom(player, currentRoom); if (currentRoom == null) { break; } } }
public static void PrintExitsToConsole(Models.Character player, Room.Models.Room currentRoom, bool animate = true) { var exits = StringDescriptionBuilder.CreateStringOfExitDescriptions(player, currentRoom.AvailableExits); if (animate) { Console.WriteLine(); TypingAnimation.Animate(exits, Color.Red); } else { Console.WriteLine(exits, Color.Red); } }
public static void PrintWeaponsToConsole(Models.Character player, Room.Models.Room currentRoom, bool animate = true) { var weapons = StringDescriptionBuilder.CreateStringOfWeaponDescriptions(player, currentRoom.RoomItems.WeaponItems); if (animate) { Console.WriteLine(); TypingAnimation.Animate(weapons == "" ? ConsoleStrings.NoWeaponsFound + "\n" : weapons, Color.Aquamarine); } else { Console.WriteLine(weapons == "" ? ConsoleStrings.NoWeaponsFound + "\n" : weapons, Color.Aquamarine); } }
// This is the main game loop, and only stops when the player goes into a 'null' room (or saves) public static void TheAdventure(Character.Models.Character player, Room.Models.Room room, bool firstRoomEntered) { var firstRoom = firstRoomEntered; var currentRoom = room; while (true) { currentRoom = RoomHandler.EnterRoom(player, currentRoom, firstRoom); firstRoom = false; if (currentRoom == null) { break; } if (currentRoom.RoomName == ConsoleStrings.SaveGame) { SaveGame(); break; } } }
public static InventoryItem HandleItemTrade(Character.Models.Character player, Character.Models.Character character, Items foundItem, Room.Models.Room currentRoom) { if (foundItem.InventoryItems.Any()) { AttributeHandler.UpdatePlayerAttributesFromInventoryItem(player, foundItem.InventoryItems.First(), true); player.Attributes.CarriedItemsCount -= foundItem.InventoryItems.First().InventorySpaceConsumed; character.CarriedItems.Add(foundItem.InventoryItems.First()); player.CarriedItems.Remove(foundItem.InventoryItems.First()); if (character.DesiredItem != null && player.Attributes.CarriedItemsCount + character.OfferedItem.InventorySpaceConsumed <= player.Attributes.MaximumCarryingCapacity) { AttributeHandler.UpdatePlayerAttributesFromInventoryItem(player, character.OfferedItem); player.Attributes.CarriedItemsCount += character.OfferedItem.InventorySpaceConsumed; player.CarriedItems.Add(character.OfferedItem); character.CarriedItems.Remove(character.OfferedItem); character.DesiredItem = new InventoryItem(); return(character.OfferedItem); } } return(new InventoryItem { ItemName = "" }); }
public static bool HandlePlayerTradingItem(string fullInput, Character.Models.Character player, Room.Models.Room currentRoom, string inputWord, bool inputResolved) { if (currentRoom.RoomCharacters.Any()) { var substring = PlayerActionHandler.CreateSubstringOfActionInput(fullInput, inputWord); var character = RoomHandler.FindAnyMatchingCharacterByKeywords(substring.Trim(), currentRoom); var inventoryKeywords = GetAllInventoryItemKeywords(player); var foundItem = FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem> { player.WeaponItem }); if (foundItem != null && character != null) { if (GiveItemIsOk(player, character, foundItem)) { var tradedItem = HandleItemTrade(player, character, foundItem, currentRoom); if (!string.IsNullOrEmpty(tradedItem.ItemName)) { TypingAnimation.Animate("\nYou give the " + foundItem.InventoryItems.First().ItemName + " to " + character.Name + ".\n" + character.Name + " gives you the " + tradedItem.ItemName + ".\n", Color.Gold); } else { TypingAnimation.Animate("Your inventory is full... You cannot take the " + tradedItem.ItemName + ".\n", Color.DarkOliveGreen); } inputResolved = true; } else { Colorful.Console.WriteLine(); TypingAnimation.Animate(character.Name + " doesn't want that item.\n", Color.DarkOliveGreen); inputResolved = true; } } } else { Colorful.Console.WriteLine("\nThere is no one here to give that to...", Color.DarkOliveGreen); inputResolved = true; } return(inputResolved); }
public static void DropWeaponInRoom(Character.Models.Character player, Room.Models.Room room) { room.RoomItems.WeaponItems.Add(player.WeaponItem); AttributeHandler.UpdatePlayerAttributesFromWeaponItem(player, player.WeaponItem, true); player.WeaponItem = new WeaponItem(); }
// This updates the room and/or player when the exchange of an item occurs public static void HandleItemAddOrRemove(Character.Models.Character player, Room.Models.Room currentRoom, Items foundItem, bool removeItemFromRoom = false) { switch (removeItemFromRoom) { // We are removing an item from a room, adding it to player inventory case true: if (foundItem?.InventoryItems?.First() != null) { var meetsAnyRequirement = false; var needsToDropSameTypeItemFirst = false; InventoryItem carriedItemOfSameType = null; var inventoryItemToAddToPlayer = foundItem.InventoryItems.First(); if (inventoryItemToAddToPlayer?.AttributeRequirementToTake == null) { meetsAnyRequirement = true; } else if (inventoryItemToAddToPlayer?.AttributeRequirementToTake != null && CanPickupItemWithAttributeRequirement(player, inventoryItemToAddToPlayer)) { meetsAnyRequirement = true; } if (inventoryItemToAddToPlayer.TreatItemAs == ItemUseTypes.Bag || inventoryItemToAddToPlayer.TreatItemAs == ItemUseTypes.Wearable) { foreach (var item in player.CarriedItems) { if (item.TreatItemAs == ItemUseTypes.Bag && inventoryItemToAddToPlayer.TreatItemAs == ItemUseTypes.Bag || item.WearableType != "" && item.WearableType == inventoryItemToAddToPlayer.WearableType) { carriedItemOfSameType = item; needsToDropSameTypeItemFirst = true; break; } } } if (PickupOrDropItemIsOk(player, foundItem) && meetsAnyRequirement) { Console.WriteLine(); if (needsToDropSameTypeItemFirst) { TypingAnimation.Animate("You need to drop your " + carriedItemOfSameType.ItemName + " before you can take the " + inventoryItemToAddToPlayer?.ItemName + ".\n", Color.ForestGreen); } else { AttributeHandler.UpdatePlayerAttributesFromInventoryItem(player, inventoryItemToAddToPlayer); inventoryItemToAddToPlayer.InOriginalLocation = false; player.CarriedItems.Add(inventoryItemToAddToPlayer); player.Attributes.CarriedItemsCount += inventoryItemToAddToPlayer.InventorySpaceConsumed; currentRoom.RoomItems.InventoryItems.Remove(inventoryItemToAddToPlayer); TypingAnimation.Animate("You take the " + inventoryItemToAddToPlayer.ItemName + ".\n", Color.ForestGreen); } } else { if (meetsAnyRequirement) { Console.WriteLine(); TypingAnimation.Animate("Your inventory is full! \n" + "Drop or use an item to pick up the " + inventoryItemToAddToPlayer?.ItemName + ".\n", Color.DarkOliveGreen); } } } else if (foundItem?.WeaponItems != null) { var weaponItemToAddToPlayer = foundItem.WeaponItems.First(); if (string.IsNullOrEmpty(player.WeaponItem.WeaponName)) { AttributeHandler.UpdatePlayerAttributesFromWeaponItem(player, weaponItemToAddToPlayer); weaponItemToAddToPlayer.InOriginalLocation = false; player.WeaponItem = weaponItemToAddToPlayer; currentRoom.RoomItems.WeaponItems.Remove(weaponItemToAddToPlayer); Console.WriteLine(); TypingAnimation.Animate("You take the " + weaponItemToAddToPlayer?.WeaponName + ".\n", Color.ForestGreen); } else { var oldWeapon = player.WeaponItem.WeaponName.Clone(); DropWeaponAndPickupNew(player, currentRoom, weaponItemToAddToPlayer); player.WeaponItem = weaponItemToAddToPlayer; currentRoom.RoomItems.WeaponItems.Remove(weaponItemToAddToPlayer); Console.WriteLine(); TypingAnimation.Animate("You drop your " + oldWeapon + " for the " + weaponItemToAddToPlayer?.WeaponName + ".\n", Color.ForestGreen); } } break; // We are adding an item to a room, removing/dropping it from player inventory case false: if (foundItem?.InventoryItems != null) { var inventoryItemToRemoveFromPlayer = foundItem.InventoryItems.First(); DropItemInRoom(player, currentRoom, inventoryItemToRemoveFromPlayer); Console.WriteLine(); TypingAnimation.Animate("You drop the " + inventoryItemToRemoveFromPlayer?.ItemName + ".\n", Color.ForestGreen); } else if (foundItem?.WeaponItems != null) { var weaponItemToRemoveFromPlayer = foundItem.WeaponItems.First(); DropWeaponInRoom(player, currentRoom); Console.WriteLine(); TypingAnimation.Animate("You drop the " + weaponItemToRemoveFromPlayer?.WeaponName + ".\n", Color.ForestGreen); } break; } }
public static void BeginAdventure(Character.Models.Character player, Room.Models.Room room) { DisplayGameIntro(); TheAdventure(player, room); }
// This handles any input the player enters inside a room, // and returns the next Room when the player decides to leave the current one public static Room.Models.Room HandlePlayerInput(string fullInput, Models.Character player, Room.Models.Room currentRoom) { var inputWords = fullInput.Split(ConsoleStrings.StringDelimiters); var inputResolved = false; foreach (var inputWord in inputWords) { string substring; List <string> inventoryKeywords; Items foundItem; switch (inputWord) { // We wouldn't normally use so many fall-throughs in an application... // But for a text based game it's really handy for supporting many inputs. // We don't want the user to try a word that should work and get frustrated. case "pickup": case "pick": case "grab": case "get": case "take": case "collect": case "gather": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; var roomItemKeywords = RoomHandler.GetAllRoomItemKeywords(currentRoom); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), roomItemKeywords, currentRoom.RoomItems.InventoryItems, currentRoom.RoomItems.WeaponItems); if (foundItem != null) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem, true); inputResolved = true; } break; case "drop": case "release": case "letgo": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inventoryKeywords = InventoryHandler.GetAllInventoryItemKeywords(player); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem> { player.WeaponItem }); if (foundItem != null) { if (InventoryHandler.PickupOrDropItemIsOk(player, foundItem, false)) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem); inputResolved = true; } else { Console.WriteLine(); TypingAnimation.Animate("You cannot drop the " + foundItem.InventoryItems?.First()?.ItemName + " until you drop other items. \n" + "(The item you're trying to drop would decrease your inventory space) \n", Color.DarkOliveGreen); inputResolved = true; } } break; case "go": case "goto": case "goin": case "walk": case "run": case "enter": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; substring = CreateSubstringOfActionInput(fullInput, inputWord); var foundRoom = RoomHandler.FindAnyMatchingRoomByKeywords(substring.Trim(), currentRoom); if (foundRoom != null) { if (RoomHandler.DoesPlayerMeetRequirementsToEnter(player, currentRoom, foundRoom)) { return(foundRoom); } inputResolved = true; } break; case "talk": case "speak": case "chat": case "say": case "ask": case "tell": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; if (currentRoom.RoomCharacters.Any()) { substring = CreateSubstringOfActionInput(fullInput, inputWord); var character = RoomHandler.FindAnyMatchingCharacterByKeywords(substring.Trim(), currentRoom); if (character != null) { var characterResponse = GetCharacterResponse(character); Console.WriteLine(); Console.WriteLine(characterResponse + "\n", Color.Gold); inputResolved = true; } } else { Console.WriteLine("\nThere is no one here to talk to...", Color.DarkOliveGreen); inputResolved = true; } break; case "give": case "trade": case "offer": case "hand": case "toss": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inputResolved = InventoryHandler.HandlePlayerTradingItem(fullInput, player, currentRoom, inputWord, inputResolved); break; case "fight": case "kill": case "attack": // TODO: Implement the combat system if an enemy is in the room... break; case "use": case "consume": case "eat": case "drink": case "read": case "look at": case "open": case "swing": case "shoot": case "fire": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inventoryKeywords = InventoryHandler.GetAllInventoryItemKeywords(player); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem> { player.WeaponItem }); if (foundItem != null) { inputResolved = InventoryHandler.HandleItemBeingUsed(player, foundItem, inputWord); } break; case "item": case "items": player.PersistDisplayedItems = true; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; inputResolved = true; break; case "weapon": case "weapons": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = true; player.PersistDisplayedExits = false; inputResolved = true; break; case "exit": case "exits": case "leave": case "door": case "doors": case "out": case "where": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = true; inputResolved = true; break; case "inventory": case "inv": case "carried": case "carrying": case "pockets": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; var playerInventory = StringDescriptionBuilder.CreateStringOfPlayerInventory(player, true); Console.WriteLine(); Console.WriteLine(playerInventory, Color.ForestGreen); inputResolved = true; break; case "character": case "status": case "stat": case "stats": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; var characterInfo = StringDescriptionBuilder.CreateStringOfPlayerInfo(player); Console.WriteLine(); Console.WriteLine(characterInfo, Color.ForestGreen); inputResolved = true; break; case "info": case "help": case "guidance": case "assist": case "assistance": case "?": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; Console.ReplaceAllColorsWithDefaults(); Console.WriteLineStyled(ConsoleStrings.GameHelp, ConsoleStringStyleSheets.GameHelpStyleSheet(Color.MediumPurple)); inputResolved = true; break; case "helpoff": case "helpon": player.PersistDisplayedItems = false; player.PersistDisplayedWeapons = false; player.PersistDisplayedExits = false; player.ShowInputHelp = !player.ShowInputHelp; Console.WriteLine( player.ShowInputHelp ? "\nInput words shown above prompt text." : "\nInput words hidden from prompt text.", Color.MediumPurple); Console.WriteLine(); inputResolved = true; break; case "save": // This isn't really necessary, I just liked the idea of the user having to complete the tutorial first if (currentRoom.RoomName == "Your Bedroom") { Console.WriteLine($"\nYou need to leave {currentRoom.RoomName} before you can save.", Color.DarkOrange); inputResolved = true; break; } Console.WriteLine("\nSave the game and close? (y/n)", Color.White); Console.WriteLine("Note - This will overwrite any current save file!", Color.White); Console.Write(">", Color.White); var response = Console.ReadLine(); if (!string.IsNullOrEmpty(response) && response.ToLower()[0].Equals('y')) { return(new Room.Models.Room { RoomName = ConsoleStrings.SaveGame }); } Console.WriteLine("\nSave cancelled.", Color.White); inputResolved = true; break; } } // We don't know what the user is trying to do at this point if (!inputResolved) { Console.WriteLine(); TypingAnimation.Animate("You " + fullInput + "...", Color.Chartreuse, 40); TypingAnimation.Animate(". . . Nothing happens. \n", Color.Chartreuse, 40); } // Keeps the Item, Weapon, or Exit descriptions displayed for easier play if (!player.PersistDisplayedItems && !player.PersistDisplayedWeapons && !player.PersistDisplayedExits) { Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4); Console.ReadLine(); } Console.Clear(); Console.ReplaceAllColorsWithDefaults(); return(null); }
// This handles any input the player enters inside a room, // and returns the next Room when the player decides to leave the current one public static Room.Models.Room HandlePlayerInput(string fullInput, Models.Character player, Room.Models.Room currentRoom) { var inputWords = fullInput.Split(ConsoleStrings.StringDelimiters); var inputResolved = false; foreach (var inputWord in inputWords) { string substring; Items foundItem; switch (inputWord) { case "pickup": case "grab": case "get": case "take": case "collect": case "gather": var roomItemKeywords = RoomHandler.GetAllRoomItemKeywords(currentRoom); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), roomItemKeywords, currentRoom.RoomItems.InventoryItems, currentRoom.RoomItems.WeaponItems); if (foundItem != null) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem, true); inputResolved = true; } break; case "drop": case "release": case "letgo": var inventoryKeywords = InventoryHandler.GetAllInventoryItemKeywords(player); substring = CreateSubstringOfActionInput(fullInput, inputWord); foundItem = InventoryHandler.FindAnyMatchingItemsByKeywords(substring.Trim(), inventoryKeywords, player.CarriedItems, new List <WeaponItem>() { player.WeaponItem }); if (foundItem != null) { InventoryHandler.HandleItemAddOrRemove(player, currentRoom, foundItem); inputResolved = true; } break; case "go": case "goto": case "goin": case "walk": case "run": case "enter": substring = CreateSubstringOfActionInput(fullInput, inputWord); var foundRoom = RoomHandler.FindAnyMatchingRoomByKeywords(substring.Trim(), currentRoom); if (foundRoom != null) { Console.WriteLine(); TypingAnimation.Animate("You go into " + foundRoom.RoomName + "... \n", Color.Chartreuse, 40); Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4); Console.ReadLine(); if (!currentRoom.RoomEntered) { currentRoom.RoomEntered = true; } return(foundRoom); } break; case "item": case "items": var items = StringDescriptionBuilder.CreateStringOfItemDescriptions(currentRoom.RoomItems.InventoryItems); Console.WriteLine(); TypingAnimation.Animate(items == "" ? ConsoleStrings.NoItemsFound : items, Color.Aquamarine); inputResolved = true; break; case "weapon": case "weapons": var weapons = StringDescriptionBuilder.CreateStringOfWeaponDescriptions(currentRoom.RoomItems.WeaponItems); Console.WriteLine(); TypingAnimation.Animate(weapons == "" ? ConsoleStrings.NoWeaponsFound : weapons, Color.Aquamarine); inputResolved = true; break; case "exit": case "exits": case "leave": case "door": case "doors": case "out": case "where": var exits = StringDescriptionBuilder.CreateStringOfExitDescriptions(currentRoom.AvailableExits); Console.WriteLine(); TypingAnimation.Animate(exits, Color.Red); inputResolved = true; break; case "inventory": case "inv": case "carried": case "carrying": case "pockets": var playerInventory = StringDescriptionBuilder.CreateStringOfPlayerInventory(player, true); Console.WriteLine(); Console.WriteLine(playerInventory, Color.ForestGreen); inputResolved = true; break; case "character": case "status": case "stat": case "stats": var characterInfo = StringDescriptionBuilder.CreateStringOfPlayerInfo(player); Console.WriteLine(); Console.WriteLine(characterInfo, Color.ForestGreen); inputResolved = true; break; case "info": case "help": case "guidance": case "assist": case "assistance": case "?": var exitDescriptions = StringDescriptionBuilder.CreateStringOfExitDescriptions(currentRoom.AvailableExits); Console.WriteLine(); Console.WriteLine(currentRoom.GenericRoomDescription, Color.Bisque); Console.WriteLine(exitDescriptions, Color.Red); Console.WriteLine(ConsoleStrings.GameHelp, Color.MediumPurple); inputResolved = true; break; } } if (!inputResolved) { Console.WriteLine(); TypingAnimation.Animate("You " + fullInput + "...", Color.Chartreuse, 40); TypingAnimation.Animate(". . . Nothing happens. \n", Color.Chartreuse, 40); } Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4); Console.ReadLine(); Console.Clear(); Console.ReplaceAllColorsWithDefaults(); return(null); }
// This updates the room and/or player when the exchange of an item occurs public static void HandleItemAddOrRemove(Character.Models.Character player, Room.Models.Room currentRoom, Items foundItem, bool removeItemFromRoom = false) { switch (removeItemFromRoom) { // We are removing an item from a room, adding it to player inventory case true: if (foundItem?.InventoryItems != null) { var inventoryItemToAdd = foundItem.InventoryItems.First(); if (player.Attributes.CarriedItemsCount + 1 <= player.Attributes.MaximumCarryingCapacity) { AttributeHandler.UpdatePlayerAttributesFromInventoryItem(player, inventoryItemToAdd); inventoryItemToAdd.InOriginalLocation = false; player.CarriedItems.Add(inventoryItemToAdd); player.Attributes.CarriedItemsCount += 1; currentRoom.RoomItems.InventoryItems.Remove(inventoryItemToAdd); Console.WriteLine(); TypingAnimation.Animate("You take the " + inventoryItemToAdd.ItemName + ".\n", Color.ForestGreen); } else { Console.WriteLine(); TypingAnimation.Animate("Your inventory is full! \n" + "Drop an item to pick up the " + inventoryItemToAdd?.ItemName + ".\n", Color.DarkOliveGreen); } } else if (foundItem?.WeaponItems != null) { var weaponItemToAdd = foundItem.WeaponItems.First(); if (string.IsNullOrEmpty(player.WeaponItem.WeaponName)) { AttributeHandler.UpdatePlayerAttributesFromWeaponItem(player, weaponItemToAdd); weaponItemToAdd.InOriginalLocation = false; player.WeaponItem = weaponItemToAdd; currentRoom.RoomItems.WeaponItems.Remove(weaponItemToAdd); Console.WriteLine(); TypingAnimation.Animate("You take the " + weaponItemToAdd?.WeaponName + ".\n", Color.ForestGreen); } else { var oldWeapon = player.WeaponItem.WeaponName.Clone(); DropWeaponAndPickupNew(player, currentRoom, weaponItemToAdd); AttributeHandler.UpdatePlayerAttributesFromWeaponItem(player, weaponItemToAdd); player.WeaponItem = weaponItemToAdd; currentRoom.RoomItems.WeaponItems.Remove(weaponItemToAdd); Console.WriteLine(); TypingAnimation.Animate("You drop your " + oldWeapon + " for the " + weaponItemToAdd?.WeaponName + ".\n", Color.ForestGreen); } } break; // We are adding an item to a room, removing/dropping it from player inventory case false: if (foundItem?.InventoryItems != null) { var inventoryItemToRemove = foundItem.InventoryItems.First(); DropItemInRoom(player, currentRoom, inventoryItemToRemove); Console.WriteLine(); TypingAnimation.Animate("You drop the " + inventoryItemToRemove?.ItemName + ".\n", Color.ForestGreen); } else if (foundItem?.WeaponItems != null) { var weaponItemToRemove = foundItem.WeaponItems.First(); DropWeaponInRoom(player, currentRoom); Console.WriteLine(); TypingAnimation.Animate("You drop the " + weaponItemToRemove?.WeaponName + ".\n", Color.ForestGreen); } break; } }