示例#1
0
        public void StartDay(Inventory inventory, Player player, Game game, Weather weather)
        {
            Console.WriteLine("You start day {0}.", game.GetCurrentDay());
            bool    dayNotOver    = true;
            bool    outOfLemonade = false;
            bool    outOfCups     = false;
            int     timePeriod    = 1;
            Pitcher pitcher       = new Pitcher(player);

            dailyIncome = 0;
            if (dayRandom.Next(0, 100) <= weather.GetRain())
            {
                isRaining = true;
                Console.WriteLine("It is raining.");
            }
            else
            {
                isRaining = false;
            }
            if (CheckRecipe(inventory, player))
            {
                pitcher.FillPitcher(inventory, player);
            }
            else
            {
                Console.WriteLine("You can't sell any lemonade today.");
                outOfLemonade = true;
                dayNotOver    = false;
            }
            if (inventory.GetCups() < 1)
            {
                Console.WriteLine("You're out of cups! You can't sell any lemonade today.");
                dayNotOver = false;
            }
            while (timePeriod <= numberOfTimePeriods && dayNotOver)
            {
                if (pitcher.GetFull() <= 0)
                {
                    if (CheckRecipe(inventory, player))
                    {
                        pitcher.FillPitcher(inventory, player);
                    }
                    else
                    {
                        Console.WriteLine("You can't sell any more lemonade today.");
                        outOfLemonade = true;
                        dayNotOver    = false;
                    }
                }
                if (inventory.GetCups() < 1)
                {
                    outOfCups = true;
                    Console.WriteLine("You've run out of cups. You can't sell any more lemonade today.");
                    dayNotOver = false;
                }
                if (!outOfLemonade && !outOfCups)
                {
                    Thread.Sleep(2000);
                    DisplayTime(timePeriod);
                    if (dayRandom.Next(0, 100) <= weather.GetRain())
                    {
                        isRaining = true;
                        Console.WriteLine("It is raining.");
                    }
                    else
                    {
                        if (isRaining)
                        {
                            Console.WriteLine("It has stopped raining.");
                        }
                        isRaining = false;
                    }
                    CheckForCustomer(player, pitcher, inventory, weather);
                }
                timePeriod++;
            }
            Console.WriteLine("Day {0} is complete.", game.GetCurrentDay());
            Console.WriteLine("You spent {0} today.", player.GetMoneySpentToday());
            Console.WriteLine("You had a total income of {0}.", dailyIncome);
            if (dailyIncome - player.GetMoneySpentToday() >= 0)
            {
                Console.WriteLine("Your profit today was {0}.", dailyIncome - player.GetMoneySpentToday());
            }
            else
            {
                Console.WriteLine("Your loss today was {0}.", dailyIncome - player.GetMoneySpentToday());
            }
            player.totalMoneyEarned += dailyIncome;
            Console.WriteLine("You have spent {0} total.", player.totalMoneySpent);
            Console.WriteLine("You have total income of {0}.", player.totalMoneyEarned);
            if (player.totalMoneyEarned - player.totalMoneySpent >= 0)
            {
                Console.WriteLine("Your total profit is {0}.", player.totalMoneyEarned - player.totalMoneySpent);
            }
            else
            {
                Console.WriteLine("Your total loss is {0}.", player.totalMoneyEarned - player.totalMoneySpent);
            }
        }