예제 #1
0
        private void CalculateCropWater(int PlotWeek, int CropWeek, Crop crop)
        {
            decimal water       = plotWeeks[PlotWeek].Water;
            decimal enoughWater = (crop.GetWaterMinimum() + crop.GetWaterMaximum()) / 2;

            if (water < enoughWater)
            {
                if (water < crop.GetWaterMinimum())
                {
                    // Not enough Water
                    crop.setCropHealth(-15, CropWeek);
                }
                else
                {
                    crop.setCropHealth(-8, CropWeek);
                }
            }
            else if (plotWeeks[PlotWeek].Water > crop.GetWaterMaximum())
            {
                //Too much water
                crop.setCropHealth(-5, CropWeek);
            }
            else if (water > enoughWater && water < crop.GetWaterMaximum())
            {
                // Right Amount of Water
                crop.setCropHealth(2, CropWeek);
            }
        }
예제 #2
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);
            }
        }