Exemple #1
0
        public void StartDay(Inventory inventory, Player player, Game game, Weather weather)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("!!~~~~Lemonade Bussiness in Progress~~~!!\n");
            Console.ResetColor();
            Console.ReadKey();
            bool    businessIsInProcess = true;
            bool    pitcherIsEmpty      = false;
            bool    CupIsOut            = false;
            int     timePeriod          = 1;
            Pitcher pitcher             = new Pitcher(player);

            cashMakeFromSale = 0;
            if (CheckRecipe(inventory, player) == true)
            {
                pitcher.Fill(inventory, player);
            }
            else
            {
                Console.WriteLine("You're missing some supplies!");
                Console.WriteLine("Please double check your inventory and recipe");
                pitcherIsEmpty      = true;
                businessIsInProcess = false;
            }
            while (timePeriod <= numberOfTimePeriods && businessIsInProcess)
            {
                if (pitcher.GetFull() <= 10)
                {
                    Console.WriteLine("You ran out of Lemonade juice!");
                    Console.WriteLine("Do you want to check if you have enough supplies to make another pitcher?");
                    string makeAnotherPitcher = Console.ReadLine().ToLower();
                    if (makeAnotherPitcher == "yes" || makeAnotherPitcher == "y")
                    {
                        if (CheckRecipe(inventory, player) && businessIsInProcess == true)
                        {
                            pitcher.Fill(inventory, player);
                        }
                        else
                        {
                            Console.WriteLine("\nSorry but you don't have enough supplies to make another Pitcher");
                        }
                    }
                    else if (makeAnotherPitcher == "no" || makeAnotherPitcher == "n")
                    {
                        Console.WriteLine("\n****Today Result****");
                        Console.WriteLine("press any key to see today result");
                        Console.ReadKey();
                        break;
                    }
                    else
                    {
                        try
                        {
                            if (makeAnotherPitcher.Equals(""))
                            {
                                Console.WriteLine("Please choose a valid option");
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Please choose a valid option");
                        }
                    }
                }
                if (inventory.RetrieveCup() <= 0)
                {
                    CupIsOut = true;
                    Console.WriteLine("\nOops! seem like you run out of cups. No more business for today.");
                    businessIsInProcess = false;
                }

                if (!pitcherIsEmpty && !CupIsOut)
                {
                    DisplayTime(timePeriod);
                    if (dayRandom.Next(0, 100) <= weather.GetRain())
                    {
                        isRaining = true;
                        Console.WriteLine("Its Raining");
                    }
                    else
                    {
                        if (isRaining)
                        {
                            Console.WriteLine("The rain have stop!");
                        }
                        isRaining = false;
                    }
                }

                try
                {
                    if (inventory.cupStorage.Count() >= 1)
                    {
                        CheckForCustomer(player, pitcher, inventory, weather);
                    }
                }
                catch
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\nThat was the last lemonade cup on the table!");
                    Console.ResetColor();
                    Console.WriteLine("\n~~~*Checking inventory for more cups*~~~");
                    Console.WriteLine("press any key to see if you have more cup\n");
                    Console.ReadKey();
                }

                timePeriod++;
            }
            EndDayResult(game, player);
        }