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 CalculateCropTemperature(int PlotWeek, int CropWeek, Crop crop) { decimal temp = plotWeeks[PlotWeek].weather.GetTemp(); decimal tempDifference = temp - crop.GetTemperature(); if (tempDifference < -4) { // Too cold crop.setCropHealth(-10, CropWeek); } else if (tempDifference > 5) { //Too Hot crop.setCropHealth(-5, CropWeek); } }
private void calTempertaute(Crop c, int CropWeek, int PlotWeek) { decimal temperature = plotWeeks[PlotWeek].getTemperture() - c.GetTemperature(); //if(temperature) }