///Get Ogres Age
        ///
        public int DisplayGetOgresAge()
        {
            bool validResponse = false;
            int  ogresAge      = 0;

            while (!validResponse)
            {
                // display header
                ConsoleUtil.HeaderText = "Ogre's Age";
                ConsoleUtil.DisplayReset();

                ConsoleUtil.DisplayPromptMessage("Please Enter Your Ogre's Age: ");
                if (int.TryParse(Console.ReadLine(), out ogresAge))
                {
                    validResponse = true;
                    ConsoleUtil.DisplayReset();
                    ConsoleUtil.DisplayMessage($"Your Ogre's name is now :  {ogresAge} .");
                }

                else
                {
                    ConsoleUtil.DisplayPromptMessage("Please enter a valid age.");
                }


                DisplayContinuePrompt();
            }

            return(ogresAge);
        }
        public int DisplayPickUpItem()
        {
            ConsoleUtil.HeaderText = "Pick Up Item";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage("Items in current location");
            ConsoleUtil.DisplayMessage("");

            int  itemID        = 0;
            bool validResponse = false;

            int locationID;

            locationID = _gameOgre.SwampLocationID;
            while (!validResponse)
            {
                foreach (Item item in _gameKingdom.Items)
                {
                    if (item.SwampLocationID == locationID)
                    {
                        Console.WriteLine(item.GameObjectID);
                        Console.WriteLine(item.Name);
                        Console.WriteLine();
                    }
                }

                ConsoleUtil.DisplayPromptMessage("Enter Item Number:");

                if (int.TryParse(Console.ReadLine(), out itemID))
                {
                    if (itemID > 0 && itemID <= 6)
                    {
                        validResponse = true;
                    }

                    else
                    {
                        Console.WriteLine("Please select an option from the list");
                    }
                }
                else
                {
                    Console.WriteLine("Please select an option from the list");
                }
            }
            DisplayContinuePrompt();

            return(itemID);
        }
        /// <summary>
        /// get and validate the player's race
        /// </summary>
        /// <returns>race as a RaceType</returns>
        public Ogre.RaceType DisplayGetOgresRace()
        {
            bool validResponse = false;

            Ogre.RaceType ogresRace = Ogre.RaceType.None;

            while (!validResponse)
            {
                //
                // display header
                //
                ConsoleUtil.HeaderText = "Ogre's Race";
                ConsoleUtil.DisplayReset();

                //
                // display all race types on a line
                //
                ConsoleUtil.DisplayMessage("Races");
                StringBuilder sb = new StringBuilder();
                foreach (Character.RaceType raceType in Enum.GetValues(typeof(Character.RaceType)))
                {
                    if (raceType != Character.RaceType.None)
                    {
                        sb.Append($" [{raceType}] ");
                    }
                }
                ConsoleUtil.DisplayMessage(sb.ToString());

                ConsoleUtil.DisplayPromptMessage("Enter Your Ogre's Race: ");

                //
                // validate user response for race
                //
                if (Enum.TryParse <Character.RaceType>(Console.ReadLine(), out ogresRace))
                {
                    validResponse = true;
                    ConsoleUtil.DisplayReset();
                    ConsoleUtil.DisplayMessage($"You have indicated {ogresRace} as your race type.");
                }
                else
                {
                    ConsoleUtil.DisplayMessage("You must limit your race to the list above.");
                    ConsoleUtil.DisplayMessage("Please reenter your race.");
                }

                DisplayContinuePrompt();
            }

            return(ogresRace);
        }
        public int DisplayPutDownTreasure()
        {
            ConsoleUtil.HeaderText = "Put Down Treasure";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage("Treasures in current inventory");
            ConsoleUtil.DisplayMessage("");

            int  treasureToPutDown = _gameOgre.SwampLocationID;
            bool validResponse     = false;

            int locationID;

            locationID = _gameOgre.SwampLocationID;
            while (!validResponse)
            {
                foreach (Treasure treasure in _gameOgre.OgresTreasures)
                {
                    Console.WriteLine(treasure.GameObjectID);
                    Console.WriteLine(treasure.Name);
                    Console.WriteLine();
                }

                ConsoleUtil.DisplayPromptMessage("Enter Treasure Number To Put Down:");
                if (int.TryParse(Console.ReadLine(), out treasureToPutDown))
                {
                    if (treasureToPutDown > 0 && treasureToPutDown <= 4)
                    {
                        validResponse = true;
                    }
                    else
                    {
                        Console.WriteLine("Please select an option from the list");
                    }
                }
                else
                {
                    Console.WriteLine("Please select an option from the list");
                }
            }
            DisplayContinuePrompt();

            return(treasureToPutDown);
        }
        /// <summary>
        /// get player's name
        /// </summary>
        /// <returns>name as a string</returns>
        public string DisplayGetOgresName()
        {
            string ogresName;

            //
            // display header
            //
            ConsoleUtil.HeaderText = "Ogre's Name";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayPromptMessage("Please Enter Your Ogre's Name: ");
            ogresName = Console.ReadLine();

            ConsoleUtil.DisplayReset();
            ConsoleUtil.DisplayMessage($"You have indicated {ogresName} as your name.");

            DisplayContinuePrompt();

            return(ogresName);
        }
