Пример #1
0
        public void BuySugar(Player Player, Inventory Inventory)
        {
            Console.WriteLine("You can either buy '8' cups of sugar for 0.53, '20' cups of sugar for 1.51, or '48' cups of sugar for 3.46. Or if you don't need any and or already have enough, you can enter 'menu' to go back to the Main Menu.");
            string amountWanted = Console.ReadLine();

            switch (amountWanted)
            {
            case "8":
                cupsOfSugarBought = 8;
                break;

            case "20":
                cupsOfSugarBought = 20;
                break;

            case "48":
                cupsOfSugarBought = 48;
                break;

            case "menu":
                ExploreStore(Player, Inventory);
                return;

            default:
                Console.WriteLine("You can only purchase '8', '20', or '48' cups of sugar at a time. Or if you are done, enter 'menu' to go back to the Main Menu.");
                BuySugar(Player, Inventory);
                return;
            }
            if (cupsOfSugarBought == 8)
            {
                sugarCost = priceOfEightCupsOfSugar;
            }
            else if (cupsOfSugarBought == 20)
            {
                sugarCost = priceOfTwentyCupsOfSugar;
            }
            else if (cupsOfSugarBought == 48)
            {
                sugarCost = priceOfFortyEightCupsOfSugar;
            }
            if (Player.money >= sugarCost)
            {
                Console.WriteLine("You have successfully bought" + ' ' + cupsOfSugarBought + ' ' + "cups of sugar.");
                SeeTotalCostForIngredients(sugarCost);
                Player.money -= sugarCost;
                Console.WriteLine("You have" + ' ' + "$" + Player.money + "left.");
                Inventory.AddCupsOfSugarFromStore(cupsOfSugarBought);
            }
            else if (Player.money < sugarCost)
            {
                Console.WriteLine("You don't have enought money to buy that amount of sugar. Please choose a lower amount, or come back with more money. If you want to buy less sugar, enter 'buy again' or if you don't have enough money and can't buy anymore and want to go back to the Main Menu, enter 'menu'.");
                string answer = Console.ReadLine();
                switch (answer)
                {
                case "buy again":
                    BuySugar(Player, Inventory);
                    break;

                case "menu":
                    ExploreStore(Player, Inventory);
                    break;

                default:
                    ExploreStore(Player, Inventory);
                    break;
                }
            }

            BuySugar(Player, Inventory);
        }