Example #1
0
        // This displays after the user assigns their traits and begins the game
        public static void DisplayGameIntro()
        {
            Console.ReplaceAllColorsWithDefaults();

            var enterKeyPressed = false;
            var r = 255;
            var g = 255;
            var b = 255;

            foreach (var line in ConsoleStrings.GameIntro)
            {
                if (enterKeyPressed)
                {
                    Console.WriteLine(line, Color.FromArgb(r, g, b));
                }
                else
                {
                    enterKeyPressed = TypingAnimation.Animate(line, Color.FromArgb(r, g, b));
                }

                g -= 25;
                b -= 25;
            }

            Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4);
            Console.ReadLine();
        }
        // Gets the player's name from input and stores it to the player object
        public static void WelcomePlayer(Models.Character player)
        {
            while (player.Name == null)
            {
                TypingAnimation.Animate("Please enter a Player name: ", Color.DarkOrange);
                Console.Write("> ", Color.Yellow);
                var input = Console.ReadLine().Trim();
                if (!string.IsNullOrWhiteSpace(input))
                {
                    player.Name = input[0].ToString().ToUpper() + input.Substring(1);
                }
                Console.Clear();
            }

            const string welcomePlayer = "Hello, {0}!";
            var          playerName    = new Formatter(player.Name, Color.Gold);

            Console.Clear();
            Console.WriteLineFormatted(welcomePlayer, Color.YellowGreen, playerName);
            Console.WriteLine();

            TypingAnimation.Animate(
                "Press <Enter> to spend your (" + player.Attributes.AvailablePoints + ") available Player Trait points...",
                Color.DarkOrange);
            Console.ReadLine();
            Console.Clear();
        }
Example #3
0
        // This displays after the user assigns their traits and begins the game
        public static void DisplayGameIntro()
        {
            Console.ReplaceAllColorsWithDefaults();

            TypingAnimation.Animate(ConsoleStrings.GameIntro, Color.DarkTurquoise);
            Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4);
            Console.ReadLine();
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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);
        }
Example #7
0
        public static bool CanPickupItemWithAttributeRequirement(Character.Models.Character player, InventoryItem inventoryItem = null, WeaponItem weaponItem = null)
        {
            if (weaponItem != null)
            {
                Console.WriteLine();
                if (PlayerMeetsRequirementForItem(player, weaponItem: weaponItem))
                {
                    TypingAnimation.Animate($"<{weaponItem.AttributeRequirementToTake.RequirementName}>!", Color.Gold);
                    weaponItem.AttributeRequirementToSee  = null;
                    weaponItem.AttributeRequirementToTake = null;
                    return(true);
                }

                TypingAnimation.Animate($"You need: <{weaponItem.AttributeRequirementToTake.RequirementName}> to take the {weaponItem.WeaponName}. \n",
                                        Color.DarkGoldenrod);
                return(false);
            }

            if (inventoryItem != null)
            {
                Console.WriteLine();
                if (PlayerMeetsRequirementForItem(player, inventoryItem: inventoryItem))
                {
                    TypingAnimation.Animate($"<{inventoryItem.AttributeRequirementToTake.RequirementName}>!",
                                            Color.Gold);
                    inventoryItem.AttributeRequirementToSee  = null;
                    inventoryItem.AttributeRequirementToTake = null;
                    return(true);
                }

                TypingAnimation.Animate($"You need: <{inventoryItem.AttributeRequirementToTake.RequirementName}> to take the {inventoryItem.ItemName}. \n",
                                        Color.DarkGoldenrod);
                return(false);
            }

            return(false);
        }