Пример #6
0
        /// <summary>
        /// get player's name
        /// </summary>
        /// <returns>name as a string</returns>
        public string DisplayGetTravelersName()
        {
            string travelersName;

            //
            // display header
            //
            ConsoleUtil.HeaderText = "TimeTraveler's Name";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayPromptMessage("Enter your name: ");
            travelersName = Console.ReadLine();

            ConsoleUtil.DisplayReset();
            ConsoleUtil.DisplayMessage($"You have indicated {travelersName} as your name.");

            DisplayContinuePrompt();

            return(travelersName);
        }
        public void DisplayTalkTo()
        {
            int           locationID     = _gameOgre.SwampLocationID;
            List <Dragon> dragonsInSwamp = new List <Dragon>();
            Dragon        dragonToTalkTo = new Dragon();

            dragonsInSwamp = _gameKingdom.GetDragonsBySwampLocationID(locationID);

            ConsoleUtil.HeaderText = "Talk To";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage(_gameKingdom.GetSwampLocationByID(locationID).Name);
            ConsoleUtil.DisplayMessage("");

            if (dragonsInSwamp != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Dragons in Current location.");
                foreach (Dragon dragon in _gameKingdom.Dragons)
                {
                    if (dragon.SwampLocationID == locationID)
                    {
                        Console.WriteLine(dragon.CharacterID + " - " + dragon.Name);
                        Console.WriteLine();
                    }
                }
                ConsoleUtil.DisplayPromptMessage("Select a number to speak with a dragon.");
                Console.WriteLine();
                int dragonIDChoice;

                if (int.TryParse(Console.ReadLine(), out dragonIDChoice))
                {
                    dragonToTalkTo = _gameKingdom.GetDragonByID(dragonIDChoice);
                    ConsoleUtil.DisplayMessage(dragonToTalkTo.Message);
                }

                DisplayContinuePrompt();
            }
        }
        public void DisplayLookAt()
        {
            int             locationID      = _gameOgre.SwampLocationID;
            List <Item>     itemsInSwamp    = new List <Item>();
            List <Treasure> treasureInSwamp = new List <Treasure>();
            Item            itemToSee       = new Item();
            Treasure        treasureToSee   = new Treasure();

            itemsInSwamp    = _gameKingdom.GetItemsBySwampLocationID(locationID);
            treasureInSwamp = _gameKingdom.GetTreasuresBySwampLocationID(locationID);

            ConsoleUtil.HeaderText = "Items in Current Location";
            ConsoleUtil.DisplayReset();

            ConsoleUtil.DisplayMessage("");
            ConsoleUtil.DisplayMessage(_gameKingdom.GetSwampLocationByID(locationID).Name);
            ConsoleUtil.DisplayMessage("");

            if (itemsInSwamp != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Items in Current location.");
                foreach (Item item in _gameKingdom.Items)
                {
                    if (item.SwampLocationID == locationID)
                    {
                        Console.WriteLine(item.GameObjectID + " - " + item.Name);
                        Console.WriteLine();
                    }
                }
                ConsoleUtil.DisplayPromptMessage("Enter item number or press Enter to move on to Treasures.");
                Console.WriteLine();
                int itemIDChoice;

                if (int.TryParse(Console.ReadLine(), out itemIDChoice))
                {
                    itemToSee = _gameKingdom.GetItemtByID(itemIDChoice);
                    ConsoleUtil.DisplayMessage(itemToSee.Description);

                    DisplayContinuePrompt();
                }
            }

            if (treasureInSwamp != null)
            {
                ConsoleUtil.DisplayMessage("");
                ConsoleUtil.DisplayMessage("Treasures in Current location.");
                foreach (Treasure treasure in _gameKingdom.Treasures)
                {
                    if (treasure.SwampLocationID == locationID)
                    {
                        Console.WriteLine(treasure.GameObjectID + " - " + treasure.Name);
                        Console.WriteLine();
                    }
                }
                ConsoleUtil.DisplayPromptMessage("Enter treasure number or press Enter to move on.");
                Console.WriteLine();
                int treasureIDChoice;

                if (int.TryParse(Console.ReadLine(), out treasureIDChoice))
                {
                    treasureToSee = _gameKingdom.GetTreasuretByID(treasureIDChoice);
                    ConsoleUtil.DisplayMessage(treasureToSee.Description);

                    DisplayContinuePrompt();
                }
            }
        }
        /// <summary>
        /// get and validate the player's TARDIS destination
        /// </summary>
        /// <returns>space-time location</returns>
        public SwampLocation DisplayGetOgresNewDestination()
        {
            bool          validResponse = false;
            int           swampID;
            SwampLocation nextSwampLocation = new SwampLocation();

            while (!validResponse)
            {
                //
                // display header
                //
                ConsoleUtil.HeaderText = "Swamp Destination";
                ConsoleUtil.DisplayReset();

                //
                // display a table of space-time locations
                //
                DisplaySwampDestinationsTable();

                //
                // get and validate user's response for a space-time location
                //
                ConsoleUtil.DisplayPromptMessage("Choose your swamp location by using its ID: ");

                //
                // user's response is an integer
                //
                if (int.TryParse(Console.ReadLine(), out swampID))
                {
                    ConsoleUtil.DisplayMessage("");



                    try
                    {
                        nextSwampLocation = _gameKingdom.GetSwampLocationByID(swampID);

                        ConsoleUtil.DisplayReset();
                        ConsoleUtil.DisplayMessage($"You have indicated {nextSwampLocation.Name} as your destination.");
                        ConsoleUtil.DisplayMessage("");

                        if (nextSwampLocation.Accessable == true)
                        {
                            validResponse = true;
                            ConsoleUtil.DisplayMessage("Your journey continues.");
                        }
                        else
                        {
                            ConsoleUtil.DisplayMessage("It appears this destination is not available to you at this time.");
                            ConsoleUtil.DisplayMessage("Please make another choice.");
                        }
                    }
                    //
                    // user's response was not in the correct range
                    //
                    catch (ArgumentOutOfRangeException ex)
                    {
                        ConsoleUtil.DisplayMessage("It appears you entered an invalid location ID.");
                        ConsoleUtil.DisplayMessage(ex.Message);
                        ConsoleUtil.DisplayMessage("Please try again.");
                    }
                }
                //
                // user's response was not an integer
                //
                else
                {
                    ConsoleUtil.DisplayMessage("It appears you did not enter a number for the location ID.");
                    ConsoleUtil.DisplayMessage("Please try again.");
                }

                DisplayContinuePrompt();
            }

            return(nextSwampLocation);
        }
