Пример #1
0
        public MerchantAction GetMechantAction(int Money)
        {
            const int buyAction  = (int)MerchantAction.Buy;
            const int sellAction = (int)MerchantAction.Sell;
            const int exitAction = (int)MerchantAction.Exit;

            var selectionText = $"{Environment.NewLine}{buyAction} - Buy{Environment.NewLine}{sellAction} - Sell{Environment.NewLine}{exitAction} - Exit";

            var menuText = $"Welcome to the Planet Merchant! {Environment.NewLine} What would you like to do?";

            menuText += selectionText;

            var moneyText = $"{Environment.NewLine} Current Money: {Money}{Environment.NewLine}";

            var builder = new StringBuilder();
            var dashes  = builder.Append('-', moneyText.Trim().Length + 2).ToString();

            WriteText.WriteLine($"{dashes}{moneyText}{dashes}");
            WriteText.WriteLine(menuText);
            Console.ReadLine();
            Console.Clear();

            var enteredText = Console.ReadLine()?.Trim();

            while (!IsValidMenuSelection(enteredText, 1, 3))
            {
                Console.WriteLine("Please attempt your selection again.");
                Console.WriteLine(selectionText);
                enteredText = Console.ReadLine()?.Trim();
            }

            var menuActionString = int.Parse(enteredText);

            return((MerchantAction)menuActionString);
        }
Пример #2
0
 internal static void WelcomeScreen()
 {
     WriteText.WriteLine("                       ╔═══════════════════════════════════════════════════════════════════════════╗", ConsoleColor.Yellow);
     WriteText.WriteLine("                       ║  ____                          ____             _       ____  _           ║", ConsoleColor.Yellow);
     WriteText.WriteLine("                       ║ / ___|  ___  _ __ ___   ___   / ___|_   _ _   _( )___  / ___|| | ___   _  ║", ConsoleColor.Yellow);
     WriteText.WriteLine(@"                       ║ \___ \ / _ \| '_ ` _ \ / _ \ | |  _| | | | | | |// __| \___ \| |/ / | | | ║", ConsoleColor.Yellow);
     WriteText.WriteLine(@"                       ║  ___) | (_) | | | | | |  __/ | |_| | |_| | |_| | \__ \  ___) |   <| |_| | ║", ConsoleColor.Yellow);
     WriteText.WriteLine(@"                       ║ |____/ \___/|_| |_| |_|\___|  \____|\__,_|\__, | |___/ |____/|_|\_\\__, | ║", ConsoleColor.Yellow);
     WriteText.WriteLine("                       ║                                           |___/                    |___/  ║", ConsoleColor.Yellow);
     WriteText.WriteLine("                       ║                                                                           ║", ConsoleColor.Yellow);
     WriteText.WriteLine("                       ╚═══════════════════════════════════════════════════════════════════════════╝", ConsoleColor.Yellow);
     WriteText.WriteLine("------------------------------------------------------------------------------------------------------------------------", ConsoleColor.Yellow);
 }
Пример #3
0
        private PlanetMenu GetMenuReturnItemForAction(MerchantAction actionToPerform, List <Items> menuItems)
        {
            var maxItemNumber = menuItems.Count;
            var backMenu      = maxItemNumber + 1;

            WriteText.WriteLine(P.PlanetType());
            var textOption  = actionToPerform == MerchantAction.Buy ? "buy" : "sell";
            var displayText = $"Please choose an item to {textOption}:";

            var itemDictionary = new Dictionary <int, Items>();

            for (var num = 0; num < maxItemNumber; num++)
            {
                var item       = menuItems[num];
                var itemNumber = num + 1;

                itemDictionary.Add(itemNumber, item);
                var itemAmount = actionToPerform == MerchantAction.Buy ? item.Price : item.GetSellValue();
                displayText += $"{Environment.NewLine}{itemNumber} - {item.Name} - Price: {itemAmount}";
            }

            displayText += $"{Environment.NewLine}{backMenu} - Back{Environment.NewLine}";

            Console.WriteLine(displayText);
            var answer = Console.ReadLine();

            while (!IsValidMenuSelection(answer, 1, backMenu))
            {
                Console.WriteLine("That is not a valid item choice. Please try again.");
                Console.WriteLine(displayText);
                answer = Console.ReadLine();
            }
            var selectedAnswer = int.Parse(answer);

            if (selectedAnswer == backMenu)
            {
                return new PlanetMenu {
                           ChosenItem = null, ExitingMenu = true
                }
            }
            ;

            var pickedItem = itemDictionary[selectedAnswer];

            return(new PlanetMenu {
                ChosenItem = pickedItem, ExitingMenu = false
            });
        }
