Пример #1
0
        private void NurishLand(int week, Crop crop)
        {
            CalculateWeatherFactors(week);
            AddWaterToSoil(week, -soiltype.GetWaterLoseRate());


            decimal AmountOfWaterToAdd = 0;
            decimal hundred            = 100;
            decimal percentage         = 1;

            if (simulation.Watering == "Minimal")
            {
                AmountOfWaterToAdd = crop.GetWaterMinimum() + (crop.GetWaterMinimum() / 100);
                percentage         = 5;
            }
            else if (simulation.Watering == "Sufficent")
            {
                AmountOfWaterToAdd = ((crop.GetWaterMaximum() + crop.GetWaterMinimum()) / 2) - (crop.GetWaterMinimum() / 100);
                percentage         = 10;
            }
            else if (simulation.Watering == "Abundant")
            {
                AmountOfWaterToAdd = crop.GetWaterMaximum() - ((crop.GetWaterMaximum() + crop.GetWaterMinimum()) / 10);
                percentage         = 15;
            }
            decimal minimumPercentageWater = percentage / hundred;

            //Give the Plot Enough Water
            if (((plotWeeks[week].Water - (plotWeeks[week].Water * minimumPercentageWater)) < AmountOfWaterToAdd))
            {
                if (AmountOfWaterToAdd - plotWeeks[week].Water < (soiltype.GetMaximumWater() * minimumPercentageWater))
                {
                    AmountOfWaterToAdd = (soiltype.GetMaximumWater() * minimumPercentageWater) + (AmountOfWaterToAdd - plotWeeks[week].Water);
                }
                else
                {
                    AmountOfWaterToAdd = AmountOfWaterToAdd - plotWeeks[week].Water;
                }

                decimal excesswater = AddWaterToSoil(week, AmountOfWaterToAdd);
                PlotWaterCost   += addWaterCost(AmountOfWaterToAdd - excesswater);
                crop.WaterCosts += addWaterCost(AmountOfWaterToAdd - excesswater);
            }

            //Nutrition Factors
            decimal AmountOfFertilizerToAdd = 0;

            if (simulation.Fertilizer == "Minimal")
            {
                AmountOfFertilizerToAdd = (crop.GetNeededNutrition() / Convert.ToDecimal(crop.GetMaturityLength())) * Convert.ToDecimal(0.5);
            }
            else if (simulation.Fertilizer == "Sufficent")
            {
                AmountOfFertilizerToAdd = crop.GetNeededNutrition() / Convert.ToDecimal(crop.GetMaturityLength());
            }
            else if (simulation.Fertilizer == "Abundant")
            {
                AmountOfFertilizerToAdd = (crop.GetNeededNutrition() / Convert.ToDecimal(crop.GetMaturityLength())) * Convert.ToDecimal(1.5);
            }

            //Give the Plot Enough Nutrition
            if (plotWeeks[week].SoilNutrition < AmountOfFertilizerToAdd)
            {
                AmountOfFertilizerToAdd = AmountOfFertilizerToAdd - plotWeeks[week].SoilNutrition;
                AddFertilizerToSoil(week, (AmountOfFertilizerToAdd));
                PlotFertilizerCost   += addFertilizerCost(AmountOfFertilizerToAdd);
                crop.FertilizerCosts += addFertilizerCost(AmountOfFertilizerToAdd);
            }
        }