예제 #1
0
        private int getIdealYield(Crop crop)
        {
            int yield = Ares * crop.GetCropYield();

            return(yield);
        }
예제 #2
0
        private decimal seedCost(Crop crop)
        {
            decimal cost = crop.GetBuyPrice() * Ares;

            return(cost);
        }
예제 #3
0
        private bool isNotEmptyAtSpecificWeek(int week, out Crop getCrop, out int weekCropWasSet)
        {
            getCrop        = null;
            weekCropWasSet = 0;
            if (plotWeeks[week].isEmpty)
            {
                return(false);
            }
            else
            {
                getCrop = plotWeeks[week].getCrop();
                // Crop not empty
                if (week == 0)
                {
                    weekCropWasSet = 0;
                    //Crop must have been set at week 0
                    return(true);
                }
                else if (plotWeeks[week - 1].isEmpty || plotWeeks[week - 1].getCrop() != getCrop)
                {
                    // Week before different therefore week is its starting date
                    weekCropWasSet = week;
                    return(true);
                }
                else
                {
                    if ((getCrop.weeks.Count - 1) > week)
                    {
                        // Not enough weeks must go forward to find begin date
                        int EndWeek = (plotWeeks.Count) - week;
                        for (int search = 1; search < EndWeek; search++)
                        {
                            if (search == EndWeek - 1)
                            {
                                weekCropWasSet = (week + search) - getCrop.GetMaturityLength();
                                return(true);
                            }
                            if (plotWeeks[week + search].isEmpty || plotWeeks[week + search].getCrop() != getCrop)
                            {
                                weekCropWasSet = (week + search) - getCrop.GetMaturityLength();
                                return(true);
                            }
                        }
                    }
                    else
                    {
                        //Look backwards until found
                        for (int search = week - 2; search >= 0; search--)
                        {
                            if (search == 0)
                            {
                                weekCropWasSet = search;
                                return(true);
                            }
                            if (plotWeeks[search].isEmpty || plotWeeks[search].getCrop() != getCrop)
                            {
                                weekCropWasSet = search + 1;
                                return(true);
                            }
                        }
                    }
                }
            }


            return(true);
        }
예제 #4
0
 private void calTempertaute(Crop c, int CropWeek, int PlotWeek)
 {
     decimal temperature = plotWeeks[PlotWeek].getTemperture() - c.GetTemperature();
     //if(temperature)
 }
예제 #5
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);
            }
        }