Example #8
0
        // This is the logic for prompting the user for input continuously
        // until the user enters keywords to get to another room.
        // (Calls into a separate method to act on the input)
        public static Models.Room EnterRoom(Character.Models.Character player, Models.Room room, bool firstRoomEntered = false)
        {
            var redisplayRoomDesc = false;

            Models.Room nextRoom = null;
            Program.CharacterCreator.Player.CurrentRoomName = room.RoomName;

            while (nextRoom == null)
            {
                Console.Clear();
                Console.ReplaceAllColorsWithDefaults();

                // Print out the current Room description to the console (animate the first time)
                if (redisplayRoomDesc)
                {
                    Console.WriteLine(room.RoomEntered ? room.GenericRoomDescription : room.InitialRoomDescription,
                                      Color.Bisque);

                    if (room.RoomCharacters.Any())
                    {
                        foreach (var character in room.RoomCharacters)
                        {
                            Console.WriteLine();
                            Console.WriteLine(character.OnMeetDescription + "\n", Color.Gold);
                        }
                    }

                    if (player.PersistDisplayedItems)
                    {
                        PlayerActionHandler.PrintItemsToConsole(player, room);
                    }

                    else if (player.PersistDisplayedWeapons)
                    {
                        PlayerActionHandler.PrintWeaponsToConsole(player, room);
                    }

                    else if (player.PersistDisplayedExits)
                    {
                        PlayerActionHandler.PrintExitsToConsole(player, room);
                    }

                    else
                    {
                        Console.WriteLine();
                    }
                }
                else
                {
                    TypingAnimation.Animate(room.RoomEntered ? room.GenericRoomDescription : room.InitialRoomDescription,
                                            Color.Bisque);
                    Console.WriteLine();
                    if (room.RoomCharacters.Any())
                    {
                        foreach (var character in room.RoomCharacters)
                        {
                            TypingAnimation.Animate(character.OnMeetDescription + "\n", Color.Gold);
                        }
                    }
                }

                Thread.Sleep(50);

                if (firstRoomEntered)
                {
                    Console.Write("TUTORIAL: ", Color.MediumPurple);

                    if (player.CarriedItems.Count == 0 || string.IsNullOrEmpty(player.WeaponItem.WeaponName))
                    {
                        Console.WriteLine("Collect the item and weapon in this room\n", Color.Aquamarine);
                        Console.WriteLineStyled(ConsoleStrings.ItemsHints, ConsoleStringStyleSheets.GameHelpStyleSheet(Color.AliceBlue));
                        Console.WriteLineStyled(ConsoleStrings.InfoHints, ConsoleStringStyleSheets.GameHelpStyleSheet(Color.AliceBlue));
                    }
                    else
                    {
                        Console.WriteLine("Exit this room\n", Color.Red);
                        Console.WriteLineStyled(ConsoleStrings.RoomHints, ConsoleStringStyleSheets.GameHelpStyleSheet(Color.AliceBlue));
                    }

                    Console.WriteLine(ConsoleStrings.FirstRoomHelpHint, Color.MediumPurple);
                }
                if (player.ShowInputHelp && !firstRoomEntered)
                {
                    Console.WriteLineStyled(ConsoleStrings.InputHelper, RoomStyleSheets.InputHelperStyleSheet());
                }

                Console.WriteWithGradient(ConsoleStrings.PlayerInputPrompt, Color.SpringGreen, Color.NavajoWhite, 4);
                Console.WriteLine();
                Console.Write("> ");
                var playerInput = Console.ReadLine();
                nextRoom = PlayerActionHandler.HandlePlayerInput(playerInput.ToLower(), player, room);

                redisplayRoomDesc = true;
            }

            return(nextRoom);
        }
