private void CalculateCropNutrition(int PlotWeek, int CropWeek, Crop crop) { decimal fertilizer = plotWeeks[PlotWeek].SoilNutrition - crop.GetNeededNutrition(); if (plotWeeks[PlotWeek].SoilNutrition < crop.GetNeededNutrition()) { // Not enough Nutrition crop.setCropHealth(-15, CropWeek); } // Crop Absorb Nutrients AddFertilizerToSoil(PlotWeek, -(crop.GetNeededNutrition())); }
private string reasonOfDeath(Crop crop) { int weekofdeath = 0; int weekThatHoldsCrop = 0; for (int i = 0; i < plotWeeks.Count; i++) { if (!plotWeeks[i].isEmpty && plotWeeks[i].getCrop() == crop) { weekThatHoldsCrop = i; break; } } for (int i = weekofdeath; i < crop.GetMaturityLength(); i++) { if (crop.weeks[i].Health < 4) { weekofdeath = i - 1; break; } else { weekThatHoldsCrop++; } } if (plotWeeks[weekThatHoldsCrop].Water < crop.GetWaterMinimum()) { return(crop.GetCropName() + " Died from lack of Water"); } else if (plotWeeks[weekThatHoldsCrop].SoilNutrition < crop.GetNeededNutrition()) { return(crop.GetCropName() + " Died from lack of Nutrients"); } decimal temp = plotWeeks[weekThatHoldsCrop].weather.GetTemp(); decimal tempDifference = temp - crop.GetTemperature(); if (tempDifference < -4) { // Too cold return(crop.GetCropName() + " died because it is too cold"); } else if (tempDifference > 5) { //Too Hot return(crop.GetCropName() + " Died because it is too warm"); } else { return("Unknown Reasons"); } }
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); } }