示例#1
0
        public int generatePurchaseChance(Lemonade recipe, Weather forcast)
        {
            int chanceToPurchase = randomSeed.Next(1, 20);

            if (forcast.getTempurature() > 75 && recipe.getIceCubes() > 2)
            {
                chanceToPurchase += 4;
            }

            double CTPDouble = ((recipe.getPrice() + 1) / 3);

            CTPDouble         = Math.Floor(CTPDouble);
            chanceToPurchase -= Convert.ToInt32(CTPDouble);

            int wateredDown = (recipe.getSugar() + recipe.getLemons()) - recipe.getIceCubes();

            if (wateredDown > 0)
            {
                chanceToPurchase += 2;
            }
            else
            {
                chanceToPurchase -= wateredDown;
            }

            return(chanceToPurchase);
        }
示例#2
0
        public bool enoughIngredients(Lemonade recipe)
        {
            if (lemonBasket.Count < recipe.getLemons() || numOfIceCubes < recipe.getIceCubes() || numOfSugar < recipe.getSugar())
            {
                return(false);
            }

            return(true);
        }
示例#3
0
 public void GameLoop()
 {
     player1.setName(UIInstance.getUserName());
     for (int i = 0; i < numDays; i++)
     {
         Weather forcast = generateWeather();
         inventoryScreen(forcast);
         Lemonade recipe = UIInstance.lemonadeCreation();
         double   profit = simulateDay(recipe, forcast);
         endOfDay(profit);
     }
     UIInstance.endScreen(player1);
 }
示例#4
0
        public int generateNumberOfCustomers(Lemonade recipe, Weather forcast)
        {
            int numberOfCustomers = 10;

            if (forcast.getWeather() == "sunny")
            {
                numberOfCustomers = randomSeed.Next(50, 75);
            }
            else if (forcast.getWeather() == "cloudy")
            {
                numberOfCustomers = randomSeed.Next(25, 50);
            }
            else if (forcast.getWeather() == "rainy")
            {
                numberOfCustomers = randomSeed.Next(11, 25);
            }
            return(numberOfCustomers);
        }
示例#5
0
        //to do check for valid ingredients
        public double simulateDay(Lemonade pitcher, Weather forcast)
        {
            Inventory playerInventory   = player1.getInventory();
            Customers customerInstance  = new Customers(pitcher, forcast);
            int       numberOfCustomers = generateNumberOfCustomers(pitcher, forcast);
            double    profit            = 0;

            if (!playerInventory.enoughIngredients(pitcher))
            {
                return(0);
            }
            player1.decrementIngredients(pitcher);
            for (int i = 0; i < numberOfCustomers; i++)
            {
                Customers currentCustomer = new Customers(pitcher, forcast);

                if (currentCustomer.isBuying() && playerInventory.areEnoughCups())
                {
                    pitcher.decrementCups();
                    playerInventory.decrementCups();
                    player1.addMoney(pitcher.getPrice());
                    profit += pitcher.getPrice();

                    if (pitcher.isEmpty())
                    {
                        if (playerInventory.enoughIngredients(pitcher))
                        {
                            player1.decrementIngredients(pitcher);
                            pitcher = new Lemonade(pitcher.getLemons(), pitcher.getSugar(), pitcher.getIceCubes(), pitcher.getPrice());
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(profit);
        }
示例#6
0
 public void decrementIngredients(Lemonade recipe)
 {
     playerInventory.subtractIceCubes(recipe.getIceCubes());
     playerInventory.subtractLemons(recipe.getLemons());
     playerInventory.subtractSugar(recipe.getSugar());
 }
示例#7
0
 public Customers(Lemonade recipe, Weather forcast)
 {
     ChanceToPurchase = generatePurchaseChance(recipe, forcast);
 }