Example #9
0
        public static bool DoesPlayerMeetRequirementsToEnter(Character.Models.Character player, Models.Room currentRoom, Models.Room foundRoom)
        {
            Console.WriteLine();
            var meetsRequirements = foundRoom?.AttributeRequirementToEnter == null && foundRoom?.ItemRequirementToEnter == null;

            if (!meetsRequirements)
            {
                if (foundRoom?.AttributeRequirementToEnter != null && foundRoom?.ItemRequirementToEnter == null &&
                    CanPlayerEnterRoom(player, foundRoom, attrReq: foundRoom.AttributeRequirementToEnter))
                {
                    Console.WriteLine($"<{foundRoom.AttributeRequirementToEnter.RequirementName}>! \n", Color.Gold);
                    meetsRequirements = true;
                }

                else if (foundRoom?.ItemRequirementToEnter != null && foundRoom?.AttributeRequirementToEnter == null &&
                         CanPlayerEnterRoom(player, foundRoom, foundRoom.ItemRequirementToEnter))
                {
                    if (foundRoom.ItemRequirementToEnter.RelevantItem.ItemName == Program.ItemCreator.Flashlight.ItemName && Program.ItemCreator.Flashlight.ItemTraits.First().TraitValue == 0)
                    {
                        Console.WriteLine($"It's too dark. Your flashlight battery is dead... \nPut in a new battery to enter {foundRoom.RoomName}.\n", Color.DarkGoldenrod);
                        return(false);
                    }
                    Console.WriteLine($"Carrying: <{foundRoom.ItemRequirementToEnter.RequirementName}>! \n", Color.Gold);
                    meetsRequirements = true;
                }

                else
                {
                    if (CanPlayerEnterRoom(player, foundRoom, attrReq: foundRoom.AttributeRequirementToEnter) &&
                        CanPlayerEnterRoom(player, foundRoom, itemReq: foundRoom.ItemRequirementToEnter))
                    {
                        if (foundRoom.ItemRequirementToEnter.RelevantItem.ItemName == Program.ItemCreator.Flashlight.ItemName)
                        {
                            foreach (var item in Program.CharacterCreator.Player.CarriedItems)
                            {
                                if (item.ItemName == Program.ItemCreator.Flashlight.ItemName &&
                                    item.ItemTraits.First().TraitValue == 0)
                                {
                                    Console.WriteLine($"It's too dark. Your flashlight battery is dead... \nPut in a new battery to enter {foundRoom.RoomName}.\n", Color.DarkGoldenrod);
                                    return(false);
                                }
                            }
                        }
                        Console.WriteLine($"<{foundRoom.AttributeRequirementToEnter.RequirementName}>! \n", Color.Gold);
                        Console.WriteLine($"Carrying: <{foundRoom.ItemRequirementToEnter.RequirementName}>! \n", Color.Gold);
                        meetsRequirements = true;
                    }
                }
            }

            if (meetsRequirements)
            {
                TypingAnimation.Animate("You go to " + foundRoom.RoomName + "... \n", Color.Chartreuse, 40);

                if (foundRoom.ItemRequirementToEnter?.RelevantItem.ItemName == Program.ItemCreator.Flashlight.ItemName)
                {
                    var consoleInfo   = "Used Flashlight: battery dropped by 2% \n";
                    var light         = player.CarriedItems.Single(i => i.ItemName == Program.ItemCreator.Flashlight.ItemName);
                    var batteryBefore = light.ItemTraits.First().TraitValue;
                    var hasBattery    = FlashlightBatteryUpdate.FlashlightBatteryChange(light, batteryBefore, 2);
                    if (!hasBattery)
                    {
                        consoleInfo = "Used Flashlight: now the battery is dead! \n";
                    }
                    TypingAnimation.Animate(consoleInfo, Color.Chartreuse, 40);
                }

                Console.WriteWithGradient(ConsoleStrings.PressEnterPrompt, Color.Yellow, Color.DarkRed, 4);
                Console.ReadLine();
                if (!currentRoom.RoomEntered)
                {
                    currentRoom.RoomEntered = true;
                }

                foundRoom.AttributeRequirementToEnter = null;
                foundRoom.AttributeRequirementToSee   = null;
                foundRoom.ItemRequirementToEnter      = null;
                foundRoom.ItemRequirementToSee        = null;
            }

            return(meetsRequirements);
        }