Пример #10
0
        /// <summary>
        /// get and validate the player's TARDIS destination
        /// </summary>
        /// <returns>space-time location</returns>
        public YearLocation DisplayGetTravelersNewDestination()
        {
            bool         validResponse = false;
            int          locationID;
            YearLocation nextYearTimeLocation = new YearLocation();

            while (!validResponse)
            {
                //
                // display header
                //
                ConsoleUtil.HeaderText = "TARDIS Destination";
                ConsoleUtil.DisplayReset();

                //
                // display a table of year-time locations
                //
                DisplayTARDISDestinationsTable();

                //
                // get and validate user's response for a space-time location
                //
                ConsoleUtil.DisplayPromptMessage("Choose the TARDIS destination by entering the ID: ");

                //
                // user's response is an integer
                //
                if (int.TryParse(Console.ReadLine(), out locationID))
                {
                    ConsoleUtil.DisplayMessage("");

                    try
                    {
                        nextYearTimeLocation = _gameYLocation.GetYearTimeLocationByID(locationID);

                        ConsoleUtil.DisplayReset();
                        ConsoleUtil.DisplayMessage($"You have indicated {nextYearTimeLocation.Name} as your TARDIS destination.");
                        ConsoleUtil.DisplayMessage("");

                        if (nextYearTimeLocation.Accessable == true)
                        {
                            validResponse = true;
                            ConsoleUtil.DisplayMessage("You will be transported immediately.");
                        }
                        else
                        {
                            ConsoleUtil.DisplayMessage("It appears this destination is not available to you at this time.");
                            ConsoleUtil.DisplayMessage("Please make another choice.");
                        }
                    }
                    //
                    // user's response was not in the correct range
                    //
                    catch (ArgumentOutOfRangeException ex)
                    {
                        ConsoleUtil.DisplayMessage("It appears you entered an invalid location ID.");
                        ConsoleUtil.DisplayMessage(ex.Message);
                        ConsoleUtil.DisplayMessage("Please try again.");
                    }
                }
                //
                // user's response was not an integer
                //
                else
                {
                    ConsoleUtil.DisplayMessage("It appears you did not enter a number for the location ID.");
                    ConsoleUtil.DisplayMessage("Please try again.");
                }

                DisplayContinuePrompt();
            }

            return(nextYearTimeLocation);
        }