Пример #4
0
 public void MainMenu()
 {
     Console.Clear();
     WriteText.WriteLine("                       ╔═══════════════════════════════════════════════════════════════════════════╗", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║  ____                          ____             _       ____  _           ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║ / ___|  ___  _ __ ___   ___   / ___|_   _ _   _( )___  / ___|| | ___   _  ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine(@"                       ║ \___ \ / _ \| '_ ` _ \ / _ \ | |  _| | | | | | |// __| \___ \| |/ / | | | ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine(@"                       ║  ___) | (_) | | | | | |  __/ | |_| | |_| | |_| | \__ \  ___) |   <| |_| | ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine(@"                       ║ |____/ \___/|_| |_| |_|\___|  \____|\__,_|\__, | |___/ |____/|_|\_\\__, | ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║                                           |___/                    |___/  ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║                                *Main Menu*                                ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ╚═══════════════════════════════════════════════════════════════════════════╝", ConsoleColor.DarkGreen);
     WriteText.WriteLine("------------------------------------------------------------------------------------------------------------------------", ConsoleColor.DarkRed);
     WriteText.WriteLine("Please choose a number from the menu", ConsoleColor.Green);
     WriteText.WriteLine("");
     WriteText.WriteLine("1. Start a new game", ConsoleColor.DarkGreen);
     WriteText.WriteLine("2. HighScores", ConsoleColor.DarkGreen);
     WriteText.WriteLine("3. Exit the game", ConsoleColor.DarkGreen);
 }
Пример #5
0
 public void HighScores()
 {
     Console.Clear();
     WriteText.WriteLine("                       ╔═══════════════════════════════════════════════════════════════════════════╗", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║  ____                          ____             _       ____  _           ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║ / ___|  ___  _ __ ___   ___   / ___|_   _ _   _( )___  / ___|| | ___   _  ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine(@"                       ║ \___ \ / _ \| '_ ` _ \ / _ \ | |  _| | | | | | |// __| \___ \| |/ / | | | ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine(@"                       ║  ___) | (_) | | | | | |  __/ | |_| | |_| | |_| | \__ \  ___) |   <| |_| | ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine(@"                       ║ |____/ \___/|_| |_| |_|\___|  \____|\__,_|\__, | |___/ |____/|_|\_\\__, | ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║                                           |___/                    |___/  ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ║                               *High Scores*                               ║", ConsoleColor.DarkGreen);
     WriteText.WriteLine("                       ╚═══════════════════════════════════════════════════════════════════════════╝", ConsoleColor.DarkGreen);
     WriteText.WriteLine("------------------------------------------------------------------------------------------------------------------------", ConsoleColor.DarkRed);
     WriteText.WriteLine("1. 10,000 Points - Bill Jeffreys\n2. 8,000 Points - Jeff Billfreys\n3. 6,000 Points - Will Williamson\n 4. 4,000 Points - Bill Billiamson", ConsoleColor.Green);
     WriteText.WriteLine("");
     WriteText.WriteLine("PRESS ENTER TO GO BACK", ConsoleColor.DarkGreen);
     Console.ReadLine();
     new Init().Run();
 }
Пример #6
0
        private static bool CustomAttributes()
        {
            Console.Clear();
            WriteText.Write("Are you ready to choose your character type?: (yes/no)", ConsoleColor.DarkGreen);
            string result;

            do
            {
                result = Console.ReadLine();
            } while (result.ToLower() != "yes" && result.ToLower() != "no");

            if (result.ToLower() == "yes")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        private int UserInput()
        {
            var input     = false;
            int selection = 0;

            do
            {
                try
                {
                    selection = int.Parse(Console.ReadLine());
                    input     = true;
                }
                catch (FormatException)
                {
                    WriteText.WriteLine("Invalid Selection");
                    Console.ReadLine();
                    Run();
                }
            } while (!input);
            return(selection);
        }
Пример #8
0
        internal static MenuChoice DisplayMenu()
        {
            Console.Clear();
            WriteText.WriteLine("                       ╔═══════════════════════════════════════════════════════════════════════════╗", ConsoleColor.DarkGreen);
            WriteText.WriteLine("                       ║  ____                          ____             _       ____  _           ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine("                       ║ / ___|  ___  _ __ ___   ___   / ___|_   _ _   _( )___  / ___|| | ___   _  ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine(@"                       ║ \___ \ / _ \| '_ ` _ \ / _ \ | |  _| | | | | | |// __| \___ \| |/ / | | | ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine(@"                       ║  ___) | (_) | | | | | |  __/ | |_| | |_| | |_| | \__ \  ___) |   <| |_| | ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine(@"                       ║ |____/ \___/|_| |_| |_|\___|  \____|\__,_|\__, | |___/ |____/|_|\_\\__, | ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine("                       ║                                           |___/                    |___/  ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine("                       ║                              START/LOAD GAME                              ║", ConsoleColor.DarkGreen);
            WriteText.WriteLine("                       ╚═══════════════════════════════════════════════════════════════════════════╝", ConsoleColor.DarkGreen);
            WriteText.WriteLine("------------------------------------------------------------------------------------------------------------------------", ConsoleColor.DarkRed);
            WriteText.WriteLine("Please choose a number from the menu", ConsoleColor.Green);
            WriteText.WriteLine("");
            WriteText.WriteLine("1. Start a new game", ConsoleColor.DarkGreen);
            WriteText.WriteLine("2. Load a previus game", ConsoleColor.DarkGreen);
            WriteText.WriteLine("3. HighScores", ConsoleColor.DarkGreen);
            WriteText.WriteLine("4. Exit the game", ConsoleColor.DarkGreen);

            var result = Console.ReadLine();

            switch (result)
            {
            case "1":
                return(MenuChoice.NewGame);

            case "2":
                return(MenuChoice.LoadGame);

            case "3":
                return(MenuChoice.HighScores);

            case "4":
                return(MenuChoice.Exit);

            default:
                return(MenuChoice.Invalid);
            }
        }