Example #10
0
        public static bool HandleItemBeingUsed(Character.Models.Character player, Items foundItem, string playerInput)
        {
            if (foundItem?.WeaponItems?.First() != null)
            {
                Console.WriteLine();
                TypingAnimation.Animate($"You swing your {foundItem.WeaponItems.First().WeaponName} around wildly.\n", Color.ForestGreen);
                return(true);
            }

            if (foundItem?.InventoryItems?.First() != null)
            {
                var item = foundItem.InventoryItems.First();
                if (item.TreatItemAs == ItemUseTypes.Default || item.TreatItemAs == ItemUseTypes.Key)
                {
                    Console.WriteLine();
                    TypingAnimation.Animate($"You {playerInput} the {item.ItemName} but nothing happens...\n",
                                            Color.ForestGreen);
                    return(true);
                }

                if (item.TreatItemAs == ItemUseTypes.Wearable)
                {
                    Console.WriteLine();
                    TypingAnimation.Animate($"You're already wearing the {item.ItemName}...\n", Color.ForestGreen);
                    return(true);
                }

                if (item.TreatItemAs == ItemUseTypes.Document)
                {
                    var traitsAdded = "";
                    foreach (var trait in item.ItemTraits)
                    {
                        if (!string.IsNullOrEmpty(trait.RelevantCharacterAttribute))
                        {
                            if (trait.TraitValue > 0)
                            {
                                traitsAdded += $"\n\t{trait.RelevantCharacterAttribute} + ({trait.TraitValue})!";
                                AttributeHandler.AddCharacterAttributesByTrait(player, trait);
                                trait.TraitName  = "";
                                trait.TraitValue = 0;
                            }
                        }
                    }

                    Console.WriteLine();
                    TypingAnimation.Animate($"You read the {item.ItemName}: {traitsAdded}\n \n\n{item.DocumentText}\n",
                                            Color.GhostWhite);
                    return(true);
                }

                if (item.TreatItemAs == ItemUseTypes.ConsumableAttribute)
                {
                    var traitsAdded = "";
                    foreach (var trait in item.ItemTraits)
                    {
                        if (!string.IsNullOrEmpty(trait.RelevantCharacterAttribute))
                        {
                            traitsAdded += $"\n\t{trait.RelevantCharacterAttribute} + ({trait.TraitValue})!";
                            AttributeHandler.AddCharacterAttributesByTrait(player, trait);
                        }
                    }

                    player.Attributes.CarriedItemsCount -= item.InventorySpaceConsumed;
                    player.CarriedItems.Remove(item);
                    Console.WriteLine();
                    TypingAnimation.Animate($"You use the {item.ItemName}: \n{traitsAdded}\n", Color.ForestGreen);
                    return(true);
                }

                if (item.TreatItemAs == ItemUseTypes.ConsumableBattery)
                {
                    var flashlight = player.CarriedItems.SingleOrDefault(i =>
                                                                         i.ItemName == Program.ItemCreator.Flashlight.ItemName);
                    var traitsAdded = "";
                    foreach (var trait in item.ItemTraits)
                    {
                        if (!string.IsNullOrEmpty(flashlight?.ItemName))
                        {
                            traitsAdded += $"\n\tFlashlight battery: ({trait.TraitValue}%)!";
                            FlashlightBatteryUpdate.FlashlightBatteryChange(flashlight,
                                                                            percentToSet: trait.TraitValue);
                        }
                    }

                    if (!string.IsNullOrEmpty(flashlight?.ItemName))
                    {
                        player.Attributes.CarriedItemsCount -= item.InventorySpaceConsumed;
                        player.CarriedItems.Remove(item);
                        Console.WriteLine();
                        TypingAnimation.Animate($"You use the {item.ItemName}: \n{traitsAdded}\n", Color.ForestGreen);
                        return(true);
                    }

                    Console.WriteLine();
                    TypingAnimation.Animate($"You don't have anything to use the {item.ItemName} on...\n",
                                            Color.DarkOliveGreen);
                    return(true);
                }

                if (item.TreatItemAs == ItemUseTypes.ConsumableHealth)
                {
                    var traitsAdded = "";
                    if (player.HealthPoints < player.MaximumHealthPoints)
                    {
                        foreach (var trait in item.ItemTraits)
                        {
                            if (string.IsNullOrEmpty(trait.RelevantCharacterAttribute))
                            {
                                if (player.HealthPoints + trait.TraitValue > player.MaximumHealthPoints)
                                {
                                    player.HealthPoints = player.MaximumHealthPoints;
                                }
                                else
                                {
                                    player.HealthPoints += trait.TraitValue;
                                }

                                traitsAdded += $"\n\tHealth Points: + ({trait.TraitValue})!";
                            }
                            else
                            {
                                traitsAdded += trait.TraitValue >= 0 ? $"\n\t{trait.RelevantCharacterAttribute} + ({trait.TraitValue})!" : $"\n\t{trait.RelevantCharacterAttribute} - ({-1 * trait.TraitValue})";
                                AttributeHandler.AddCharacterAttributesByTrait(player, trait);
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(traitsAdded))
                    {
                        player.Attributes.CarriedItemsCount -= item.InventorySpaceConsumed;
                        player.CarriedItems.Remove(item);
                        Console.WriteLine();
                        TypingAnimation.Animate($"You consume the {item.ItemName}: \n{traitsAdded}\n",
                                                Color.ForestGreen);
                        return(true);
                    }

                    Console.WriteLine();
                    TypingAnimation.Animate(
                        $"You don't need to use the {item.ItemName}, you have full Health Points...\n",
                        Color.DarkOliveGreen);
                    return(true);
                }

                if (item.TreatItemAs == ItemUseTypes.ConsumableAmmo)
                {
                    var traitsAdded = "";

                    if (!string.IsNullOrEmpty(player.WeaponItem?.WeaponName) &&
                        !string.IsNullOrEmpty(player.WeaponItem?.AmmunitionType) &&
                        player.WeaponItem.AmmunitionType == item.AmmunitionType)
                    {
                        player.WeaponItem.AmmunitionAmount += item.AmmunitionAmount;
                        traitsAdded += $"\n\t{player.WeaponItem.WeaponName} Ammo + ({item.AmmunitionAmount}) = ({player.WeaponItem.AmmunitionAmount})!";
                        player.Attributes.CarriedItemsCount -= item.InventorySpaceConsumed;
                        player.CarriedItems.Remove(item);
                        Console.WriteLine();
                        TypingAnimation.Animate($"You use the {item.ItemName}: \n{traitsAdded}\n", Color.ForestGreen);
                        return(true);
                    }

                    Console.WriteLine();
                    TypingAnimation.Animate($"You don't have a weapon that uses {item.AmmunitionType}...\n",
                                            Color.DarkOliveGreen);
                    return(true);
                }
            }

            return(false);
        }
Example #11
0
        // 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;
            }
        }
