Example #1
0
        public void RunDay(Player player, Weather weather)
        {
            UI.DisplayActualWeatherForToday(weather);
            UI.DisplayPlayerInventory(player);

            while (UI.DoesUserWantTo("buy anything from the store"))
            {
                Store.DisplayItemsForSale();
                Store.ProcessOrder(player);
                UI.DisplayPlayerInventory(player);
            }

            player.recipe.DisplayRecipe();

            while (UI.DoesUserWantTo("change the recipe"))
            {
                player.ChangeRecipe();
                player.recipe.DisplayRecipe();
            }

            int cupsSold = 0;

            if (player.RanOutOfInventoryItems())
            {
                return;
            }
            player.MakePitcherOfLemonade();
            List <Customer> buyingCustomers = GenerateCustomerList(weather, player.recipe);

            foreach (Customer buyingCustomer in buyingCustomers)
            {
                if (buyingCustomer.isBuying == true)
                {
                    if (player.RanOutOfInventoryItems())
                    {
                        break;
                    }
                    cupsSold++;
                    player.AdjustInventoryAfterSale(cupsSold);
                }
            }
        }
Example #2
0
 public bool RunGame()
 {
     UI.DisplayTitleScreen();
     player       = new Human();
     inventories  = new List <Inventory>();
     numberOfDays = UI.SetGameLengthInDays();
     GenerateDaysAndWeathers();
     UI.DisplayCompleteWeatherForecast(weathers);
     for (byte i = 0; i < numberOfDays; i++)
     {
         inventories.Add(new Inventory(player.inventory));
         if (i + 1 < numberOfDays)
         {
             UI.DisplayWeatherForTomorrow(weathers[i + 1]);
         }
         days[i].RunDay(player, weathers[i]);
         UI.DisplayResults(inventories[i], player.inventory, InventoryDifference(inventories[i], player.inventory));
     }
     UI.DisplayResults(inventories[0], player.inventory, InventoryDifference(inventories[0], player.inventory));
     return(UI.DoesUserWantTo("keep playing"));
 }