Example #12
0
        // 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);
        }
Example #14
0
        public static bool TryLoadGame()
        {
            const string saveFile = "TheHaunting_SavedGame.xml";

            if (File.Exists(saveFile) && File.ReadAllText(saveFile).Length != 0)
            {
                TypingAnimation.Animate("A save file was found, would you like to load it? (y/n)", Color.DarkOrange);
                Console.Write(">", Color.DarkOrange);
                var response = System.Console.ReadLine();
                if (string.IsNullOrEmpty(response) || response?.ToLower()[0] == 'y')
                {
                    try
                    {
                        using (var reader = XmlReader.Create(saveFile))
                        {
                            // Skip root node
                            reader.ReadToFollowing("C"); // Name of first class, we serialize Character as "C" for XML sneakiness :)

                            // Characters
                            Program.CharacterCreator.Player = (Character.Models.Character)Program.CharacterSerializer.Deserialize(reader);
                            Program.CharacterCreator.Ghoul  = (Character.Models.Character)Program.CharacterSerializer.Deserialize(reader);

                            // Rooms
                            Program.RoomCreator.YourBedroom                   = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourLivingRoom                = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourKitchen                   = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourBasement                  = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourFrontEntryway             = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourFrontPorch                = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourShed                      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.YourDriveway                  = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.RoadConnectingYourHouseToTown = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);

                            Program.RoomCreator.ForestLake                   = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.ForestLakeTent               = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.EastForest                   = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.EastForestLowerClearing      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.EastForestUpperClearing      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.DeepEastForest               = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.DeepEastForestLowerRiver     = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.DeepEastForestUpperRiver     = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.DeepEastForestUpperRiverCave = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.EastForestCampground         = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.PathBetweenCampAndEastRoad   = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.EastRoadToTown               = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);

                            Program.RoomCreator.TownSouthEntrance      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.TownNorthEntrance      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.TownEastEntrance       = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.TownWestEntrance       = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthSquare     = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyNorthSquare     = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyEastSquare      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyWestSquare      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthMainStreet = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyNorthMainStreet = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyEastPlaza       = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyWestPlaza       = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburyTownCenter      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            // South Side
                            Program.RoomCreator.AshburySouthSquareEastAlley      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthEastVeterinaryClinic = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthEastCornerLot        = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthEastDurrowHouse      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthEastAviary           = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthEastWell             = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                            Program.RoomCreator.AshburySouthSquareWestAlley      = (Room.Models.Room)Program.RoomSerializer.Deserialize(reader);
                        }

                        Console.Clear();
                        // Important that we add all the room exits back to the rooms, or we can't go anywhere!
                        Program.RoomCreator.AddExitsToAllRooms();
                        return(true);
                    }
                    catch (Exception e)
                    {
                        Console.Write("\nSomething went wrong loading the file :( ...", Color.Red);
                        Console.ReadLine();
                        Console.Clear();
                        Environment.Exit(0);
                    }
                }
            }

            Console.Clear();
            return(false);
        }
        // Continuously asks user for a trait to add a point to until all available point are spent
        public static void SetPlayerTraits(Models.Character player)
        {
            var pendingPlayerAttributes = player.Attributes;
            var displayInfo             = false;
            var playerReady             = false;

            while (!playerReady)
            {
                string input;
                while (pendingPlayerAttributes.AvailablePoints > 0)
                {
                    TypingAnimation.Animate(
                        player.Name + ", you have (" + pendingPlayerAttributes.AvailablePoints + ") points to spend.",
                        Color.Chartreuse,
                        20);
                    Console.WriteLine();
                    Console.WriteLine("Current trait values:", Color.DarkOrange);
                    Console.WriteLine("\t1. (Def)ense \t= " + pendingPlayerAttributes.Defense, Color.AliceBlue);
                    if (displayInfo)
                    {
                        Console.WriteLine("\t - How resilient your character is to damage.", Color.Gray);
                        Console.WriteLine();
                    }

                    Console.WriteLine("\t2. (Dex)terity \t= " + pendingPlayerAttributes.Dexterity, Color.AliceBlue);
                    if (displayInfo)
                    {
                        Console.WriteLine("\t - How agile or evasive your character is.", Color.Gray);
                        Console.WriteLine();
                    }

                    Console.WriteLine("\t3. (Luc)k \t= " + pendingPlayerAttributes.Luck, Color.AliceBlue);
                    if (displayInfo)
                    {
                        Console.WriteLine("\t - How fortunate your character will be in their adventure.", Color.Gray);
                        Console.WriteLine();
                    }

                    Console.WriteLine("\t4. (Sta)mina \t= " + pendingPlayerAttributes.Stamina, Color.AliceBlue);
                    if (displayInfo)
                    {
                        Console.WriteLine("\t - How many overall Health Points your character can have.", Color.Gray);
                        Console.WriteLine();
                    }

                    Console.WriteLine("\t5. (Str)ength \t= " + pendingPlayerAttributes.Strength, Color.AliceBlue);
                    if (displayInfo)
                    {
                        Console.WriteLine("\t - How strong your character is; how much damage they can do.", Color.Gray);
                        Console.WriteLine();
                    }

                    Console.WriteLine("\t6. (Wis)dom \t= " + pendingPlayerAttributes.Wisdom, Color.AliceBlue);
                    if (displayInfo)
                    {
                        Console.WriteLine("\t - How knowledgeable, sensible, or perceptive your character is " +
                                          "\n\t   in regard to situations or their surroundings.", Color.Gray);
                        Console.WriteLine();
                    }

                    Console.WriteLine("\t?. Info - Toggle info on what each trait does...", Color.Gray);
                    Console.WriteLine();
                    Console.WriteLine("Enter the number or trait name you'd like to add (1) point to.", Color.OrangeRed);
                    Console.Write("> ", Color.Yellow);
                    input = Console.ReadLine().ToLower();
                    if (input == "?" || input == "info")
                    {
                        displayInfo = !displayInfo;
                        Console.Clear();
                        continue;
                    }

                    pendingPlayerAttributes = UpdateCharacterAttributesByInput(pendingPlayerAttributes, input);
                    Console.Clear();
                }
                TypingAnimation.Animate(player.Name + ", here are your final trait values: \n", Color.Red);
                Console.WriteLine("\tDefense \t= " + pendingPlayerAttributes.Defense, Color.AliceBlue);
                Console.WriteLine("\tDexterity \t= " + pendingPlayerAttributes.Dexterity, Color.AliceBlue);
                Console.WriteLine("\tLuck \t\t= " + pendingPlayerAttributes.Luck, Color.AliceBlue);
                Console.WriteLine("\tStamina \t= " + pendingPlayerAttributes.Stamina, Color.AliceBlue);
                Console.WriteLine("\tStrength \t= " + pendingPlayerAttributes.Strength, Color.AliceBlue);
                Console.WriteLine("\tWisdom \t\t= " + pendingPlayerAttributes.Wisdom, Color.AliceBlue);
                Console.WriteLine();
                Console.WriteLine("Do you want to begin your adventure? (y/n)", Color.AntiqueWhite);
                Console.Write("> ", Color.Yellow);
                input = Console.ReadLine().ToLower();
                switch (input)
                {
                case "n":
                case "no":
                    pendingPlayerAttributes = new CharacterAttribute();
                    Console.Clear();
                    Console.ReplaceAllColorsWithDefaults();
                    break;

                default:
                    playerReady = true;
                    Console.Clear();
                    break;
                }
            }

            var healthIncrease = CharacterDefaults.HealthPerStaminaPointIncrease
                                 * (pendingPlayerAttributes.Stamina -
                                    CharacterDefaults.DefaultValueForAllAttributes);

            player.Attributes           = pendingPlayerAttributes;
            player.MaximumHealthPoints += healthIncrease;
            player.HealthPoints        += healthIncrease;
        }
        // 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;
            }
        }